Skip to content

Commit

Permalink
Merge pull request #22 from qwacko/dev
Browse files Browse the repository at this point in the history
Fixed bundler and reliance on lodash
  • Loading branch information
qwacko authored Dec 25, 2023
2 parents 5e84d46 + 4241236 commit 63e001c
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 40 deletions.
8 changes: 2 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "skroutes",
"version": "0.0.14",
"version": "0.0.15",
"scripts": {
"dev": "vite dev",
"build": "vite build && npm run package",
Expand Down Expand Up @@ -32,7 +32,6 @@
"@sveltejs/kit": "^2.0.0",
"@sveltejs/package": "^2.2.2",
"@sveltejs/vite-plugin-svelte": "^3.0.0",
"@types/lodash-es": "^4.17.10",
"@typescript-eslint/eslint-plugin": "^6.9.1",
"@typescript-eslint/parser": "^6.9.1",
"eslint": "^8.53.0",
Expand All @@ -51,8 +50,5 @@
},
"svelte": "./dist/index.js",
"types": "./dist/index.d.ts",
"type": "module",
"dependencies": {
"lodash-es": "^4.17.21"
}
"type": "module"
}
22 changes: 0 additions & 22 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion src/lib/helpers.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { isObject } from 'lodash-es';
function isObject(item: any): boolean {
return item && typeof item === 'object' && !Array.isArray(item);
}

function pruneUndefined(obj: Record<string, unknown>): Record<string, unknown> {
const result: Record<string, unknown> = {};
Expand Down
29 changes: 20 additions & 9 deletions src/routes/store/[id]/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
import { browser } from '$app/environment';
import { goto } from '$app/navigation';
import { page } from '$app/stores';
import { objectToSearchParams } from '$lib/helpers.js';
import { set, update } from 'lodash-es';
import { pageInfoStore } from '../../routeConfig.js';
const pageStore = pageInfoStore({
Expand All @@ -12,6 +10,25 @@
updateDelay: 500,
onUpdate: (newURL) => (browser ? goto(newURL) : undefined)
});
const handleInput = (
newValue: Event & {
currentTarget: EventTarget & HTMLInputElement;
}
) => {
if (newValue.target && 'value' in newValue.target) {
const newString = newValue.target.value as string;
if ($pageStore.searchParams && $pageStore.searchParams.nested) {
$pageStore.searchParams.nested.item1 = newString;
} else {
// Handle the case where `nested` doesn't exist yet
$pageStore.searchParams = {
...$pageStore.searchParams,
nested: { item1: newString }
};
}
}
};
</script>

{#if $pageStore.params}
Expand All @@ -25,13 +42,7 @@
id="topLevel"
type="string"
value={$pageStore.searchParams?.nested?.item1}
on:input={(newValue) => {
if (newValue.target && 'value' in newValue.target) {
const newString = newValue.target.value;
const newObject = set($pageStore, 'searchParams.nested.item1', newString);
$pageStore = newObject;
}
}}
on:input={(newValue) => handleInput(newValue)}
/>
{/if}

Expand Down
3 changes: 1 addition & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
"skipLibCheck": true,
"sourceMap": true,
"strict": true,
"moduleResolution": "NodeNext",
"module":"NodeNext"
"moduleResolution": "Bundler",
}
}

0 comments on commit 63e001c

Please sign in to comment.