Skip to content

Commit 4aeda4d

Browse files
committed
initial commit
0 parents  commit 4aeda4d

15 files changed

+746
-0
lines changed

.editorconfig

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# editorconfig.org
2+
root = true
3+
4+
# All files should use
5+
# - tabs unless specified otherwise
6+
# - unix-style newlines with a newline ending every file
7+
[*]
8+
indent_style = space
9+
indent_size = 2
10+
end_of_line = lf
11+
charset = utf-8
12+
trim_trailing_whitespace = true
13+
insert_final_newline = true
14+
15+
[*.md]
16+
trim_trailing_whitespace = false

.gitignore

+106
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
# Logs
2+
logs
3+
*.log
4+
npm-debug.log*
5+
yarn-debug.log*
6+
yarn-error.log*
7+
lerna-debug.log*
8+
9+
# Diagnostic reports (https://nodejs.org/api/report.html)
10+
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
11+
12+
# Runtime data
13+
pids
14+
*.pid
15+
*.seed
16+
*.pid.lock
17+
18+
# Directory for instrumented libs generated by jscoverage/JSCover
19+
lib-cov
20+
21+
# Coverage directory used by tools like istanbul
22+
coverage
23+
*.lcov
24+
25+
# nyc test coverage
26+
.nyc_output
27+
28+
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
29+
.grunt
30+
31+
# Bower dependency directory (https://bower.io/)
32+
bower_components
33+
34+
# node-waf configuration
35+
.lock-wscript
36+
37+
# Compiled binary addons (https://nodejs.org/api/addons.html)
38+
build/Release
39+
40+
# Dependency directories
41+
node_modules/
42+
jspm_packages/
43+
44+
# TypeScript v1 declaration files
45+
typings/
46+
47+
# TypeScript cache
48+
*.tsbuildinfo
49+
50+
# Optional npm cache directory
51+
.npm
52+
53+
# Optional eslint cache
54+
.eslintcache
55+
56+
# Microbundle cache
57+
.rpt2_cache/
58+
.rts2_cache_cjs/
59+
.rts2_cache_es/
60+
.rts2_cache_umd/
61+
62+
# Optional REPL history
63+
.node_repl_history
64+
65+
# Output of 'npm pack'
66+
*.tgz
67+
68+
# Yarn Integrity file
69+
.yarn-integrity
70+
71+
# dotenv environment variables file
72+
.env
73+
.env.test
74+
75+
# parcel-bundler cache (https://parceljs.org/)
76+
.cache
77+
78+
# Next.js build output
79+
.next
80+
81+
# Nuxt.js build / generate output
82+
.nuxt
83+
dist
84+
85+
# Gatsby files
86+
.cache/
87+
# Comment in the public line in if your project uses Gatsby and *not* Next.js
88+
# https://nextjs.org/blog/next-9-1#public-directory-support
89+
# public
90+
91+
# vuepress build output
92+
.vuepress/dist
93+
94+
# Serverless directories
95+
.serverless/
96+
97+
# FuseBox cache
98+
.fusebox/
99+
100+
# DynamoDB Local files
101+
.dynamodb/
102+
103+
# TernJS port file
104+
.tern-port
105+
106+
.vscode

.npmrc

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
registry = https://registry.npmjs.org/

.nvmrc

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
v14

.prettierrc

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"printWidth": 100,
3+
"semi": false,
4+
"singleQuote": true,
5+
"trailingComma": "all",
6+
"bracketSpacing": true
7+
}

.xo-config.json

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"envs": ["es2020", "browser"],
3+
"space": true,
4+
"prettier": true,
5+
"extends": [
6+
"plugin:jest/recommended",
7+
"plugin:jest/style",
8+
"plugin:jest-dom/recommended",
9+
"plugin:testing-library/recommended"
10+
],
11+
"overrides": [
12+
{
13+
"files": "src/**/*.js",
14+
"nodeVersion": ">=14"
15+
}
16+
]
17+
}

LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2020 [these people](https://github.com/sastan/svelte-hyperscript/graphs/contributors)
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

+60
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# svelte-hyperscript
2+
3+
> use [hyperscript](https://github.com/hyperhype/hyperscript) to create svelte components
4+
5+
[![GitHub license](https://img.shields.io/github/license/sastan/svelte-hyperscript)](https://github.com/sastan/svelte-hyperscript/blob/main/LICENSE) [![NPM version](https://img.shields.io/npm/v/svelte-hyperscript.svg?style=flat)](https://www.npmjs.com/package/svelte-hyperscript) [![NPM downloads](https://img.shields.io/npm/dm/svelte-hyperscript.svg?style=flat)](https://www.npmjs.com/package/svelte-hyperscript)
6+
7+
## Installation
8+
9+
```sh
10+
npm install svelte-hyperscript
11+
```
12+
13+
CDN: [UNPKG](https://unpkg.com/svelte-hyperscript/) | [jsDelivr](https://cdn.jsdelivr.net/npm/svelte-hyperscript/) (available as `window.svelteHyperscript`)
14+
15+
## Usage
16+
17+
This package exposes an hyperscript compatible function: `h(tag, properties, ...children)` which return a svelte component.
18+
19+
```js
20+
import h from 'svelte-hyperscript'
21+
22+
import Button from '../src/Button.svelte'
23+
24+
let clicked = 0
25+
const LabeledButton = h(Button, { 'on:click': () => (clicked += 1) }, h('span', null, 'Click Me!'))
26+
27+
const button = new LabeledButton({
28+
target: document.body,
29+
})
30+
```
31+
32+
This project is the core for [svelte-jsx](https://www.npmjs.com/package/svelte-jsx)
33+
and [svelte-htm](https://www.npmjs.com/package/svelte-htm). Their aim is to simplify svelte component testing.
34+
35+
## Feature Set
36+
37+
- [x] on:eventname
38+
- [ ] on:eventname modifiers
39+
- [ ] bind:property **but** using setter/getter
40+
- [ ] use:action
41+
- [ ] transition:fn
42+
- [ ] in:fn/out:fn
43+
- [x] `<slot>`
44+
- [x] `<slot name="name">`
45+
- [x] `<slot let:name={setter}>`
46+
- [ ] `<slot let:name={property}>{property}</slot>`
47+
- [ ] Client-side component API
48+
- [ ] component.\$set(props)
49+
- [ ] component.\$on(event, callback)
50+
- [ ] component.\$destroy()
51+
- [x] context propagation
52+
- [ ] Lifecycle component: `<Component init={() => setContext()}>...<//>`
53+
54+
## NPM Statistics
55+
56+
[![NPM](https://nodei.co/npm/svelte-hyperscript.png)](https://nodei.co/npm/svelte-hyperscript/)
57+
58+
## License
59+
60+
`svelte-hyperscript` is open source software [licensed as MIT](https://github.com/sastan/svelte-hyperscript/blob/main/LICENSE).

babel.config.js

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
module.exports = (api) => {
2+
const isTest = api.env('test')
3+
4+
return {
5+
presets: [
6+
[
7+
'@babel/preset-env',
8+
{
9+
useBuiltIns: 'usage', // Load the same polyfill only once
10+
corejs: 3,
11+
bugfixes: true, // Compile the broken syntax to the closest non-broken modern syntax
12+
shippedProposals: true, // No transformation of feature proposals, if target env have native support
13+
loose: true,
14+
modules: isTest && 'commonjs',
15+
ignoreBrowserslistConfig: true,
16+
targets: isTest ? { node: 'current' } : `node ${require('./package.json').engines.node}`,
17+
},
18+
],
19+
],
20+
plugins: [
21+
[
22+
'@babel/plugin-transform-runtime',
23+
{
24+
absoluteRuntime: false,
25+
corejs: false,
26+
helpers: true,
27+
regenerator: false,
28+
useESModules: !isTest,
29+
version: require('@babel/runtime-corejs3/package.json').version,
30+
},
31+
],
32+
],
33+
}
34+
}

jest.config.js

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
// For a detailed explanation regarding each configuration property, visit:
2+
// https://jestjs.io/docs/en/configuration.html
3+
4+
module.exports = {
5+
// Automatically clear mock calls and instances between every test
6+
clearMocks: true,
7+
8+
// The directory where Jest should output its coverage files
9+
coverageDirectory: 'coverage',
10+
11+
// An array of regexp pattern strings used to skip coverage collection
12+
coveragePathIgnorePatterns: ['/node_modules/', '/dist/'],
13+
14+
// An object that configures minimum threshold enforcement for coverage results
15+
coverageThreshold: {
16+
global: {
17+
branches: 100,
18+
functions: 100,
19+
lines: 100,
20+
statements: 100,
21+
},
22+
},
23+
24+
setupFilesAfterEnv: ['@testing-library/jest-dom'],
25+
26+
// The test environment that will be used for testing
27+
// testEnvironment: "jest-environment-jsdom",
28+
testEnvironment: 'jest-environment-jsdom-sixteen',
29+
30+
// No transforms - just plain js
31+
transform: {
32+
'^.+\\.svelte$': 'svelte-jester',
33+
'^.+\\.[jt]sx?$': 'babel-jest',
34+
},
35+
36+
moduleFileExtensions: ['js', 'svelte'],
37+
}

package.json

+78
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
{
2+
"name": "svelte-hyperscript",
3+
"version": "1.0.0",
4+
"description": "hyperscript for svelte",
5+
"source": "src/h.js",
6+
"main": "./dist/cjs/h.js",
7+
"exports": {
8+
"./package.json": "./package.json",
9+
".": {
10+
"import": "./dist/esm/h.js",
11+
"require": "./dist/cjs/h.js",
12+
"umd": "./dist/umd/h.js"
13+
}
14+
},
15+
"module": "./dist/esm/h.js",
16+
"unpkg": "./dist/umd/h.js",
17+
"sideEffects": false,
18+
"files": [
19+
"dist"
20+
],
21+
"scripts": {
22+
"build": "rollup -c && echo '{\"type\":\"module\"}' > dist/esm/package.json",
23+
"lint": "xo",
24+
"fix": "xo --fix",
25+
"test": "jest",
26+
"test:watch": "npm test -- --watch",
27+
"test:coverage": "npm test -- --coverage"
28+
},
29+
"engines": {
30+
"node": ">=10"
31+
},
32+
"dependencies": {
33+
"@babel/runtime-corejs3": "^7.10.3",
34+
"core-js": "^3.6.5"
35+
},
36+
"peerDependencies": {
37+
"svelte": "3.x"
38+
},
39+
"repository": {
40+
"type": "git",
41+
"url": "git+https://github.com/sastan/svelte-hyperscript.git"
42+
},
43+
"keywords": [
44+
"svelte",
45+
"hyperscript"
46+
],
47+
"author": "Sascha Tandel <[email protected]>",
48+
"license": "MIT",
49+
"bugs": {
50+
"url": "https://github.com/sastan/svelte-hyperscript/issues"
51+
},
52+
"homepage": "https://github.com/sastan/svelte-hyperscript#readme",
53+
"devDependencies": {
54+
"@babel/core": "^7.10.3",
55+
"@babel/plugin-transform-runtime": "^7.10.3",
56+
"@babel/preset-env": "^7.10.3",
57+
"@jest/globals": "^26.0.1",
58+
"@rollup/plugin-babel": "^5.0.3",
59+
"@rollup/plugin-commonjs": "^13.0.0",
60+
"@rollup/plugin-node-resolve": "^8.0.1",
61+
"@testing-library/jest-dom": "^5.7.0",
62+
"@testing-library/svelte": "^3.0.0",
63+
"babel-jest": "^26.0.1",
64+
"eslint": "^6.8.0",
65+
"eslint-plugin-jest": "^23.13.1",
66+
"eslint-plugin-jest-dom": "^2.1.0",
67+
"eslint-plugin-testing-library": "^3.1.3",
68+
"jest": "^26.0.1",
69+
"jest-environment-jsdom-sixteen": "^1.0.3",
70+
"prettier": "^2.0.5",
71+
"rollup": "^2.17.1",
72+
"rollup-plugin-node-externals": "^2.2.0",
73+
"rollup-plugin-terser": "^6.1.0",
74+
"svelte": "^3.22.3",
75+
"svelte-jester": "^1.0.6",
76+
"xo": "^0.30.0"
77+
}
78+
}

0 commit comments

Comments
 (0)