From ef4dc1bf18dce9661f8715d9ab791ae4bdb5cf40 Mon Sep 17 00:00:00 2001 From: Eric Liu Date: Thu, 9 Jun 2022 06:22:13 -0700 Subject: [PATCH 1/4] chore(deps-dev): add svelte-preprocess --- package.json | 3 ++- yarn.lock | 20 ++++++++++++++++---- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 03930b17..9f381da7 100644 --- a/package.json +++ b/package.json @@ -35,9 +35,10 @@ "svelte": "^3.48.0", "svelte-check": "^2.7.1", "svelte-focus-key": "^0.3.2", + "svelte-preprocess": "^4.10.7", "svelte2tsx": "^0.5.10", "totalist": "^3.0.0", - "typescript": "^4.7.2", + "typescript": "^4.7.3", "vitest": "^0.13.1" }, "repository": { diff --git a/yarn.lock b/yarn.lock index 773fc839..58557cb9 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1378,6 +1378,18 @@ svelte-preprocess@^4.10.5: sorcery "^0.10.0" strip-indent "^3.0.0" +svelte-preprocess@^4.10.7: + version "4.10.7" + resolved "https://registry.yarnpkg.com/svelte-preprocess/-/svelte-preprocess-4.10.7.tgz#3626de472f51ffe20c9bc71eff5a3da66797c362" + integrity sha512-sNPBnqYD6FnmdBrUmBCaqS00RyCsCpj2BG58A1JBswNF7b0OKviwxqVrOL/CKyJrLSClrSeqQv5BXNg2RUbPOw== + dependencies: + "@types/pug" "^2.0.4" + "@types/sass" "^1.16.0" + detect-indent "^6.0.0" + magic-string "^0.25.7" + sorcery "^0.10.0" + strip-indent "^3.0.0" + svelte2tsx@^0.5.10: version "0.5.10" resolved "https://registry.yarnpkg.com/svelte2tsx/-/svelte2tsx-0.5.10.tgz#32f244534361325e40f8976173ce2569c7e71fdb" @@ -1464,10 +1476,10 @@ typescript@*, typescript@^4.6.3: resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.6.3.tgz#eefeafa6afdd31d725584c67a0eaba80f6fc6c6c" integrity sha512-yNIatDa5iaofVozS/uQJEl3JRWLKKGJKh6Yaiv0GLGSuhpFJe7P3SbHZ8/yjAHRQwKRoA6YZqlfjXWmVzoVSMw== -typescript@^4.7.2: - version "4.7.2" - resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.7.2.tgz#1f9aa2ceb9af87cca227813b4310fff0b51593c4" - integrity sha512-Mamb1iX2FDUpcTRzltPxgWMKy3fhg0TN378ylbktPGPK/99KbDtMQ4W1hwgsbPAsG3a0xKa1vmw4VKZQbkvz5A== +typescript@^4.7.3: + version "4.7.3" + resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.7.3.tgz#8364b502d5257b540f9de4c40be84c98e23a129d" + integrity sha512-WOkT3XYvrpXx4vMMqlD+8R8R37fZkjyLGlxavMc4iB8lrl8L0DeTcHbYgw/v0N/z9wAFsgBhcsF0ruoySS22mA== universalify@^0.1.2: version "0.1.2" From 33dcd936020205aa271c142162064585d3530e1a Mon Sep 17 00:00:00 2001 From: Eric Liu Date: Thu, 9 Jun 2022 06:22:52 -0700 Subject: [PATCH 2/4] build: set up typescript --- global.d.ts | 2 ++ svelte.config.js | 2 ++ 2 files changed, 4 insertions(+) create mode 100644 global.d.ts diff --git a/global.d.ts b/global.d.ts new file mode 100644 index 00000000..b5eb779a --- /dev/null +++ b/global.d.ts @@ -0,0 +1,2 @@ +/// +/// \ No newline at end of file diff --git a/svelte.config.js b/svelte.config.js index e64ed6ef..a39771c3 100644 --- a/svelte.config.js +++ b/svelte.config.js @@ -1,5 +1,6 @@ import adapter from "@sveltejs/adapter-static"; import fs from "fs"; +import preprocess from "svelte-preprocess" import { optimizeImports } from "carbon-preprocess-svelte"; const pkg = JSON.parse( @@ -16,6 +17,7 @@ const CONTENT = { /** @type {import('@sveltejs/kit').Config} */ const config = { preprocess: [ + preprocess(), optimizeImports(), { script: ({ content }) => { From 0d0e1ff19f15fcf99dd5c1add63fa8501651e3cb Mon Sep 17 00:00:00 2001 From: Eric Liu Date: Thu, 9 Jun 2022 06:23:15 -0700 Subject: [PATCH 3/4] refactor: convert source components to use TypeScript --- src/Highlight.svelte | 65 +++++++++++++++++++++++++++++--------- src/HighlightAuto.svelte | 44 +++++++++++++++++++------- src/HighlightSvelte.svelte | 36 ++++++++++++++------- src/{index.js => index.ts} | 0 4 files changed, 107 insertions(+), 38 deletions(-) rename src/{index.js => index.ts} (100%) diff --git a/src/Highlight.svelte b/src/Highlight.svelte index 42b2cd32..10ef981f 100644 --- a/src/Highlight.svelte +++ b/src/Highlight.svelte @@ -1,26 +1,61 @@ - + + + + + +