From 7933adb9a2845492f91174d265cd1192dbfbbb42 Mon Sep 17 00:00:00 2001 From: Bert B <44912991+bertybot@users.noreply.github.com> Date: Wed, 1 Nov 2023 13:24:49 -0400 Subject: [PATCH] [Svelte 4] Update Package to support Svelte 4 (#1) * Updates * Update * update tests * Update --------- Co-authored-by: RBengtson --- .changeset/README.md | 8 + .changeset/config.json | 11 + .changeset/many-suits-search.md | 11 + .eslintignore | 2 + .eslintrc.cjs | 31 +- .github/dependabot.yml | 11 + .github/workflows/pr.yml | 28 + .github/workflows/release.yml | 40 + .gitignore | 1 + README.md | 2 +- package.json | 53 +- pnpm-lock.yaml | 3440 +++++++++++++----- src/lib/Elements/Audio.svelte | 2 +- src/lib/Elements/CodeBlock.svelte | 1 - src/lib/Elements/IFrame.svelte | 7 +- src/lib/RenderElement.svelte | 5 +- src/lib/RenderElements.svelte | 26 +- src/lib/RenderNode.svelte | 19 - src/lib/RenderText.svelte | 2 +- src/lib/RichText.svelte | 6 +- src/lib/supressWarnings.ts | 15 + src/lib/types.ts | 76 +- src/test/RichText.test.ts | 5 +- src/test/__snapshots__/RichText.test.ts.snap | 126 +- src/test/testComponents/TestCode.svelte | 2 +- 25 files changed, 2780 insertions(+), 1150 deletions(-) create mode 100644 .changeset/README.md create mode 100644 .changeset/config.json create mode 100644 .changeset/many-suits-search.md create mode 100644 .github/dependabot.yml create mode 100644 .github/workflows/pr.yml create mode 100644 .github/workflows/release.yml delete mode 100644 src/lib/RenderNode.svelte create mode 100644 src/lib/supressWarnings.ts diff --git a/.changeset/README.md b/.changeset/README.md new file mode 100644 index 0000000..e5b6d8d --- /dev/null +++ b/.changeset/README.md @@ -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) diff --git a/.changeset/config.json b/.changeset/config.json new file mode 100644 index 0000000..174858c --- /dev/null +++ b/.changeset/config.json @@ -0,0 +1,11 @@ +{ + "$schema": "https://unpkg.com/@changesets/config@2.3.1/schema.json", + "changelog": "@changesets/cli/changelog", + "commit": false, + "fixed": [], + "linked": [], + "access": "restricted", + "baseBranch": "master", + "updateInternalDependencies": "patch", + "ignore": [] +} diff --git a/.changeset/many-suits-search.md b/.changeset/many-suits-search.md new file mode 100644 index 0000000..a6355e8 --- /dev/null +++ b/.changeset/many-suits-search.md @@ -0,0 +1,11 @@ +--- +'rich-text-svelte-renderer': major +--- + +Svelte 4 update + +- Update to support Svelte 4 +- Added `slug` prop to prevent error on CSR in Sveltekit +- Updated Types/linting +- removed unused code +- updated package exports \ No newline at end of file diff --git a/.eslintignore b/.eslintignore index 3897265..94e8213 100644 --- a/.eslintignore +++ b/.eslintignore @@ -11,3 +11,5 @@ node_modules pnpm-lock.yaml package-lock.json yarn.lock +svelte.config.js +/dist \ No newline at end of file diff --git a/.eslintrc.cjs b/.eslintrc.cjs index 3ccf435..9533461 100644 --- a/.eslintrc.cjs +++ b/.eslintrc.cjs @@ -1,16 +1,31 @@ module.exports = { - root: true, parser: '@typescript-eslint/parser', - extends: ['eslint:recommended', 'plugin:@typescript-eslint/recommended', 'prettier'], - plugins: ['svelte3', '@typescript-eslint'], + extends: [ + 'eslint:recommended', + 'plugin:svelte/recommended', + 'plugin:@typescript-eslint/recommended', + 'prettier' + ], + plugins: ['@typescript-eslint'], ignorePatterns: ['*.cjs'], - overrides: [{ files: ['*.svelte'], processor: 'svelte3/svelte3' }], - settings: { - 'svelte3/typescript': () => require('typescript') + overrides: [ + { + files: ['*.svelte'], + parser: 'svelte-eslint-parser', + parserOptions: { + parser: '@typescript-eslint/parser' + } + } + ], + globals: { + NodeJS: true + }, + rules: { + '@typescript-eslint/no-unused-vars': ['error', { argsIgnorePattern: '^_' }] }, parserOptions: { - sourceType: 'module', - ecmaVersion: 2020 + project: './tsconfig.json', + extraFileExtensions: ['.svelte'] }, env: { browser: true, diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..dbd6520 --- /dev/null +++ b/.github/dependabot.yml @@ -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/github/administering-a-repository/configuration-options-for-dependency-updates + +version: 2 +updates: + - package-ecosystem: '' # See documentation for possible values + directory: '/' # Location of package manifests + schedule: + interval: 'weekly' diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml new file mode 100644 index 0000000..21a5dee --- /dev/null +++ b/.github/workflows/pr.yml @@ -0,0 +1,28 @@ +name: Pull Request Validation + +on: + pull_request: + branches: + - main + +jobs: + release: + name: Pull Request Validation + runs-on: ubuntu-latest + steps: + - name: Checkout Repo + uses: actions/checkout@v3 + + - name: Setup Node.js 20.x + uses: actions/setup-node@v3 + with: + node-version: 20.x + + - name: Install pnpm + run: npm install -g pnpm + + - name: Install Dependencies + run: pnpm install + + - name: Run Unit Tests + run: pnpm vitest run diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..48386c6 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,40 @@ +name: Release + +on: + push: + branches: + - main + +concurrency: ${{ github.workflow }}-${{ github.ref }} + +jobs: + release: + name: Release + runs-on: ubuntu-latest + steps: + - name: Checkout Repo + uses: actions/checkout@v3 + + - name: Setup Node.js 20.x + uses: actions/setup-node@v3 + with: + node-version: 20.x + + - name: Install pnpm + run: npm install -g pnpm + + - name: Install Dependencies + run: pnpm install + + - name: Run Unit Tests + run: pnpm vitest run + + - name: Create Release Pull Request or Publish to npm + id: changesets + uses: changesets/action@v1 + with: + # This expects you to have a script called release which does a build for your packages and calls changeset publish + publish: pnpm run release + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/.gitignore b/.gitignore index 6635cf5..c585df7 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,4 @@ node_modules !.env.example vite.config.js.timestamp-* vite.config.ts.timestamp-* +/dist \ No newline at end of file diff --git a/README.md b/README.md index 33f02bf..59c950e 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,7 @@ To render the content on your application, you'll need to provide the array of e ````svelte -