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

@cognite/reveal-parser-worker

v1.3.0

Published

Parser worker for reveal viewer

Downloads

661

Readme

Reveal parser worker

Used as a dependency for @cognite/reveal.

Parser-worker has some parts written on Rust, so build output contains worker files and .wasm file.

Getting started

Note that if you want to simply run the viewer you don't need to build parser-worker. It's already used as a dependency from the NPM to have proper types and built version is coming from Cognite CDN. Build it only if you're about to change parser-worker and want to test local changes.

Also, you might want to build it if you need to create a build with custom PUBLIC_PATH and host it on your own static server.

Don't forget that if you're committing your changes, you will need to publish a new NPM release and upload worker build to CDN.

Prerequisites

Install wasm-pack

Windows

With Rust installed and ready to go, open a command shell and run cargo install wasm-pack

Linux / macOS

You can either run the same command as in Windows, or install it faster through https://rustwasm.github.io/wasm-pack/

Build

cd ./parser-worker
yarn
yarn build

In case if you need to build with custom public path, just set the environment variable PUBLIC_PATH and run the build.

PUBLIC_PATH="https://static.server/parser-worker/" yarn build:prod

Notice that environment variable setting syntax differs if you use Windows.

set PUBLIC_PATH="https://static.server/parser-worker/" && yarn build:prod

If you set the env variable correctly, during the build you should see this printing in your console:

> ⬡ <webpack-log>: Worker local build config:
> ⬡ <webpack-log>:  { publicPath: 'https://static.server/parser-worker/' }

Now parser-worker/dist/local folder contains the built worker and wasm files. You can host them at your static server.

Local development

If you want to test your own changes in worker or rust module locally, all you need to do is to copy files from parser-worker/dist/local to some folder in examples.

You can simply use yarn local-cdn it does:

  • run parser-worker build
  • copy files to examples/public/local-cdn
  • build viewer with publicPath pointing on 'local-cdn'
  • run the examples server.

You will also need to link @cognite/reveal-parser-worker to the local version in order to get proper type declarations:

  • From parser-worker/: yarn link
  • From viewer/: yarn link @cognite/reveal-parser-worker

Notice that it builds the viewer with the same public path, so you don't have to override revealEnv in examples. If you do some changes for the viewer at the same time, you might want to run viewer build separately. For the viewer either build it with the same PUBLIC_PATH env variable, or specify the path to worker files in examples with revealEnv (see examples/routes.tsx).

If you're not overriding the revealEnv with the path to local-cdn - you should build the viewer with PUBLIC_PATH env variable that points on /local-cdn folder. For example:

cd ../viewer
PUBLIC_PATH="/local-cdn" yarn build --watch  

Make sure the path you use for building the parser-worker matches the path you run examples on (where worker files are available).

In case if you want to test worker changes outside examples, you still can use yarn local-cdn command, but notice that you'll need to override path to reveal workers with the revealEnv in your target project.

import { revealEnv, Cognite3DViewer } from '@cognite/reveal';
revealEnv.publicPath = `https://localhost:3000/local-cdn/`;

// ... then use reveal normally ...
const viewer = new Cognite3DViewer(/*...*/)

Note, that if you make any changes in build setup, it's important to run another examples-server on a different port than local-cdn, to have cross-domain worker initialisation in examples, and make sure both cases (same domain and different one) work fine.

See: https://github.com/cognitedata/reveal/blob/master/viewer/src/utilities/workers/WorkerPool.ts#L60-L65