Skip to content
Draft
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
14 changes: 14 additions & 0 deletions .changeset/share-solid2-migration.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
"@solid-primitives/share": major
---

Migrate to Solid.js v2.0 (beta.10)

## Breaking Changes

**Peer dependencies**: `solid-js@^2.0.0-beta.10` and `@solidjs/web@^2.0.0-beta.10` are now required.

### `@solid-primitives/share`

- `isServer` is now imported from `@solidjs/web` (was `solid-js/web`)
- `createWebShare` — internal `createEffect` converted to the split compute/apply pattern required by Solid 2.0; the `on` helper (removed in Solid 2.0) is no longer used
7 changes: 4 additions & 3 deletions packages/share/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,10 @@ import { createWebShare } from "@solid-primitives/share";
const [data, setData] = createSignal<ShareData>({});
const shareStatus = createWebShare(data);

createEffect(() => {
console.log(shareStatus.status, shareStatus.message);
});
createEffect(
() => shareStatus.status,
status => console.log("Share status:", status, shareStatus.message),
);
```

## Changelog
Expand Down
2 changes: 1 addition & 1 deletion packages/share/dev/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { type Component, createEffect, createSignal } from "solid-js";
import { type Component, createSignal } from "solid-js";

import { createWebShare } from "../src/index.js";

Expand Down
8 changes: 5 additions & 3 deletions packages/share/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@solid-primitives/share",
"version": "2.2.4",
"version": "3.0.0",
"description": "Primitives to help with sharing content on social media and beyond.",
"author": "David Di Biase <dave@solidjs.com>",
"contributors": [
Expand Down Expand Up @@ -52,10 +52,12 @@
"test:ssr": "pnpm run vitest --mode ssr"
},
"peerDependencies": {
"solid-js": "^1.6.12"
"@solidjs/web": "^2.0.0-beta.10",
"solid-js": "^2.0.0-beta.10"
},
"typesVersions": {},
"devDependencies": {
"solid-js": "^1.9.7"
"@solidjs/web": "2.0.0-beta.10",
"solid-js": "2.0.0-beta.10"
}
}
2 changes: 1 addition & 1 deletion packages/share/src/social-share.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { type Accessor, createSignal } from "solid-js";
import { isServer } from "solid-js/web";
import { isServer } from "@solidjs/web";
import { type Network } from "./networks.js";

export type SharePopupOptions = {
Expand Down
28 changes: 15 additions & 13 deletions packages/share/src/web-share.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { type Accessor, createEffect, createSignal, on, type OnOptions } from "solid-js";
import { isServer } from "solid-js/web";
import { type Accessor, createEffect, createSignal } from "solid-js";
import { isServer } from "@solidjs/web";

/**
* Generates a simple non-reactive WebShare primitive for sharing.
Expand Down Expand Up @@ -67,24 +67,26 @@ export type ShareStatus = {
*/
export const createWebShare = (
data: Accessor<ShareData>,
deferInitial: boolean = false,
deferInitial = false,
): ShareStatus => {
if (isServer) {
return {};
}
const [status, setStatus] = createSignal<ShareStatus>({});
const share = makeWebShare();
let skipFirst = deferInitial;
createEffect(
on(
data,
dataValue => {
setStatus({});
share(dataValue)
.then(() => setStatus({ status: true }))
.catch(e => setStatus({ status: false, message: e.toString() }));
},
{ defer: deferInitial } satisfies OnOptions as any,
),
() => data(),
dataValue => {
if (skipFirst) {
skipFirst = false;
return;
}
setStatus({});
share(dataValue)
.then(() => setStatus({ status: true }))
.catch(e => setStatus({ status: false, message: e.toString() }));
},
);

return {
Expand Down
34 changes: 32 additions & 2 deletions pnpm-lock.yaml

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