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

@concord-consortium/dynamic-text

v1.0.6

Published

Dynamic text manager and React component

Downloads

158

Readme

Dynamic text manager and React component

This repo consists of the following elements which work in tandem to enable "dynamic text" within Activity Player (AP). Currently dynamic text has the following features:

  • Enabling text to be read aloud

In the future we may add the following:

  • Text translations
  • Integration of the existing glossary highlighting code

System Design

DynamicText Component (component.tsx)

This is a React component that registers itself using a class instance, passed in a DynamicTextContext context, of the DynamicTextInterface which is implemented by both the DynamicTextManager and the DynamicTextProxy. This allows the component to be directly used in AP (which hosts an instance of DynamicTextManager) and each question interactive (which uses DynamicTextProxy to send LARA API custom messages to the host).

This component listens for messages to update its state in a callback after it registers itelf and then updates its className based on the read aloud properties passed in the callback. It also has a click handler that selects the component via the DynamicTextInterface interface.

DynamicTextContext React Context (context.ts)

This is a simple context provider containing a value of an instance of the DynamicTextInterface class. It also includes a helper hook. This context is used in AP to hold an instance of the DynamicTextManager and in question-interactives to hold an instance of the DynamicTextProxy.

DynamicTextManager Class (manager.ts)

This class implments the DynamicTextInterface and manages a map of registered DynamicText components along with tracking the currently selected component (which may be null to denote no component is selected). It also handles reading the selected text aloud if the component marks the text to be read aloud. A singleton instance of this class is created in AP and is set as the value for the DynamicTextContext.

DynamicTextProxy Class (proxy.ts)

This class also implements the DynamicTextInterface and proxies the method calls to the host via a Lara custom message. A singleton instance of this class is created per question interactive and is set as the value for the DynamicTextContext in each question interactive. The host then listens for custom dynamic text messages via the Lara api and calls the corresponding methods on its instance of the DynamicTextManager.

Note: the iframe-runtime in question-interactives contains an additional pure message proxy for all custom messages. This allows for interactives like the carousel, full screen, scaffolded and side by side interactive to pass messages from the interactives they host up to AP.

Development

All code is in TypeScript and built using Rollup. The build process first calls the Typescript compiler to generate the type information and then rollup to bundle the code. To build the code run npm run build, there is no watcher script.

Publishing

This library is published on npm as @concord-consortium/dynamic-text. To publish a new version update the package.json version and run npm publish. A prepublish script is included in package.json which builds the code so no separate build step is required.

License

This library is Copyright 2023 (c) by the Concord Consortium and is distributed under the MIT license.

See LICENSE for the complete license text.