Giter Club home page Giter Club logo

fulcro-inspect's Introduction

fulcro-inspect

Clojars Project

Latest Release: CircleCI

Inspect Fulcro applications

Usage for Fulcro 2.x with Chrome

Add the latest version of this library (see above) as a dependency:

[fulcrologic/fulcro-inspect "x.x.x"]

Add a preload to your compiler options:

:compiler {...
           :preloads        [fulcro.inspect.preload]}

The inspector will find the running Fulcro application, and be ready to inspect it!

Next you have to install the Chrome Extension: https://chrome.google.com/webstore/detail/fulcro-inspect/meeijplnfjcihnhkpanepcaffklobaal

Be sure to reload your page after installing it. Now you can see the Fulcro logo get colors when it detects a Fulcro app, from then open Fulcro Inspect tab on the Chrome Devtools and happy inspecting!

Usage for Fulcro 3.x with Chrome

Do not include this library as a dependency. Inspect is written in Fulcro 2.x, and adding it to your dependencies will confuse you by having two different version of Fulcro (which can co-exist, but will cause confusion). Instead just install the Chrome extension https://chrome.google.com/webstore/detail/fulcro-inspect/meeijplnfjcihnhkpanepcaffklobaal and add the following preload to your shadow-cljs config:

:compiler {...
           :preloads        [com.fulcrologic.fulcro.inspect.preload]}

That preload is actually part of Fulcro 3.x itself.

In case you are having trouble to run the extension on Chrome, try to unblock third part cookies:

  1. Go to chrome://settings/content/cookies
  2. Uncheck Block third-party cookies
  3. Restart browser

Using the Fulcro 3.x Electron App

Fulcro Inspect now has a standalone electron app. This only works with Fulcro 3, and there are no plans to back-port to 2.x. You can download a release for your platform in the Releases section of this repository.

https://github.com/fulcrologic/fulcro-inspect/releases

NOTE: Fulcrologic does not currently have signing keys, so these binaries will complain that they are unsigned.

The Electron app creates a well-known websocket server port that Fulcro applications can connect to for exchanging inspect messages. This means you need to have your application configured with a different preload that knows how to connect.

IMPORTANT: Inspect 2.3.0-RC1 requires Fulcro 3.1.5-RC1 or greater. The electron app is built with sente version 1.15.0 (as of the latest electron release). If you use sente on your project for websockets this version difference could cause problems depending on the version difference.

WARNING: React Native builds will need to set an environment variable (or JVM system property) SENTE_ELIDE_JS_REQUIRE=true in order for sente to work inside of mobile runtimes.

To use the electron inspect make sure you add this preload to your preloads:

:compiler {...
           :preloads        [com.fulcrologic.fulcro.inspect.websocket-preload]}

or call the function com.fulcrologic.fulcro.inspect.inspect-ws/install-ws somewhere in your development startup.

Choosing the Websocket Port

The Electron app includes an input field at the top of the UI for the websocket port to use (default 8237). Pressing Restart Websockets will cause it to save the port and restart the websocket server. This allows you to use an alternate port should 8237 already be bound by another process; however, in order to do this you must change the port in two places: That input field, and in your build configuration.

In your CLJS build, set closure-defines. In shadow-cljs.edn this is done like this:

 :builds   {:main     {:target     :browser
                       ...
                       :dev        {:closure-defines  {com.fulcrologic.fulcro.inspect.inspect_ws/SERVER_PORT 3003}}
                       :devtools   {:preloads [com.fulcrologic.fulcro.inspect.websocket-preload]}}}

The value of SERVER_PORT must match what you wish to use in the Electron app. The electron app itself will remember the port you last used between restarts, so you can safely set some known good value for this in your system (note: only admins can use ports 1-1024, so choose a number bigger than that).

Known Limitations

  • Applications connect to inspect when they start. If you start the electron version of Inspect after your app, then you'll need to reload you app for it to connect.

Inspect Features

DB Tab

The DB tab contains the state of the app.

Use the triangles to expand/collapse data:

Expand/collapse data

Click on expanded keys to watch their content:

Watch DB

Use cmd/meta key + click to expand/collapse the whole sub-tree:

Expand/collapse sub-tree

To copy contents from maps or sequences, expand it and them click on the copy button:

Copy data

Building Chrome Extension

If you want to build the extension yourself and run from it, first run the release builder:

./script/release-chrome

The extension release version will be ready at releases/chrome.

Now, in the chrome extensions page (chrome://extensions/), first make sure you have Developer mode turned on, then look for a button saying Load Unpacked, click on it and navigate to the releases/chrome diretory to load the extension from there.

Contributing

To run the development version of the extension, first install the npm packages:

npm install

And then run the shadow compilation:

npm run dev-chrome

The go in at Chrome extensions and add the unpackaged version from the path shells/chrome.

Remember to disable the chrome store version to avoid having multiple instances running.

To use the client versin on the app, install locally with lein install or use clojure deps.edn to point the :local/root at this repository.

Authors

Fulcro Inspect was written and contributed by Wilker Lucio.

License

The MIT License (MIT) Copyright (c) 2017, Fulcrologic, LLC

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

fulcro-inspect's People

Contributors

awkay avatar dvingo avatar holyjak avatar lilactown avatar mitchelkuijpers avatar pancia avatar wilkerlucio avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

fulcro-inspect's Issues

Add settings tab

Add a settings panel, currently wanted nobs:

  • Max number of recorded transactions (currently 100)
  • Max number of recorded network requests (currently 50)
  • Max number of db history (currently 100)

Add ability to re-run a transaction in the transaction log

Now that the history view has the ability to reset app state to a specific step, it might be useful to be able to re-run certain transactions just by clicking on a button on their row. For example, a load might be triggered by internal logic (say startup), but you may want to retry it in the current context instead of reloading the entire app.

inspector db viewer stops working when using workspaces

Fulcroinspect version 1.0.16.
Chrome Version 76.0.3809.132 (Official Build) (64-bit)
Os: Mac 10.14.6 (18G95)

I have one workspaces defcard that will stop the fulcro inspect db viewer from working. (clicking on the inspector button for the card does nothing) After attempting to open this card i need to restart chrome for the inspector to work.

The card renders and works fine. The name of the card is playlist-viewer-factory. If i change the name of the card to be something else (then restart chrome) the inspector works.

Not really sure what other information would be helpful in debugging this, feel free to ask.

Add UI Performance Tab

Fulcro 3 will include hooks to measure rendering performance. Add a tab to display the info.

Add Internationalization Tab

The i18n support could easily let you edit strings in-place in the UI, and save the translations to the PO files. This would make internationalizing your app a very easy task. Basic steps:

  • Add dev mode hooks to tr and friends to support toggling into "editable mode". Normally they render strings...in this mode they'd render interactive components that look like strings.
  • Add tab to inspect that allows you to see the internationalized strings as a table, where selecting an element highlights it in the UI, etc.

DB History

  • Store last N states
  • UI to navigate the data

Data Watcher - watch a query

Some way to add watches that are Fulcro queries, so we can get live feedback on some specific part of the DB filtered via the given query.

Shortcut stops working on the iframe side after code reload

When the page reloads the iframe seems to get re-mounted, when that happens the keyboard event listener is lost and for some reason (debug needed) it can't attach the event back. This doesn't prevent the shortcut to work on the main frame, clicking there and hitting the shortcut works, but it's a little annoyance that you have to click out before the keystroke works.

Float on bottom

Add option to make inspector live attached to the footer instead of the right side.

Improve history slider

The history slider on the DB tab should do a better job of rendering so that the UI looks correct. Leveraging the history against the real root render might be possible, and would be desirable...a better general history API into Fulcro itself would be helpful, perhaps. The current history support in Fulcro could probably be leverage to make this more consistent and sane (e.g. marking history steps with a unique ID that could be shared with the copy of state in Inspect, along with a goto function that Inspect could use to control the history "cursor")

OgE Integration

  • Flame graph support on network requests
  • Run queries against app network

Not working in an iframe

The current version of fulcro-inspect 2.2.0-beta8 is not connecting to my app which runs in an iframe.

"socket.io-client" is not available

I updated shadow-cljs (2.8.61) and Fulcro (3.0.2), and sprang upon this problem. I'm not sure if either or both are the cause of it.

The required JS dependency "socket.io-client" is not available, it was required by "com/fulcrologic/fulcro/inspect/inspect_ws.cljs".

So I did the old yarn add socket.io-client. Though the complaint is gone, Fulcro Inspect seems unsatisfied by this solution, reporting that no app is connected.

Support ClojureScript 1.10.64

Hi,

ClojureScript 1.10.64 is no longer returning 2-element vectors for map entries, it now returns a dedicated map entry type and that seems to be the cause of this error:

screen shot 2018-02-27 at 9 30 21 pm

Resizable columns in Query tab

I was writing a query today and felt I needed more space to see the whole thing. Would it be possible to make these areas resizable? ๐Ÿ˜ฌ

Thanks!

Process inspector events on a web worker

On large apps, the processing of fulcro-inspect handlers can have a perceived effect on the app performance. Moving the processing to a web worker might solve this issue.

DB Snapshot

  • Record state snapshots
  • UI to navigate recorded data snapshots
  • Apply snapshot back to app state

Infinite loops in networking

Got a custom remote that goes into an infinite loop with inspect. Works fine with prior versions (was using beta8 I think). It is hitting REST endpoint. Not sure why yet, but it is quite surprising and bothersome...v2.2.1

Assertion error on startup (minimal case to follow)

In the project I'm working on, about 18 copies of this error appears. I currently suspect it's related to the number of mutations I've registered. I will investigate soon. As the title says, minimal case to follow.

[fulcro.client.impl.application] Mutation  fulcro.inspect.ui.transactions/add-tx  failed with exception Error: Assert failed: Path [:fulcro.inspect.ui.transactions/tx-list-id [:fulcro.inspect.core/app-id some-app.ui.root/Root] :fulcro.inspect.ui.transactions/tx-list] for append must target an app-state vector.
(vector? (get-in state data-path))

Remote inspect

A remote app to inspect your fulcro data. This feature is for a new stand-alone app, this app will open a web-socket port and have a web-ui view (probably in Electron), this will listen for changes into apps that connect remotely to the stand-alone app.

With this, we can inspect apps running on different environments like React Native, Chrome plugins/extensions, etc.

Have a Force Root Render button

Sometimes when I'm debugging why a component is not updating, it would be useful to trigger a root re-render to see if it's a query/follow-on-read issue or a state issue.

Probably makes sense to put this button in the elements tab.

`nil` running through props

(ns applets.inspect-bug.core
  (:require [fulcro.client :as fc]
            [fulcro.client.primitives :as prim :refer [defsc]]
            [fulcro.client.dom :as dom]))

(defonce app (atom nil))

(defsc Business [_ {:business/keys [favorite-food]}]
  {:initial-state (fn [_] {:business/favorite-food "lolly-pops"})
   :query [:business/favorite-food]}
  (assert (string? favorite-food))
  (dom/p (str "In this business the favourite food is " favorite-food)))

(defsc BusinessRoot [this _]
       {:initial-state (fn [_] {:ui/root (prim/get-initial-state Business _)})
        :query         [{:ui/root (prim/get-query Business)}]}
       (let [{:ui/keys [root]} (prim/props this)]
         (dom/div ((prim/factory Business) root))))

(defn mount []
  (reset! app (fc/mount @app BusinessRoot "app")))

(defn ^:export init [_]
  (reset! app (fc/new-fulcro-client))
  (mount))

So the above code works fine. But when you introduce Fulcro Inspect and press the key that toggles the tool's visibility you get a big stack trace. I won't include the full thing, but these lines might help:

core.cljs:11 Uncaught Error: Assert failed: (string? favorite-food)
...
fulcro.client.primitives.force_update.cljs$core$IFn$_invoke$arity$2 @ primitives.cljc:2045
fulcro$client$primitives$force_update @ primitives.cljc:2041
fulcro.client.primitives.force_update.cljs$core$IFn$_invoke$arity$1 @ primitives.cljc:2049
fulcro$client$primitives$force_update @ primitives.cljc:2041
fulcro$client$primitives$update_component_BANG_ @ primitives.cljc:2069
fulcro$client$primitives$optimal_render @ primitives.cljc:2114
fulcro.client.primitives.Reconciler.fulcro$client$impl$protocols$IReconciler$reconcile_BANG_$arity$2 @ primitives.cljc:2257
fulcro.client.impl.protocols.reconcile_BANG_.cljs$core$IFn$_invoke$arity$2 @ protocols.cljc:23
fulcro$client$impl$protocols$reconcile_BANG_ @ protocols.cljc:11
fulcro.client.primitives.Reconciler.fulcro$client$impl$protocols$IReconciler$reconcile_BANG_$arity$1 @ primitives.cljc:2232
fulcro.client.impl.protocols.reconcile_BANG_.cljs$core$IFn$_invoke$arity$1 @ protocols.cljc:23
fulcro$client$impl$protocols$reconcile_BANG_ @ protocols.cljc:11
(anonymous) @ primitives.cljc:1971
requestAnimationFrame (async)
fulcro$client$primitives$queue_render_BANG_ @ primitives.cljc:1966
fulcro$client$primitives$schedule_render_BANG_ @ primitives.cljc:1971
fulcro$client$primitives$add_fn @ primitives.cljc:2191
cljs.core.Atom.cljs$core$IWatchable$_notify_watches$arity$3 @ core.cljs:4394

Finding text in DB does not work

I tried to search for a value using ctrl/command + f but it pops up search in the current page, not the DB. I noticed there is a Find field at the bottom but that doesn't work as well.

Thanks!

Chrome plugin icon on toolbar never "lights up"

The plugin seems to be working for me, but at first I thought it was broken because the icon in the main toolbar is always "off", even though it has detected an app andthe menu item within it is working, as is the devtools tab itself.

Chrome plugin sucks CPU

Not sure what happened, but when using the chrome plugin it started sucking CPU like mad. The older version of inspect didn't do this. The main note is the the app I'm running has a very high transaction rate during page load (perhaps 50+ transact! calls on page load).

I had to back out to an earlier version for normal work because it added too much overhead. 2.1.0 is fine.

Docked version

Experiment to try to dock the inspector panel so you can see more of the page content.

Element Panel

  • Pick elements by clicking
  • Element tab UI - class name
  • Element tab UI - props
  • Element tab UI - ident
  • Element tab UI - query
  • Pick only from the current app
  • Arrow design for label

Remember inspector state

Make inspect remember the view state on page reload; the settings will be saved on local storage.

Things to be remembered:

  • Open state (open/closed)
  • Inspector size
  • Dock Side

Use db hashes for app scrubbing

Currently, we send the db from the devtool to the screen, this can be made more efficient by using the hash optimization like we do for transaction transmission.

Problems with expression parsing (purely cosmetic)

It seems that the query tab sometimes has problems understanding deep levels of nesting (though I've only encountered this in writing arguments to functions).

Screenshot 2019-10-21 at 14 56 20

To reproduce, paste the following into the editor:

[{(:zd/search_articles_advanced_2
   {:n_results 10
    :filter_expr {:should [{:must [{:terminal_exprs {:matches_text "Water"}}]}]}})
  [:zd.Article/article_title]}]

Inspect interferes with progress updates in networking

I just customized networking for file uploads, and when inspect is present it wraps the networking and causes it to mis-detect the kind of network, which in turn sends nil for the progress update function, and that keeps progress updates from reporting.

Show IDs of state machine mutations in transactions tab

This is a fulcro incubator specific thing, but perhaps it will also apply to a few fulcro things. These days, I get a lot of

fulcro.incubator.ui-state-machines/trigger-state-machine-event
fulcro.incubator.pessimistic-mutations/finish-pmutation
fulcro.client.mutations/merge!

so the transactions tab in the fulcro inspector becomes less useful. I almost always have to scroll to the right to be able to distinguish between all these generic mutations. I think exposing IDs (somehow) would be a huge usability boost.

Check client version from Remote

The system might stop working in case user client version of Fulcro inspect is outdated. We should verify and alert the user in case he is using some outdated version.

app-id nil

I am getting this 3 times when starting my application that uses the tool:

[ 2.547s] [fulcro.client] Mutation fulcro.inspect.ui.transactions/add-tx failed with exception Error: Assert failed: Path [:fulcro.inspect.ui.transactions/tx-list-id [:fulcro.inspect.core/app-id nil] :fulcro.inspect.ui.transactions/tx-list] for append must target an app-state vector. (vector? (get-in state data-path))

Does the host application have to have a "displayName"? From the fulcro.inspector source:

(some-> reconciler fp/app-root fp/react-type (gobj/get "displayName") symbol)

What is this "displayName" and how to ensure that hosting applications always have it?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.