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

@teletron/magic-mirror-wrapper-node

v0.1.3

Published

This NPM package provides the functionality required for the backend part of a Teletron extension that wraps a [magic mirror](https://magicmirror.builders) module.

Downloads

14

Readme

magic-mirror-wrapper-node

This NPM package provides the functionality required for the backend part of a Teletron extension that wraps a magic mirror module.

The author of this wrapper is in no way affiliated with the Magic Mirror project. He is however a fan of the project and the community that has been build around it. This wrapper must be seen as an ode to magic mirror. This code is, similar to the Magic Mirror codebase, released under the MIT license.

Installation

Inside the folder where you want to place the backend code for the extension, run:

npm install @teletron/magic-mirror-wrapper-node

Usage

Inside the script where the "main" section of the package.json of the extension points to place the following:

const path = require('node:path');
const { start } = require('@teletron/magic-mirror-wrapper-node');

async function extensionStart(extensionManager) {
  await start(
    'module', // the name of the module
    'extension', // the name of the extension, as defined in the teletron section of the extension package.json
    teletron, // the ExtensionManager object provided by Teletron at initialization
    path.join(__dirname, '../module-code') // the path to the code of the module
  );

  // Add the component configuration
  extensionManager.components.add({
    name: 'componentname',
    displayName: 'Display name for Component',
    configuration: {
      fields: [
        {
          attribute: 'text',
          type: 'text',
          required: true,
          label: 'Text to display',
        },
      ],
    },
  });

  // Tell Teletron where to read the web scripts, the folder is ./web in this example. The second parameter is the files to load.
  // web.umd.js is the umd version of the @teletron/magic-mirror-wrapper-web, web.js is the custom initialization script, and web.css
  // is the css file, also from the @teletron/magic-mirror-wrapper-web package.
  extensionManager.assets(path.join(__dirname, './web'), [
    'web.umd.js',
    'web.js',
    'web.css',
  ]);
}

module.exports = extensionStart;

node_helper.js

In Magic Mirror modules it is possible to have a node worker running. This is done by providing a file called node_helper.js in the module folder. This wrapper will start the helper.

Some manual changes are required for the node_helper to work in this wrapper.

Necessary changes

Magic Mirror uses these two aliases, to make it easier for module developers.

moduleAlias.addAlias('node_helper', path.join(**dirname, '../../build/node/nodeHelper.js'));
moduleAlias.addAlias('logger', path.join(**dirname, '../../build/node/logger.js'));

These two aliases are not present in this wrapper, in order to make it work you need to replace the require statements:

const NodeHelper = require('node_helper');
const Logger = require('logger');

// become
const { NodeHelper, Logger } = require('@teletron/magic-mirror-wrapper-node');

Development

Contributing

Contributions are welcome. This does not necessarily have to be code, it can also be updated documentation, tutorials, bug reports or pull requests.

Please create an issue to propose a feature you want to implement, so that the details can be discussed in advance.

Updating the Magic Mirror version

This module uses parts of the magic mirror repository. When a new version of magic mirror releases, you can update these dependencies using the script below.

cd backend
rm -rf ./magic-mirror/*.*
mkdir /tmp/mm-clone
cd /tmp/mm-clone
git clone --depth 1 [email protected]:MichMich/MagicMirror.git .
cd -
cp -R /tmp/mm-clone/translations ./magic-mirror
rm -rf /tmp/mm-clone

Update the major and minor version of this package to have it reflect the last version tag of magic mirror. So that it is clear what the version is of the Magic Mirror assets that are used.

Debugging

To see the wrappers' debug logs, set the DEBUG environment variable to:

DEBUG=teletron:extensions:magic-mirror-wrapper:*