npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

rmlformatter

v2.14.99

Published

Roomle Component Definition language support and formatter

Downloads

1

Readme

Roomle Component Formatter

Includes JSON escaper/unescaper, which provides a possibility to replace /n with //n and vice-versa. This allows to have multiline value JSONs but still be able to use code prettifiers, schemas etc.

Features

RC-JSON Language and Tooling

  • If you open a .json file, that has components in its absolute path and the file contains "id": as a string, the language is automatically switched to RC-JSON.
    • If you want to force always or never open JSONs as RC-JSONs, you can change this in the settings under the entry
  • You can switch any JSON to RC-JSON and back using the "Change Language Mode" command or the >RC-JSON and >JSON buttons in the status bar.
  • RC-JSON loses JSON validations (because it is by its nature an invalid JSON). Different tools are still appliable if JSON is escaped (See Multiline Escaper feature).
    • Hint: If you want to still validate the JSON, you can always switch to it via the >JSON status bar button.
    • Note: If you are in the RC-JSON language and JSON fails to parse, the error pop-up will offer you to switch to JSON language.

Syntax Highlighting for Roomle Component Definition and Roomle Script

  • Syntax highlighting definition for the JSON structure is derived from JSON. Roomle Script syntax highlighting is derived from JavaScript.

  • This is tested with VS Code's default Light and Dark schemes.

RC-JSON syntax highlight of the Json sctructure

RC-JSON syntax highlight of the Roomle Script

Convert JSON to RC-JSON and back

  • Converts RC-JSON to a valid JSON. This collapses line breaks in the values and replaces them with \ns.
  • This allows you to quickly find JSON parse errors.
  • The selected langauge will be remembered the next time you open the file or switch to its tab again until end of the current VS Code instance.

Roomle Component Definition Formatter

  • A strict formatter supporting Roomle Script
  • Rules:
    • Indentation: 4 spaces
    • Indentation reasons:
      • { }, ( ), [ ], BeginObjGroup(); EndObjGroup();
      • geometry modifier functions (all transformations, set texture) indent by 1 space
    • Exactly one space around operators, one behind commas and semicolons
    • No spaces around ( and ) except 'for (' and 'if ('
    • No trailing spaces, empty have no spaces
    • Multiline string ends with a closing quote at the level of next JSON attribute
    • Ignores string values (= characters between apostrophes)
  • You can display the button for this functionality in the extension settings.

Roomle Component Definition Squasher, Deformater and Rescripter

In order to reduce file size, you can squash the component definition, which deletes all non-functional space characters in the RoomleScripts. This does not squash the JSON structure itself, because it is stored in a squashed form in the Rubens Admin database anyway. However, Rubens Admin keeps the RoomleScripts as they are. * ZIP files generated for import will have the component definitions squashed already.

In order to go further, you can deformat, which also deletes new line characters that are not inside strings.

You can apply the rescript function to poorly formatted or deformatted components. However, this is not covering 100% cases right and can not be considered as a true inverse function to deformatting. Rescript function is highly useful for automatically generated components, for example IDM based components. Use it with care.

Roomle Component Definition JSON Structure Normalizer

  • Sorts attributes of the JSON in a unified, defined way.
  • Especially useful if you are comparing true changes of component definition files with Git.
  • You can display the button for this functionality in the extension settings.

Automatic Formatting and Normalizing on Save

  • Whenever you save, the format and normalization are applied.
  • This can be set in the extension settings using the "Roomle: Autoformat On Save" setting.

Mass Formatting Tool

  • Context menu of directories in the Explorer view: Roomle: Process components, applies selected modifier functions: format, normalize, squash, deformat, rescript. Apply more at once by typing a comma-separated list.
    • Intended usage: open a folder you want to apply the modifiers in a separate VS Code instance. Use this command.
    • Warning: Always make sure you will be processing only the components you really want to.

Autocomplete Provider for Roomle Components

  • On autocomplete feed call, it inserts the following entries into the autocomplete list:
    • parameter keys
      • along with parameter keys, it also lists the possible values in the documentation area of the VS Code's Autocomplete
    • superseding keys with overrides support
    • internal variables
      • this is done by RegEx search for structures of [a-zA-Z0-9_.]*\s=\s (some.thing space = space)
      • not yet context-aware (everything is available everywhere)
  • Autocomplete feed is called automatically on changing editor tabs, opening new RC-JSON documents and applying formatting.

Code outline and tagging

  • Allows to quickly navigate between the component attributes and supports adding of your own /* #tag named tags */ and /* #region code regions */.

RC-JSON syntax highlight of the Roomle Script

Roomle Formatter Output Channel

  • Along with message pop-up windows, you can display eventual errors in the output channel.
  • You can invoke the output channel automatically on extension activation if you allow it in the extension settings.

Run configurator with componentId

  • Default mapped to Ctrl + LeftAlt + R or Cmd + Option + R, this will run a configurator in your browser with the componentId of your currently open component.
  • This does not load content from your disk. Content is loaded from the Rubens Admin database.
  • You can modify the URL base in the extension settings.

Open component definition entry in Rubens Admin

  • If you have a file ./content/metadata.json in your working folder, you can utilize the >RuAd status bar icon or run command Roomle: Open component definition entry in the Rubens Admin.
  • A tenant name is needed for this. This will be taken from the name of the VS Code working folder or defined in the metadata.json file.
    • Note: This is a change against versions 2.6.0 and older, which took the tenant name from the path differently.
  • Example file:
{
    "tenant": "mytenant", // default tenant name, if is not overriden; undefined -> name of the working folder is taken
    "catalogToTenantOverride": {
        "anothercatalogue": "anothertenant", // override tenant if componentId is in `anothercatalogue`, including its drafts
        "anothercatalogue_draft43": "yetanothertenant" // only this draft is open in `yetanothertenant`
    }
}

Code folding regions

Code between

/* #region code regions */
/* #endregion */

can be folded if this is allowed in your VS Code settings.

TABLE of parameters function

Usage:

  1. Write the following in a RoomleScript
#TABLE parameter1, parameter2, ...
  1. Apply formatting

The result is an if-structure of all possible parameter values (validValues, valueObject) combinations.

Set component definition as unused

This will delete all attributes from the component definition but id and onUpdate with a note that the component is unused.

Requirements

JSON keys and values delimiter characters must be quote "

There can't be quote characters inside values, even "

No other extensions are required.

Known Issues

  • While mass formatting all open JSONs, pressing the stop formatting button does not help when a script is too big making the formatter stuck.