Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
pskd73 authored Dec 6, 2023
0 parents commit 30f9c1f
Show file tree
Hide file tree
Showing 24 changed files with 3,884 additions and 0 deletions.
13 changes: 13 additions & 0 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
on: push
name: Install and Test
jobs:
install:
name: Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- uses: pnpm/action-setup@v2
with:
version: 8
- run: pnpm i
- run: pnpm build && pnpm run lint
35 changes: 35 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
node_modules
.pnp
.pnp.js

# testing
coverage

# misc
.DS_Store
*.pem

# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# local env files
.env
.env.local
.env.development.local
.env.test.local
.env.production.local

# turbo
.turbo

# vercel
.vercel

# packages
dist
tsconfig.tsbuildinfo
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
auto-install-peers = true
8 changes: 8 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"eslint.workingDirectories": [
{
"mode": "auto"
}
],
"typescript.tsdk": "node_modules/typescript/lib"
}
60 changes: 60 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# Remotion Library Starter

This Turborepo template:

- allows you to develop your own Remotion libraries and components
- includes best practices for developing Remotion libraries out of the box
- includes an example package for testing your library

## Getting started

To create your own library, [use this repository as a template](https://github.com/new?owner=remotion-dev&template_name=library-starter&template_owner=remotion-dev).

After cloning the resulting library, start developing it:

```
pnpm i
pnpm run dev
```

Open the browser on http://localhost:3000 to see the testbed.
Edit the `packages/library` folder to change your library and edit `packages/example` to edit your testbed.

## Linting

To lint your code, run:

```sh
pnpm run lint
```

either from the root or from an individual package.

## Changing the library name

Before publishing, you should change the default name of `my-library` to your library name.

1. Stop all commands such as `pnpm run dev`
1. Ensure your desired NPM package name is available.
1. Find and replace all occurrences of `my-library` with your library name in the project, except for the occurence in `pnpm-lock.yaml`
1. Run `pnpm i`.

Also change your name in `packages/library/LICENSE.md` and `packages/library/package.json` as well as adjust the `packages/library/README.md`.

## Publishing

1. Run `pnpm run build` to build your library.
1. Increment the version of your library in `packages/library/package.json`.
1. Run `pnpm recursive publish` to publish your library to NPM.

## Cleaning

You can clear all caches and dependencies by running the following command in the root:

```bash
pnpm run clean
```

## Credits

This package was authored by [Mohit Yadav](https://github.com/Just-Moh-it/) and inspired by [Create-t3-turbo](https://github.com/t3-oss/create-t3-turbo/).
26 changes: 26 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"name": "library-starter",
"description": "Turborepo template that makes it easy to develop a library in the Remotion ecosystem with the best practices applied out of the box",
"author": {
"name": "Mohit Yadav",
"email": "yo@mohitya.dev",
"url": "https://mohitya.dev/",
"github": "https://github.com/Just-Moh-it/"
},
"private": true,
"scripts": {
"build": "turbo run build",
"lint": "turbo run lint",
"format": "prettier --write \"**/*.{ts,tsx,md}\"",
"dev": "turbo run dev",
"clean": "rm -rf packages/**/dist && rm -rf packages/**/.turbo && rm -rf packages/**/node_modules && rm -rf .turbo"
},
"devDependencies": {
"eslint": "^8.48.0",
"prettier": "^3.0.3",
"turbo": "1.10.15",
"tsup": "7.2.0",
"typescript": "^5.2.2"
},
"packageManager": "pnpm@8.6.10"
}
3 changes: 3 additions & 0 deletions packages/example/.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "@remotion"
}
3 changes: 3 additions & 0 deletions packages/example/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
## Studio example

Remotion studio environment that lets you test out internal components and hooks.
25 changes: 25 additions & 0 deletions packages/example/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"name": "studio",
"main": "./index.tsx",
"scripts": {
"start": "remotion studio",
"dev": "remotion studio --no-open",
"lint": "eslint src"
},
"dependencies": {
"react": "^18.2.0",
"react-dom": "^18.2.0",
"remotion": "^4.0.46",
"my-library": "workspace:*"
},
"peerDependencies": {
"remotion": "*"
},
"devDependencies": {
"@remotion/cli": "^4.0.46",
"@remotion/eslint-config": "^4.0.46",
"@types/react": "^18.2.26",
"@types/react-dom": "^18.2.11"
},
"private": true
}
21 changes: 21 additions & 0 deletions packages/example/src/Example.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { useCurrentSecond } from "my-library";
import { AbsoluteFill } from "remotion";

export default function Example() {
const second = useCurrentSecond();

return (
<AbsoluteFill
style={{
backgroundColor: "white",
flexDirection: "column",
alignItems: "center",
justifyContent: "center",
}}
>
<h1 style={{ fontSize: 200, fontFamily: "sans-serif", color: "black" }}>
Second {second.toFixed(2)}
</h1>
</AbsoluteFill>
);
}
19 changes: 19 additions & 0 deletions packages/example/src/Root.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { Composition } from "remotion";
import Example from "./Example";

const Root = () => {
return (
<>
<Composition
id="Example"
component={Example}
durationInFrames={30 * 10}
fps={30}
height={1080}
width={1920}
/>
</>
);
};

export default Root;
4 changes: 4 additions & 0 deletions packages/example/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { registerRoot } from "remotion";
import Root from "./Root";

registerRoot(Root);
8 changes: 8 additions & 0 deletions packages/example/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"jsx": "react-jsx"
},
"include": ["src"],
"exclude": ["node_modules"]
}
3 changes: 3 additions & 0 deletions packages/library/.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "@remotion"
}
7 changes: 7 additions & 0 deletions packages/library/LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Copyright 2023 Mohit Yadav

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 changes: 25 additions & 0 deletions packages/library/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
## `my-library`

A React hook for use with [Remotion](https://remotion.dev/) that returns the current second.

### Usage

```tsx
import { useCurrentSecond } from "my-library";
import { AbsoluteFill } from "remotion";

export const Example: React.FC = () => {
const second = useCurrentSecond();

return (
<AbsoluteFill>
<h1>Second: {second}</h1>
</AbsoluteFill>
);
};
```

## License

See the [LICENSE.md](LICENSE.md) file for the license of this repo.
To use Remotion, a company license is needed for some entities. [Read the terms here](https://github.com/remotion-dev/remotion/blob/main/LICENSE.md).
22 changes: 22 additions & 0 deletions packages/library/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"name": "my-library",
"version": "0.0.1",
"description": "Example react hook for use in remotion to get current second.",
"main": "./dist/index.js",
"module": "./dist/index.mjs",
"types": "./dist/index.d.ts",
"scripts": {
"build": "tsup src/index.ts --format cjs,esm --dts",
"dev": "tsup src/index.ts --format cjs,esm --dts --watch",
"lint": "eslint src"
},
"peerDependencies": {
"remotion": "*"
},
"devDependencies": {
"remotion": "^4.0.46"
},
"publishConfig": {
"access": "public"
}
}
1 change: 1 addition & 0 deletions packages/library/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from "./use-current-second";
8 changes: 8 additions & 0 deletions packages/library/src/use-current-second.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { useCurrentFrame, useVideoConfig } from "remotion";

export const useCurrentSecond = () => {
const currentFrame = useCurrentFrame();
const { fps } = useVideoConfig();

return currentFrame / fps;
};
8 changes: 8 additions & 0 deletions packages/library/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"rootDir": "src"
},
"include": ["src"],
"exclude": ["node_modules"]
}
Loading

0 comments on commit 30f9c1f

Please sign in to comment.