create-partylayer-app 0.4.0 → 0.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-partylayer-app",
3
- "version": "0.4.0",
3
+ "version": "0.4.1",
4
4
  "description": "Scaffold a PartyLayer dApp (Canton wallet integration) in seconds.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -10,9 +10,10 @@
10
10
  "lint": "next lint"
11
11
  },
12
12
  "dependencies": {
13
- "@partylayer/react": "^0.9.1",
14
- "@partylayer/sdk": "^0.10.0",
15
- "@partylayer/session": "^1.1.0",
13
+ "@partylayer/react": "^2.1.0",
14
+ "@partylayer/sdk": "^0.15.0",
15
+ "@partylayer/session": "^1.1.4",
16
+ "@tanstack/react-query": "^5.0.0",
16
17
  "next": "^14.2.5",
17
18
  "react": "^18.3.1",
18
19
  "react-dom": "^18.3.1"
@@ -1,7 +1,7 @@
1
1
  import { getServerSession, truncateParty } from '@/lib/session';
2
2
  import { ConnectButton } from '@/components/ConnectButton';
3
3
 
4
- // Reading cookies() opts this route into dynamic (per-request) rendering — which
4
+ // Reading cookies() opts this route into dynamic (per-request) rendering, which
5
5
  // is exactly what SSR session needs: the server reads the session cookie on
6
6
  // every request and renders the connected state into the initial HTML.
7
7
  export default function Home() {
@@ -11,7 +11,7 @@ export default function Home() {
11
11
  return (
12
12
  <main className="app">
13
13
  <h1>{{PROJECT_NAME}}</h1>
14
- <p className="subtitle">A PartyLayer dApp on Canton — connect any verified wallet.</p>
14
+ <p className="subtitle">A PartyLayer dApp on Canton: connect any verified wallet.</p>
15
15
 
16
16
  {/* SERVER-RENDERED connected state (Option A: server owns the display). This
17
17
  appears in the initial HTML from the cookie, before any client JS, so
@@ -22,11 +22,11 @@ export default function Home() {
22
22
  </p>
23
23
  ) : (
24
24
  <p className="session" data-testid="server-cta">
25
- Not connected — connect a wallet to continue.
25
+ Not connected: connect a wallet to continue.
26
26
  </p>
27
27
  )}
28
28
 
29
- {/* Interactive client island — reconciles silently with the live provider. */}
29
+ {/* Interactive client island: reconciles silently with the live provider. */}
30
30
  <ConnectButton />
31
31
  </main>
32
32
  );
@@ -1,19 +1,29 @@
1
1
  'use client';
2
2
 
3
- import { useMemo, type ReactNode } from 'react';
3
+ import { useMemo, useState, type ReactNode } from 'react';
4
+ import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
4
5
  import { PartyLayerKit } from '@partylayer/react';
5
6
  import { createCookieStorage } from '@partylayer/session';
6
7
 
7
8
  /**
8
9
  * Client provider boundary. cookieStorage on the client uses document.cookie
9
- * (synchronous → flash-free), the SAME cookie the server reads in lib/session.ts
10
- * — so server HTML and client hydration agree.
10
+ * (synchronous, flash-free), the SAME cookie the server reads in lib/session.ts,
11
+ * so server HTML and client hydration agree.
12
+ *
13
+ * The QueryClient is created with useState so each browser client gets one stable
14
+ * instance (never shared across server requests), the SSR-safe pattern for the
15
+ * App Router. PartyLayer's data hooks (@partylayer/react/query) read this client;
16
+ * the base session surface works without it, but it is set up so the query hooks
17
+ * are ready when you reach for them.
11
18
  */
12
19
  export function Providers({ children }: { children: ReactNode }) {
13
20
  const storage = useMemo(() => createCookieStorage(), []);
21
+ const [queryClient] = useState(() => new QueryClient());
14
22
  return (
15
- <PartyLayerKit network="devnet" appName="{{PROJECT_NAME}}" sessionOptions={{ storage }}>
16
- {children}
17
- </PartyLayerKit>
23
+ <QueryClientProvider client={queryClient}>
24
+ <PartyLayerKit network="devnet" appName="{{PROJECT_NAME}}" sessionOptions={{ storage }}>
25
+ {children}
26
+ </PartyLayerKit>
27
+ </QueryClientProvider>
18
28
  );
19
29
  }
@@ -9,8 +9,9 @@
9
9
  "preview": "vite preview"
10
10
  },
11
11
  "dependencies": {
12
- "@partylayer/react": "^0.9.1",
13
- "@partylayer/sdk": "^0.10.0",
12
+ "@partylayer/react": "^2.1.0",
13
+ "@partylayer/sdk": "^0.15.0",
14
+ "@tanstack/react-query": "^5.0.0",
14
15
  "react": "^18.3.1",
15
16
  "react-dom": "^18.3.1"
16
17
  },
@@ -12,7 +12,7 @@ export default function App() {
12
12
  <PartyLayerKit network="devnet" appName="{{PROJECT_NAME}}">
13
13
  <main className="app">
14
14
  <h1>{{PROJECT_NAME}}</h1>
15
- <p className="subtitle">A PartyLayer dApp on Canton — connect any verified wallet.</p>
15
+ <p className="subtitle">A PartyLayer dApp on Canton: connect any verified wallet.</p>
16
16
  <ConnectButton />
17
17
  <SessionPanel />
18
18
  </main>
@@ -1,10 +1,20 @@
1
1
  import { StrictMode } from 'react';
2
2
  import { createRoot } from 'react-dom/client';
3
+ import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
3
4
  import App from './App';
4
5
  import './index.css';
5
6
 
7
+ // PartyLayer's data hooks (the `@partylayer/react/query` entrypoint:
8
+ // useDamlContract, useChoice, the cost hooks) are built on TanStack Query, so
9
+ // they need a QueryClient in context. Create one here and wrap the app. The base
10
+ // session surface (PartyLayerKit, ConnectButton, useAccount) works without it,
11
+ // but having it set up means the query hooks are ready when you reach for them.
12
+ const queryClient = new QueryClient();
13
+
6
14
  createRoot(document.getElementById('root')!).render(
7
15
  <StrictMode>
8
- <App />
16
+ <QueryClientProvider client={queryClient}>
17
+ <App />
18
+ </QueryClientProvider>
9
19
  </StrictMode>,
10
20
  );
@@ -9,7 +9,7 @@
9
9
  "preview": "vite preview"
10
10
  },
11
11
  "dependencies": {
12
- "@partylayer/sdk": "^0.10.0"
12
+ "@partylayer/sdk": "^0.15.0"
13
13
  },
14
14
  "devDependencies": {
15
15
  "typescript": "^5.6.2",
@@ -10,10 +10,11 @@
10
10
  "postinstall": "nuxt prepare"
11
11
  },
12
12
  "dependencies": {
13
- "@partylayer/sdk": "^0.10.0",
14
- "@partylayer/session": "^1.1.0",
15
- "@partylayer/vue": "^0.1.3",
13
+ "@partylayer/sdk": "^0.15.0",
14
+ "@partylayer/session": "^1.1.4",
15
+ "@partylayer/vue": "^1.0.1",
16
16
  "@pinia/nuxt": "^0.5.5",
17
+ "@tanstack/vue-query": "^5.0.0",
17
18
  "pinia": "^2.2.0",
18
19
  "vue": "^3.5.0"
19
20
  },
@@ -15,14 +15,14 @@ const sessionStore = useSessionStore();
15
15
  <template>
16
16
  <main class="app">
17
17
  <h1>{{PROJECT_NAME}}</h1>
18
- <p class="subtitle">A PartyLayer dApp on Canton — Nuxt 3 + Pinia, SSR session.</p>
18
+ <p class="subtitle">A PartyLayer dApp on Canton: Nuxt 3 + Pinia, SSR session.</p>
19
19
 
20
20
  <!-- SERVER-RENDERED party from the cookie (initial HTML, no flash) -->
21
21
  <p v-if="serverParty" class="session">
22
22
  Connected as <code data-testid="server-party">{{ truncateParty(serverParty) }}</code>
23
23
  </p>
24
24
  <p v-else class="session" data-testid="server-cta">
25
- Not connected — connect a wallet to continue.
25
+ Not connected: connect a wallet to continue.
26
26
  </p>
27
27
 
28
28
  <!-- Pinia-backed interactive session (reads the Pinia store, not the composables) -->
@@ -1,14 +1,22 @@
1
+ import { VueQueryPlugin } from '@tanstack/vue-query';
1
2
  import { createPartyLayer } from '@partylayer/sdk';
2
3
  import { createPartyLayerSession } from '@partylayer/vue';
3
4
  import { createCookieStorage } from '@partylayer/session';
4
5
 
5
6
  /**
6
7
  * Client-only plugin: create the PartyLayer client and provide the session store
7
- * app-wide. cookieStorage on the client uses document.cookie — the SAME cookie
8
+ * app-wide. cookieStorage on the client uses document.cookie, the SAME cookie
8
9
  * the server reads for SSR (lib/session.ts). The connected/wallet UI is
9
10
  * client-side; the server-rendered party comes from the cookie directly.
11
+ *
12
+ * VueQueryPlugin supplies the QueryClient that PartyLayer's data composables
13
+ * (useDamlContract, useChoice, the cost composables) build on. It is registered
14
+ * client-side here, so there is no SSR query state to dehydrate; the base session
15
+ * composables work without it, but it is set up so the query composables are
16
+ * ready when you reach for them. For SSR query prefetch, see the Nuxt SSR guide.
10
17
  */
11
18
  export default defineNuxtPlugin((nuxtApp) => {
19
+ nuxtApp.vueApp.use(VueQueryPlugin);
12
20
  const client = createPartyLayer({ network: 'devnet', app: { name: '{{PROJECT_NAME}}' } });
13
21
  nuxtApp.vueApp.use(
14
22
  createPartyLayerSession({