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

@astrauka/wix-code-typescript-wrapper

v0.13.0

Published

Allows to write typescript developing code with Wix Local Editor. Compiles and uploads javascript to Wix.

Downloads

18

Readme

wix-code-typescript-wrapper

Allows writing typescript developing code with Wix Local Editor. Compiles and uploads javascript to Wix. Currently, there's no way to write typescript code in Local Editor. This library allows writing typescript code, then compiles it to javascript and puts to src directory where Wix Editor expects to find the javascript. It's far from perfect. You need to store typescript code in some repository as it's not part of Local Editor sources.

Disclaimer

This project is not maintained by Wix, and it has no deep integration with Local Editor. It adds a build and code sync step, transforming your typescript code to javascript and putting it in the right place. Typescript files are not synced to remote, which means you cannot edit typescript files in Web Editor. Changes in Web Editor will be overridden on build for files that have typescript sources defined.

Setup

  • initialize your Wix project with Local Editor
  • add the @astrauka/wix-code-typescript-wrapper module to development dependencies
  • initialize typescript project structure npx wix-code-ts init
  • update package.json with build configuration, copy configuration from example project:
    • scripts
    • watch
    • devDependencies
  • rewrite javascript files to typescript

Directory structure

typescript
  backend
    universal - shared between backend and frontend
    backend-api.ts - javascript module hosting functions to be invoked from frontend, will be copied to backend-api.jsw
    data.ts - data hooks
    tsconfig.json - typescript configuration, optimized to produce nice javascript output
  frontend
    pages - pages code, naming - PageName.ts
    public - public code, backend/universal is copied to public/universal to reuse common code
    page-elements.d.ts - define global page elements
    tsconfig.json - typescript configuration, optimized to produce nice javascript output
    wix-types.ts - references wix page types

Copying rules

  • backend -> src/backend
  • backend/backend-api.ts -> src/backend/backend-api.jsw
  • frontend/pages -> src/pages
  • frontend/public -> src/public
  • backend/universal -> src/public/universal

Files in src/backend and src/public are deleted to not leave trash on renaming a file. You have to port all files from bakcend and public to typescript at once.

Files in src/pages are not deleted. If there's no typescript file defined, the src file will not be deleted. When there is typescript file defined, it's compiled version will override the src file.

Development flow

  • pull changes from remote npm run wix:pull
  • start build watcher npm run build:watch
  • launch Local Editor npm run wix:editor
  • on file updated, it gets built and synced to src directory. To see the changes, exit preview mode and enter it again (Wix Local Editor limitation)
  • once you're done with the changes, use Local Editor to push files to remote

Local Editor only pushes directories that it manages, this means you can create custom directories for your purposes. They are not synced to remove, so you need to use version control system to sync the changes. This applies to the typescript directory as well. There's no deep integration to Local Editor or any other magic.

Once you experiment with the APIs, it's more convenient to do it in Web Editor and copy/paste the code when it works.

Limitations

Page elements autocompletion

PageElements define global page elements. There's no support for page specific elements.

In Web Editor $w('#element') gets autocompletion and type determination for each page separately. This is because each page element has a separate combination of pageElements.d.ts and tsconfig.json.

This project does not support this feature. You need to define the types of page elements: $w('#button' as 'Button) to get autocompletion and fix typescript compiler warnings.

Contribution guidelines

Check if there's no open issue discussing the same problem. If not, create an issue. Let's discuss the need and possible implementation and agree on who can implement it.