-
-
Notifications
You must be signed in to change notification settings - Fork 468
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revert "Add Svelte TypeScript support (#1866)"
This reverts commit c01b56e.
- Loading branch information
Showing
24 changed files
with
782 additions
and
2,482 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,4 @@ | ||
dist | ||
types | ||
node_modules | ||
package-lock.json | ||
yarn.lock | ||
.svelte-kit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,8 +5,7 @@ | |
"description": "The Svelte adapter for Inertia.js", | ||
"contributors": [ | ||
"Jonathan Reinink <[email protected]>", | ||
"Pedro Borges <[email protected]>", | ||
"Dmytro Morozov <[email protected]>" | ||
"Pedro Borges <[email protected]>" | ||
], | ||
"homepage": "https://inertiajs.com/", | ||
"repository": { | ||
|
@@ -20,54 +19,17 @@ | |
"keywords": [ | ||
"svelte" | ||
], | ||
"scripts": { | ||
"build": "svelte-kit sync && svelte-package && publint", | ||
"prepublishOnly": "npm run build", | ||
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json", | ||
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch" | ||
"exports": { | ||
".": "./src/index.js", | ||
"./server": "./src/server.js" | ||
}, | ||
"files": [ | ||
"dist", | ||
"!dist/**/*.test.*", | ||
"!dist/**/*.spec.*" | ||
], | ||
"main": "src/index.js", | ||
"peerDependencies": { | ||
"svelte": "^3.20.0 || ^4.0.0" | ||
}, | ||
"devDependencies": { | ||
"@sveltejs/adapter-auto": "^3.2.0", | ||
"@sveltejs/kit": "^2.5.5", | ||
"@sveltejs/package": "^2.3.0", | ||
"@sveltejs/vite-plugin-svelte": "^3.0.2", | ||
"publint": "^0.2.7", | ||
"svelte": "^4.2.12", | ||
"svelte-check": "^3.6.8", | ||
"tslib": "^2.6.2", | ||
"typescript": "^5.4.3", | ||
"vite": "^5.2.7" | ||
}, | ||
"exports": { | ||
".": { | ||
"types": "./dist/index.d.ts", | ||
"svelte": "./dist/index.js" | ||
}, | ||
"./server": { | ||
"types": "./dist/server.d.ts", | ||
"svelte": "./dist/server.js" | ||
} | ||
}, | ||
"import": "./dist/index.js", | ||
"types": "./dist/index.d.ts", | ||
"type": "module", | ||
"typesVersions": { | ||
">4.0": { | ||
".": [ | ||
"./dist/index.d.ts" | ||
] | ||
} | ||
}, | ||
"dependencies": { | ||
"@inertiajs/core": "^1.1.0", | ||
"lodash": "^4.5.0" | ||
"@inertiajs/core": "1.1.0", | ||
"lodash.clonedeep": "^4.5.0", | ||
"lodash.isequal": "^4.5.0" | ||
} | ||
} |
12 changes: 5 additions & 7 deletions
12
...ages/svelte/src/lib/components/App.svelte → packages/svelte/src/App.svelte
100644 → 100755
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 13 additions & 14 deletions
27
...ges/svelte/src/lib/components/Link.svelte → packages/svelte/src/Link.svelte
100644 → 100755
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<script context="module"> | ||
export const h = (component, props, children) => { | ||
return { | ||
component, | ||
...(props ? { props } : {}), | ||
...(children ? { children } : {}), | ||
} | ||
} | ||
</script> | ||
|
||
<script> | ||
import store from './store' | ||
export let component | ||
export let props = {} | ||
export let children = [] | ||
let prevComponent | ||
let key | ||
$: { | ||
if (prevComponent !== component) { | ||
key = Date.now() | ||
prevComponent = component | ||
} | ||
} | ||
</script> | ||
|
||
{#if $store.component} | ||
{#key key} | ||
<svelte:component this={component} {...props}> | ||
{#each children as child, index (component && component.length === index ? $store.key : null)} | ||
<svelte:self {...child} /> | ||
{/each} | ||
</svelte:component> | ||
{/key} | ||
{/if} |
7 changes: 2 additions & 5 deletions
7
...ages/svelte/src/lib/components/SSR.svelte → packages/svelte/src/SSR.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import { router, setupProgress } from '@inertiajs/core' | ||
import App from './App.svelte' | ||
import SSR from './SSR.svelte' | ||
import store from './store' | ||
|
||
export default async function createInertiaApp({ id = 'app', resolve, setup, progress = {}, page }) { | ||
const isServer = typeof window === 'undefined' | ||
const el = isServer ? null : document.getElementById(id) | ||
const initialPage = page || JSON.parse(el.dataset.page) | ||
const resolveComponent = (name) => Promise.resolve(resolve(name)) | ||
|
||
await resolveComponent(initialPage.component).then((initialComponent) => { | ||
store.set({ | ||
component: initialComponent, | ||
page: initialPage, | ||
}) | ||
}) | ||
|
||
if (!isServer) { | ||
router.init({ | ||
initialPage, | ||
resolveComponent, | ||
swapComponent: async ({ component, page, preserveState }) => { | ||
store.update((current) => ({ | ||
component, | ||
page, | ||
key: preserveState ? current.key : Date.now(), | ||
})) | ||
}, | ||
}) | ||
|
||
if (progress) { | ||
setupProgress(progress) | ||
} | ||
|
||
return setup({ | ||
el, | ||
App, | ||
props: { | ||
initialPage, | ||
resolveComponent, | ||
}, | ||
}) | ||
} | ||
|
||
if (isServer) { | ||
const { html, head } = SSR.render({ id, initialPage }) | ||
|
||
return { | ||
body: html, | ||
head: [head], | ||
} | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
packages/svelte/src/lib/index.ts → packages/svelte/src/index.js
100644 → 100755
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.