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

tts-types

v0.0.3

Published

<div align="center">

Downloads

9

Readme

Typescript Declarations for Tabletop Simulator

Hello! These types are intended to be used with Typescript to Lua. With that compiler you can transpile .ts files into .lua files. This package is the safety net for the Tabletop Simulator functions and objects. Let your editor have some nice autocompletion!.

Usage

  1. Install these packages and make a src directory:
npm i tts-types typescript typescript-to-lua
mkdir src
  1. Create tsconfig.json:
{
  "compilerOptions": {
    "rootDir": ".",
    "outDir": "build",

    "target": "ESNext",
    "lib": ["ESNext"],
    
    "moduleResolution": "nodenext",
    "module": "NodeNext",

    "declaration": false,
    "declarationMap": false,

    "strict": true,
    "types": ["tts-types"],
  },
  "tstl": {
    "luaTarget": "5.2",
    "noImplicitSelf": true,
    "tstlVerbose": true,
    "luaBundle": "bundle.lua",
    "luaBundleEntry": "src/index.ts",
  },
}

note: we use "luaTarget": "5.2" to be compatible with the LUA version Tabletop Simulator uses.

  1. Create src/index.ts
// The OnLoad function. This is called after everything in the game save finishes loading.
// Most of your script code goes here.
function onLoad( saveData: any ) {

  // Lock color-UI cube
  let cube = getObjectFromGUID( "c1a0d1" )
  cube.interactable = false
  cube.setLock( true )
}
  1. Your project is ready! run npx tstl to compile it into Lua
npx tstl

You will have some output like this:

Loaded 0 plugins
Parsing project settings
Transforming C:/Source/tts-test/src/index.ts
Printing C:/Source/tts-test/src/index.ts
Constructing emit plan
Resolving dependencies for C:/Source/tts-test/src/index.ts
Emitting output
Emitting C:/Source/tts-test/build/bundle.lua
Emit finished!

Your .lua file now exists at build/bundle.lua:

--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]

local ____modules = {}
local ____moduleCache = {}
local ____originalRequire = require
local function require(file, ...)
    if ____moduleCache[file] then
        return ____moduleCache[file].value
    end
    if ____modules[file] then
        local module = ____modules[file]
        ____moduleCache[file] = { value = (select("#", ...) > 0) and module(...) or module(file) }
        return ____moduleCache[file].value
    else
        if ____originalRequire then
            return ____originalRequire(file)
        else
            error("module '" .. file .. "' not found")
        end
    end
end
____modules = {
["src.index"] = function(...) 
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
function onLoad(saveData)
    local cube = getObjectFromGUID("c1a0d1")
    cube.interactable = false
    cube.setLock(true)
end
 end,
}
return require("src.index", ...)

I use this to copy it in automatically (package.json):

"scripts": {
    "compile": "tstl && npm run deploy",
    "deploy": "copy \"build\\bundle.lua\" \"%LOCALAPPDATA%\\Temp\\TabletopSimulator\\Tabletop Simulator Lua\\Global.-1.lua\""
}

So I can simply use npm run compile

Contributing (TODO)

  • Finish tests
  • Create example projects

Development

  1. Clone
  2. npm install
  3. npm run build to build the project
  4. npm run test to run tests