Skip to content

Commit

Permalink
Move plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
lxsmnsyc committed Dec 5, 2023
1 parent f976990 commit 22dcc59
Show file tree
Hide file tree
Showing 15 changed files with 461 additions and 73 deletions.
18 changes: 18 additions & 0 deletions packages/plugins/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
module.exports = {
"root": true,
"extends": [
'lxsmnsyc/typescript',
],
"parserOptions": {
"project": "./tsconfig.eslint.json",
"tsconfigRootDir": __dirname,
},
"rules": {
"import/no-extraneous-dependencies": [
"error", {
"devDependencies": ["**/*.test.ts"]
}
],
"prefer-template": "off"
}
};
107 changes: 107 additions & 0 deletions packages/plugins/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage
*.lcov

# nyc test coverage
.nyc_output

# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# TypeScript v1 declaration files
typings/

# TypeScript cache
*.tsbuildinfo

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
.env
.env.production
.env.development

# parcel-bundler cache (https://parceljs.org/)
.cache

# Next.js build output
.next

# Nuxt.js build / generate output
.nuxt
dist

# Gatsby files
.cache/
# Comment in the public line in if your project uses Gatsby and *not* Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
# public

# vuepress build output
.vuepress/dist

# Serverless directories
.serverless/

# FuseBox cache
.fusebox/

# DynamoDB Local files
.dynamodb/

# TernJS port file
.tern-port

.npmrc
7 changes: 7 additions & 0 deletions packages/plugins/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
MIT License Copyright (c) 2023 Alexis Munsayac <alexis.munsayac@gmail.com>

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 (including the next paragraph) 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.
110 changes: 110 additions & 0 deletions packages/plugins/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
# seroval

> Stringify JS values
[![NPM](https://img.shields.io/npm/v/seroval.svg)](https://www.npmjs.com/package/seroval) [![JavaScript Style Guide](https://badgen.net/badge/code%20style/airbnb/ff5a5f?icon=airbnb)](https://github.com/airbnb/javascript)

## Install

```bash
npm install --save seroval
```

```bash
yarn add seroval
```

```bash
pnpm add seroval
```

## Usage

```js
import { serialize } from 'seroval';

const object = {
number: [Math.random(), -0, NaN, Infinity, -Infinity],
string: ['hello world', '<script>Hello World</script>'],
boolean: [true, false],
null: null,
undefined: undefined,
bigint: 9007199254740991n,
array: [,,,], // holes
regexp: /[a-z0-9]+/i,
date: new Date(),
map: new Map([['hello', 'world']]),
set: new Set(['hello', 'world']),
};

// self cyclic references
// recursive objects
object.self = object;
// recursive arrays
object.array.push(object.array);
// recursive maps
object.map.set('self', object.map);
// recursive sets
object.set.add(object.set);

// mutual cyclic references
object.array.push(object.map);
object.map.set('mutual', object.set);
object.set.add(object.array);

const result = serialize(object);
console.log(result);
```

Output (as a string):

```js
((h,j,k,m,o)=>(o={number:[0.3325212548332517,-0,0/0,1/0,-1/0],string:["hello world","\x3Cscript>Hello World\x3C/script>"],boolean:[!0,!1],null:null,undefined:void 0,bigint:9007199254740991n,array:h=[,,,,k=(j=[],new Map([["hello","world"],["mutual",m=new Set(["hello","world"])]]))],regexp:/[a-z0-9]+/i,date:new Date("2023-11-19T09:25:24.118Z"),map:k,set:m},h[3]=h,k.set("self",k),m.add(m).add(h),o.self=o,o))()

// Formatted for readability
((h, j, k, m, o) => (
(o = {
number: [0.3325212548332517, -0, 0 / 0, 1 / 0, -1 / 0],
string: ["hello world", "\x3Cscript>Hello World\x3C/script>"],
boolean: [!0, !1],
null: null,
undefined: void 0,
bigint: 9007199254740991n,
array: (h = [
,
,
,
,
(k =
((j = []),
new Map([
["hello", "world"],
["mutual", (m = new Set(["hello", "world"]))],
]))),
]),
regexp: /[a-z0-9]+/i,
date: new Date("2023-11-19T09:25:24.118Z"),
map: k,
set: m,
}),
(h[3] = h),
k.set("self", k),
m.add(m).add(h),
(o.self = o),
o
))();
```

## Docs

- [Serialization](https://github.com/lxsmnsyc/seroval/blob/main/docs/serialization.md)
- [Compatibility](https://github.com/lxsmnsyc/seroval/blob/main/docs/compatibility.md)
- [Isomorphic References](https://github.com/lxsmnsyc/seroval/blob/main/docs/isomorphic-refs.md)

## Sponsors

![Sponsors](https://github.com/lxsmnsyc/sponsors/blob/main/sponsors.svg?raw=true)

## License

MIT © [lxsmnsyc](https://github.com/lxsmnsyc)
86 changes: 86 additions & 0 deletions packages/plugins/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
{
"name": "seroval-plugins",
"type": "module",
"version": "0.15.1",
"files": [
"dist",
"web"
],
"engines": {
"node": ">=10"
},
"license": "MIT",
"keywords": [
"pridepack"
],
"devDependencies": {
"@types/node": "^20.8.3",
"@vitest/ui": "^1.0.1",
"eslint": "^8.51.0",
"eslint-config-lxsmnsyc": "^0.6.6",
"pridepack": "2.5.1",
"seroval": "0.15.1",
"tslib": "^2.6.2",
"typescript": "^5.3.2",
"vitest": "^1.0.1"
},
"peerDependencies": {
"seroval": ">=0.15"
},
"scripts": {
"prepublishOnly": "pridepack clean && pridepack build",
"build": "pridepack build",
"type-check": "pridepack check",
"lint": "pridepack lint",
"clean": "pridepack clean",
"watch": "pridepack watch",
"start": "pridepack start",
"dev": "pridepack dev",
"test": "vitest",
"test:ui": "vitest --ui"
},
"private": false,
"description": "Stringify JS values",
"repository": {
"url": "https://github.com/lxsmnsyc/seroval.git",
"type": "git"
},
"homepage": "https://github.com/lxsmnsyc/seroval/tree/main/packages/plugins",
"bugs": {
"url": "https://github.com/lxsmnsyc/seroval/issues"
},
"publishConfig": {
"access": "public"
},
"author": "Alexis Munsayac",
"types": "./dist/types/src/index.d.ts",
"main": "./dist/cjs/production/index.cjs",
"module": "./dist/esm/production/index.mjs",
"exports": {
".": {
"development": {
"require": "./dist/cjs/development/index.cjs",
"import": "./dist/esm/development/index.mjs"
},
"require": "./dist/cjs/production/index.cjs",
"import": "./dist/esm/production/index.mjs",
"types": "./dist/types/src/index.d.ts"
},
"./plugins/web/url": {
"development": {
"require": "./dist/cjs/development/plugins/web/url.cjs",
"import": "./dist/esm/development/plugins/web/url.mjs"
},
"require": "./dist/cjs/production/plugins/web/url.cjs",
"import": "./dist/esm/production/plugins/web/url.mjs",
"types": "./dist/types/plugins/web/url/index.d.ts"
}
},
"typesVersions": {
"*": {
"plugins/web/url": [
"./dist/types/plugins/web/url/index.d.ts"
]
}
}
}
6 changes: 6 additions & 0 deletions packages/plugins/pridepack.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"target": "es2018",
"entrypoints": {
"./web/url": "web/url/index.ts"
}
}
23 changes: 23 additions & 0 deletions packages/plugins/tsconfig.eslint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"exclude": ["node_modules"],
"include": ["web"],
"compilerOptions": {
"module": "ESNext",
"lib": ["ESNext", "DOM"],
"importHelpers": true,
"declaration": true,
"sourceMap": true,
"rootDir": "./",
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true,
"moduleResolution": "bundler",
"jsx": "react",
"esModuleInterop": true,
"target": "ESNext",
"useDefineForClassFields": false,
"declarationMap": true
}
}
23 changes: 23 additions & 0 deletions packages/plugins/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"exclude": ["node_modules"],
"include": ["web"],
"compilerOptions": {
"module": "ESNext",
"lib": ["ESNext", "DOM"],
"importHelpers": true,
"declaration": true,
"sourceMap": true,
"rootDir": "./",
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true,
"moduleResolution": "bundler",
"jsx": "react",
"esModuleInterop": true,
"target": "ESNext",
"useDefineForClassFields": false,
"declarationMap": true
}
}
Loading

0 comments on commit 22dcc59

Please sign in to comment.