Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature: add gelf, a gunified elf for managing pvp hypergraphs from elf world #1389

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

tylerchilds
Copy link

This pull request binds a gun to a custom element generator and ports the basic/note.html example into it

The gelf.js file needs performance improvements before it is ready for production use. Currently, it stringifys the graph fragment for the custom element's data table as it goes into and out of the gun.

gelf.js support atomic data operations with the $.teach and can be reflected in gun per field to be the most optimized. In order to support this, gelf will need support for arrays as a primitive data structure.

We will solve the performance issues in the future as the existing is performant enough as gelf is an entity component system that drives towards shallow graph fragments.

Also to be solved in the future is the default router to support returning .js, such as the hello-world.html example that currently fails to resolve hello-world.js

@amark
Copy link
Owner

amark commented Oct 19, 2024

my favorite @tylerchilds ! :)

3 questions / concerns:

  1. .innerHTML = serious security concern, waaah waah I have to be that bad boy
  2. most of the code looks like its utility functions? Can we <script src="https://ty.chi/elf.js"></script> instead so we get your updates/improvements over time? I dislike deps being copied into GUN.
  3. Wait I thought you wanted the ObjectArray support that you were gonna commit/PR?

@tylerchilds
Copy link
Author

thanks for the time @amark!

  1. I use a virtual dom library in the plan98 fork of tag, which allows to not execute scripts when manipulating a node https://diffhtml.org/api.html#options-execute-scripts

More in 2.

  1. The plan98 version of elf/tag that i use is context-less by default. I leave an open-ended slot for injecting stateful context. See the version with nulls in tylerchilds/plan98 here:

https://github.com/tylerchilds/plan98/blob/plan98/client/public/module.js#L81

compared to in this PR, where the this variable can be exposed to be controlled by the intersection of gun+elf/tag as the brain. in my research, different approaches to atomically read,write, and react to data is slightly so different, that it would be more complicated to create a generic interface that I could comfortably call a definitive version of tag.

in this fork of gun+elf/tag, I use this to anticipate a seed that can serve as a root node in a gun graph: binding this, which is { seed: 'something'}

utilizing this by gun

The contract I expect out of any elf/tag fork is that there's an html tag that can be utilized by hypertext authors. For context, this is a pure braid fork of elf/tag

back to innerHTML, if it makes sense in the gun fork to throw a sanitizer around innerHTML, we can do that or we can pull in the vdom library i use in plan98 and we can disable scripts on innerHTML.

I can also back this out entirely, I added this to make it easier to interface the lower level internals of the elf/tag data structures with guns as an opinionated fork by both authors.

  1. I can open the array up in a PR, but since I haven't tested the array data structure for going from array to object in graph land as we have it and then back from object to array in userland as i need it, I haven't opened that. I can add that to this PR or open it in a standalone one.

From my end, it'll be easier to work off this fork as a baseline for that to maintain compatibility with the learn/teach functions to make sure the arrays are backwards compatible with elves that might get ported from their current local state to a more hyper state with gun.

@tylerchilds
Copy link
Author

@amark i went ahead and added the array code to this pr

@@ -1250,6 +1250,9 @@
}
k && (to.path || (to.path = [])).push(k);
if(!(v = valid(d)) && !(g = Gun.is(d))){
if(as.array && d instanceof Array) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this file is built from files in src, so you're going to have to add this change in src/put.js too?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good call, thanks, added!

@tylerchilds
Copy link
Author

removed the innerHTML logic on gelf/note.html and added gelf/array-test.html

i started updating gelf.js to use the gun.open api instead of JSON.stringify and JSON.parse, but need to investigate further what I might be missing.

can push a wip commit with the broken state.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants