Skip to content

Commit

Permalink
feat: first draft
Browse files Browse the repository at this point in the history
  • Loading branch information
crimx committed Dec 31, 2024
1 parent 7321c5d commit 598e87d
Show file tree
Hide file tree
Showing 31 changed files with 10,972 additions and 1,595 deletions.
4 changes: 0 additions & 4 deletions .eslintignore

This file was deleted.

22 changes: 0 additions & 22 deletions .eslintrc.cjs

This file was deleted.

11 changes: 11 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file

version: 2
updates:
- package-ecosystem: "npm" # See documentation for possible values
directory: "/" # Location of package manifests
schedule:
interval: "weekly"
44 changes: 44 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: build
on:
push:
branches:
- main
jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout 🛎️
uses: actions/checkout@v4

- uses: actions/setup-node@v4
with:
node-version: lts/*
cache: npm

- name: Install dependencies 📦
run: npm ci

- name: Lint 🧹
run: |
npm run lint
npm run ts-check
- name: Build 🔧
run: npm run build

- name: Test 🧪
run: npm run test:ci

- name: Coveralls 🎉
uses: coverallsapp/github-action@v2
with:
github-token: ${{ secrets.GITHUB_TOKEN }}

- name: Build Docs 📖
run: npm run docs

- name: Deploy 🚀
uses: JamesIves/github-pages-deploy-action@v4
with:
branch: gh-pages
folder: docs
30 changes: 30 additions & 0 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
on: ["pull_request"]

name: Build and Test PR

jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- name: Checkout 🛎️
uses: actions/checkout@v4

- uses: actions/setup-node@v4
with:
node-version: lts/*
cache: npm

- name: Install dependencies 📦
run: npm ci

- name: Lint 🧹
run: |
npm run lint
npm run ts-check
- name: Build 🔧
run: npm run build

- name: Test 🧪
run: npm run test:ci
36 changes: 36 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Node.js Package

on:
push:
tags: "v**"
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
steps:
- name: Checkout 🛎️
uses: actions/checkout@v4

- uses: actions/setup-node@v4
with:
node-version: lts/*
registry-url: "https://registry.npmjs.org"
cache: npm

- name: Install dependencies 📦
run: npm install

- name: Build 🔧
run: npm run build

- name: Publish Package 🚀
run: npm publish --provenance --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
3 changes: 2 additions & 1 deletion .prettierrc.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"trailingComma": "es5",
"printWidth": 120,
"trailingComma": "all",
"tabWidth": 2,
"semi": true,
"singleQuote": false,
Expand Down
47 changes: 12 additions & 35 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,51 +1,28 @@
{
"typescript.tsdk": "node_modules/typescript/lib",
"cSpell.enabled": true,
"eslint.enable": true,
"prettier.enable": true,
"conventionalCommits.gitmoji": false,
"conventionalCommits.promptFooter": false,
"editor.tabSize": 2,
"editor.formatOnSave": true,
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.codeActionsOnSave": {
"source.fixAll": true,
"source.addMissingImports": true
},
"eslint.validate": ["javascript", "javascriptreact", "html", "vue", "svelte"],
"typescript.tsdk": "node_modules/typescript/lib",
"[html]": {
"editor.formatOnSave": true,
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[css]": {
"editor.formatOnSave": true,
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[scss]": {
"editor.formatOnSave": true,
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[json]": {
"editor.formatOnSave": true,
"editor.defaultFormatter": "esbenp.prettier-vscode"
"source.fixAll": "explicit",
"source.addMissingImports": "explicit",
"source.organizeImports": "never"
},
"editor.defaultFormatter": "esbenp.prettier-vscode",
"[javascript]": {
"editor.formatOnSave": true,
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[svelte]": {
"editor.formatOnSave": true,
"editor.defaultFormatter": "svelte.svelte-vscode"
"[javascriptreact]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[typescript]": {
"editor.formatOnSave": true,
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[typescriptreact]": {
"editor.formatOnSave": true,
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[markdown]": {
"editor.formatOnSave": true,
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[yaml]": {
"editor.formatOnSave": true,
"editor.defaultFormatter": "esbenp.prettier-vscode"
}
}
2 changes: 1 addition & 1 deletion LICENSE.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2022 wopjs
Copyright (c) 2024 CRIMX

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
39 changes: 30 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,36 @@
# @wopjs/template
# [value-enhancer](https://github.com/crimx/value-enhancer)

[![Docs](https://www.paka.dev/badges/v0/cute.svg)](https://www.paka.dev/npm/@wopjs/template)
<p align="center">
<img width="200" src="https://raw.githubusercontent.com/crimx/value-enhancer/main/assets/value-enhancer.svg">
</p>

Collection of common utilities.
[![Docs](https://img.shields.io/badge/Docs-read-%23fdf9f5)](https://crimx.github.io/value-enhancer)
[![Build Status](https://github.com/crimx/value-enhancer/actions/workflows/build.yml/badge.svg)](https://github.com/crimx/value-enhancer/actions/workflows/build.yml)
[![npm-version](https://img.shields.io/npm/v/value-enhancer.svg)](https://www.npmjs.com/package/value-enhancer)
[![Coverage Status](https://img.shields.io/coverallsCoverage/github/crimx/value-enhancer)](https://coveralls.io/github/crimx/value-enhancer)
[![minified-size](https://img.shields.io/bundlephobia/minzip/value-enhancer)](https://bundlephobia.com/package/value-enhancer)

## Install
Enhance value with plain and explicit reactive wrapper. Think of it as hook-style signals.

```
npm add @wopjs/template
```
Docs: <https://value-enhancer.js.org>

## Features

## License
- Plain reactivity.
Without the implicit-cast Proxy magic like Vue Reactivity and MobX.
- Single-layer shallow reactivity.
It does not convert the value with `Object.defineProperty` nor `Proxy`. Keeping everything as plain JavaScript value makes it easier to work with other libraries and easier for the JavaScript engine to optimize.
- Safe and fast lazy computation.
It solves multi-level derivation issue (like in [Svelte Stores](<(https://svelte.dev/repl/6218ae0ecf5c455195b4a76d7f0cff9f?version=3.49.0)>)) with smart lazy value evaluation.
- Weak side effects.
`Val`s are managed with `FinalizationRegistry` and `WeakRef` which means you can create and access derived `Val.value` without worrying about memory leaks. Disposers returned by subscriptions can also be easily managed with libraries like [`@wopjs/disposable`](https://github.com/wopjs/disposable).
- Explicit.
Reactive objects are easy to tell since their types are different from normal objects. Subscription also requires explicit dependency declaration which reduce the work of repetitive dynamic dependency collection in Proxy/Signal implementations.
- Simple DX.
Designed with ergonomics in mind. No hidden rules for getting or setting values. What you see is what you get.

MIT @ [wopjs](https://github.com/wopjs)
## Install

```bash
npm add value-enhancer
```
9 changes: 9 additions & 0 deletions assets/docs.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
.tsd-hierarchy {
display: none;
}

@media (min-width: 1025px) {
.tsd-index-group {
display: none;
}
}
5 changes: 5 additions & 0 deletions assets/value-enhancer.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 5 additions & 1 deletion cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,20 @@
"words": [
"coverallsapp",
"CRIMX",
"endregion",
"hyrious",
"lcov",
"Parens",
"pnpm",
"preinstall",
"treeshake",
"tsup",
"typedoc",
"Vals",
"vite",
"vitest",
"wopjs"
"wopjs",
"yoctocolors"
],
"ignorePaths": [
"**/coverage/**",
Expand Down
76 changes: 76 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
import jsEslint from "@eslint/js";
import gitignore from "eslint-config-flat-gitignore";
import eslintConfigPrettier from "eslint-config-prettier";
import importX from "eslint-plugin-import-x";
import perfectionist from "eslint-plugin-perfectionist";
import tsEslint from "typescript-eslint";

export default tsEslint.config(
jsEslint.configs.recommended,
...tsEslint.configs.recommended,
eslintConfigPrettier,
importX.flatConfigs.recommended,
perfectionist.configs["recommended-natural"],
gitignore(),
{
languageOptions: {
ecmaVersion: "latest",
globals: {
console: true,
process: true,
},
sourceType: "module",
},
rules: {
"prefer-const": "off",
"sort-imports": "off",
},
},
{
rules: {
"import-x/consistent-type-specifier-style": ["error", "prefer-inline"],
"import-x/no-duplicates": ["error", { considerQueryString: true, "prefer-inline": true }],
"import-x/no-unresolved": "off",
"import-x/order": "off",
"perfectionist/sort-imports": [
"error",
{
groups: [
"side-effect-style",
"style",
["builtin-type", "external-type", "internal-type", "parent-type", "sibling-type", "index-type"],
["builtin", "external"],
["internal", "parent", "sibling", "index"],
"object",
"unknown",
],
},
],
},
},
{
files: ["**/*.{js,mjs,cjs,jsx,mjsx,ts,tsx,mtsx}"],
languageOptions: {
parser: tsEslint.parser,
},
plugins: {
"@typescript-eslint": tsEslint.plugin,
},
rules: {
"@typescript-eslint/consistent-type-imports": ["error", { fixStyle: "inline-type-imports" }],
"@typescript-eslint/no-empty-interface": "off",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-non-null-assertion": "off",
"@typescript-eslint/no-unused-expressions": "off",
"@typescript-eslint/no-unused-vars": [
"error",
{
argsIgnorePattern: "^_",
destructuredArrayIgnorePattern: "^_",
ignoreRestSiblings: true,
varsIgnorePattern: "^_",
},
],
},
},
);
1 change: 1 addition & 0 deletions mangle-cache.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
Loading

0 comments on commit 598e87d

Please sign in to comment.