From ad652e364a988d4897367df02dc74bf5f8056521 Mon Sep 17 00:00:00 2001 From: Jeppe Reinhold Date: Fri, 13 Dec 2024 12:51:26 +0100 Subject: [PATCH 1/8] replace import subpaths with the default $lib alias --- package.json | 12 +-- pnpm-lock.yaml | 75 ++++++++++++++++++- src/{ => lib}/compiler/plugins.ts | 10 +-- .../appendix/create-export-default.test.ts | 2 +- .../appendix/create-export-default.ts | 4 +- .../appendix/create-export-order.test.ts | 0 .../appendix/create-export-order.ts | 4 +- .../appendix/create-import.test.ts | 0 .../post-transform/appendix/create-import.ts | 2 +- .../create-named-export-story.test.ts | 2 +- .../appendix/create-named-export-story.ts | 2 +- ...variable-from-runtime-stories-call.test.ts | 0 ...eate-variable-from-runtime-stories-call.ts | 4 +- .../post-transform/create-appendix.ts | 8 +- .../define-meta/destructure-meta.ts | 4 +- .../post-transform/define-meta/index.test.ts | 6 +- .../post-transform/define-meta/index.ts | 4 +- .../define-meta/insert-description.ts | 10 +-- .../compiler/post-transform/index.test.ts | 6 +- .../compiler/post-transform/index.ts | 6 +- .../remove-export-default.test.ts | 4 +- .../post-transform/remove-export-default.ts | 2 +- .../post-transform/shared/description.ts | 4 +- .../post-transform/story/index.test.ts | 8 +- .../compiler/post-transform/story/index.ts | 4 +- .../story/insert-description.ts | 12 +-- .../post-transform/story/insert-svelte-csf.ts | 12 +-- .../component-meta-to-define-meta.test.ts | 4 +- .../codemods/component-meta-to-define-meta.ts | 2 +- .../export-const-to-define-meta.test.ts | 4 +- .../codemods/export-const-to-define-meta.ts | 2 +- .../codemods/import-declaration.test.ts | 4 +- .../codemods/import-declaration.ts | 4 +- .../codemods/legacy-story.test.ts | 4 +- .../pre-transform/codemods/legacy-story.ts | 4 +- .../codemods/template-to-snippet.test.ts | 4 +- .../codemods/template-to-snippet.ts | 4 +- .../compiler/pre-transform/index.test.ts | 2 +- src/{ => lib}/compiler/pre-transform/index.ts | 14 ++-- src/{ => lib}/estree.d.ts | 0 src/{ => lib}/index.test.ts | 2 +- src/{ => lib}/index.ts | 0 src/{ => lib}/indexer/index.ts | 8 +- src/{ => lib}/indexer/parser.ts | 16 ++-- src/{ => lib}/legacy-types.d.ts | 0 src/{ => lib}/parser/README.md | 0 .../define-meta/component-identifier.ts | 8 +- .../analyse/define-meta/meta-identifier.ts | 6 +- .../parser/analyse/define-meta/properties.ts | 4 +- .../parser/analyse/story/attributes.test.ts | 8 +- .../parser/analyse/story/attributes.ts | 4 +- .../story/attributes/identifiers.test.ts | 8 +- .../analyse/story/attributes/identifiers.ts | 12 +-- .../parser/analyse/story/children.test.ts | 4 +- .../parser/analyse/story/children.ts | 10 +-- src/{ => lib}/parser/ast.ts | 0 .../parser/extract/compiled/nodes.ts | 6 +- .../parser/extract/compiled/stories.ts | 2 +- .../parser/extract/compiled/story.ts | 6 +- .../parser/extract/svelte/define-meta.test.ts | 4 +- .../parser/extract/svelte/define-meta.ts | 10 +-- .../extract/svelte/fragment-nodes.test.ts | 2 +- .../parser/extract/svelte/fragment-nodes.ts | 2 +- .../extract/svelte/instance-nodes.test.ts | 2 +- .../parser/extract/svelte/instance-nodes.ts | 2 +- .../extract/svelte/legacy-export-meta.ts | 8 +- .../extract/svelte/module-nodes.test.ts | 4 +- .../parser/extract/svelte/module-nodes.ts | 4 +- .../parser/extract/svelte/nodes.test.ts | 2 +- src/{ => lib}/parser/extract/svelte/nodes.ts | 2 +- .../parser/extract/svelte/snippet-block.ts | 8 +- .../extract/svelte/story/attributes.test.ts | 4 +- .../parser/extract/svelte/story/attributes.ts | 6 +- .../extract/svelte/story/children.test.ts | 4 +- .../parser/extract/svelte/story/children.ts | 2 +- src/{ => lib}/preset.ts | 4 +- src/{ => lib}/runtime/LegacyMeta.svelte | 0 src/{ => lib}/runtime/LegacyStory.svelte | 0 src/{ => lib}/runtime/LegacyTemplate.svelte | 0 src/{ => lib}/runtime/StoriesExtractor.svelte | 4 +- src/{ => lib}/runtime/Story.svelte | 0 src/{ => lib}/runtime/StoryRenderer.svelte | 0 .../runtime/contexts/extractor.svelte.ts | 0 .../runtime/contexts/renderer.svelte.ts | 0 .../runtime/contexts/template.svelte.ts | 0 .../runtime/create-runtime-stories.ts | 4 +- src/{ => lib}/runtime/emit-code.test.ts | 0 src/{ => lib}/runtime/emit-code.ts | 0 src/{ => lib}/svelte.d.ts | 0 src/{ => lib}/types.test.ts | 2 +- src/{ => lib}/types.ts | 0 src/{ => lib}/utils/error.ts | 2 +- src/{ => lib}/utils/error/legacy-api/index.ts | 4 +- .../utils/error/parser/analyse/define-meta.ts | 2 +- .../utils/error/parser/analyse/story.ts | 6 +- .../utils/error/parser/extract/compiled.ts | 4 +- .../utils/error/parser/extract/svelte.ts | 6 +- src/{ => lib}/utils/identifier-utils.test.ts | 0 src/{ => lib}/utils/identifier-utils.ts | 0 tests/extractor.ts | 2 +- tsconfig.json | 10 ++- 101 files changed, 276 insertions(+), 203 deletions(-) rename src/{ => lib}/compiler/plugins.ts (90%) rename src/{ => lib}/compiler/post-transform/appendix/create-export-default.test.ts (95%) rename src/{ => lib}/compiler/post-transform/appendix/create-export-default.ts (69%) rename src/{ => lib}/compiler/post-transform/appendix/create-export-order.test.ts (100%) rename src/{ => lib}/compiler/post-transform/appendix/create-export-order.ts (86%) rename src/{ => lib}/compiler/post-transform/appendix/create-import.test.ts (100%) rename src/{ => lib}/compiler/post-transform/appendix/create-import.ts (93%) rename src/{ => lib}/compiler/post-transform/appendix/create-named-export-story.test.ts (95%) rename src/{ => lib}/compiler/post-transform/appendix/create-named-export-story.ts (96%) rename src/{ => lib}/compiler/post-transform/appendix/create-variable-from-runtime-stories-call.test.ts (100%) rename src/{ => lib}/compiler/post-transform/appendix/create-variable-from-runtime-stories-call.ts (88%) rename src/{ => lib}/compiler/post-transform/create-appendix.ts (84%) rename src/{ => lib}/compiler/post-transform/define-meta/destructure-meta.ts (87%) rename src/{ => lib}/compiler/post-transform/define-meta/index.test.ts (91%) rename src/{ => lib}/compiler/post-transform/define-meta/index.ts (87%) rename src/{ => lib}/compiler/post-transform/define-meta/insert-description.ts (91%) rename src/{ => lib}/compiler/post-transform/index.test.ts (97%) rename src/{ => lib}/compiler/post-transform/index.ts (88%) rename src/{ => lib}/compiler/post-transform/remove-export-default.test.ts (91%) rename src/{ => lib}/compiler/post-transform/remove-export-default.ts (92%) rename src/{ => lib}/compiler/post-transform/shared/description.ts (97%) rename src/{ => lib}/compiler/post-transform/story/index.test.ts (93%) rename src/{ => lib}/compiler/post-transform/story/index.ts (87%) rename src/{ => lib}/compiler/post-transform/story/insert-description.ts (88%) rename src/{ => lib}/compiler/post-transform/story/insert-svelte-csf.ts (76%) rename src/{ => lib}/compiler/pre-transform/codemods/component-meta-to-define-meta.test.ts (97%) rename src/{ => lib}/compiler/pre-transform/codemods/component-meta-to-define-meta.ts (99%) rename src/{ => lib}/compiler/pre-transform/codemods/export-const-to-define-meta.test.ts (95%) rename src/{ => lib}/compiler/pre-transform/codemods/export-const-to-define-meta.ts (97%) rename src/{ => lib}/compiler/pre-transform/codemods/import-declaration.test.ts (93%) rename src/{ => lib}/compiler/pre-transform/codemods/import-declaration.ts (89%) rename src/{ => lib}/compiler/pre-transform/codemods/legacy-story.test.ts (98%) rename src/{ => lib}/compiler/pre-transform/codemods/legacy-story.ts (98%) rename src/{ => lib}/compiler/pre-transform/codemods/template-to-snippet.test.ts (94%) rename src/{ => lib}/compiler/pre-transform/codemods/template-to-snippet.ts (93%) rename src/{ => lib}/compiler/pre-transform/index.test.ts (99%) rename src/{ => lib}/compiler/pre-transform/index.ts (94%) rename src/{ => lib}/estree.d.ts (100%) rename src/{ => lib}/index.test.ts (99%) rename src/{ => lib}/index.ts (100%) rename src/{ => lib}/indexer/index.ts (82%) rename src/{ => lib}/indexer/parser.ts (94%) rename src/{ => lib}/legacy-types.d.ts (100%) rename src/{ => lib}/parser/README.md (100%) rename src/{ => lib}/parser/analyse/define-meta/component-identifier.ts (64%) rename src/{ => lib}/parser/analyse/define-meta/meta-identifier.ts (83%) rename src/{ => lib}/parser/analyse/define-meta/properties.ts (92%) rename src/{ => lib}/parser/analyse/story/attributes.test.ts (95%) rename src/{ => lib}/parser/analyse/story/attributes.ts (96%) rename src/{ => lib}/parser/analyse/story/attributes/identifiers.test.ts (97%) rename src/{ => lib}/parser/analyse/story/attributes/identifiers.ts (83%) rename src/{ => lib}/parser/analyse/story/children.test.ts (98%) rename src/{ => lib}/parser/analyse/story/children.ts (91%) rename src/{ => lib}/parser/ast.ts (100%) rename src/{ => lib}/parser/extract/compiled/nodes.ts (96%) rename src/{ => lib}/parser/extract/compiled/stories.ts (94%) rename src/{ => lib}/parser/extract/compiled/story.ts (82%) rename src/{ => lib}/parser/extract/svelte/define-meta.test.ts (90%) rename src/{ => lib}/parser/extract/svelte/define-meta.ts (86%) rename src/{ => lib}/parser/extract/svelte/fragment-nodes.test.ts (98%) rename src/{ => lib}/parser/extract/svelte/fragment-nodes.ts (97%) rename src/{ => lib}/parser/extract/svelte/instance-nodes.test.ts (96%) rename src/{ => lib}/parser/extract/svelte/instance-nodes.ts (95%) rename src/{ => lib}/parser/extract/svelte/legacy-export-meta.ts (88%) rename src/{ => lib}/parser/extract/svelte/module-nodes.test.ts (98%) rename src/{ => lib}/parser/extract/svelte/module-nodes.ts (97%) rename src/{ => lib}/parser/extract/svelte/nodes.test.ts (94%) rename src/{ => lib}/parser/extract/svelte/nodes.ts (95%) rename src/{ => lib}/parser/extract/svelte/snippet-block.ts (92%) rename src/{ => lib}/parser/extract/svelte/story/attributes.test.ts (93%) rename src/{ => lib}/parser/extract/svelte/story/attributes.ts (86%) rename src/{ => lib}/parser/extract/svelte/story/children.test.ts (93%) rename src/{ => lib}/parser/extract/svelte/story/children.ts (91%) rename src/{ => lib}/preset.ts (90%) rename src/{ => lib}/runtime/LegacyMeta.svelte (100%) rename src/{ => lib}/runtime/LegacyStory.svelte (100%) rename src/{ => lib}/runtime/LegacyTemplate.svelte (100%) rename src/{ => lib}/runtime/StoriesExtractor.svelte (79%) rename src/{ => lib}/runtime/Story.svelte (100%) rename src/{ => lib}/runtime/StoryRenderer.svelte (100%) rename src/{ => lib}/runtime/contexts/extractor.svelte.ts (100%) rename src/{ => lib}/runtime/contexts/renderer.svelte.ts (100%) rename src/{ => lib}/runtime/contexts/template.svelte.ts (100%) rename src/{ => lib}/runtime/create-runtime-stories.ts (95%) rename src/{ => lib}/runtime/emit-code.test.ts (100%) rename src/{ => lib}/runtime/emit-code.ts (100%) rename src/{ => lib}/svelte.d.ts (100%) rename src/{ => lib}/types.test.ts (99%) rename src/{ => lib}/types.ts (100%) rename src/{ => lib}/utils/error.ts (99%) rename src/{ => lib}/utils/error/legacy-api/index.ts (94%) rename src/{ => lib}/utils/error/parser/analyse/define-meta.ts (98%) rename src/{ => lib}/utils/error/parser/analyse/story.ts (96%) rename src/{ => lib}/utils/error/parser/extract/compiled.ts (95%) rename src/{ => lib}/utils/error/parser/extract/svelte.ts (97%) rename src/{ => lib}/utils/identifier-utils.test.ts (100%) rename src/{ => lib}/utils/identifier-utils.ts (100%) diff --git a/package.json b/package.json index df16965c..fe5335e9 100644 --- a/package.json +++ b/package.json @@ -13,15 +13,6 @@ }, "license": "MIT", "type": "module", - "imports": { - "#tests/*": { - "development": "./tests/*.ts" - }, - "#*": { - "development": "./src/*.ts", - "default": "./dist/*.js" - } - }, "exports": { ".": { "types": "./dist/index.d.ts", @@ -44,7 +35,7 @@ "README.md" ], "scripts": { - "build": "svelte-package --input ./src --types", + "build": "svelte-package --types", "build-storybook": "storybook build", "check": "svelte-check", "chromatic": "chromatic --exit-zero-on-changes", @@ -82,6 +73,7 @@ "@storybook/svelte": "^8.0.0", "@storybook/svelte-vite": "^8.0.0", "@storybook/test": "^8.0.0", + "@sveltejs/kit": "^2.11.1", "@sveltejs/package": "^2.3.7", "@sveltejs/vite-plugin-svelte": "4.0.0", "@tsconfig/svelte": "^5.0.4", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 4529480a..118b90c8 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -72,6 +72,9 @@ importers: '@storybook/test': specifier: ^8.0.0 version: 8.3.6(storybook@8.3.5) + '@sveltejs/kit': + specifier: ^2.11.1 + version: 2.11.1(@sveltejs/vite-plugin-svelte@4.0.0(svelte@5.1.4)(vite@5.3.2(@types/node@20.14.9)))(svelte@5.1.4)(vite@5.3.2(@types/node@20.14.9)) '@sveltejs/package': specifier: ^2.3.7 version: 2.3.7(svelte@5.1.4)(typescript@5.5.2) @@ -1006,6 +1009,15 @@ packages: peerDependencies: storybook: ^8.3.6 + '@sveltejs/kit@2.11.1': + resolution: {integrity: sha512-dAiHDEd+AOm20eYdMPV1a2eKBOc0s/7XsSs7PCoNv2kKS7BAoVRC9uzR+FQmxLtp8xuEo9z8CtrMQoszkThltQ==} + engines: {node: '>=18.13'} + hasBin: true + peerDependencies: + '@sveltejs/vite-plugin-svelte': ^3.0.0 || ^4.0.0-next.1 || ^5.0.0 + svelte: ^4.0.0 || ^5.0.0-next.0 + vite: ^5.0.3 || ^6.0.0 + '@sveltejs/package@2.3.7': resolution: {integrity: sha512-LYgUkde5GUYqOpXbcoCGUpEH4Ctl3Wj4u4CVZBl56dEeLW5fGHE037ZL1qlK0Ky+QD5uUfwONSeGwIOIighFMQ==} engines: {node: ^16.14 || >=18} @@ -1075,6 +1087,9 @@ packages: '@types/connect@3.4.38': resolution: {integrity: sha512-K6uROf1LD88uDQqJCktA4yzL1YYAK6NgfsI0v/mTgyPKWsX1CnJ0XPSDhViejru1GcRkLWb8RlzFYJRqGUbaug==} + '@types/cookie@0.6.0': + resolution: {integrity: sha512-4Kh9a6B2bQciAhf7FSuMRRkUWecJgJu9nPnx3yzpsfXX/c50REIqpHY4C82bXP90qrLtXtkDxTZosYO3UpOwlA==} + '@types/debug@4.1.12': resolution: {integrity: sha512-vIChWdVG3LG1SMxEvI/AK+FWJthlrqlTu7fbrlywTkkaONwk/UAGaULXRlf8vkzFBLVm0zkMdCquhL5aOjhXPQ==} @@ -1916,6 +1931,10 @@ packages: cookie-signature@1.0.6: resolution: {integrity: sha512-QADzlaHc8icV8I7vbaJXJwod9HWYp8uCqf1xa4OfNu1T7JVxQIrUgOWtHdNDtPiywmFbiS12VjotIXLrKM3orQ==} + cookie@0.6.0: + resolution: {integrity: sha512-U71cyTamuh1CRNCfpGY6to28lxvNwPG4Guz/EVjgf3Jmzv0vlDp1atT9eS5dDjMYHucpHbWns6Lwf3BKz6svdw==} + engines: {node: '>= 0.6'} + cookie@0.7.1: resolution: {integrity: sha512-6DnInpx7SJ2AK3+CTUE/ZM0vWTUboZCegxhC2xiIydHR9jNuTAASBrfEpHhiGOZw/nX51bHt6YQl8jsGo4y/0w==} engines: {node: '>= 0.6'} @@ -2118,6 +2137,9 @@ packages: resolution: {integrity: sha512-TLz+x/vEXm/Y7P7wn1EJFNLxYpUD4TgMosxY6fAVJUnJMbupHBOncxyWUG9OpTaH9EBD7uFI5LfEgmMOc54DsA==} engines: {node: '>=8'} + devalue@5.1.1: + resolution: {integrity: sha512-maua5KUiapvEwiEAe+XnlZ3Rh0GD+qI1J/nb9vrJc3muPXvcF/8gXYTWF76+5DAqHyDUtOIImEuo0YKE9mshVw==} + devlop@1.1.0: resolution: {integrity: sha512-RWmIqhcFf1lRYBvNmr7qTNuyCt/7/ns2jbpp1+PalgE/rDQcBT0fioSMUpJ93irlUhC5hrg4cYqe6U+0ImW0rA==} @@ -2463,6 +2485,9 @@ packages: esm-env@1.0.0: resolution: {integrity: sha512-Cf6VksWPsTuW01vU9Mk/3vRue91Zevka5SjyNf3nEpokFRuqt/KjUQoGAwq9qMmhpLTHmXzSIrFRw8zxWzmFBA==} + esm-env@1.2.1: + resolution: {integrity: sha512-U9JedYYjCnadUlXk7e1Kr+aENQhtUaoaV9+gZm1T8LC/YBAPJx3NSPIAurFOC0U5vrdSevnUJS2/wUVxGwPhng==} + espree@7.3.1: resolution: {integrity: sha512-v3JCNCE64umkFpmkFGqzVKsOT0tN1Zr+ueqLZfpV1Ob8e+CEgPWa+OxCoGH3tnhimMKIaBm4m/vaRpJ/krRz2g==} engines: {node: ^10.12.0 || >=12.0.0} @@ -2773,6 +2798,9 @@ packages: resolution: {integrity: sha512-DpLKbNU4WylpxJykQujfCcwYWiV/Jhm50Goo0wrVILAv5jOr9d+H+UR3PhSCD2rCCEIg0uc+G+muBTwD54JhDQ==} engines: {node: '>= 0.4'} + globalyzer@0.1.0: + resolution: {integrity: sha512-40oNTM9UfG6aBmuKxk/giHn5nQ8RVz/SS4Ir6zgzOv9/qC3kKZ9v4etGTcJbEl/NyVQH7FGU7d+X1egr57Md2Q==} + globby@10.0.0: resolution: {integrity: sha512-3LifW9M4joGZasyYPz2A1U74zbC/45fvpXUvO/9KbSa+VV0aGZarWkfdgKyR9sExNP0t0x0ss/UMJpNpcaTspw==} engines: {node: '>=8'} @@ -2789,6 +2817,9 @@ packages: resolution: {integrity: sha512-yANWAN2DUcBtuus5Cpd+SKROzXHs2iVXFZt/Ykrfz6SAXqacLX25NZpltE+39ceMexYF4TtEadjuSTw8+3wX4g==} engines: {node: '>=4'} + globrex@0.1.2: + resolution: {integrity: sha512-uHJgbwAMwNFf5mLst7IWLNg14x1CkeqglJb/K3doi4dw6q2IvAAmM/Y81kevy83wP+Sst+nutFTYOGg3d1lsxg==} + gopd@1.0.1: resolution: {integrity: sha512-d65bNlIadxvpb/A2abVdlqKqV563juRnZ1Wtk6s1sIR8uNsXR70xqIzVqxVf1eTqDunwT2MkczEeaezCKTZhwA==} @@ -4571,6 +4602,9 @@ packages: set-blocking@2.0.0: resolution: {integrity: sha512-KiKBS8AnWGEyLzofFfmvKwpdPzqiy16LvQfK3yv/fVH7Bj13/wl3JSR1J+rfgRE9q7xUJK4qvgS8raSOeLUehw==} + set-cookie-parser@2.7.1: + resolution: {integrity: sha512-IOc8uWeOZgnb3ptbCURJWNjWUPcO3ZnTTdzsurqERrP6nPyv+paC55vJM0LpOlT2ne+Ix+9+CRG1MNLlyZ4GjQ==} + set-function-length@1.2.2: resolution: {integrity: sha512-pgRc4hJ4/sNjWCSS9AmnS40x3bNMDTknHgL5UaMBTMyJnU90EgWh1Rz+MC9eFu4BuN/UwZjKQuY/1v3rM7HMfg==} engines: {node: '>= 0.4'} @@ -4904,6 +4938,9 @@ packages: through@2.3.8: resolution: {integrity: sha512-w89qg7PI8wAdvX60bMDP+bFoD5Dvhm9oLheFp5O4a2QF0cSBGsBX4qZmadPMvVqlLJBBci+WqGGOAPvcDeNSVg==} + tiny-glob@0.2.9: + resolution: {integrity: sha512-g/55ssRPUjShh+xkfx9UPDXqhckHEsHr4Vd9zX55oSdGZc/MD0m3sferOkwWtp98bv+kcVfEHtRJgBVJzelrzg==} + tiny-invariant@1.3.3: resolution: {integrity: sha512-+FbBPE1o9QAYvviau/qC5SE3caw21q3xkvWKBtja5vgqOWIHHJ3ioaq1VPfn/Szqctz2bU/oYeKd9/z5BL+PVg==} @@ -6892,6 +6929,24 @@ snapshots: dependencies: storybook: 8.3.5 + '@sveltejs/kit@2.11.1(@sveltejs/vite-plugin-svelte@4.0.0(svelte@5.1.4)(vite@5.3.2(@types/node@20.14.9)))(svelte@5.1.4)(vite@5.3.2(@types/node@20.14.9))': + dependencies: + '@sveltejs/vite-plugin-svelte': 4.0.0(svelte@5.1.4)(vite@5.3.2(@types/node@20.14.9)) + '@types/cookie': 0.6.0 + cookie: 0.6.0 + devalue: 5.1.1 + esm-env: 1.2.1 + import-meta-resolve: 4.1.0 + kleur: 4.1.5 + magic-string: 0.30.12 + mrmime: 2.0.0 + sade: 1.8.1 + set-cookie-parser: 2.7.1 + sirv: 3.0.0 + svelte: 5.1.4 + tiny-glob: 0.2.9 + vite: 5.3.2(@types/node@20.14.9) + '@sveltejs/package@2.3.7(svelte@5.1.4)(typescript@5.5.2)': dependencies: chokidar: 4.0.1 @@ -6979,6 +7034,8 @@ snapshots: dependencies: '@types/node': 20.14.9 + '@types/cookie@0.6.0': {} + '@types/debug@4.1.12': dependencies: '@types/ms': 0.7.34 @@ -8089,6 +8146,8 @@ snapshots: cookie-signature@1.0.6: {} + cookie@0.6.0: {} + cookie@0.7.1: {} core-util-is@1.0.3: @@ -8247,6 +8306,8 @@ snapshots: detect-newline@3.1.0: {} + devalue@5.1.1: {} + devlop@1.1.0: dependencies: dequal: 2.0.3 @@ -8770,6 +8831,8 @@ snapshots: esm-env@1.0.0: {} + esm-env@1.2.1: {} + espree@7.3.1: dependencies: acorn: 7.4.1 @@ -9156,6 +9219,8 @@ snapshots: define-properties: 1.2.1 gopd: 1.0.1 + globalyzer@0.1.0: {} + globby@10.0.0: dependencies: '@types/glob': 7.2.0 @@ -9195,6 +9260,8 @@ snapshots: pify: 3.0.0 slash: 1.0.0 + globrex@0.1.2: {} + gopd@1.0.1: dependencies: get-intrinsic: 1.2.4 @@ -11375,6 +11442,8 @@ snapshots: set-blocking@2.0.0: optional: true + set-cookie-parser@2.7.1: {} + set-function-length@1.2.2: dependencies: define-data-property: 1.1.4 @@ -11438,7 +11507,6 @@ snapshots: '@polka/url': 1.0.0-next.25 mrmime: 2.0.0 totalist: 3.0.1 - optional: true slash@1.0.0: {} @@ -11779,6 +11847,11 @@ snapshots: through@2.3.8: optional: true + tiny-glob@0.2.9: + dependencies: + globalyzer: 0.1.0 + globrex: 0.1.2 + tiny-invariant@1.3.3: {} tinybench@2.8.0: {} diff --git a/src/compiler/plugins.ts b/src/lib/compiler/plugins.ts similarity index 90% rename from src/compiler/plugins.ts rename to src/lib/compiler/plugins.ts index 503dd699..3fc3c0d0 100644 --- a/src/compiler/plugins.ts +++ b/src/lib/compiler/plugins.ts @@ -14,11 +14,11 @@ import MagicString from 'magic-string'; import { preprocess } from 'svelte/compiler'; import type { Plugin } from 'vite'; -import { codemodLegacyNodes } from '#compiler/pre-transform/index'; -import { transformStoriesCode } from '#compiler/post-transform/index'; -import { getSvelteAST } from '#parser/ast'; -import { extractCompiledASTNodes } from '#parser/extract/compiled/nodes'; -import { extractSvelteASTNodes } from '#parser/extract/svelte/nodes'; +import { codemodLegacyNodes } from '$lib/compiler/pre-transform/index'; +import { transformStoriesCode } from '$lib/compiler/post-transform/index'; +import { getSvelteAST } from '$lib/parser/ast'; +import { extractCompiledASTNodes } from '$lib/parser/extract/compiled/nodes'; +import { extractSvelteASTNodes } from '$lib/parser/extract/svelte/nodes'; export async function preTransformPlugin(): Promise { const [{ createFilter }, { print }] = await Promise.all([ diff --git a/src/compiler/post-transform/appendix/create-export-default.test.ts b/src/lib/compiler/post-transform/appendix/create-export-default.test.ts similarity index 95% rename from src/compiler/post-transform/appendix/create-export-default.test.ts rename to src/lib/compiler/post-transform/appendix/create-export-default.test.ts index cd1531c1..7a1485af 100644 --- a/src/compiler/post-transform/appendix/create-export-default.test.ts +++ b/src/lib/compiler/post-transform/appendix/create-export-default.test.ts @@ -3,7 +3,7 @@ import { describe, it } from 'vitest'; import { createExportDefaultMeta } from './create-export-default'; -import type { ESTreeAST } from '#parser/ast'; +import type { ESTreeAST } from '$lib/parser/ast'; describe(createExportDefaultMeta.name, () => { it('creates a new export default correctly', ({ expect }) => { diff --git a/src/compiler/post-transform/appendix/create-export-default.ts b/src/lib/compiler/post-transform/appendix/create-export-default.ts similarity index 69% rename from src/compiler/post-transform/appendix/create-export-default.ts rename to src/lib/compiler/post-transform/appendix/create-export-default.ts index c01de2b0..a525cb26 100644 --- a/src/compiler/post-transform/appendix/create-export-default.ts +++ b/src/lib/compiler/post-transform/appendix/create-export-default.ts @@ -1,5 +1,5 @@ -import type { getMetaIdentifier } from '#parser/analyse/define-meta/meta-identifier'; -import type { ESTreeAST } from '#parser/ast'; +import type { getMetaIdentifier } from '$lib/parser/analyse/define-meta/meta-identifier'; +import type { ESTreeAST } from '$lib/parser/ast'; interface Params { metaIdentifier: ReturnType; diff --git a/src/compiler/post-transform/appendix/create-export-order.test.ts b/src/lib/compiler/post-transform/appendix/create-export-order.test.ts similarity index 100% rename from src/compiler/post-transform/appendix/create-export-order.test.ts rename to src/lib/compiler/post-transform/appendix/create-export-order.test.ts diff --git a/src/compiler/post-transform/appendix/create-export-order.ts b/src/lib/compiler/post-transform/appendix/create-export-order.ts similarity index 86% rename from src/compiler/post-transform/appendix/create-export-order.ts rename to src/lib/compiler/post-transform/appendix/create-export-order.ts index 3351311c..9ff021c7 100644 --- a/src/compiler/post-transform/appendix/create-export-order.ts +++ b/src/lib/compiler/post-transform/appendix/create-export-order.ts @@ -1,5 +1,5 @@ -import type { getStoriesIdentifiers } from '#parser/analyse/story/attributes/identifiers'; -import type { ESTreeAST } from '#parser/ast'; +import type { getStoriesIdentifiers } from '$lib/parser/analyse/story/attributes/identifiers'; +import type { ESTreeAST } from '$lib/parser/ast'; interface Params { storyIdentifiers: ReturnType; diff --git a/src/compiler/post-transform/appendix/create-import.test.ts b/src/lib/compiler/post-transform/appendix/create-import.test.ts similarity index 100% rename from src/compiler/post-transform/appendix/create-import.test.ts rename to src/lib/compiler/post-transform/appendix/create-import.test.ts diff --git a/src/compiler/post-transform/appendix/create-import.ts b/src/lib/compiler/post-transform/appendix/create-import.ts similarity index 93% rename from src/compiler/post-transform/appendix/create-import.ts rename to src/lib/compiler/post-transform/appendix/create-import.ts index 736fb1bf..6b3065bb 100644 --- a/src/compiler/post-transform/appendix/create-import.ts +++ b/src/lib/compiler/post-transform/appendix/create-import.ts @@ -1,6 +1,6 @@ import pkg from '@storybook/addon-svelte-csf/package.json' with { type: 'json' }; -import type { ESTreeAST } from '#parser/ast'; +import type { ESTreeAST } from '$lib/parser/ast'; /** * The export is defined in the `package.json` export map diff --git a/src/compiler/post-transform/appendix/create-named-export-story.test.ts b/src/lib/compiler/post-transform/appendix/create-named-export-story.test.ts similarity index 95% rename from src/compiler/post-transform/appendix/create-named-export-story.test.ts rename to src/lib/compiler/post-transform/appendix/create-named-export-story.test.ts index e50cc4bd..ea2ea7e5 100644 --- a/src/compiler/post-transform/appendix/create-named-export-story.test.ts +++ b/src/lib/compiler/post-transform/appendix/create-named-export-story.test.ts @@ -4,7 +4,7 @@ import { describe, it } from 'vitest'; import { createNamedExportStory } from './create-named-export-story'; import { createVariableFromRuntimeStoriesCall } from './create-variable-from-runtime-stories-call'; -import type { ESTreeAST } from '#parser/ast'; +import type { ESTreeAST } from '$lib/parser/ast'; describe(createNamedExportStory.name, () => { it('correctly creates a variable with named exports order', ({ expect }) => { diff --git a/src/compiler/post-transform/appendix/create-named-export-story.ts b/src/lib/compiler/post-transform/appendix/create-named-export-story.ts similarity index 96% rename from src/compiler/post-transform/appendix/create-named-export-story.ts rename to src/lib/compiler/post-transform/appendix/create-named-export-story.ts index 1f794589..96597c50 100644 --- a/src/compiler/post-transform/appendix/create-named-export-story.ts +++ b/src/lib/compiler/post-transform/appendix/create-named-export-story.ts @@ -1,6 +1,6 @@ import type { createVariableFromRuntimeStoriesCall } from './create-variable-from-runtime-stories-call'; -import type { ESTreeAST } from '#parser/ast'; +import type { ESTreeAST } from '$lib/parser/ast'; interface Params { exportName: string; diff --git a/src/compiler/post-transform/appendix/create-variable-from-runtime-stories-call.test.ts b/src/lib/compiler/post-transform/appendix/create-variable-from-runtime-stories-call.test.ts similarity index 100% rename from src/compiler/post-transform/appendix/create-variable-from-runtime-stories-call.test.ts rename to src/lib/compiler/post-transform/appendix/create-variable-from-runtime-stories-call.test.ts diff --git a/src/compiler/post-transform/appendix/create-variable-from-runtime-stories-call.ts b/src/lib/compiler/post-transform/appendix/create-variable-from-runtime-stories-call.ts similarity index 88% rename from src/compiler/post-transform/appendix/create-variable-from-runtime-stories-call.ts rename to src/lib/compiler/post-transform/appendix/create-variable-from-runtime-stories-call.ts index 386518e0..7902271f 100644 --- a/src/compiler/post-transform/appendix/create-variable-from-runtime-stories-call.ts +++ b/src/lib/compiler/post-transform/appendix/create-variable-from-runtime-stories-call.ts @@ -1,5 +1,5 @@ -import type { getMetaIdentifier } from '#parser/analyse/define-meta/meta-identifier'; -import type { ESTreeAST } from '#parser/ast'; +import type { getMetaIdentifier } from '$lib/parser/analyse/define-meta/meta-identifier'; +import type { ESTreeAST } from '$lib/parser/ast'; interface Params { storiesFunctionDeclaration: ESTreeAST.FunctionDeclaration; diff --git a/src/compiler/post-transform/create-appendix.ts b/src/lib/compiler/post-transform/create-appendix.ts similarity index 84% rename from src/compiler/post-transform/create-appendix.ts rename to src/lib/compiler/post-transform/create-appendix.ts index ad5f0f4f..1a1496c9 100644 --- a/src/compiler/post-transform/create-appendix.ts +++ b/src/lib/compiler/post-transform/create-appendix.ts @@ -7,10 +7,10 @@ import { createRuntimeStoriesImport } from './appendix/create-import'; import { createVariableFromRuntimeStoriesCall } from './appendix/create-variable-from-runtime-stories-call'; import { createNamedExportStory } from './appendix/create-named-export-story'; -import { getMetaIdentifier } from '#parser/analyse/define-meta/meta-identifier'; -import type { CompiledASTNodes } from '#parser/extract/compiled/nodes'; -import type { SvelteASTNodes } from '#parser/extract/svelte/nodes'; -import { getStoriesIdentifiers } from '#parser/analyse/story/attributes/identifiers'; +import { getMetaIdentifier } from '$lib/parser/analyse/define-meta/meta-identifier'; +import type { CompiledASTNodes } from '$lib/parser/extract/compiled/nodes'; +import type { SvelteASTNodes } from '$lib/parser/extract/svelte/nodes'; +import { getStoriesIdentifiers } from '$lib/parser/analyse/story/attributes/identifiers'; interface Params { code: MagicString; diff --git a/src/compiler/post-transform/define-meta/destructure-meta.ts b/src/lib/compiler/post-transform/define-meta/destructure-meta.ts similarity index 87% rename from src/compiler/post-transform/define-meta/destructure-meta.ts rename to src/lib/compiler/post-transform/define-meta/destructure-meta.ts index 7fdd0e53..6fd22c46 100644 --- a/src/compiler/post-transform/define-meta/destructure-meta.ts +++ b/src/lib/compiler/post-transform/define-meta/destructure-meta.ts @@ -1,5 +1,5 @@ -import type { CompiledASTNodes } from '#parser/extract/compiled/nodes'; -import { NoDestructuredDefineMetaCallError } from '#utils/error/parser/analyse/define-meta'; +import type { CompiledASTNodes } from '$lib/parser/extract/compiled/nodes'; +import { NoDestructuredDefineMetaCallError } from '$lib/utils/error/parser/analyse/define-meta'; interface Params { nodes: CompiledASTNodes; diff --git a/src/compiler/post-transform/define-meta/index.test.ts b/src/lib/compiler/post-transform/define-meta/index.test.ts similarity index 91% rename from src/compiler/post-transform/define-meta/index.test.ts rename to src/lib/compiler/post-transform/define-meta/index.test.ts index 57b15a43..cbc4dc71 100644 --- a/src/compiler/post-transform/define-meta/index.test.ts +++ b/src/lib/compiler/post-transform/define-meta/index.test.ts @@ -9,9 +9,9 @@ import { describe, it } from 'vitest'; import { transformDefineMeta } from '.'; -import { getSvelteAST } from '#parser/ast'; -import { extractSvelteASTNodes } from '#parser/extract/svelte/nodes'; -import { extractCompiledASTNodes } from '#parser/extract/compiled/nodes'; +import { getSvelteAST } from '$lib/parser/ast'; +import { extractSvelteASTNodes } from '$lib/parser/extract/svelte/nodes'; +import { extractCompiledASTNodes } from '$lib/parser/extract/compiled/nodes'; const __dirname = path.dirname(url.fileURLToPath(import.meta.url)); diff --git a/src/compiler/post-transform/define-meta/index.ts b/src/lib/compiler/post-transform/define-meta/index.ts similarity index 87% rename from src/compiler/post-transform/define-meta/index.ts rename to src/lib/compiler/post-transform/define-meta/index.ts index bc20527e..2b5c22a8 100644 --- a/src/compiler/post-transform/define-meta/index.ts +++ b/src/lib/compiler/post-transform/define-meta/index.ts @@ -4,8 +4,8 @@ import type MagicString from 'magic-string'; import { destructureMetaFromDefineMeta } from './destructure-meta'; import { insertDefineMetaJSDocCommentAsDescription } from './insert-description'; -import type { CompiledASTNodes } from '#parser/extract/compiled/nodes'; -import type { SvelteASTNodes } from '#parser/extract/svelte/nodes'; +import type { CompiledASTNodes } from '$lib/parser/extract/compiled/nodes'; +import type { SvelteASTNodes } from '$lib/parser/extract/svelte/nodes'; interface Params { code: MagicString; diff --git a/src/compiler/post-transform/define-meta/insert-description.ts b/src/lib/compiler/post-transform/define-meta/insert-description.ts similarity index 91% rename from src/compiler/post-transform/define-meta/insert-description.ts rename to src/lib/compiler/post-transform/define-meta/insert-description.ts index 085e7f13..1979e0ba 100644 --- a/src/compiler/post-transform/define-meta/insert-description.ts +++ b/src/lib/compiler/post-transform/define-meta/insert-description.ts @@ -8,11 +8,11 @@ import { getDescriptionPropertyValue, getDocsPropertyValue, getParametersPropertyValue, -} from '#compiler/post-transform/shared/description'; -import { createASTObjectExpression, createASTProperty, type ESTreeAST } from '#parser/ast'; -import type { SvelteASTNodes } from '#parser/extract/svelte/nodes'; -import type { CompiledASTNodes } from '#parser/extract/compiled/nodes'; -import { getDefineMetaFirstArgumentObjectExpression } from '#parser/extract/svelte/define-meta'; +} from '$lib/compiler/post-transform/shared/description'; +import { createASTObjectExpression, createASTProperty, type ESTreeAST } from '$lib/parser/ast'; +import type { SvelteASTNodes } from '$lib/parser/extract/svelte/nodes'; +import type { CompiledASTNodes } from '$lib/parser/extract/compiled/nodes'; +import { getDefineMetaFirstArgumentObjectExpression } from '$lib/parser/extract/svelte/define-meta'; interface Params { nodes: { diff --git a/src/compiler/post-transform/index.test.ts b/src/lib/compiler/post-transform/index.test.ts similarity index 97% rename from src/compiler/post-transform/index.test.ts rename to src/lib/compiler/post-transform/index.test.ts index 1d00c268..ecadcc1d 100644 --- a/src/compiler/post-transform/index.test.ts +++ b/src/lib/compiler/post-transform/index.test.ts @@ -8,9 +8,9 @@ import { describe, it } from 'vitest'; import { transformStoriesCode } from '.'; -import { getSvelteAST } from '#parser/ast'; -import { extractSvelteASTNodes } from '#parser/extract/svelte/nodes'; -import { extractCompiledASTNodes } from '#parser/extract/compiled/nodes'; +import { getSvelteAST } from '$lib/parser/ast'; +import { extractSvelteASTNodes } from '$lib/parser/extract/svelte/nodes'; +import { extractCompiledASTNodes } from '$lib/parser/extract/compiled/nodes'; const __dirname = path.dirname(url.fileURLToPath(import.meta.url)); diff --git a/src/compiler/post-transform/index.ts b/src/lib/compiler/post-transform/index.ts similarity index 88% rename from src/compiler/post-transform/index.ts rename to src/lib/compiler/post-transform/index.ts index d19a7968..2bc09071 100644 --- a/src/compiler/post-transform/index.ts +++ b/src/lib/compiler/post-transform/index.ts @@ -5,9 +5,9 @@ import { transformDefineMeta } from './define-meta'; import { removeExportDefault } from './remove-export-default'; import { createAppendix } from './create-appendix'; -import type { CompiledASTNodes } from '#parser/extract/compiled/nodes'; -import { extractStoriesNodesFromExportDefaultFn } from '#parser/extract/compiled/stories'; -import type { SvelteASTNodes } from '#parser/extract/svelte/nodes'; +import type { CompiledASTNodes } from '$lib/parser/extract/compiled/nodes'; +import { extractStoriesNodesFromExportDefaultFn } from '$lib/parser/extract/compiled/stories'; +import type { SvelteASTNodes } from '$lib/parser/extract/svelte/nodes'; interface Params { code: MagicString; diff --git a/src/compiler/post-transform/remove-export-default.test.ts b/src/lib/compiler/post-transform/remove-export-default.test.ts similarity index 91% rename from src/compiler/post-transform/remove-export-default.test.ts rename to src/lib/compiler/post-transform/remove-export-default.test.ts index 78fd6b8f..56581ff6 100644 --- a/src/compiler/post-transform/remove-export-default.test.ts +++ b/src/lib/compiler/post-transform/remove-export-default.test.ts @@ -8,8 +8,8 @@ import { describe, it } from 'vitest'; import { removeExportDefault } from './remove-export-default'; -import { extractCompiledASTNodes } from '#parser/extract/compiled/nodes'; -import { StorybookSvelteCSFError } from '#utils/error'; +import { extractCompiledASTNodes } from '$lib/parser/extract/compiled/nodes'; +import { StorybookSvelteCSFError } from '$lib/utils/error'; const __dirname = path.dirname(url.fileURLToPath(import.meta.url)); diff --git a/src/compiler/post-transform/remove-export-default.ts b/src/lib/compiler/post-transform/remove-export-default.ts similarity index 92% rename from src/compiler/post-transform/remove-export-default.ts rename to src/lib/compiler/post-transform/remove-export-default.ts index 2eae3733..fce851b6 100644 --- a/src/compiler/post-transform/remove-export-default.ts +++ b/src/lib/compiler/post-transform/remove-export-default.ts @@ -1,7 +1,7 @@ import { print } from 'esrap'; import type MagicString from 'magic-string'; -import type { CompiledASTNodes } from '#parser/extract/compiled/nodes'; +import type { CompiledASTNodes } from '$lib/parser/extract/compiled/nodes'; interface Params { code: MagicString; diff --git a/src/compiler/post-transform/shared/description.ts b/src/lib/compiler/post-transform/shared/description.ts similarity index 97% rename from src/compiler/post-transform/shared/description.ts rename to src/lib/compiler/post-transform/shared/description.ts index dce4ab86..3ed301b4 100644 --- a/src/compiler/post-transform/shared/description.ts +++ b/src/lib/compiler/post-transform/shared/description.ts @@ -1,9 +1,9 @@ import { logger } from '@storybook/node-logger'; import dedent from 'dedent'; -import type { ESTreeAST, SvelteAST } from '#parser/ast'; +import type { ESTreeAST, SvelteAST } from '$lib/parser/ast'; -import { createASTObjectExpression } from '#parser/ast'; +import { createASTObjectExpression } from '$lib/parser/ast'; interface FindPropertyOptions { name: string; diff --git a/src/compiler/post-transform/story/index.test.ts b/src/lib/compiler/post-transform/story/index.test.ts similarity index 93% rename from src/compiler/post-transform/story/index.test.ts rename to src/lib/compiler/post-transform/story/index.test.ts index b279e4f8..6346550a 100644 --- a/src/compiler/post-transform/story/index.test.ts +++ b/src/lib/compiler/post-transform/story/index.test.ts @@ -9,10 +9,10 @@ import { describe, it } from 'vitest'; import { transformStory } from '.'; -import { getSvelteAST } from '#parser/ast'; -import { extractSvelteASTNodes } from '#parser/extract/svelte/nodes'; -import { extractCompiledASTNodes } from '#parser/extract/compiled/nodes'; -import { extractStoriesNodesFromExportDefaultFn } from '#parser/extract/compiled/stories'; +import { getSvelteAST } from '$lib/parser/ast'; +import { extractSvelteASTNodes } from '$lib/parser/extract/svelte/nodes'; +import { extractCompiledASTNodes } from '$lib/parser/extract/compiled/nodes'; +import { extractStoriesNodesFromExportDefaultFn } from '$lib/parser/extract/compiled/stories'; const __dirname = path.dirname(url.fileURLToPath(import.meta.url)); diff --git a/src/compiler/post-transform/story/index.ts b/src/lib/compiler/post-transform/story/index.ts similarity index 87% rename from src/compiler/post-transform/story/index.ts rename to src/lib/compiler/post-transform/story/index.ts index 4b9fb666..721fcbb0 100644 --- a/src/compiler/post-transform/story/index.ts +++ b/src/lib/compiler/post-transform/story/index.ts @@ -4,8 +4,8 @@ import type MagicString from 'magic-string'; import { insertStoryHTMLCommentAsDescription } from './insert-description'; import { insertSvelteCSFToStoryParameters } from './insert-svelte-csf'; -import type { extractStoriesNodesFromExportDefaultFn } from '#parser/extract/compiled/stories'; -import type { SvelteASTNodes } from '#parser/extract/svelte/nodes'; +import type { extractStoriesNodesFromExportDefaultFn } from '$lib/parser/extract/compiled/stories'; +import type { SvelteASTNodes } from '$lib/parser/extract/svelte/nodes'; interface Params { code: MagicString; diff --git a/src/compiler/post-transform/story/insert-description.ts b/src/lib/compiler/post-transform/story/insert-description.ts similarity index 88% rename from src/compiler/post-transform/story/insert-description.ts rename to src/lib/compiler/post-transform/story/insert-description.ts index adc5b945..e71c43a9 100644 --- a/src/compiler/post-transform/story/insert-description.ts +++ b/src/lib/compiler/post-transform/story/insert-description.ts @@ -9,13 +9,13 @@ import { getParametersPropertyValue, getDocsPropertyValue, getDescriptionPropertyValue, -} from '#compiler/post-transform/shared/description'; -import { createASTObjectExpression, createASTProperty } from '#parser/ast'; +} from '$lib/compiler/post-transform/shared/description'; +import { createASTObjectExpression, createASTProperty } from '$lib/parser/ast'; -import type { ESTreeAST } from '#parser/ast'; -import type { extractStoriesNodesFromExportDefaultFn } from '#parser/extract/compiled/stories'; -import { getStoryPropsObjectExpression } from '#parser/extract/compiled/story'; -import type { SvelteASTNodes } from '#parser/extract/svelte/nodes'; +import type { ESTreeAST } from '$lib/parser/ast'; +import type { extractStoriesNodesFromExportDefaultFn } from '$lib/parser/extract/compiled/stories'; +import { getStoryPropsObjectExpression } from '$lib/parser/extract/compiled/story'; +import type { SvelteASTNodes } from '$lib/parser/extract/svelte/nodes'; interface Params { nodes: { diff --git a/src/compiler/post-transform/story/insert-svelte-csf.ts b/src/lib/compiler/post-transform/story/insert-svelte-csf.ts similarity index 76% rename from src/compiler/post-transform/story/insert-svelte-csf.ts rename to src/lib/compiler/post-transform/story/insert-svelte-csf.ts index 6ee2ffeb..91337be8 100644 --- a/src/compiler/post-transform/story/insert-svelte-csf.ts +++ b/src/lib/compiler/post-transform/story/insert-svelte-csf.ts @@ -1,13 +1,13 @@ import { findPropertyParametersIndex, getParametersPropertyValue, -} from '#compiler/post-transform/shared/description'; +} from '$lib/compiler/post-transform/shared/description'; -import type { extractStoriesNodesFromExportDefaultFn } from '#parser/extract/compiled/stories'; -import { getStoryPropsObjectExpression } from '#parser/extract/compiled/story'; -import type { SvelteASTNodes, extractSvelteASTNodes } from '#parser/extract/svelte/nodes'; -import { getStoryChildrenRawCode } from '#parser/analyse/story/children'; -import { createASTObjectExpression, createASTProperty } from '#parser/ast'; +import type { extractStoriesNodesFromExportDefaultFn } from '$lib/parser/extract/compiled/stories'; +import { getStoryPropsObjectExpression } from '$lib/parser/extract/compiled/story'; +import type { SvelteASTNodes, extractSvelteASTNodes } from '$lib/parser/extract/svelte/nodes'; +import { getStoryChildrenRawCode } from '$lib/parser/analyse/story/children'; +import { createASTObjectExpression, createASTProperty } from '$lib/parser/ast'; interface Params { nodes: { diff --git a/src/compiler/pre-transform/codemods/component-meta-to-define-meta.test.ts b/src/lib/compiler/pre-transform/codemods/component-meta-to-define-meta.test.ts similarity index 97% rename from src/compiler/pre-transform/codemods/component-meta-to-define-meta.test.ts rename to src/lib/compiler/pre-transform/codemods/component-meta-to-define-meta.test.ts index a2bb80c0..c0b8c6c8 100644 --- a/src/compiler/pre-transform/codemods/component-meta-to-define-meta.test.ts +++ b/src/lib/compiler/pre-transform/codemods/component-meta-to-define-meta.test.ts @@ -3,8 +3,8 @@ import { describe, it } from 'vitest'; import { transformComponentMetaToDefineMeta } from './component-meta-to-define-meta'; -import type { SvelteAST } from '#parser/ast'; -import { parseAndExtractSvelteNode } from '#tests/extractor'; +import type { SvelteAST } from '$lib/parser/ast'; +import { parseAndExtractSvelteNode } from '$lib/tests/extractor'; describe(transformComponentMetaToDefineMeta.name, () => { it('works with a simple example', async ({ expect }) => { diff --git a/src/compiler/pre-transform/codemods/component-meta-to-define-meta.ts b/src/lib/compiler/pre-transform/codemods/component-meta-to-define-meta.ts similarity index 99% rename from src/compiler/pre-transform/codemods/component-meta-to-define-meta.ts rename to src/lib/compiler/pre-transform/codemods/component-meta-to-define-meta.ts index dfd4f685..e9dc56e9 100644 --- a/src/compiler/pre-transform/codemods/component-meta-to-define-meta.ts +++ b/src/lib/compiler/pre-transform/codemods/component-meta-to-define-meta.ts @@ -3,7 +3,7 @@ import { createASTExpressionTag, type ESTreeAST, type SvelteAST, -} from '#parser/ast'; +} from '$lib/parser/ast'; interface Params { component: SvelteAST.Component; diff --git a/src/compiler/pre-transform/codemods/export-const-to-define-meta.test.ts b/src/lib/compiler/pre-transform/codemods/export-const-to-define-meta.test.ts similarity index 95% rename from src/compiler/pre-transform/codemods/export-const-to-define-meta.test.ts rename to src/lib/compiler/pre-transform/codemods/export-const-to-define-meta.test.ts index 8b308772..c7044173 100644 --- a/src/compiler/pre-transform/codemods/export-const-to-define-meta.test.ts +++ b/src/lib/compiler/pre-transform/codemods/export-const-to-define-meta.test.ts @@ -4,8 +4,8 @@ import { describe, it } from 'vitest'; import { transformExportMetaToDefineMeta } from './export-const-to-define-meta'; -import type { ESTreeAST } from '#parser/ast'; -import { parseAndExtractSvelteNode } from '#tests/extractor'; +import type { ESTreeAST } from '$lib/parser/ast'; +import { parseAndExtractSvelteNode } from '$lib/tests/extractor'; describe(transformExportMetaToDefineMeta.name, () => { it('works with advanced example', async ({ expect }) => { diff --git a/src/compiler/pre-transform/codemods/export-const-to-define-meta.ts b/src/lib/compiler/pre-transform/codemods/export-const-to-define-meta.ts similarity index 97% rename from src/compiler/pre-transform/codemods/export-const-to-define-meta.ts rename to src/lib/compiler/pre-transform/codemods/export-const-to-define-meta.ts index e3c66ccb..b0618d4f 100644 --- a/src/compiler/pre-transform/codemods/export-const-to-define-meta.ts +++ b/src/lib/compiler/pre-transform/codemods/export-const-to-define-meta.ts @@ -1,4 +1,4 @@ -import type { ESTreeAST } from '#parser/ast'; +import type { ESTreeAST } from '$lib/parser/ast'; /** * Codemod to transform AST node of `export const meta` export named declaration to `defineMeta` variable declaration. diff --git a/src/compiler/pre-transform/codemods/import-declaration.test.ts b/src/lib/compiler/pre-transform/codemods/import-declaration.test.ts similarity index 93% rename from src/compiler/pre-transform/codemods/import-declaration.test.ts rename to src/lib/compiler/pre-transform/codemods/import-declaration.test.ts index 3a2fa812..273f143f 100644 --- a/src/compiler/pre-transform/codemods/import-declaration.test.ts +++ b/src/lib/compiler/pre-transform/codemods/import-declaration.test.ts @@ -3,8 +3,8 @@ import { describe, it } from 'vitest'; import { transformImportDeclaration } from './import-declaration'; -import type { ESTreeAST } from '#parser/ast'; -import { parseAndExtractSvelteNode } from '#tests/extractor'; +import type { ESTreeAST } from '$lib/parser/ast'; +import { parseAndExtractSvelteNode } from '$lib/tests/extractor'; describe(transformImportDeclaration.name, () => { it("removes legacy components and add 'defineMeta'", async ({ expect }) => { diff --git a/src/compiler/pre-transform/codemods/import-declaration.ts b/src/lib/compiler/pre-transform/codemods/import-declaration.ts similarity index 89% rename from src/compiler/pre-transform/codemods/import-declaration.ts rename to src/lib/compiler/pre-transform/codemods/import-declaration.ts index d1c85973..e1ccbc67 100644 --- a/src/compiler/pre-transform/codemods/import-declaration.ts +++ b/src/lib/compiler/pre-transform/codemods/import-declaration.ts @@ -1,5 +1,5 @@ -import type { ESTreeAST } from '#parser/ast'; -import { DefaultOrNamespaceImportUsedError } from '#utils/error/parser/extract/svelte'; +import type { ESTreeAST } from '$lib/parser/ast'; +import { DefaultOrNamespaceImportUsedError } from '$lib/utils/error/parser/extract/svelte'; interface Params { node: ESTreeAST.ImportDeclaration; diff --git a/src/compiler/pre-transform/codemods/legacy-story.test.ts b/src/lib/compiler/pre-transform/codemods/legacy-story.test.ts similarity index 98% rename from src/compiler/pre-transform/codemods/legacy-story.test.ts rename to src/lib/compiler/pre-transform/codemods/legacy-story.test.ts index cb140d8e..59be93dc 100644 --- a/src/compiler/pre-transform/codemods/legacy-story.test.ts +++ b/src/lib/compiler/pre-transform/codemods/legacy-story.test.ts @@ -3,8 +3,8 @@ import { describe, it } from 'vitest'; import { transformLegacyStory } from './legacy-story'; -import type { SvelteAST } from '#parser/ast'; -import { parseAndExtractSvelteNode } from '#tests/extractor'; +import type { SvelteAST } from '$lib/parser/ast'; +import { parseAndExtractSvelteNode } from '$lib/tests/extractor'; describe(transformLegacyStory.name, () => { it("it moves 'autodocs' prop to 'tags' correctly", async ({ expect }) => { diff --git a/src/compiler/pre-transform/codemods/legacy-story.ts b/src/lib/compiler/pre-transform/codemods/legacy-story.ts similarity index 98% rename from src/compiler/pre-transform/codemods/legacy-story.ts rename to src/lib/compiler/pre-transform/codemods/legacy-story.ts index 13c2d316..58192817 100644 --- a/src/compiler/pre-transform/codemods/legacy-story.ts +++ b/src/lib/compiler/pre-transform/codemods/legacy-story.ts @@ -8,8 +8,8 @@ import { createASTProperty, type ESTreeAST, type SvelteAST, -} from '#parser/ast'; -import { InvalidTemplateAttribute } from '#utils/error/legacy-api/index'; +} from '$lib/parser/ast'; +import { InvalidTemplateAttribute } from '$lib/utils/error/legacy-api/index'; import type { State } from '..'; diff --git a/src/compiler/pre-transform/codemods/template-to-snippet.test.ts b/src/lib/compiler/pre-transform/codemods/template-to-snippet.test.ts similarity index 94% rename from src/compiler/pre-transform/codemods/template-to-snippet.test.ts rename to src/lib/compiler/pre-transform/codemods/template-to-snippet.test.ts index b100c02f..df03dc96 100644 --- a/src/compiler/pre-transform/codemods/template-to-snippet.test.ts +++ b/src/lib/compiler/pre-transform/codemods/template-to-snippet.test.ts @@ -4,8 +4,8 @@ import { describe, it } from 'vitest'; import { transformTemplateToSnippet } from './template-to-snippet'; -import type { SvelteAST } from '#parser/ast'; -import { parseAndExtractSvelteNode } from '#tests/extractor'; +import type { SvelteAST } from '$lib/parser/ast'; +import { parseAndExtractSvelteNode } from '$lib/tests/extractor'; describe(transformTemplateToSnippet.name, () => { it("covers a case without provided prop 'id'", async ({ expect }) => { diff --git a/src/compiler/pre-transform/codemods/template-to-snippet.ts b/src/lib/compiler/pre-transform/codemods/template-to-snippet.ts similarity index 93% rename from src/compiler/pre-transform/codemods/template-to-snippet.ts rename to src/lib/compiler/pre-transform/codemods/template-to-snippet.ts index 93a5e6dd..af5c5dd9 100644 --- a/src/compiler/pre-transform/codemods/template-to-snippet.ts +++ b/src/lib/compiler/pre-transform/codemods/template-to-snippet.ts @@ -1,5 +1,5 @@ -import { getStringValueFromAttribute } from '#parser/analyse/story/attributes'; -import type { SvelteAST } from '#parser/ast'; +import { getStringValueFromAttribute } from '$lib/parser/analyse/story/attributes'; +import type { SvelteAST } from '$lib/parser/ast'; interface Params { component: SvelteAST.Component; diff --git a/src/compiler/pre-transform/index.test.ts b/src/lib/compiler/pre-transform/index.test.ts similarity index 99% rename from src/compiler/pre-transform/index.test.ts rename to src/lib/compiler/pre-transform/index.test.ts index 592ff114..cb18dc9e 100644 --- a/src/compiler/pre-transform/index.test.ts +++ b/src/lib/compiler/pre-transform/index.test.ts @@ -5,7 +5,7 @@ import { describe, it } from 'vitest'; import { codemodLegacyNodes } from './index'; -import { getSvelteAST } from '#parser/ast'; +import { getSvelteAST } from '$lib/parser/ast'; describe(codemodLegacyNodes.name, () => { it("replaces 'export const meta' with 'defineMeta'", async ({ expect }) => { diff --git a/src/compiler/pre-transform/index.ts b/src/lib/compiler/pre-transform/index.ts similarity index 94% rename from src/compiler/pre-transform/index.ts rename to src/lib/compiler/pre-transform/index.ts index 72216a4e..a09a3147 100644 --- a/src/compiler/pre-transform/index.ts +++ b/src/lib/compiler/pre-transform/index.ts @@ -1,12 +1,12 @@ import pkg from '@storybook/addon-svelte-csf/package.json' with { type: 'json' }; -import { transformComponentMetaToDefineMeta } from '#compiler/pre-transform/codemods/component-meta-to-define-meta'; -import { transformExportMetaToDefineMeta } from '#compiler/pre-transform/codemods/export-const-to-define-meta'; -import { transformImportDeclaration } from '#compiler/pre-transform/codemods/import-declaration'; -import { transformLegacyStory } from '#compiler/pre-transform/codemods/legacy-story'; -import { transformTemplateToSnippet } from '#compiler/pre-transform/codemods/template-to-snippet'; -import { createASTScript, type ESTreeAST, type SvelteAST } from '#parser/ast'; -import { DuplicatedUnidentifiedTemplateError } from '#utils/error/legacy-api/index'; +import { transformComponentMetaToDefineMeta } from '$lib/compiler/pre-transform/codemods/component-meta-to-define-meta'; +import { transformExportMetaToDefineMeta } from '$lib/compiler/pre-transform/codemods/export-const-to-define-meta'; +import { transformImportDeclaration } from '$lib/compiler/pre-transform/codemods/import-declaration'; +import { transformLegacyStory } from '$lib/compiler/pre-transform/codemods/legacy-story'; +import { transformTemplateToSnippet } from '$lib/compiler/pre-transform/codemods/template-to-snippet'; +import { createASTScript, type ESTreeAST, type SvelteAST } from '$lib/parser/ast'; +import { DuplicatedUnidentifiedTemplateError } from '$lib/utils/error/legacy-api/index'; interface Params { ast: SvelteAST.Root; diff --git a/src/estree.d.ts b/src/lib/estree.d.ts similarity index 100% rename from src/estree.d.ts rename to src/lib/estree.d.ts diff --git a/src/index.test.ts b/src/lib/index.test.ts similarity index 99% rename from src/index.test.ts rename to src/lib/index.test.ts index d4be01ea..f20285f0 100644 --- a/src/index.test.ts +++ b/src/lib/index.test.ts @@ -11,7 +11,7 @@ import type { StoryAnnotations, StoryContext as BaseStoryContext, SvelteRenderer, -} from '#types'; +} from '$lib/types'; import Button from '../examples/components/Button.svelte'; diff --git a/src/index.ts b/src/lib/index.ts similarity index 100% rename from src/index.ts rename to src/lib/index.ts diff --git a/src/indexer/index.ts b/src/lib/indexer/index.ts similarity index 82% rename from src/indexer/index.ts rename to src/lib/indexer/index.ts index 60d5f291..8d9fc230 100644 --- a/src/indexer/index.ts +++ b/src/lib/indexer/index.ts @@ -1,14 +1,14 @@ import type { IndexInput, Indexer } from '@storybook/types'; -import { parseForIndexer } from '#indexer/parser'; +import { parseForIndexer } from '$lib/indexer/parser'; import { GetDefineMetaFirstArgumentError, IndexerParseError, MissingModuleTagError, NoStoryComponentDestructuredError, -} from '#utils/error/parser/extract/svelte'; -import { LegacyTemplateNotEnabledError } from '#utils/error/legacy-api/index'; -import { NoDestructuredDefineMetaCallError } from '#utils/error/parser/analyse/define-meta'; +} from '$lib/utils/error/parser/extract/svelte'; +import { LegacyTemplateNotEnabledError } from '$lib/utils/error/legacy-api/index'; +import { NoDestructuredDefineMetaCallError } from '$lib/utils/error/parser/analyse/define-meta'; export const createIndexer = (legacyTemplate: boolean): Indexer => ({ test: /\.svelte$/, diff --git a/src/indexer/parser.ts b/src/lib/indexer/parser.ts similarity index 94% rename from src/indexer/parser.ts rename to src/lib/indexer/parser.ts index c6f1ae79..322c9075 100644 --- a/src/indexer/parser.ts +++ b/src/lib/indexer/parser.ts @@ -4,25 +4,25 @@ import pkg from '@storybook/addon-svelte-csf/package.json' with { type: 'json' } import { preprocess } from 'svelte/compiler'; import type { IndexInput } from '@storybook/types'; -import { getSvelteAST, type ESTreeAST, type SvelteAST } from '#parser/ast'; -import { extractStoryAttributesNodes } from '#parser/extract/svelte/story/attributes'; -import { getStoryIdentifiers } from '#parser/analyse/story/attributes/identifiers'; +import { getSvelteAST, type ESTreeAST, type SvelteAST } from '$lib/parser/ast'; +import { extractStoryAttributesNodes } from '$lib/parser/extract/svelte/story/attributes'; +import { getStoryIdentifiers } from '$lib/parser/analyse/story/attributes/identifiers'; import { getArrayOfStringsValueFromAttribute, getStringValueFromAttribute, -} from '#parser/analyse/story/attributes'; +} from '$lib/parser/analyse/story/attributes'; import { getPropertyArrayOfStringsValue, getPropertyStringValue, -} from '#parser/analyse/define-meta/properties'; -import type { StorybookAddonSvelteCsFOptions } from '#preset'; +} from '$lib/parser/analyse/define-meta/properties'; +import type { StorybookAddonSvelteCsFOptions } from '$lib/preset'; import { DefaultOrNamespaceImportUsedError, GetDefineMetaFirstArgumentError, MissingModuleTagError, NoStoryComponentDestructuredError, -} from '#utils/error/parser/extract/svelte'; -import { NoDestructuredDefineMetaCallError } from '#utils/error/parser/analyse/define-meta'; +} from '$lib/utils/error/parser/extract/svelte'; +import { NoDestructuredDefineMetaCallError } from '$lib/utils/error/parser/analyse/define-meta'; interface Results { meta: Pick; diff --git a/src/legacy-types.d.ts b/src/lib/legacy-types.d.ts similarity index 100% rename from src/legacy-types.d.ts rename to src/lib/legacy-types.d.ts diff --git a/src/parser/README.md b/src/lib/parser/README.md similarity index 100% rename from src/parser/README.md rename to src/lib/parser/README.md diff --git a/src/parser/analyse/define-meta/component-identifier.ts b/src/lib/parser/analyse/define-meta/component-identifier.ts similarity index 64% rename from src/parser/analyse/define-meta/component-identifier.ts rename to src/lib/parser/analyse/define-meta/component-identifier.ts index bd54493c..e5bf1191 100644 --- a/src/parser/analyse/define-meta/component-identifier.ts +++ b/src/lib/parser/analyse/define-meta/component-identifier.ts @@ -1,7 +1,7 @@ -import type { ESTreeAST } from '#parser/ast'; -import { extractDefineMetaPropertiesNodes } from '#parser/extract/svelte/define-meta'; -import type { SvelteASTNodes } from '#parser/extract/svelte/nodes'; -import { InvalidComponentValueError } from '#utils/error/parser/analyse/define-meta'; +import type { ESTreeAST } from '$lib/parser/ast'; +import { extractDefineMetaPropertiesNodes } from '$lib/parser/extract/svelte/define-meta'; +import type { SvelteASTNodes } from '$lib/parser/extract/svelte/nodes'; +import { InvalidComponentValueError } from '$lib/utils/error/parser/analyse/define-meta'; interface Params { nodes: SvelteASTNodes; diff --git a/src/parser/analyse/define-meta/meta-identifier.ts b/src/lib/parser/analyse/define-meta/meta-identifier.ts similarity index 83% rename from src/parser/analyse/define-meta/meta-identifier.ts rename to src/lib/parser/analyse/define-meta/meta-identifier.ts index 7a97c39d..dcade30e 100644 --- a/src/parser/analyse/define-meta/meta-identifier.ts +++ b/src/lib/parser/analyse/define-meta/meta-identifier.ts @@ -1,9 +1,9 @@ -import type { ESTreeAST } from '#parser/ast'; -import type { SvelteASTNodes } from '#parser/extract/svelte/nodes'; +import type { ESTreeAST } from '$lib/parser/ast'; +import type { SvelteASTNodes } from '$lib/parser/extract/svelte/nodes'; import { NoDestructuredDefineMetaCallError, NoMetaIdentifierFoundError, -} from '#utils/error/parser/analyse/define-meta'; +} from '$lib/utils/error/parser/analyse/define-meta'; interface Params { node: SvelteASTNodes['defineMetaVariableDeclaration']; diff --git a/src/parser/analyse/define-meta/properties.ts b/src/lib/parser/analyse/define-meta/properties.ts similarity index 92% rename from src/parser/analyse/define-meta/properties.ts rename to src/lib/parser/analyse/define-meta/properties.ts index 9c780fc2..ef92c299 100644 --- a/src/parser/analyse/define-meta/properties.ts +++ b/src/lib/parser/analyse/define-meta/properties.ts @@ -1,9 +1,9 @@ -import type { ESTreeAST } from '#parser/ast'; +import type { ESTreeAST } from '$lib/parser/ast'; import { ArrayElementNotStringError, NoArrayExpressionError, NoStringLiteralError, -} from '#utils/error/parser/analyse/define-meta'; +} from '$lib/utils/error/parser/analyse/define-meta'; interface GetStringOptions { node: ESTreeAST.Property; diff --git a/src/parser/analyse/story/attributes.test.ts b/src/lib/parser/analyse/story/attributes.test.ts similarity index 95% rename from src/parser/analyse/story/attributes.test.ts rename to src/lib/parser/analyse/story/attributes.test.ts index ac9a5324..7f61e8af 100644 --- a/src/parser/analyse/story/attributes.test.ts +++ b/src/lib/parser/analyse/story/attributes.test.ts @@ -2,10 +2,10 @@ import { describe, it } from 'vitest'; import { getArrayOfStringsValueFromAttribute, getStringValueFromAttribute } from './attributes'; -import { getSvelteAST } from '#parser/ast'; -import { extractSvelteASTNodes } from '#parser/extract/svelte/nodes'; -import { extractStoryAttributesNodes } from '#parser/extract/svelte/story/attributes'; -import { StorybookSvelteCSFError } from '#utils/error'; +import { getSvelteAST } from '$lib/parser/ast'; +import { extractSvelteASTNodes } from '$lib/parser/extract/svelte/nodes'; +import { extractStoryAttributesNodes } from '$lib/parser/extract/svelte/story/attributes'; +import { StorybookSvelteCSFError } from '$lib/utils/error'; describe(getStringValueFromAttribute.name, () => { it("throws error when a `` 'name' attribute value is not a string", async ({ diff --git a/src/parser/analyse/story/attributes.ts b/src/lib/parser/analyse/story/attributes.ts similarity index 96% rename from src/parser/analyse/story/attributes.ts rename to src/lib/parser/analyse/story/attributes.ts index 40c90840..f289e6b7 100644 --- a/src/parser/analyse/story/attributes.ts +++ b/src/lib/parser/analyse/story/attributes.ts @@ -1,9 +1,9 @@ -import type { SvelteAST } from '#parser/ast'; +import type { SvelteAST } from '$lib/parser/ast'; import { AttributeNotArrayError, AttributeNotArrayOfStringsError, AttributeNotStringError, -} from '#utils/error/parser/analyse/story'; +} from '$lib/utils/error/parser/analyse/story'; interface Params { node: SvelteAST.Attribute | undefined; diff --git a/src/parser/analyse/story/attributes/identifiers.test.ts b/src/lib/parser/analyse/story/attributes/identifiers.test.ts similarity index 97% rename from src/parser/analyse/story/attributes/identifiers.test.ts rename to src/lib/parser/analyse/story/attributes/identifiers.test.ts index 88b0e0ab..6095cf58 100644 --- a/src/parser/analyse/story/attributes/identifiers.test.ts +++ b/src/lib/parser/analyse/story/attributes/identifiers.test.ts @@ -2,10 +2,10 @@ import { describe, expect, it } from 'vitest'; import { getStoryIdentifiers, getStoriesIdentifiers } from './identifiers'; -import { getSvelteAST } from '#parser/ast'; -import { extractSvelteASTNodes } from '#parser/extract/svelte/nodes'; -import { extractStoryAttributesNodes } from '#parser/extract/svelte/story/attributes'; -import { StorybookSvelteCSFError } from '#utils/error'; +import { getSvelteAST } from '$lib/parser/ast'; +import { extractSvelteASTNodes } from '$lib/parser/extract/svelte/nodes'; +import { extractStoryAttributesNodes } from '$lib/parser/extract/svelte/story/attributes'; +import { StorybookSvelteCSFError } from '$lib/utils/error'; describe(getStoryIdentifiers.name, () => { it("extracts 'exportName' attribute when is a Text string", async () => { diff --git a/src/parser/analyse/story/attributes/identifiers.ts b/src/lib/parser/analyse/story/attributes/identifiers.ts similarity index 83% rename from src/parser/analyse/story/attributes/identifiers.ts rename to src/lib/parser/analyse/story/attributes/identifiers.ts index ed073354..77e79c71 100644 --- a/src/parser/analyse/story/attributes/identifiers.ts +++ b/src/lib/parser/analyse/story/attributes/identifiers.ts @@ -1,13 +1,13 @@ -import { getStringValueFromAttribute } from '#parser/analyse/story/attributes'; -import type { SvelteAST } from '#parser/ast'; -import type { SvelteASTNodes } from '#parser/extract/svelte/nodes'; -import { extractStoryAttributesNodes } from '#parser/extract/svelte/story/attributes'; -import { isValidVariableName, storyNameToExportName } from '#utils/identifier-utils'; +import { getStringValueFromAttribute } from '$lib/parser/analyse/story/attributes'; +import type { SvelteAST } from '$lib/parser/ast'; +import type { SvelteASTNodes } from '$lib/parser/extract/svelte/nodes'; +import { extractStoryAttributesNodes } from '$lib/parser/extract/svelte/story/attributes'; +import { isValidVariableName, storyNameToExportName } from '$lib/utils/identifier-utils'; import { DuplicateStoryIdentifiersError, InvalidStoryExportNameError, NoStoryIdentifierError, -} from '#utils/error/parser/analyse/story'; +} from '$lib/utils/error/parser/analyse/story'; type StoryIdentifiers = { exportName: string; diff --git a/src/parser/analyse/story/children.test.ts b/src/lib/parser/analyse/story/children.test.ts similarity index 98% rename from src/parser/analyse/story/children.test.ts rename to src/lib/parser/analyse/story/children.test.ts index 16b5f6df..8cab603d 100644 --- a/src/parser/analyse/story/children.test.ts +++ b/src/lib/parser/analyse/story/children.test.ts @@ -2,8 +2,8 @@ import { describe, it } from 'vitest'; import { getStoryChildrenRawCode } from './children'; -import { getSvelteAST } from '#parser/ast'; -import { extractSvelteASTNodes } from '#parser/extract/svelte/nodes'; +import { getSvelteAST } from '$lib/parser/ast'; +import { extractSvelteASTNodes } from '$lib/parser/extract/svelte/nodes'; describe(getStoryChildrenRawCode.name, () => { describe('When a `` is a self-closing tag...', () => { diff --git a/src/parser/analyse/story/children.ts b/src/lib/parser/analyse/story/children.ts similarity index 91% rename from src/parser/analyse/story/children.ts rename to src/lib/parser/analyse/story/children.ts index 1abdbd79..12323906 100644 --- a/src/parser/analyse/story/children.ts +++ b/src/lib/parser/analyse/story/children.ts @@ -1,13 +1,13 @@ import dedent from 'dedent'; -import { getDefineMetaComponentValue } from '#parser/analyse/define-meta/component-identifier'; -import type { SvelteAST } from '#parser/ast'; -import type { extractSvelteASTNodes } from '#parser/extract/svelte/nodes'; -import { extractStoryChildrenSnippetBlock } from '#parser/extract/svelte/story/children'; +import { getDefineMetaComponentValue } from '$lib/parser/analyse/define-meta/component-identifier'; +import type { SvelteAST } from '$lib/parser/ast'; +import type { extractSvelteASTNodes } from '$lib/parser/extract/svelte/nodes'; +import { extractStoryChildrenSnippetBlock } from '$lib/parser/extract/svelte/story/children'; import { findSetTemplateSnippetBlock, findStoryAttributeChildrenSnippetBlock, -} from '#parser/extract/svelte/snippet-block'; +} from '$lib/parser/extract/svelte/snippet-block'; interface Params { nodes: { diff --git a/src/parser/ast.ts b/src/lib/parser/ast.ts similarity index 100% rename from src/parser/ast.ts rename to src/lib/parser/ast.ts diff --git a/src/parser/extract/compiled/nodes.ts b/src/lib/parser/extract/compiled/nodes.ts similarity index 96% rename from src/parser/extract/compiled/nodes.ts rename to src/lib/parser/extract/compiled/nodes.ts index 053bedb8..17214283 100644 --- a/src/parser/extract/compiled/nodes.ts +++ b/src/lib/parser/extract/compiled/nodes.ts @@ -2,15 +2,15 @@ import pkg from '@storybook/addon-svelte-csf/package.json' with { type: 'json' } import type { ProgramNode } from 'rollup'; import type { Visitors } from 'zimmerframe'; -import type { ESTreeAST } from '#parser/ast'; +import type { ESTreeAST } from '$lib/parser/ast'; import { MissingDefineMetaVariableDeclarationError, MissingImportedDefineMetaError, NoExportDefaultError, NoStoriesFunctionDeclarationError, NoStoryIdentifierFoundError, -} from '#utils/error/parser/extract/compiled'; -import { DefaultOrNamespaceImportUsedError } from '#utils/error/parser/extract/svelte'; +} from '$lib/utils/error/parser/extract/compiled'; +import { DefaultOrNamespaceImportUsedError } from '$lib/utils/error/parser/extract/svelte'; /** * Important AST nodes from the compiled output of a single `*.stories.svelte` file. diff --git a/src/parser/extract/compiled/stories.ts b/src/lib/parser/extract/compiled/stories.ts similarity index 94% rename from src/parser/extract/compiled/stories.ts rename to src/lib/parser/extract/compiled/stories.ts index 36d68e0d..9edf746c 100644 --- a/src/parser/extract/compiled/stories.ts +++ b/src/lib/parser/extract/compiled/stories.ts @@ -2,7 +2,7 @@ import type { Visitors } from 'zimmerframe'; import type { CompiledASTNodes } from './nodes'; -import type { ESTreeAST } from '#parser/ast'; +import type { ESTreeAST } from '$lib/parser/ast'; interface Params { nodes: CompiledASTNodes; diff --git a/src/parser/extract/compiled/story.ts b/src/lib/parser/extract/compiled/story.ts similarity index 82% rename from src/parser/extract/compiled/story.ts rename to src/lib/parser/extract/compiled/story.ts index 67ea564c..af58e885 100644 --- a/src/parser/extract/compiled/story.ts +++ b/src/lib/parser/extract/compiled/story.ts @@ -1,6 +1,6 @@ -import type { ESTreeAST } from '#parser/ast'; -import type { extractStoriesNodesFromExportDefaultFn } from '#parser/extract/compiled/stories'; -import { NoCompiledStoryPropsObjectExpression } from '#utils/error/parser/extract/compiled'; +import type { ESTreeAST } from '$lib/parser/ast'; +import type { extractStoriesNodesFromExportDefaultFn } from '$lib/parser/extract/compiled/stories'; +import { NoCompiledStoryPropsObjectExpression } from '$lib/utils/error/parser/extract/compiled'; interface Params { node: Awaited>[number]; diff --git a/src/parser/extract/svelte/define-meta.test.ts b/src/lib/parser/extract/svelte/define-meta.test.ts similarity index 90% rename from src/parser/extract/svelte/define-meta.test.ts rename to src/lib/parser/extract/svelte/define-meta.test.ts index 5c53d045..3f5d869b 100644 --- a/src/parser/extract/svelte/define-meta.test.ts +++ b/src/lib/parser/extract/svelte/define-meta.test.ts @@ -2,8 +2,8 @@ import { describe, it } from 'vitest'; import { extractDefineMetaPropertiesNodes } from './define-meta'; -import { getSvelteAST, type ESTreeAST } from '#parser/ast'; -import { extractSvelteASTNodes } from '#parser/extract/svelte/nodes'; +import { getSvelteAST, type ESTreeAST } from '$lib/parser/ast'; +import { extractSvelteASTNodes } from '$lib/parser/extract/svelte/nodes'; describe(extractDefineMetaPropertiesNodes.name, () => { it('extracts correctly selected properties', async ({ expect }) => { diff --git a/src/parser/extract/svelte/define-meta.ts b/src/lib/parser/extract/svelte/define-meta.ts similarity index 86% rename from src/parser/extract/svelte/define-meta.ts rename to src/lib/parser/extract/svelte/define-meta.ts index 960c92bd..869b7344 100644 --- a/src/parser/extract/svelte/define-meta.ts +++ b/src/lib/parser/extract/svelte/define-meta.ts @@ -1,9 +1,9 @@ -import type { ESTreeAST } from '#parser/ast'; -import type { SvelteASTNodes } from '#parser/extract/svelte/nodes'; -import type { CompiledASTNodes } from '#parser/extract/compiled/nodes'; +import type { ESTreeAST } from '$lib/parser/ast'; +import type { SvelteASTNodes } from '$lib/parser/extract/svelte/nodes'; +import type { CompiledASTNodes } from '$lib/parser/extract/compiled/nodes'; -import { GetDefineMetaFirstArgumentError } from '#utils/error/parser/extract/svelte'; -import type { Cmp, Meta } from '#types'; +import { GetDefineMetaFirstArgumentError } from '$lib/utils/error/parser/extract/svelte'; +import type { Cmp, Meta } from '$lib/types'; interface Options>> { nodes: SvelteASTNodes | CompiledASTNodes; diff --git a/src/parser/extract/svelte/fragment-nodes.test.ts b/src/lib/parser/extract/svelte/fragment-nodes.test.ts similarity index 98% rename from src/parser/extract/svelte/fragment-nodes.test.ts rename to src/lib/parser/extract/svelte/fragment-nodes.test.ts index edddb66c..f08460b5 100644 --- a/src/parser/extract/svelte/fragment-nodes.test.ts +++ b/src/lib/parser/extract/svelte/fragment-nodes.test.ts @@ -4,7 +4,7 @@ import { extractFragmentNodes } from './fragment-nodes'; import { extractInstanceNodes } from './instance-nodes'; import { extractModuleNodes } from './module-nodes'; -import { getSvelteAST } from '#parser/ast'; +import { getSvelteAST } from '$lib/parser/ast'; describe(extractFragmentNodes.name, () => { it("extracts '' AST nodes correctly", async () => { diff --git a/src/parser/extract/svelte/fragment-nodes.ts b/src/lib/parser/extract/svelte/fragment-nodes.ts similarity index 97% rename from src/parser/extract/svelte/fragment-nodes.ts rename to src/lib/parser/extract/svelte/fragment-nodes.ts index 7803cf96..b8ea2efd 100644 --- a/src/parser/extract/svelte/fragment-nodes.ts +++ b/src/lib/parser/extract/svelte/fragment-nodes.ts @@ -3,7 +3,7 @@ import type { Visitors } from 'zimmerframe'; import type { extractModuleNodes } from './module-nodes'; import type { extractInstanceNodes } from './instance-nodes'; -import type { SvelteAST } from '#parser/ast'; +import type { SvelteAST } from '$lib/parser/ast'; interface Result { storyComponents: Array<{ diff --git a/src/parser/extract/svelte/instance-nodes.test.ts b/src/lib/parser/extract/svelte/instance-nodes.test.ts similarity index 96% rename from src/parser/extract/svelte/instance-nodes.test.ts rename to src/lib/parser/extract/svelte/instance-nodes.test.ts index 553bf299..5114eed4 100644 --- a/src/parser/extract/svelte/instance-nodes.test.ts +++ b/src/lib/parser/extract/svelte/instance-nodes.test.ts @@ -3,7 +3,7 @@ import { describe, expect, it } from 'vitest'; import { extractInstanceNodes } from './instance-nodes'; import { extractModuleNodes } from './module-nodes'; -import { getSvelteAST, type ESTreeAST } from '#parser/ast'; +import { getSvelteAST, type ESTreeAST } from '$lib/parser/ast'; describe(extractInstanceNodes.name, () => { it("extract 'setTemplateCall' correctly when used", async () => { diff --git a/src/parser/extract/svelte/instance-nodes.ts b/src/lib/parser/extract/svelte/instance-nodes.ts similarity index 95% rename from src/parser/extract/svelte/instance-nodes.ts rename to src/lib/parser/extract/svelte/instance-nodes.ts index 1bddf531..e92d354b 100644 --- a/src/parser/extract/svelte/instance-nodes.ts +++ b/src/lib/parser/extract/svelte/instance-nodes.ts @@ -2,7 +2,7 @@ import type { Visitors } from 'zimmerframe'; import type { extractModuleNodes } from './module-nodes'; -import type { ESTreeAST, SvelteAST } from '#parser/ast'; +import type { ESTreeAST, SvelteAST } from '$lib/parser/ast'; interface Result { setTemplateCall: ESTreeAST.CallExpression | undefined; diff --git a/src/parser/extract/svelte/legacy-export-meta.ts b/src/lib/parser/extract/svelte/legacy-export-meta.ts similarity index 88% rename from src/parser/extract/svelte/legacy-export-meta.ts rename to src/lib/parser/extract/svelte/legacy-export-meta.ts index 59b98ab1..b4823339 100644 --- a/src/parser/extract/svelte/legacy-export-meta.ts +++ b/src/lib/parser/extract/svelte/legacy-export-meta.ts @@ -1,10 +1,10 @@ import type { ObjectExpression, Property } from 'estree'; -import type { SvelteASTNodes } from '#parser/extract/svelte/nodes'; -import type { CompiledASTNodes } from '#parser/extract/compiled/nodes'; +import type { SvelteASTNodes } from '$lib/parser/extract/svelte/nodes'; +import type { CompiledASTNodes } from '$lib/parser/extract/compiled/nodes'; -import { GetDefineMetaFirstArgumentError } from '#utils/error/parser/extract/svelte'; -import type { Cmp, Meta } from '#types'; +import { GetDefineMetaFirstArgumentError } from '$lib/utils/error/parser/extract/svelte'; +import type { Cmp, Meta } from '$lib/types'; interface Options>> { nodes: SvelteASTNodes | CompiledASTNodes; diff --git a/src/parser/extract/svelte/module-nodes.test.ts b/src/lib/parser/extract/svelte/module-nodes.test.ts similarity index 98% rename from src/parser/extract/svelte/module-nodes.test.ts rename to src/lib/parser/extract/svelte/module-nodes.test.ts index 5da08810..a3f38ba8 100644 --- a/src/parser/extract/svelte/module-nodes.test.ts +++ b/src/lib/parser/extract/svelte/module-nodes.test.ts @@ -2,8 +2,8 @@ import { describe, it } from 'vitest'; import { extractModuleNodes } from './module-nodes'; -import { getSvelteAST } from '#parser/ast'; -import { StorybookSvelteCSFError } from '#utils/error'; +import { getSvelteAST } from '$lib/parser/ast'; +import { StorybookSvelteCSFError } from '$lib/utils/error'; describe(extractModuleNodes.name, () => { it('fails when module tag not found', ({ expect }) => { diff --git a/src/parser/extract/svelte/module-nodes.ts b/src/lib/parser/extract/svelte/module-nodes.ts similarity index 97% rename from src/parser/extract/svelte/module-nodes.ts rename to src/lib/parser/extract/svelte/module-nodes.ts index eb5c57d4..42bb4e7a 100644 --- a/src/parser/extract/svelte/module-nodes.ts +++ b/src/lib/parser/extract/svelte/module-nodes.ts @@ -1,14 +1,14 @@ import pkg from '@storybook/addon-svelte-csf/package.json' with { type: 'json' }; import type { Visitors } from 'zimmerframe'; -import type { ESTreeAST, SvelteAST } from '#parser/ast'; +import type { ESTreeAST, SvelteAST } from '$lib/parser/ast'; import { DefaultOrNamespaceImportUsedError, MissingDefineMetaImportError, MissingDefineMetaVariableDeclarationError, MissingModuleTagError, NoStoryComponentDestructuredError, -} from '#utils/error/parser/extract/svelte'; +} from '$lib/utils/error/parser/extract/svelte'; const AST_NODES_NAMES = { defineMeta: 'defineMeta', diff --git a/src/parser/extract/svelte/nodes.test.ts b/src/lib/parser/extract/svelte/nodes.test.ts similarity index 94% rename from src/parser/extract/svelte/nodes.test.ts rename to src/lib/parser/extract/svelte/nodes.test.ts index 2aef1a4a..6457b1aa 100644 --- a/src/parser/extract/svelte/nodes.test.ts +++ b/src/lib/parser/extract/svelte/nodes.test.ts @@ -2,7 +2,7 @@ import { describe, it } from 'vitest'; import { extractSvelteASTNodes } from './nodes'; -import { getSvelteAST } from '#parser/ast'; +import { getSvelteAST } from '$lib/parser/ast'; describe(extractSvelteASTNodes.name, () => { it('works with a simple example', ({ expect }) => { diff --git a/src/parser/extract/svelte/nodes.ts b/src/lib/parser/extract/svelte/nodes.ts similarity index 95% rename from src/parser/extract/svelte/nodes.ts rename to src/lib/parser/extract/svelte/nodes.ts index f8e0fa40..638bed43 100644 --- a/src/parser/extract/svelte/nodes.ts +++ b/src/lib/parser/extract/svelte/nodes.ts @@ -2,7 +2,7 @@ import { extractModuleNodes } from './module-nodes'; import { extractFragmentNodes } from './fragment-nodes'; import { extractInstanceNodes } from './instance-nodes'; -import type { SvelteAST } from '#parser/ast'; +import type { SvelteAST } from '$lib/parser/ast'; /** * Selected nodes extracted from the Svelte AST via `svelte.compile`, diff --git a/src/parser/extract/svelte/snippet-block.ts b/src/lib/parser/extract/svelte/snippet-block.ts similarity index 92% rename from src/parser/extract/svelte/snippet-block.ts rename to src/lib/parser/extract/svelte/snippet-block.ts index 778bd800..ceb8864d 100644 --- a/src/parser/extract/svelte/snippet-block.ts +++ b/src/lib/parser/extract/svelte/snippet-block.ts @@ -1,11 +1,11 @@ -import type { SvelteAST } from '#parser/ast'; -import type { SvelteASTNodes } from '#parser/extract/svelte/nodes'; -import { extractStoryAttributesNodes } from '#parser/extract/svelte/story/attributes'; +import type { SvelteAST } from '$lib/parser/ast'; +import type { SvelteASTNodes } from '$lib/parser/extract/svelte/nodes'; +import { extractStoryAttributesNodes } from '$lib/parser/extract/svelte/story/attributes'; import { InvalidSetTemplateFirstArgumentError, InvalidStoryChildrenAttributeError, -} from '#utils/error/parser/extract/svelte'; +} from '$lib/utils/error/parser/extract/svelte'; /** * Svelte 5 allows to passing `children` as attribute _(aka prop)_. diff --git a/src/parser/extract/svelte/story/attributes.test.ts b/src/lib/parser/extract/svelte/story/attributes.test.ts similarity index 93% rename from src/parser/extract/svelte/story/attributes.test.ts rename to src/lib/parser/extract/svelte/story/attributes.test.ts index 91fc862c..8832c45b 100644 --- a/src/parser/extract/svelte/story/attributes.test.ts +++ b/src/lib/parser/extract/svelte/story/attributes.test.ts @@ -2,8 +2,8 @@ import { describe, expect, it } from 'vitest'; import { extractStoryAttributesNodes } from './attributes'; -import { getSvelteAST } from '#parser/ast'; -import { extractSvelteASTNodes } from '#parser/extract/svelte/nodes'; +import { getSvelteAST } from '$lib/parser/ast'; +import { extractSvelteASTNodes } from '$lib/parser/extract/svelte/nodes'; describe(extractStoryAttributesNodes.name, () => { it("extracts '' attributes correctly", async () => { diff --git a/src/parser/extract/svelte/story/attributes.ts b/src/lib/parser/extract/svelte/story/attributes.ts similarity index 86% rename from src/parser/extract/svelte/story/attributes.ts rename to src/lib/parser/extract/svelte/story/attributes.ts index dcfdda52..6a398ff6 100644 --- a/src/parser/extract/svelte/story/attributes.ts +++ b/src/lib/parser/extract/svelte/story/attributes.ts @@ -1,8 +1,8 @@ import type { ComponentProps } from 'svelte'; -import type { SvelteAST } from '#parser/ast'; -import type { Cmp } from '#types'; -import type Story from '#runtime/Story.svelte'; +import type { SvelteAST } from '$lib/parser/ast'; +import type { Cmp } from '$lib/types'; +import type Story from '$lib/runtime/Story.svelte'; type StoryAttributes = Array>>; diff --git a/src/parser/extract/svelte/story/children.test.ts b/src/lib/parser/extract/svelte/story/children.test.ts similarity index 93% rename from src/parser/extract/svelte/story/children.test.ts rename to src/lib/parser/extract/svelte/story/children.test.ts index 4aa4bb87..15a97217 100644 --- a/src/parser/extract/svelte/story/children.test.ts +++ b/src/lib/parser/extract/svelte/story/children.test.ts @@ -2,8 +2,8 @@ import { describe, it } from 'vitest'; import { extractStoryChildrenSnippetBlock } from './children'; -import { getSvelteAST } from '#parser/ast'; -import { extractSvelteASTNodes } from '#parser/extract/svelte/nodes'; +import { getSvelteAST } from '$lib/parser/ast'; +import { extractSvelteASTNodes } from '$lib/parser/extract/svelte/nodes'; describe(extractStoryChildrenSnippetBlock.name, () => { it('returns correctly AST node, when a `` compponent has a snippet block `children` inside', async ({ diff --git a/src/parser/extract/svelte/story/children.ts b/src/lib/parser/extract/svelte/story/children.ts similarity index 91% rename from src/parser/extract/svelte/story/children.ts rename to src/lib/parser/extract/svelte/story/children.ts index 27648764..7ecbcc94 100644 --- a/src/parser/extract/svelte/story/children.ts +++ b/src/lib/parser/extract/svelte/story/children.ts @@ -1,4 +1,4 @@ -import type { SvelteAST } from '#parser/ast'; +import type { SvelteAST } from '$lib/parser/ast'; type Result = SvelteAST.SnippetBlock | undefined; diff --git a/src/preset.ts b/src/lib/preset.ts similarity index 90% rename from src/preset.ts rename to src/lib/preset.ts index 6260e9b8..f857c3d9 100644 --- a/src/preset.ts +++ b/src/lib/preset.ts @@ -1,8 +1,8 @@ import type { StorybookConfig } from '@storybook/svelte-vite'; import type { Options } from '@storybook/types'; -import { transformPlugin, preTransformPlugin } from '#compiler/plugins'; -import { createIndexer } from '#indexer/index'; +import { transformPlugin, preTransformPlugin } from '$lib/compiler/plugins'; +import { createIndexer } from '$lib/indexer/index'; export interface StorybookAddonSvelteCsFOptions extends Options { /** diff --git a/src/runtime/LegacyMeta.svelte b/src/lib/runtime/LegacyMeta.svelte similarity index 100% rename from src/runtime/LegacyMeta.svelte rename to src/lib/runtime/LegacyMeta.svelte diff --git a/src/runtime/LegacyStory.svelte b/src/lib/runtime/LegacyStory.svelte similarity index 100% rename from src/runtime/LegacyStory.svelte rename to src/lib/runtime/LegacyStory.svelte diff --git a/src/runtime/LegacyTemplate.svelte b/src/lib/runtime/LegacyTemplate.svelte similarity index 100% rename from src/runtime/LegacyTemplate.svelte rename to src/lib/runtime/LegacyTemplate.svelte diff --git a/src/runtime/StoriesExtractor.svelte b/src/lib/runtime/StoriesExtractor.svelte similarity index 79% rename from src/runtime/StoriesExtractor.svelte rename to src/lib/runtime/StoriesExtractor.svelte index a4189d2a..714fd5fe 100644 --- a/src/runtime/StoriesExtractor.svelte +++ b/src/lib/runtime/StoriesExtractor.svelte @@ -1,12 +1,12 @@