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

@rbxts/fabric

v1.1.11

Published

roblox-ts typings for evaera's Fabric.

Downloads

23

Readme

@rbxts/fabric

roblox-ts typings for evaera's Fabric.

npm i @rbxts/fabric @rbxts/t

NPM

Usage

ExampleUnit.ts

import { Fabric, UnitDefinition, ThisFabricUnit } from "@rbxts/fabric";

const fabric = new Fabric("game");

declare global {
	interface FabricUnits {
		ExampleUnit: ExampleUnitDefinition;
	}
}

//NOTE: you should never define the `name` field here. `name` should always be the same as the key in `FabricUnits`, which is done automatically for you.
interface ExampleUnitDefinition extends UnitDefinition<"ExampleUnit"> {
	//IMPORTANT: these three fields are for typing only, and they have to be optional so that the below implementation does not have to define them
	data?: { bar: boolean };
	_addLayerData?: { bar: true }; //if `_addLayerData` is not specified, `data` will be used.
	ref?: Player;

	//alternatively, if you are using `defaults` for this unit, you could omit the `data` field above and just add `defaults: { bar: boolean }`,
	//in which you would also have to do `defaults: { bar: true }` in the below implementation of this interface

	foo(this: ThisFabricUnit<"ExampleUnit">): void;
}

const exampleUnitDefinition: ExampleUnitDefinition = {
	name: "ExampleUnit",

	foo() {
		this.addLayer("exampleScope", { bar: true }); //here, `bar` must equal `true`.

		//hypothetically, if `_addLayerData` was not specified, then `bar` would be able to be `true` OR `false`, since those are of type `boolean`.
	},
};

fabric.registerUnit(exampleUnitDefinition);

const unit = fabric.getOrCreateUnitByRef("ExampleUnit", game); //attach an ExampleUnit to `game`
unit.foo();
print(unit.data!.bar); // > true

Changelog

1.1.11

- Fixed imports on `Symbol.d.ts` and `ServerTransmitter.d.ts`
- Add a hidden `_layers` typing to Units

1.1.10

- `lastData` parameter in `updated` lifecycles can be undefined

1.1.9

- Improved `UnitCollection:resolve()` typings

1.1.8

- Expose `UnitCollection:resolve(unitResolvable)` to be able to check if a unit has been registered
- (slightly) better Roact support

1.1.7

- Removed a package modification

1.1.6

- Fix `data` object detection for `defaults`

1.1.5

- `Unit.get(key): T[key]` now returns T[key] if it is specified in the `defaults` field, and T[key] | undefined if not. However, if `defaults` is not typed, it will respect the type of the field specified in `data`
- `addLayer` and `mergeBaseLayer` now accept a Partial of the data typing
- `defaults` can only be typed if `data` is an object

1.1.4

- Fixed defaults typing
- If `data` is not typed, `defaults` will be used
- Expose `DEBUG`

1.1.3

- Rollback fix for #3 (`getUnit` and `getOrCreateUnit`, as well as `UnitDefinition.units` ref validity)

1.1.2

- Fix PickByUnitRef

1.1.1

- `Unit.getUnit` and `Unit.getOrCreateUnit` now check for ref validity
- `UnitDefinition.units` now checks for ref validity and uses the `_addLayerData` type if applicable
- Members of `Reducers`, `Symbol`, and `SinglePromiseEvent` now show in intellisense
- `RoactUnitProps<TInstance, TFabricUnitNames>` exposed, can be used to intersect Roact props
- Unit data is no longer automatically made Partial<TData>
- Reorganized types

1.0.0

- Initial release