Giter Site home page Giter Site logo

mattzeunert / immutable-object-formatter-extension Goto Github PK

View Code? Open in Web Editor NEW
134.0 6.0 14.0 770 KB

Make ImmutableJS objects more readable when viewed in Chrome DevTools

Home Page: https://chrome.google.com/webstore/detail/hgldghadipiblonfkkicmgcbbijnpeog

JavaScript 98.39% HTML 1.61%
immutablejs chrome-devtools

immutable-object-formatter-extension's Introduction

Immutable.js Object Formatter (Chrome Extension)

Transforms Immutable JS objects to a more readable format when they are logged to the console.

Install the Chrome Extension

Based on immutable-devtools.

The Chrome extension will only work if you enable Custom Formatters in the DevTools settings.

Step 1: Open DevTools settings

Step 2: Enable custom formatters

How it works

The code in "/immutable-devtools" is essentially just a copy of immutable-devtools.

The two main differences are:

  1. We can't use instanceof Immutable.Record to detect if an object is a record, since we don't have access to the Immutable module that's loaded on the page. (We only have access to the one loaded in the extension.)
    We can still identify Records correctly, but the way we do it means there's a chance that an internal change in how Immutable.JS works could break that.
  2. The code can be loaded and unloaded several times on the same page, so we can't rely on variables inside the modules to detect if the formatters have already been injected into the page. Instead I'm setting a window.__ImmutableJSDevToolsFormattersInstalled property.

Then all that's left to do is to load the code in "devtools.js".

Running the code locally

  1. npm install
  2. npm run dev
  3. Load the "/extension" directory as an unpacked Chrome extension
  4. Open "/test-page/index.html" to check everything looks as expected

Make sure to reload the extension after any changes.

immutable-object-formatter-extension's People

Contributors

gilbertek avatar mattzeunert 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  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

immutable-object-formatter-extension's Issues

Not seeing formatted results

I've installed the extension and enabled "Enable custom formatters" in chrome dev tool settings as per readme, but after doing so, I'm still not seeing the formatting in the screenshot.

I'm using Chrome v56.0.2924.76 (64-bit) on a MBP. Is there anything else I'm missing to get this to work? My current console settings look like this.

image

Symbols in maps causes formatter to break

Hey, thanks for this extension.

I get this error:

Custom Formatter Failed: Uncaught TypeError: Cannot convert a Symbol value to a number

When attempting to expand a immutable Map with symbols as keys.

ImmutableJS 4.0 breaks chrome extension

I believe that an api change in 4.0 will break immutable object formatter extension. Try this codepen for an example of a record not being formatted in the chrome console when logged out. Instead, I get "Custom Formatter Failed: record.keySeq is not a function" and an unformatted object:

image

Formatted objects in console are not accessible via keyboard

I am used to navigate objects in the console using only my keyboard, but the formatted version of the immutable objects will not expand if you use your keyboard. You have to use your mouse to click through and expand the objects.

I am happy to submit a PR for this--could you please advise what is the best approach?

Couldn't get working… until I restarted Chrome

OS: MacOS 10.12.6 (16G1314)
Chrome version: 65.0.3325.181

I've enabled the custom formatters…
screen shot 2018-05-01 at 09 11 13

… and now I've realised my browser needed to restart for a version update, so this is not an actual issue, but reporting it in case anyone else has the same problem & looks here for answers.

incorrectly displays Map properties of Records as Objects (Immutable 4.0.0-rc.9 only?)

I'm using Immutable 4.0.0-rc.9, but I'm not sure whether this happens with Immutable 3.

image

> console.log(Immutable);
(index):142 {default: {…}, version: "4.0.0-rc.9", Collection: ƒ, Iterable: ƒ, Seq: ƒ, …}
> const {Record, Map} = Immutable
undefined
> const Foo = Record({bar: Map()})
undefined
> Foo()
Record {
  bar: Object
    __proto__: Object
}
> Foo().get('bar')
Map[0]

Privacy Concerns

Hi,

I noticed when installing this chrome extension, it required some very liberal content permissions. I.E. it can read and change all your data on the websites you visit.

screen shot 2018-01-30 at 8 33 37 am

Can you explain why the object formatter requires such extreme permissions, and whether you can guarantee our data is safe? I will not be using the extension until those concerns are addressed. Thank you.

Nested properties not showing up

Great extension thank you so much Matt. I have had this issue for a few weeks now, when opening nested properties allI see is white. The work around is right clicking the object and selecting 'store as global variable' which can then be inspected at the bottom of the console. But this is inefficient... I have googled to see if others are having this issue and can't find any info - I know some other ppl are solving it the way I am right now too though. This does not happen with every object and I can't find the pattern for when it happens vs doesn't. This also happens when property values are extremely long and don't fit in the console window (resizing will fix it) but this isn't always the case.

Edit: I do think this has to do with line length. There are some values that are so long they would have to wrap even with the console window as wide as it can get and these are the ones that are not showing up.

Screen Shot 2019-10-10 at 3 28 25 PM

Screen Shot 2019-10-10 at 3 28 42 PM

possible way to determine if something is a record

Not at all elegant, but this is true for Records (not sure if it's true for anything else though):

Object.getPrototypeOf(Object.getPrototypeOf(Object.getPrototypeOf(thing)))['@@__IMMUTABLE_KEYED__@@']

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.