Skip to content

Commit

Permalink
feat: release v0.2.0 🎉
Browse files Browse the repository at this point in the history
  • Loading branch information
daltonmenezes committed Nov 16, 2022
0 parents commit b725914
Show file tree
Hide file tree
Showing 164 changed files with 13,506 additions and 0 deletions.
8 changes: 8 additions & 0 deletions .changeset/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Changesets

Hello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool that works
with multi-package repos, or single-package repos to help you version and publish your code. You can
find the full documentation for it [in our repository](https://github.com/changesets/changesets)

We have a quick list of common questions to get you started engaging with this project in
[our documentation](https://github.com/changesets/changesets/blob/main/docs/common-questions.md)
11 changes: 11 additions & 0 deletions .changeset/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"$schema": "https://unpkg.com/@changesets/[email protected]/schema.json",
"changelog": "@changesets/cli/changelog",
"commit": false,
"fixed": [],
"linked": [],
"access": "public",
"baseBranch": "main",
"updateInternalDependencies": "patch",
"ignore": ["web", "desktop"]
}
12 changes: 12 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
root = true

[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.md]
trim_trailing_whitespace = false
3 changes: 3 additions & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
github: daltonmenezes
patreon: daltonmenezes
issuehunt: daltonmenezes/interprocess?tab=idle
90 changes: 90 additions & 0 deletions .github/workflows/gh-page.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
name: Release GH Page

on:
workflow_dispatch:
release:
types:
- "published"

permissions:
contents: read
pages: write
id-token: write

concurrency:
group: "pages"
cancel-in-progress: true

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Detect package manager
id: detect-package-manager
run: |
if [ -f "${{ github.workspace }}/yarn.lock" ]; then
echo "::set-output name=manager::yarn"
echo "::set-output name=command::install"
echo "::set-output name=runner::yarn"
exit 0
elif [ -f "${{ github.workspace }}/package.json" ]; then
echo "::set-output name=manager::npm"
echo "::set-output name=command::ci"
echo "::set-output name=runner::npx --no-install"
exit 0
else
echo "Unable to determine packager manager"
exit 1
fi
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: "16"
cache: ${{ steps.detect-package-manager.outputs.manager }}

- name: Setup Pages
uses: actions/configure-pages@v2
with:
token: ${{ secrets.GITHUB_TOKEN }}
static_site_generator: next
generator_config_file: ./apps/web/next.config.mjs

- name: Restore cache
uses: actions/cache@v3
with:
path: |
./apps/web/.next/cache
key: ${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json', '**/yarn.lock') }}-${{ hashFiles('**.[jt]s', '**.[jt]sx') }}
restore-keys: |
${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json', '**/yarn.lock') }}-
- name: Install dependencies
run: ${{ steps.detect-package-manager.outputs.manager }} ${{ steps.detect-package-manager.outputs.command }}

- name: Build with Next.js
working-directory: ./apps/web
run: ${{ steps.detect-package-manager.outputs.runner }} next build

- name: Static HTML export with Next.js
working-directory: ./apps/web
run: ${{ steps.detect-package-manager.outputs.runner }} next export

- name: Upload artifact
uses: actions/upload-pages-artifact@v1
with:
path: ./apps/web/out

deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
needs: build
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v1
34 changes: 34 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Release

on:
workflow_dispatch:
release:
types:
- "published"

concurrency: ${{ github.workflow }}-${{ github.ref }}

jobs:
release:
name: Release
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@v2

- name: Setup Node.js 16.x
uses: actions/setup-node@v2
with:
node-version: 16.x

- name: Install Dependencies
run: yarn

- name: Create Release Pull Request or Publish to npm
id: changesets
uses: changesets/action@v1
with:
publish: yarn release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
34 changes: 34 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
node_modules/
.pnp
.pnp.js

# testing
coverage

# next.js
.next/
out/
build
dist

# misc
.DS_Store
*.pem

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

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

# turbo
.turbo
1 change: 1 addition & 0 deletions .husky/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
_
4 changes: 4 additions & 0 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npx --no-install commitlint --edit "$1"
4 changes: 4 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npx lint-staged
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2022 - * Dalton Menezes

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.
155 changes: 155 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
<p align="center">
<a href="#interprocess">
<img alt="preview" src="https://github.com/daltonmenezes/interprocess/raw/main/apps/web/public/banner.svg" width="100%">
</a>
</p>

<h3 align="center"><strong>interprocess</strong>: 💬 A scalable and type-safe Electron IPC management tool with enhanced DX</h3>

<p align="center">
<!-- GitHub -->
<a href="https://github.com/sponsors/daltonmenezes">
<img alt="github url" src="https://img.shields.io/badge/support%20on-github-1C1E26?style=for-the-badge&labelColor=1C1E26&color=ff7ac8"/>
</a>
<!-- Patreon -->
<a href="https://www.patreon.com/daltonmenezes">
<img alt="patreon url" src="https://img.shields.io/badge/support%20on-patreon-1C1E26?style=for-the-badge&labelColor=1C1E26&color=50e1c7"/>
</a>
<!-- Version -->
<a href="https://github.com/daltonmenezes/interprocess/releases">
<img alt="releases url" src="https://img.shields.io/npm/v/interprocess.svg?style=for-the-badge&labelColor=1C1E26&color=ff7ac8"/>
</a>
<!-- License -->
<a href="https://github.com/daltonmenezes/interprocess/blob/main/LICENSE">
<img alt="license url" src="https://img.shields.io/badge/license%20-MIT-1C1E26?style=for-the-badge&labelColor=1C1E26&color=50e1c7"/>
</a>
</p>

> Electron IPC is good, but difficult to maintain and scale, either because of the numerous channels you have to remember, or because of the inconsistent API between processes and the absence of inferred types of your channels and handlers. These are some of the things that interprocess comes to solve!
# 💬 Features
- 🚀 Best-in-class DX with a fully-typed API
- 🧠 Enchanced and consistent API
- 🔥 Type-safe and scalable
- 🪄 Code splitting support
- 🕸️ All edges connected (APIs to handle all processes)
- 💖 `invoke` and `handle` methods in both processes with the same expected behavior

# 💬 Installation
In your terminal, run:
```bash
yarn add interprocess

# OR

npm i interprocess
```

# 💬 Usage

Let's build something simple that can show you some of the interprocess's power!

First, create the following folders at `src`:

- `shared/ipcs` (this folder structure is optional)

Then, create a file named as `index.ts` in the `ipcs` folder with the following content:

```ts
import { createInterprocess } from 'interprocess'

const ipcs = createInterprocess({
main: {
async getPing(_, data: 'ping') {
const message = `from renderer: ${data} on main process`

console.log(message)

return message
},
},

renderer: {
async getPong(_, data: 'pong') {
const message = `from main: ${data} on renderer process`

console.log(message)

return message
},
},
})

export const {
ipcMain,
ipcRenderer,
exposeApiToGlobalWindow
} = ipcs
```

On the main process:

```ts
import { BrowserWindow, app } from 'electron'
import { ipcMain } from 'shared/ipcs'

app.whenReady().then(() => {
const mainWindow = new BrowserWindow({
webPreferences: {
preload: path.join(__dirname, '../preload/index.js'),
sandbox: false,
},
})

ipcMain.handle.getPing()

mainWindow.on('ready-to-show', () => {
ipcMain.invoke.getPong(mainWindow, 'pong')
})
})
```

In the preload script:

```ts
import { exposeApiToGlobalWindow } from 'shared/ipcs'

declare global {
interface Window {
[key]: typeof api
}
}

const { key, api } = exposeApiToGlobalWindow({
exposeAll: true, // expose handlers and invokers,
})
```
On the renderer process:
```ts
const { invoke, handle } = window.api

invoke.getPing('ping')
handle.getPong()
```
This is a simple way to work with interprocess, but there's a lot of more cool features you can take advantage, like overrides, code splitting, invoker's response (for renderer and main process 🎉) and more. See the [Knowledge section for more](#-knowledge)

# 💬 Knowledge
- [Docs](https://daltonmenezes.github.io/interprocess/docs/getting-started/overview)
- [Example (in-depth)](https://github.com/daltonmenezes/interprocess/tree/main/apps/desktop)


# 💬 Contributing
> **Note**: contributions are always welcome, but always **ask first**, — please — before work on a PR.
That said, there's a bunch of ways you can contribute to this project, like by:

- :beetle: Reporting a bug
- :page_facing_up: Improving the docs
- :rotating_light: Sharing this project and recommending it to your friends
- :dollar: Supporting this project on GitHub Sponsors or Patreon
- :bug: Funding an issue on IssueHunt
- :star2: Giving a star on this repository

# License

[MIT © Dalton Menezes](https://github.com/daltonmenezes/interprocess/blob/main/LICENSE)
3 changes: 3 additions & 0 deletions apps/desktop/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "@daltonmenezes/eslint-config"
}
Loading

0 comments on commit b725914

Please sign in to comment.