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

Support Node diagram through ReactDOM.render #44

Merged
merged 1,180 commits into from
Nov 21, 2019
Merged

Conversation

Chetabahana
Copy link

@Chetabahana Chetabahana commented Nov 21, 2019

U### Summary

Main Code: js/tree.js

var node, root, tree = {

    feed : function(id, size) {

        // Accessing _internalRoot && __reactInternalInstance$
        // https://szhshp.org/tech/2019/08/10/reactindepthrender.html
        // https://dev.to/carlmungazi/a-journey-through-reactdom-render-302c

        var graphiql = document.getElementById('graphiql');
        root = graphiql._reactRootContainer._internalRoot;
        console.dir(root.current);

        var container = graphiql.getElementsByClassName('graphiql-container')[0];
        node = tree.getReact(container);
        console.log(node.return);

        draw.getJSON();

    },

    getReact : function(dom) {

        // Obejct keys Iteration
        // https://stackoverflow.com/a/55310101/4058484
        // https://medium.com/@sitambas/get-global-element-state-a408a744e99d

        const getObjectKeys = (obj, prefix = '') => {
            return Object.entries(obj).reduce((collector, [key, val]) => {
                const newKeys = [ ...collector, prefix ? `${prefix}.${key}` : key ]
                if (Object.prototype.toString.call(val) === '[object Object]') {
                    const newPrefix = prefix ? `${prefix}.${key}` : key
                    const otherKeys = getObjectKeys(val, newPrefix)
                    return [ ...newKeys, ...otherKeys ]
                }
                return newKeys
            }, [])
        }

        let key = Object.keys(dom).find(key=>key.startsWith("__reactInternalInstance$"));
        //return getObjectKeys({a: 1, b: 2, c: { d: 3, e: { f: 4 }}});
        return dom[key];

    }

}

Checklist

  1. Privileged views and APIs are guarded by proper permission checks.
  2. All visible strings are translated with proper context.
  3. All data-formatting is locale-aware (dates, numbers, and so on).
  4. Database queries are optimized and the number of queries is constant.
  5. Database migration files are up to date.
  6. The changes are tested.
  7. The code is documented (docstrings, project documentation).
  8. GraphQL schema and type definitions are up to date.
  9. Changes are mentioned in the changelog.

Reference

Screenshots

85412192-89816500-b593-11ea-8107-016c0df9f398 (1)

screencapture

392ff2229ae341d7ec21e7c330084603
7d5299ec-flow-700x394
1280px-Laminar_and_turbulent_flows svg
sketch-laminar-flow-turbulent-flow
Comparison-of-Stokes-flow-and-LNS-flow-Stokes-flow-ReT1-linearized-Navier-Stokes-flow
sphere-vortices-velocity-flow-B
f_azul_1
image-1
olas
intoscana it_
Waves_in_pacifica_1
68-93-huraca-300x200
foto18
69-93-tornado
air-turbulence

liquido
downloadfile-5
foto19
foto20
RKPL_Still_613x343-520x291
image
downloadfile-4
tmp643420765391159297
downloadfile-3
mathematics-07-01060-g001
downloadfile-1
wave-crests-Figure-result-superposition-sets-two
I13-23-turbulent
airfoil
navier-stokes20model201
37167304621de46d28a2dd4c5cbf7f75
800wm
main-qimg-e62cdf168aa64721e9a83f4de3e9952b
wave-equation-and-navier-stokes-equation-mug-mugs
IXW6h
9a71660d9ac796a72ae8973233b9268f
The-Navier-Stokes-equations-for-incompressible-fluid-flow
spiral_matplotlib
lukas
stability-to-the-incompressible-navier-stokes-equations
navier-stokes-equations-in-planar-domains
9783540527701
9781461459743
41A8M0gcDuL SX331_BO1,204,203,200
41le7kpXObL SX331_BO1,204,203,200
9781536102925-e1544462290531-500x756
downloadfile-2
14075_69ee114722e3e7df044c4eaec11ff77c
14406581_f1024
ipad-geometric-art-spiral-kaleidoscope-fluid-01
downloadfile
abstractions_2ae510aef3f08dd6dea87a2052655c59
downloadfile-1
phpc89Wlc
phpvGY2D0
005888004_1-206bb35bfc0d9dde07dc659843eaece8
7163c5ae52c5aebcdecc4b259292ccb4
exact-solutions-to-the-navier-stokes-equation
FluidCube-1024x609
LBZrC
main-qimg-399add1da7e5cbb126091221bc40b444
maxresdefault-1
eq7_lec10
picture1
eulereqs
navier+stokes1
screenshot
screenshot
hqdefault-3
hqdefault-2
hqdefault-1
maxresdefault
downloadfile
natural_convection1
screenshot-1
screenshot
hqdefault
streamlines pt_PT
1-s2 0-S0898122117306168-gr15
465972 fig 007a
465972 fig 004
903618 fig 008a
903618 fig 008b
Plots-of-Jeffery-Hamel-flow-showing-a-velocity-magnitude-and-vectors-and-b-pressure_Q320
channel

volvocar
1_6ysnV5YUffrGmhHSjOkNxA
flow_velocity pt_PT

@Chetabahana Chetabahana merged commit 7909de0 into Chetabahana Nov 21, 2019
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.

2 participants