Skip to content

fix: bumpup svelte #13

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/tasty-eggs-jam.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"svelte-jsx-snippet": minor
---

Bumpup svelte
4 changes: 2 additions & 2 deletions packages/svelte-jsx-snippet/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,14 @@
},
"homepage": "https://github.com/ssssota/svelte-jsx-snippet#readme",
"devDependencies": {
"svelte": "5.0.0-next.132",
"svelte": "5.0.0-next.136",
"svelte-jsx-snippet": "workspace:*",
"typescript": "^5.4.5",
"vite": "^5.0.3",
"vite-plugin-doctest": "^1.0.0",
"vitest": "^1.2.0"
},
"peerDependencies": {
"svelte": ">=5.0.0-next.132"
"svelte": ">=5.0.0-next.136"
}
}
5 changes: 3 additions & 2 deletions packages/svelte-jsx-snippet/src/index-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { FunctionComponent } from "./jsx-runtime/types";
import { ComponentType, SvelteComponent } from "svelte";
import { jsx as _jsx } from "./jsx-runtime/index-server";
import { hydrationMarkerE, hydrationMarkerS } from "./constants";
import { add_snippet_symbol } from "./utils";

export const jsx$ = <P extends Record<string, unknown>, S extends keyof P>(
Component: ComponentType<SvelteComponent<P>>,
Expand All @@ -16,14 +17,14 @@ export const jsx$ = <P extends Record<string, unknown>, S extends keyof P>(
}
return [
key,
$.add_snippet_symbol(($$payload: { out: string }) => {
add_snippet_symbol(($$payload: { out: string }) => {
$$payload.out += String(value);
}),
] as const;
}
return [key, value] as const;
});
return $.add_snippet_symbol(($$payload: { out: string }) => {
return add_snippet_symbol(($$payload: { out: string }) => {
$$payload.out += hydrationMarkerS;
(Component as any)($$payload, Object.fromEntries(propertyEntries));
$$payload.out += hydrationMarkerE;
Expand Down
5 changes: 3 additions & 2 deletions packages/svelte-jsx-snippet/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import * as $ from "svelte/internal/client";
import type { FunctionComponent } from "./jsx-runtime/types";
import type { ComponentType, SvelteComponent } from "svelte";
import { jsx as _jsx, Fragment } from "./jsx-runtime";
import { add_snippet_symbol } from "./utils";

/**
* Convert a Svelte component to a JSX function component
Expand Down Expand Up @@ -31,14 +32,14 @@ export const jsx$ = <P extends Record<string, unknown>, S extends keyof P>(
const template = $.template(value, 1);
return [
key,
$.add_snippet_symbol(($$anchor: unknown) => {
add_snippet_symbol(($$anchor: unknown) => {
$.append($$anchor, template());
}),
] as const;
}
return [key, value] as const;
});
return $.add_snippet_symbol(($$anchor: unknown) => {
return add_snippet_symbol(($$anchor: unknown) => {
const fragment = $.comment();
const root = $.first_child(fragment);

Expand Down
10 changes: 7 additions & 3 deletions packages/svelte-jsx-snippet/src/jsx-runtime/index-server.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import type { Snippet } from "svelte";
import * as $ from "svelte/internal/server";
import { buildChildList, isVoidElement, renderProps } from "../utils";
import {
add_snippet_symbol,
buildChildList,
isVoidElement,
renderProps,
} from "../utils";
import type { FunctionComponent, JsxDevOpts } from "./types";
import { FRAGMENT, hydrationMarkerE, hydrationMarkerS } from "../constants";

Expand All @@ -14,7 +18,7 @@ const jsxDEV = <T extends string | FunctionComponent<any>>(
_opts?: JsxDevOpts,
_ctx?: unknown,
): Snippet<[]> => {
return $.add_snippet_symbol(($$payload: { out: string }) => {
return add_snippet_symbol(($$payload: { out: string }) => {
const { children, ...rest } = props;
const childList = buildChildList(children);
if (type === FRAGMENT || type === Fragment) {
Expand Down
9 changes: 7 additions & 2 deletions packages/svelte-jsx-snippet/src/jsx-runtime/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
import type { Snippet } from "svelte";
import type { SvelteHTMLElements } from "svelte/elements";
import * as $ from "svelte/internal/client";
import { buildChildList, isVoidElement, renderProps } from "../utils";
import {
add_snippet_symbol,
buildChildList,
isVoidElement,
renderProps,
} from "../utils";
import type { FunctionComponent, JSXChildren, JsxDevOpts } from "./types";
import { FRAGMENT, TEMPLATE_FRAGMENT, injectMarker } from "../constants";

Expand Down Expand Up @@ -33,7 +38,7 @@ const jsxDEV = <T extends string | FunctionComponent<any>>(
: `<${type}${renderProps(rest)}>${childrenContent}</${type}>`
: injectMarker;
const template = $.template(content, fragment ? TEMPLATE_FRAGMENT : 0);
return $.add_snippet_symbol(($$anchor: unknown) => {
return add_snippet_symbol(($$anchor: unknown) => {
const root = template();

if (fragment || rootIsHtml) {
Expand Down
6 changes: 6 additions & 0 deletions packages/svelte-jsx-snippet/src/utils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
import { escape } from "svelte/internal/server";

const snippet_symbol = Symbol.for("svelte.snippet");
export function add_snippet_symbol(fn: (...args: any[]) => any) {
fn[snippet_symbol] = true;
return fn;
}

const voidElementSet = new Set([
"area",
"base",
Expand Down
72 changes: 36 additions & 36 deletions pnpm-lock.yaml

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

2 changes: 1 addition & 1 deletion site/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"@testing-library/svelte": "^5.1.0",
"jsdom": "^24.0.0",
"mizu.css": "^0.1.2",
"svelte": "^5.0.0-next.132",
"svelte": "^5.0.0-next.136",
"svelte-check": "^3.6.0",
"svelte-jsx-snippet": "workspace:*",
"tslib": "^2.4.1",
Expand Down