Skip to content

Commit

Permalink
package init
Browse files Browse the repository at this point in the history
  • Loading branch information
phryneas committed Dec 20, 2024
1 parent 29378d5 commit d28e848
Show file tree
Hide file tree
Showing 14 changed files with 4,792 additions and 255 deletions.
66 changes: 66 additions & 0 deletions .yarn/patches/@tanstack-react-router-npm-1.91.3-8e077b923e.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
diff --git a/dist/cjs/router.cjs b/dist/cjs/router.cjs
index 540b3d44e8a7163e9c6ff6063002c046e497149c..db9db4fcf5dbf81ec49f4027bb5875855f1cdb49 100644
--- a/dist/cjs/router.cjs
+++ b/dist/cjs/router.cjs
@@ -1442,7 +1442,7 @@ ${script}\`)` : ""}; if (typeof __TSR__ !== 'undefined') __TSR__.cleanScripts()<
!this.streamedKeys.has(key),
"Key has already been streamed: " + key
);
- this.streamedKeys.add(key);
+ this.emit({ type: 'onStreamedValue', key });
this.injectScript(
`__TSR__.streamedValues['${key}'] = { value: ${(_a = this.serializer) == null ? void 0 : _a.call(this, this.options.transformer.stringify(value))}}`
);
@@ -1495,7 +1495,12 @@ ${script}\`)` : ""}; if (typeof __TSR__ !== 'undefined') __TSR__.cleanScripts()<
});
if (typeof document !== "undefined") {
window.__TSR__ROUTER__ = this;
+ this.streamedKeys = new Set(
+ Object.keys(window.__TSR__?.streamedValues || {}),
+ );
}
+
+ this.subscribe('onStreamedValue', ({ key }) => this.streamedKeys.add(key));
}
get state() {
return this.__store.state;
diff --git a/dist/esm/router.d.ts b/dist/esm/router.d.ts
index 2c52a521d9ac164e395c128e1749448cd166f620..7b98a7ed3ea6e9aaa86100fa0a00b895d2a39b30 100644
--- a/dist/esm/router.d.ts
+++ b/dist/esm/router.d.ts
@@ -472,6 +472,10 @@ export type RouterEvents = {
pathChanged: boolean;
hrefChanged: boolean;
};
+ onStreamedValue: {
+ type: 'onStreamedValue'
+ key: string
+ };
};
export type RouterEvent = RouterEvents[keyof RouterEvents];
export type RouterListener<TRouterEvent extends RouterEvent> = {
diff --git a/dist/esm/router.js b/dist/esm/router.js
index 88e500ca78d521c4ab2041c7c42367dee4526b54..ca0381faa1fbd950abf2d9185420ec1a43c10dc6 100644
--- a/dist/esm/router.js
+++ b/dist/esm/router.js
@@ -1440,7 +1440,7 @@ ${script}\`)` : ""}; if (typeof __TSR__ !== 'undefined') __TSR__.cleanScripts()<
!this.streamedKeys.has(key),
"Key has already been streamed: " + key
);
- this.streamedKeys.add(key);
+ this.emit({ type: 'onStreamedValue', key })
this.injectScript(
`__TSR__.streamedValues['${key}'] = { value: ${(_a = this.serializer) == null ? void 0 : _a.call(this, this.options.transformer.stringify(value))}}`
);
@@ -1493,7 +1493,11 @@ ${script}\`)` : ""}; if (typeof __TSR__ !== 'undefined') __TSR__.cleanScripts()<
});
if (typeof document !== "undefined") {
window.__TSR__ROUTER__ = this;
+ this.streamedKeys = new Set(
+ Object.keys(window.__TSR__?.streamedValues || {}),
+ );
}
+ this.subscribe('onStreamedValue', ({ key }) => this.streamedKeys.add(key))
}
get state() {
return this.__store.state;
26 changes: 26 additions & 0 deletions .yarn/patches/@tanstack-start-npm-1.91.3-de6292cf0b.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
diff --git a/dist/cjs/client/Meta.cjs b/dist/cjs/client/Meta.cjs
index 2495f0e4597b6e75470af5b8c8d33fc32a68e699..c96fb28d719fc018a0c11e9136736f455bc8c685 100644
--- a/dist/cjs/client/Meta.cjs
+++ b/dist/cjs/client/Meta.cjs
@@ -118,7 +118,7 @@ const useMetaElements = () => {
reactRouter.ScriptOnce,
{
log: false,
- children: `__TSR__={matches:[],streamedValues:{},queue:[],runQueue:()=>{let e=!1;__TSR__.queue=__TSR__.queue.filter((_=>!_()||(e=!0,!1))),e&&__TSR__.runQueue()},initMatch:e=>{__TSR__.queue.push((()=>(__TSR__.matches[e.index]||(__TSR__.matches[e.index]=e,Object.entries(e.extracted).forEach((([e,_])=>{if("stream"===_.type){let e;_.value=new ReadableStream({start(_){e=_}}),_.value.controller=e}else if("promise"===_.type){let e,t;_.value=new Promise(((_,u)=>{e=_,t=u})),_.resolve=e,_.reject=t}}))),!0))),__TSR__.runQueue()},resolvePromise:e=>{__TSR__.queue.push((()=>{const _=__TSR__.matches[e.matchIndex];if(_){const t=_.extracted[e.id];if(t)return t.resolve(e.value.data),!0}return!1})),__TSR__.runQueue()},cleanScripts:()=>{document.querySelectorAll(".tsr-once").forEach((e=>{e.remove()}))}};`
+ children: `__TSR__={matches:[],streamedValues:new Proxy({},{set(e,_,t){const r=Reflect.set(e,_,t);return window.__TSR__ROUTER__&&__TSR__ROUTER__.emit({type:"onStreamedValue",key:_}),r}}),queue:[],runQueue:()=>{let e=!1;__TSR__.queue=__TSR__.queue.filter((_=>!_()||(e=!0,!1))),e&&__TSR__.runQueue()},initMatch:e=>{__TSR__.queue.push((()=>(__TSR__.matches[e.index]||(__TSR__.matches[e.index]=e,Object.entries(e.extracted).forEach((([e,_])=>{if("stream"===_.type){let e;_.value=new ReadableStream({start(_){e=_}}),_.value.controller=e}else if("promise"===_.type){let e,t;_.value=new Promise(((_,u)=>{e=_,t=u})),_.resolve=e,_.reject=t}}))),!0))),__TSR__.runQueue()},resolvePromise:e=>{__TSR__.queue.push((()=>{const _=__TSR__.matches[e.matchIndex];if(_){const t=_.extracted[e.id];if(t)return t.resolve(e.value.data),!0}return!1})),__TSR__.runQueue()},cleanScripts:()=>{document.querySelectorAll(".tsr-once").forEach((e=>{e.remove()}))}};`
}
),
/* @__PURE__ */ jsxRuntime.jsx(
diff --git a/dist/esm/client/Meta.js b/dist/esm/client/Meta.js
index bb69cd494686acbc26c9a6ec409e8ba8c36436a3..d7add4aaeb87f6ff7550802b9afbd59e468551d4 100644
--- a/dist/esm/client/Meta.js
+++ b/dist/esm/client/Meta.js
@@ -100,7 +100,7 @@ const useMetaElements = () => {
ScriptOnce,
{
log: false,
- children: `__TSR__={matches:[],streamedValues:{},queue:[],runQueue:()=>{let e=!1;__TSR__.queue=__TSR__.queue.filter((_=>!_()||(e=!0,!1))),e&&__TSR__.runQueue()},initMatch:e=>{__TSR__.queue.push((()=>(__TSR__.matches[e.index]||(__TSR__.matches[e.index]=e,Object.entries(e.extracted).forEach((([e,_])=>{if("stream"===_.type){let e;_.value=new ReadableStream({start(_){e=_}}),_.value.controller=e}else if("promise"===_.type){let e,t;_.value=new Promise(((_,u)=>{e=_,t=u})),_.resolve=e,_.reject=t}}))),!0))),__TSR__.runQueue()},resolvePromise:e=>{__TSR__.queue.push((()=>{const _=__TSR__.matches[e.matchIndex];if(_){const t=_.extracted[e.id];if(t)return t.resolve(e.value.data),!0}return!1})),__TSR__.runQueue()},cleanScripts:()=>{document.querySelectorAll(".tsr-once").forEach((e=>{e.remove()}))}};`
+ children: `__TSR__={matches:[],streamedValues:new Proxy({},{set(e,_,t){const r=Reflect.set(e,_,t);return window.__TSR__ROUTER__&&__TSR__ROUTER__.emit({type:"onStreamedValue",key:_}),r}}),queue:[],runQueue:()=>{let e=!1;__TSR__.queue=__TSR__.queue.filter((_=>!_()||(e=!0,!1))),e&&__TSR__.runQueue()},initMatch:e=>{__TSR__.queue.push((()=>(__TSR__.matches[e.index]||(__TSR__.matches[e.index]=e,Object.entries(e.extracted).forEach((([e,_])=>{if("stream"===_.type){let e;_.value=new ReadableStream({start(_){e=_}}),_.value.controller=e}else if("promise"===_.type){let e,t;_.value=new Promise(((_,u)=>{e=_,t=u})),_.resolve=e,_.reject=t}}))),!0))),__TSR__.runQueue()},resolvePromise:e=>{__TSR__.queue.push((()=>{const _=__TSR__.matches[e.matchIndex];if(_){const t=_.extracted[e.id];if(t)return t.resolve(e.value.data),!0}return!1})),__TSR__.runQueue()},cleanScripts:()=>{document.querySelectorAll(".tsr-once").forEach((e=>{e.remove()}))}};`
}
),
/* @__PURE__ */ jsx(

This file was deleted.

2 changes: 1 addition & 1 deletion integration-test/react-router/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"isbot": "^5.1.17",
"react": "^19",
"react-dom": "^19",
"react-router": "patch:react-router@npm%3A7.0.2#~/.yarn/patches/react-router-npm-7.0.2-b96f2bd13c.patch"
"react-router": "patch:react-router@npm%3A7.0.2#~/../.yarn/patches/react-router-npm-7.0.2-b96f2bd13c.patch"
},
"devDependencies": {
"@react-router/dev": "^7.0.1",
Expand Down
10 changes: 5 additions & 5 deletions integration-test/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ __metadata:

"@apollo/client-integration-react-router@exec:./shared/build-client-integration-react-router.cjs::locator=%40integration-test%2Froot%40workspace%3A.":
version: 0.11.5
resolution: "@apollo/client-integration-react-router@exec:./shared/build-client-integration-react-router.cjs#./shared/build-client-integration-react-router.cjs::hash=e00fd5&locator=%40integration-test%2Froot%40workspace%3A."
resolution: "@apollo/client-integration-react-router@exec:./shared/build-client-integration-react-router.cjs#./shared/build-client-integration-react-router.cjs::hash=08a50e&locator=%40integration-test%2Froot%40workspace%3A."
dependencies:
"@apollo/client-react-streaming": "npm:0.11.5"
peerDependencies:
Expand Down Expand Up @@ -101,7 +101,7 @@ __metadata:

"@apollo/experimental-nextjs-app-support@exec:./shared/build-experimental-nextjs-app-support.cjs::locator=%40integration-test%2Froot%40workspace%3A.":
version: 0.11.8-alpha.1
resolution: "@apollo/experimental-nextjs-app-support@exec:./shared/build-experimental-nextjs-app-support.cjs#./shared/build-experimental-nextjs-app-support.cjs::hash=af96a6&locator=%40integration-test%2Froot%40workspace%3A."
resolution: "@apollo/experimental-nextjs-app-support@exec:./shared/build-experimental-nextjs-app-support.cjs#./shared/build-experimental-nextjs-app-support.cjs::hash=2ee804&locator=%40integration-test%2Froot%40workspace%3A."
dependencies:
"@apollo/client-react-streaming": "npm:0.11.8-alpha.1"
peerDependencies:
Expand Down Expand Up @@ -8897,9 +8897,9 @@ __metadata:
languageName: node
linkType: hard

"react-router@patch:react-router@npm%3A7.0.2#~/.yarn/patches/react-router-npm-7.0.2-b96f2bd13c.patch":
"react-router@patch:react-router@npm%3A7.0.2#~/../.yarn/patches/react-router-npm-7.0.2-b96f2bd13c.patch":
version: 7.0.2
resolution: "react-router@patch:react-router@npm%3A7.0.2#~/.yarn/patches/react-router-npm-7.0.2-b96f2bd13c.patch::version=7.0.2&hash=c518b8"
resolution: "react-router@patch:react-router@npm%3A7.0.2#~/../.yarn/patches/react-router-npm-7.0.2-b96f2bd13c.patch::version=7.0.2&hash=c518b8"
dependencies:
"@types/cookie": "npm:^0.6.0"
cookie: "npm:^1.0.1"
Expand Down Expand Up @@ -8934,7 +8934,7 @@ __metadata:
postcss: "npm:^8.4.49"
react: "npm:^19"
react-dom: "npm:^19"
react-router: "patch:react-router@npm%3A7.0.2#~/.yarn/patches/react-router-npm-7.0.2-b96f2bd13c.patch"
react-router: "patch:react-router@npm%3A7.0.2#~/../.yarn/patches/react-router-npm-7.0.2-b96f2bd13c.patch"
tailwindcss: "npm:^3.4.15"
typescript: "npm:^5.6.3"
vite: "npm:^5.4.11"
Expand Down
6 changes: 2 additions & 4 deletions packages/tanstack-start/package-shape.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,12 @@
"@apollo/client-integration-react-router": {
"browser": [
"ApolloClient",
"ApolloHydrationHelper",
"createApolloLoaderHandler",
"routerWithApolloClient",
"built_for_browser"
],
"node": [
"ApolloClient",
"ApolloHydrationHelper",
"createApolloLoaderHandler",
"routerWithApolloClient",
"built_for_browser"
]
}
Expand Down
8 changes: 6 additions & 2 deletions packages/tanstack-start/package.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
{
"name": "@apollo/client-integration-react-router",
"name": "@apollo/client-integration-tanstack-start",
"version": "0.11.5",
"repository": {
"url": "git+https://github.com/apollographql/apollo-client-nextjs"
},
"keywords": [
"apollo",
"react-router",
"tanstack-start",
"tanstack",
"apollo-client",
"graphql",
"ssr"
Expand Down Expand Up @@ -69,6 +70,8 @@
"@arethetypeswrong/cli": "0.15.3",
"@internal/test-utils": "workspace:^",
"@microsoft/api-extractor": "7.43.2",
"@tanstack/react-router": "patch:@tanstack/react-router@npm%3A1.91.3#~/.yarn/patches/@tanstack-react-router-npm-1.91.3-8e077b923e.patch",
"@tanstack/start": "patch:@tanstack/start@npm%3A1.91.3#~/.yarn/patches/@tanstack-start-npm-1.91.3-de6292cf0b.patch",
"@testing-library/dom": "^10.4.0",
"@testing-library/react": "^16.1.0",
"@total-typescript/shoehorn": "0.1.2",
Expand All @@ -93,6 +96,7 @@
"vitest": "1.6.0"
},
"peerDependencies": {
"@tanstack/react-router": "*",
"react": "^19",
"react-router": "^7.0.2"
},
Expand Down
26 changes: 0 additions & 26 deletions packages/tanstack-start/src/ApolloClient.tsx

This file was deleted.

28 changes: 0 additions & 28 deletions packages/tanstack-start/src/ApolloHydrationHelper.tsx

This file was deleted.

Loading

0 comments on commit d28e848

Please sign in to comment.