Skip to content

Commit

Permalink
Merge pull request #944 from jill64/dev
Browse files Browse the repository at this point in the history
minor: Update dependencies and refactor code structure
  • Loading branch information
wraith-ci[bot] authored Dec 31, 2024
2 parents 6f65f6f + c8b2fc9 commit 566ad71
Show file tree
Hide file tree
Showing 13 changed files with 880 additions and 1,454 deletions.
12 changes: 5 additions & 7 deletions cdk/arch/lambda-s3.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,9 @@ import {
environment,
lambdaRuntime,
memorySize,
stream,
stream
} from '../external/params'
import {
lambdaModifier
} from '../external/cdk-modifiers'
import { lambdaModifier } from '../external/cdk-modifiers'

export class CDKStack extends Stack {
constructor(scope: Construct, id: string, props?: StackProps) {
Expand All @@ -43,10 +41,10 @@ export class CDKStack extends Stack {
memorySize,
timeout: Duration.seconds(30),
environment
});
})

// allow custom modification of CDK lambda function
lambdaModifier(lambdaFunction);
lambdaModifier(lambdaFunction)

const lambdaURL = lambdaFunction.addFunctionUrl({
authType: aws_lambda.FunctionUrlAuthType.NONE,
Expand Down
5 changes: 4 additions & 1 deletion cdk/external/cdk-modifiers.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
/* $$__ADAPTER_IMPORTS__$$ */
import * as cdk from 'aws-cdk-lib'

export const lambdaModifier = (lambdaFunction: cdk.aws_lambda.Function) => {} /* $$__LAMBDA_MODIFIER__$$ */
export const lambdaModifier = (
// eslint-disable-next-line
lambdaFunction: cdk.aws_lambda.Function
) => {} /* $$__LAMBDA_MODIFIER__$$ */
1 change: 0 additions & 1 deletion cf2/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable no-var */
import { ViewerRequestHandler } from 'cf2-builder'

export default ((event) => {
Expand Down
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@jill64/sveltekit-adapter-aws",
"description": "🔌 SveleteKit AWS adapter with multiple architecture",
"version": "1.9.71",
"version": "1.10.0",
"type": "module",
"main": "dist/index.js",
"license": "MIT",
Expand Down Expand Up @@ -32,7 +32,7 @@
"repository": {
"type": "git",
"url": "git+https://github.com/jill64/sveltekit-adapter-aws.git",
"image": "https://opengraph.githubassets.com/000accb0cba21a8e7aeb7efe51fb468efe71c43a52fa53f55a0006fa70f840a7/jill64/sveltekit-adapter-aws"
"image": "https://opengraph.githubassets.com/1489952fa61841934c190807d164afd94b9086578affd2d39f61cbbc04d29741/jill64/sveltekit-adapter-aws"
},
"publishConfig": {
"access": "public"
Expand All @@ -59,13 +59,13 @@
"@sveltejs/kit": "^2.0.0"
},
"devDependencies": {
"@jill64/eslint-config-ts": "1.1.44",
"@jill64/eslint-config-ts": "2.0.1",
"@jill64/prettier-config": "1.0.0",
"@jill64/playwright-config": "2.4.2",
"@sveltejs/kit": "2.13.0",
"@sveltejs/kit": "2.15.1",
"@types/node": "22.10.2",
"@playwright/test": "1.47.2",
"cf2-builder": "1.1.24",
"@playwright/test": "1.49.1",
"cf2-builder": "1.1.29",
"typescript": "5.7.2"
},
"dependencies": {
Expand Down
6 changes: 4 additions & 2 deletions packages/adapter/src/steps/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export const setup = async ({ builder, tmp, options }: Context) => {
__DOMAIN_NAME__: options.domain?.fqdn ?? '',
__CERTIFICATE_ARN__: options.domain?.certificateArn ?? '',
__LAMBDA_RUNTIME__: options.runtime ?? 'NODE_LATEST',
'{} /* $$__ENVIRONMENT__$$ */': JSON.stringify(options.env ?? {}),
'{} /* $$__ENVIRONMENT__$$ */': JSON.stringify(options.env ?? {})
}
)

Expand All @@ -80,7 +80,9 @@ export const setup = async ({ builder, tmp, options }: Context) => {
path.join(options.out, 'external', 'cdk-modifiers.ts'),
{
'/* $$__ADAPTER_IMPORTS__$$ */': options.adapterImports?.join('\n') ?? '',
'(lambdaFunction: cdk.aws_lambda.Function) => {} /* $$__LAMBDA_MODIFIER__$$ */': options.lambdaModifier?.toString() ?? '(lambdaFunction: cdk.aws_lambda.Function) => {}'
'(lambdaFunction: cdk.aws_lambda.Function) => {} /* $$__LAMBDA_MODIFIER__$$ */':
options.lambdaModifier?.toString() ??
'(lambdaFunction: cdk.aws_lambda.Function) => {}'
}
)

Expand Down
6 changes: 3 additions & 3 deletions packages/adapter/src/types/AdapterOptions.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { aws_lambda } from 'aws-cdk-lib'
import { BuildOptions } from 'esbuild'
import type { ArchitectureType } from './ArchitectureType.js'
import { aws_lambda } from 'aws-cdk-lib'

export type AdapterOptions = {
/**
Expand Down Expand Up @@ -91,7 +91,7 @@ export type AdapterOptions = {
certificateArn: string
}
/**
* Adds imports to the adapter params.ts to allow things like `lambdaModifier`
* Adds imports to the adapter params.ts to allow things like `lambdaModifier`
* to access types
* @example ["import { Stack } from 'aws-cdk-lib'"]
*/
Expand All @@ -107,5 +107,5 @@ export type AdapterOptions = {
* }
* ```
*/
lambdaModifier?: (lambdaFunction: aws_lambda.Function) => { }
lambdaModifier?: (lambdaFunction: aws_lambda.Function) => unknown
}
12 changes: 6 additions & 6 deletions packages/site/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@
"preview": "pnpm build && vite preview",
"lint": "pnpm check & npx eslint .",
"check": "svelte-kit sync && npx svelte-check --tsconfig ./tsconfig.json",
"format": "npx @jill64/psx"
"format": "npx psvx"
},
"devDependencies": {
"@jill64/eslint-config-svelte": "1.3.6",
"@jill64/eslint-config-svelte": "2.0.2",
"@fontsource/fira-mono": "5.1.0",
"@jill64/sentry-sveltekit-edge": "1.2.55",
"@neoconfetti/svelte": "2.2.1",
"@sveltejs/kit": "2.13.0",
"@sveltejs/kit": "2.15.1",
"@types/cookie": "1.0.0",
"svelte": "4.2.19",
"vite": "5.4.11",
"@sveltejs/vite-plugin-svelte": "3.1.2"
"svelte": "5.16.0",
"vite": "6.0.6",
"@sveltejs/vite-plugin-svelte": "5.0.3"
}
}
4 changes: 3 additions & 1 deletion packages/site/src/routes/+layout.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
import { browser } from '$app/environment'
import Header from './Header.svelte'
import './styles.css'
let { children } = $props()
</script>

<svelte:head>
Expand All @@ -13,7 +15,7 @@
<Header />

<main>
<slot />
{@render children()}
</main>

<footer>
Expand Down
28 changes: 13 additions & 15 deletions packages/site/src/routes/Counter.svelte
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
<script lang="ts">
import { spring } from 'svelte/motion'
import { Spring } from 'svelte/motion'
let count = 0
let count = $state(0)
const displayed_count = spring()
$: displayed_count.set(count)
$: offset = modulo($displayed_count, 1)
let displayed_count = new Spring(0)
$effect(() => {
displayed_count.set(count)
})
let offset = $derived(modulo(displayed_count.current, 1))
function modulo(n: number, m: number) {
// handle negative numbers
Expand All @@ -14,10 +18,7 @@
</script>

<div class="counter">
<button
on:click={() => (count -= 1)}
aria-label="Decrease the counter by one"
>
<button onclick={() => (count -= 1)} aria-label="Decrease the counter by one">
<svg aria-hidden="true" viewBox="0 0 1 1">
<path d="M0,0.5 L1,0.5" />
</svg>
Expand All @@ -29,16 +30,13 @@
style="transform: translate(0, {100 * offset}%)"
>
<strong class="hidden" aria-hidden="true"
>{Math.floor($displayed_count + 1)}</strong
>{Math.floor(displayed_count.current + 1)}</strong
>
<strong>{Math.floor($displayed_count)}</strong>
<strong>{Math.floor(displayed_count.current)}</strong>
</div>
</div>

<button
on:click={() => (count += 1)}
aria-label="Increase the counter by one"
>
<button onclick={() => (count += 1)} aria-label="Increase the counter by one">
<svg aria-hidden="true" viewBox="0 0 1 1">
<path d="M0,0.5 L1,0.5 M0.5,0 L0.5,1" />
</svg>
Expand Down
40 changes: 25 additions & 15 deletions packages/site/src/routes/sverdle/+page.svelte
Original file line number Diff line number Diff line change
@@ -1,35 +1,39 @@
<script lang="ts">
import { confetti } from '@neoconfetti/svelte'
import { enhance } from '$app/forms'
import type { PageData, ActionData } from './$types'
import { confetti } from '@neoconfetti/svelte'
import type { ActionData, PageData } from './$types'
import { reduced_motion } from './reduced-motion'
export let data: PageData
export let form: ActionData
let {
data,
form
}: {
data: PageData
form: ActionData
} = $props()
/** Whether or not the user has won */
$: won = data.answers.at(-1) === 'xxxxx'
let won = $derived(data.answers.at(-1) === 'xxxxx')
/** The index of the current guess */
$: i = won ? -1 : data.answers.length
let i = $derived(won ? -1 : data.answers.length)
/** Whether the current guess can be submitted */
$: submittable = data.guesses[i]?.length === 5
let submittable = $derived(data.guesses[i]?.length === 5)
/**
* A map of classnames for all letters that have been guessed,
* used for styling the keyboard
*/
let classnames: Record<string, 'exact' | 'close' | 'missing'>
let classnames: Record<string, 'exact' | 'close' | 'missing'> = $state({})
/**
* A map of descriptions for all letters that have been guessed,
* used for adding text for assistive technology (e.g. screen readers)
*/
let description: Record<string, string>
let description: Record<string, string> = $state({})
$: {
$effect(() => {
classnames = {}
description = {}
Expand All @@ -48,7 +52,7 @@
}
}
})
}
})
/**
* Modify the game state without making a trip to the server,
Expand Down Expand Up @@ -155,7 +159,10 @@
>

<button
on:click|preventDefault={update}
onclick={(e) => {
e.preventDefault()
update(e)
}}
data-key="backspace"
formaction="?/update"
name="key"
Expand All @@ -168,7 +175,10 @@
<div class="row">
{#each row as letter}
<button
on:click|preventDefault={update}
onclick={(e) => {
e.preventDefault()
update(e)
}}
data-key={letter}
class={classnames[letter]}
disabled={data.guesses[i].length === 5}
Expand Down Expand Up @@ -197,7 +207,7 @@
stageHeight: window.innerHeight,
colors: ['#ff3e00', '#40b3ff', '#676778']
}}
/>
></div>
{/if}

<style>
Expand Down
4 changes: 2 additions & 2 deletions packages/site/svelte.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ const config = {
KEY3: 'VALUE3'
},
stream: process.env.BUFFERED_RESPONSE !== 'TRUE',
adapterImports: [ "import { Stack } from 'aws-cdk-lib'" ],
adapterImports: ["import { Stack } from 'aws-cdk-lib'"],
lambdaModifier: (fn) => {
const stack = Stack.of(fn)
fn.addEnvironment("abc", "def")
fn.addEnvironment('abc', 'def')
}
})
}
Expand Down
3 changes: 2 additions & 1 deletion packages/site/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"allowJs": true,
"checkJs": true,
"strict": true,
"moduleResolution": "Bundler"
"moduleResolution": "Bundler",
"skipLibCheck": true
}
}
Loading

0 comments on commit 566ad71

Please sign in to comment.