Skip to content

Commit

Permalink
Merge pull request #60 from trash-and-fire/53-version-200
Browse files Browse the repository at this point in the history
53 version 200
  • Loading branch information
trash-and-fire authored Feb 12, 2023
2 parents 65d7f77 + 0250c9e commit b2a5e19
Show file tree
Hide file tree
Showing 60 changed files with 10,053 additions and 640 deletions.
11 changes: 8 additions & 3 deletions .eslintrc.js → .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ function typescriptRules(annotations) {
}
],
"@typescript-eslint/no-inferrable-types": "off",
"import/extensions": ["error", "always"],
};
if (annotations !== false) {
result["@typescript-eslint/typedef"] = [
Expand All @@ -67,20 +68,24 @@ function typescriptRules(annotations) {

module.exports = {
root: true,
plugins: [
'eslint-plugin-import',
],
ignorePatterns: ["dist/*"],
overrides: [
{
extends: [
"eslint:recommended",
"plugin:node/recommended"
],
files: ['.eslintrc.js', 'webpack.config.js', 'gulpfile.js', 'repl-maker.js', 'scripts/**/*.{js,cjs}'],
files: ['.eslintrc.cjs', 'webpack.config.cjs', 'gulpfile.cjs', 'repl-maker.cjs', 'scripts/**/*.{js,cjs}'],
parserOptions: {
"ecmaVersion": 2017
"ecmaVersion": 2020
},
env: {
node: true,
browser: false,
es6: true
es2020: true,
},
rules: {
"node/no-unpublished-require": "off",
Expand Down
115 changes: 99 additions & 16 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,34 +6,117 @@ jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/setup-node@v2
- uses: bahmutov/npm-install@v1
- name: Checkout
uses: actions/checkout@v3

- name: Install Node.js
uses: actions/setup-node@v3
with:
node-version: 16

- uses: pnpm/action-setup@v2
name: Install pnpm
id: pnpm-install
with:
useLockFile: false
- run: npm run lint
version: 7

- name: Get pnpm store directory
id: pnpm-cache
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
- uses: actions/cache@v3
name: Setup pnpm cache
with:
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install dependencies
run: pnpm install

- name: Lint files
run: pnpm run lint

test:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v1
- uses: actions/setup-node@v2
- uses: bahmutov/npm-install@v1
- name: Checkout
uses: actions/checkout@v3

- name: Install Node.js
uses: actions/setup-node@v3
with:
node-version: 16

- uses: pnpm/action-setup@v2
name: Install pnpm
id: pnpm-install
with:
useLockFile: false
- run: npm run test
version: 7

- name: Get pnpm store directory
id: pnpm-cache
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
- uses: actions/cache@v3
name: Setup pnpm cache
with:
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install dependencies
run: pnpm install

- name: Run tests
run: pnpm run test
env:
CI: true

validate:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v1
- uses: actions/setup-node@v2
- uses: bahmutov/npm-install@v1
- name: Checkout
uses: actions/checkout@v3

- name: Install Node.js
uses: actions/setup-node@v3
with:
node-version: 16

- uses: pnpm/action-setup@v2
name: Install pnpm
id: pnpm-install
with:
useLockFile: false
- run: npm run build-package
- run: npm run validate
version: 7

- name: Get pnpm store directory
id: pnpm-cache
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
- uses: actions/cache@v3
name: Setup pnpm cache
with:
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install dependencies
run: pnpm install

- name: Check - build package
run: npm run build-package

- name: Check - svelte errors
run: npm run validate
1 change: 0 additions & 1 deletion .npmrc
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
save-exact=true
package-lock=false
24 changes: 24 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Svelte Lightweight Charts changelog

## 2.0.0

This major release raises the required `lightweight-charts` package version to 4.0.0 providing support for new features from the package.

Check out `lightweight-charts@4.0.0` [release notes](https://github.com/tradingview/lightweight-charts/releases/tag/v4.0.0) first.

### Major updates

- Compatibility with SvelteKit. The package comes as ESM compatible, which provides full support for modern tools and bundlers.

### Breaking changes

- ESM only (CJS support can be added on demand in the future).
- Removed deprecated chart action exports: `chart`, `ChartActionParams` and default export.
- `<[Type]Series>`: removed `scaleMargins` property instead use the same property on `<PriceScale>` component.
- `<PriceLine>`: `price` is required property now.
- `<PriceScale>`: `drawTicks` property is renamed to `ticksVisible`.

### New features

- `<AreaSeries>`: added `invertFilledArea` property which when set to true will invert the filled area (draw above the line instead of below it).
- `<PriceScale>`: added `textColor` property.
23 changes: 6 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,23 +37,6 @@ npm install lightweight-charts svelte-lightweight-charts
</Chart>
```

### SSR and SvelteKit

`lightweight-charts` are not currently compatible with the node environment. Direct import of this module will throw an exception.

I made an experimental version of the package that should solve this problem. To install the next version, run:
```bash
npm install svelte-lightweight-charts@next
```
Add to your `svelte.config.js`:
```
vite: {
ssr: {
noExternal: ['svelte-lightweight-charts', 'lightweight-charts']
}
}
```

## Getting reference to lightweight-chart objects

You can use the `ref` property to get a reference to a lightweight-chart api-instance from any component.
Expand Down Expand Up @@ -198,3 +181,9 @@ Package is written on TypeScript and transpiled to plain `*.js` and `*.svelte` f
## Related projects

Need a wrapper for another framework? Check out my [lightweight-charts-react-wrapper](https://github.com/trash-and-fire/lightweight-charts-react-wrapper)

## Licence

MIT

Review the license [requirements](https://github.com/tradingview/lightweight-charts#license) for the required "attribution notice" in the Lightweight Chart Repository.
15 changes: 8 additions & 7 deletions gulpfile.js → gulpfile.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const {spawn} = require('child_process');
const crc = require('crc-32');
const {argv} = require('yargs');

const SvelteReplRepository = require('./repl-maker');
const SvelteReplRepository = require('./repl-maker.cjs');

function convertToTypings(content, file) {
const filename = file.basename[0].toUpperCase() + file.basename.slice(1);
Expand All @@ -30,10 +30,11 @@ function typings() {
.pipe(dest('./dist'));
}

async function applyPreprocess(content, file) {
const ts = require('svelte-preprocess').typescript();
ts.filename = file.basename;
// TODO: remove source mapping url
async function applyPreprocess(content, file, options) {
const ts = require('svelte-preprocess').typescript(options ?? {
tsconfigFile: './tsconfig.build.json',
});
ts.filename = file.path;
const garbage = require('svelte-preprocess').replace([
[/<!--[^]*?-->|<script(\s[^]*?)?(?:>([^]*?)<\/script>|\/>)/gi, (value, attributes) => {
if (attributes !== undefined && attributes.includes('lang="ts"')) {
Expand Down Expand Up @@ -85,7 +86,7 @@ function typescript() {
function index() {
return src(['./dist/index.d.ts'])
.pipe(transform('utf8', (content) => {
return String(content).replace(/\.interface'/g, '.svelte\'');
return String(content).replace(/\.interface.js'/g, '.svelte\'');
}))
.pipe(dest('./dist'));
}
Expand All @@ -105,7 +106,7 @@ function samples(...args) {

const resolveComponents = () => src(['./src/demo/samples/components/*.svelte'])
.pipe(transform('utf8', (contents, file) => {
return applyPreprocess(contents, file).then((code) => {
return applyPreprocess(contents, file, {}).then((code) => {
components.set(`components/${file.basename}`, {
hash: crc.str(contents),
name: file.basename,
Expand Down
Loading

0 comments on commit b2a5e19

Please sign in to comment.