Skip to content

Commit

Permalink
Merge pull request #75 from KaruroChori/settings
Browse files Browse the repository at this point in the history
Several fixes and initial work for v0.1.3
  • Loading branch information
KaruroChori authored Dec 21, 2024
2 parents d96010a + 3a76ee8 commit ee815e8
Show file tree
Hide file tree
Showing 14 changed files with 168 additions and 33 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
graphviz \
python3-pip \
python3-setuptools
python3 -m pip install mkdocs mkdocs-github-admonitions-plugin mkdocs-get-deps pymdown-extensions
python3 -m pip install mkdocs mkdocs-github-admonitions-plugin mkdocs-get-deps pymdown-extensions mdx_truly_sane_lists
doxygen
mkdocs build
bun install -g gh-pages
Expand Down
16 changes: 11 additions & 5 deletions MILESTONES.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,25 @@ For past releases please check in [here](./docs/releases/).
## 0.1.3

- [x] Move all components to the revised codegen format
- [ ] Initial settings implementation
- [ ] New getters and setters design (and updated schemas).
- [ ] Implement flex, grid, scroll & pack via codegen.
- [ ] Tidy up the XML caching
- [ ] Tidy up the JS scripting interface.
- [ ] deb package
- [x] flatpak distribution
- [x] docs generation

## 0.1.5

- [x] Support for script modules
- [ ] Full support for getters and setters
- [ ] Tidy up the JS scripting interface.
- [ ] Complete support for getters and setters
- [x] Support basic policies via env flags & settings
- [ ] Implement flex, grid, scroll & pack via codegen.

## 0.1.7

- [x] Final implementation of the static xml builder (now external dependency)
- [ ] Full infrastructure for benchmarking & tests implemented
- [x] Support basic policies via env flags
- [ ] deb package

## 0.2.x

Expand Down
25 changes: 18 additions & 7 deletions RELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,37 @@ This second alpha release is still not usable in real-world scenarios, yet some

The main objectives for this release are:

- To improve the build system moving it to a separate repo.
- To introduce a wider range of fltk widgets.
- To improve the build system, moving it to a separate repo.
- Complete the revised code-generation of widgets
- Better serialization/de-serialization of XML props & revised getters/setters
- To introduce a wider range of fltk widgets.
- Documentation efforts.

### What's new?

This is what has been implemented so far (and some missing feature for context):

- [ ] Improvements to the build system

- [ ] migration of distribution-related features to [external repo]()
- [ ] fix linking to follow https://github.com/KaruroChori/vs-fltk/issues/63
- [ ] debian and arch packages are now supported
- [ ] install script can be now be safely used

- [ ] New widgets & improvements

- [ ] flex
- [ ] grid
- [ ] Updated code-gen

- [x] Use the new schema
- [ ] Updated core features
- [x] Removed most of the globals
- [x] Removed most of the globals & reworked singletons
- [x] Reworked `ui_tree` interface to be more generic and not only viable for xml trees.
- [x] Added guards to decide which features to compile `vs.fltk` with.
- [ ] Support for automatic search of files for components, based on a priority list.
- [ ] Linking external libraries and exposing symbols to `vs`
- [ ] Documentation!
- [x] Landing page for the project
- [x] `doxygen` for C++ code
- [x] `mkdocs` to distribute the main documentation
- [ ] Documenting:
- [ ] settings
- [ ] paths/virtual paths
- [ ] some basic information to use vs
4 changes: 1 addition & 3 deletions TODO.md
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
- [ ] Restore vs_debug
- [ ] Allow http only withou libcurl via https://github.com/lazy-eggplant/libhttp

- [ ] Allow http only without libcurl via https://github.com/lazy-eggplant/libhttp
14 changes: 14 additions & 0 deletions bindings/native/include/vs.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,3 +108,17 @@ extern void vs_debug(const char* key, const char* value);

//Extra functions
char* itoa(int value, char* result, int base);

enum vs_types_t{
TYPE_UNKNOWN,
TYPE_FLAG,
TYPE_ENUM,
TYPE_RAW,
TYPE_PATH,
TYPE_STRING,
TYPE_COLOR,
TYPE_SCALAR_1,
TYPE_SCALAR_2,
TYPE_SCALAR_4
};
typedef vs_types_t vs_types_t;
24 changes: 17 additions & 7 deletions commons/configs/default.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,25 @@
<!-- Default profile for `vs`. This one is copied by default in your home during the first
configuration -->
<vs-profile display-name="" version="1.0">
<runtime>
<logging verbosity="" file=""></logging>
<locale>
<user>
<entry key="name" value=""/>
</user>
<languages>
<entry key="en-uk" value="0"/>
<entry key="en" value="1"/>
</languages>
<theme src="default" scheme="eggplant" mode="inherit"/>
<initial-scene src="app://commons/hub.xml"/>
<base-theme src="default"/>
<parsing mode="fast" max-threads="8">
</parsing>
</locale>
<runtime>
<logging verbosity="" file=""/>
<parsing mode="fast" max-threads="8"/>
<base-policy>
</base-policy>
</runtime>
<policies>
<group name="test-1">
<template name="test-1">
<allow.native></allow.native>
<allow.quickjs></allow.quickjs>
<allow.wasm></allow.wasm>
Expand All @@ -25,7 +35,7 @@ configuration -->
<cache.resources></cache.resources>

<theme></theme>
</group>
</template>

<domain extends="test-1">
<matches>
Expand Down
56 changes: 56 additions & 0 deletions docs/full-specs/settings.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
## Order of evaluation for policies

Directives on policies are applied base on the following priority (highest to lowest)

- built-in compiled profile (vs can be built with embedded policies)
- command line environment variables
- `runtime/base-policy`
- `domain` if not a recognized app. Else `app` and its domain policies are ignored.
- Any locally defined policy within the app or components.

## Structure of a settings profile

This is the tree structure of any settings XML file:

- `vs-profile`
- `locale`
- `user`: dictionary of user data, mostly used for forms auto fill-in.
- `languages`: dictionary of supported languages. They are ordered by preference (lower number higher preference) and when ambiguous by order in the XML file.
- `theme`: base user theme. It supports some attributes:
- `src` the location of a theme xml file to be used as parent.
- `scheme` pick up a color scheme if internally defined (default allowed).
- `mode` determines if using dark, light, high contrast etc. or if this choice should be left to the OS if `inherit` (default).
- `initial-scene`: path for the scene to show up when starting `vs`
- `runtime`
- `logging`
- `parsing`
- `base-policy` same structure as one entry in the policies, but this is applied as a global override to fully shut of features of `vs`.
- `policies`
- `template` reusable entries, used to avoid copy and paste. Their content is expanded in `domain` and `app` extending from them.
- `name` unique name in the config file
- `extends` comma separated list of sources to copy from.
- `domain`
- `extends` comma separated list of sources to copy from.
- `app`
- `extends` comma separated list of sources to copy from.

### User dictionary

Entries in the user dictionary are arbitrary and publicly exposed as `user://` virtual paths. Apps cannot mutate them, this is only possible via settings.
They are not a replacement for secrets!

User data should only include things like user's nickname, public email, daytime zone, etc.

### Language codes

Language codes are expressed as a pair `language`, `country`. Country is optional, which means any satisfying the language itself can be picked.

### Policy structure

#### Flag entries

Most entries are flags supporting one of three values:

- `yes`: use the upstream value from the parent, but if that is `no` report a warning/error.
- `no`: revoke this permission.
- `inherit` (default): use the upstream value from the parent.
1 change: 0 additions & 1 deletion include/globals.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ struct global_ctx_t{

js_rt_t js_rt;
cache::mem_storage_t mem_storage;
field_models_t value_models;
};

}
8 changes: 7 additions & 1 deletion include/singletons.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@ struct debug_t{

void operator()(const char* field, const char* value);
} extern debug;
}

struct field_models_t{
field_model_t models[];

enum{
UNKNOWN, FLAG, ENUM, RAW, PATH, STRING, COLOR, SCALAR_1, SCALAR_2, SCALAR_4
};
} extern field_models;
}
8 changes: 2 additions & 6 deletions include/ui-frame.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,10 @@ struct field_t{
};

struct field_model_t{
int(*serialize)(void* obj, const char* src);
int(*deserialize)(const void* obj, char** src);
int(*deserialize)(void* obj_dst, const char* src); //Setup obj based on data from src
int(*serialize)(const void* obj_src, const char** dst); //Create a new string with the serialized information of obj inside
};

struct field_models_t{
std::vector<field_model_t> entries;
//TODO
};

enum class symbol_type_t{
VOID, //Function not to be defined
Expand Down
20 changes: 20 additions & 0 deletions include/utils/settings.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/**
* @file settings.hpp
* @author karurochari
* @brief Structures to store the instance settings
*
* @copyright Copyright (c) 2024
*
*/

#pragma once

#include <pugixml.hpp>

namespace vs{

struct settings_t{

};

}
4 changes: 2 additions & 2 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ docs_dir: docs

theme:
name: readthedocs
custom_dir: ./
logo: commons/assets/logos/vs.light.svg
#logo: commons/assets/logos/vs.light.svg
markdown_extensions:
- admonition
- pymdownx.tilde
- pymdownx.tasklist
- mdx_truly_sane_lists
- sane_lists
- smarty
- toc:
Expand Down
18 changes: 18 additions & 0 deletions src/singletons.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,23 @@ curl_t curl;
debug_t debug;
#endif

field_models_t field_models ={{
[field_models_t::FLAG] = {
+[](void* _dst, const char* src)->int{
bool* dst = (bool*) _dst;
if(strcmp(src, "false")==0){*dst=false;return 0;}
else if(strcmp(src,"true")==0){*dst=true;return 0;}
return 1;
},
+[](const void* _src, const char** dst)->int{
const bool* src = (const bool*) _src;
if(*src==true){auto tmp = malloc(sizeof("true"));memcpy(tmp,"true",sizeof("true"));*dst=(const char*)tmp;return 0;}
else if(*src==false){auto tmp = malloc(sizeof("false"));memcpy(tmp,"false",sizeof("false"));*dst=(const char*)tmp;return 0;}
else dst=nullptr;
return 1;
}
},
}};

}
}
1 change: 1 addition & 0 deletions src/utils/settings.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#include <utils/settings.hpp>

0 comments on commit ee815e8

Please sign in to comment.