houdini-react 1.2.22 → 1.2.23
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/build/plugin/vite.d.ts +1 -1
- package/build/plugin-cjs/index.js +229 -116
- package/build/plugin-esm/index.js +227 -114
- package/build/runtime/index.d.ts +2 -19
- package/build/runtime/routing/Router.d.ts +14 -0
- package/build/runtime-cjs/index.d.ts +2 -19
- package/build/runtime-cjs/index.js +4 -43
- package/build/runtime-cjs/routing/Router.d.ts +14 -0
- package/build/runtime-cjs/routing/Router.js +43 -0
- package/build/runtime-esm/index.d.ts +2 -19
- package/build/runtime-esm/index.js +2 -45
- package/build/runtime-esm/routing/Router.d.ts +14 -0
- package/build/runtime-esm/routing/Router.js +42 -0
- package/package.json +2 -2
|
@@ -75577,10 +75577,10 @@ var validateHeaderValue = typeof http.validateHeaderValue === "function" ? http.
|
|
|
75577
75577
|
throw error;
|
|
75578
75578
|
}
|
|
75579
75579
|
};
|
|
75580
|
-
var
|
|
75580
|
+
var Headers2 = class extends URLSearchParams {
|
|
75581
75581
|
constructor(init) {
|
|
75582
75582
|
let result = [];
|
|
75583
|
-
if (init instanceof
|
|
75583
|
+
if (init instanceof Headers2) {
|
|
75584
75584
|
const raw = init.raw();
|
|
75585
75585
|
for (const [name, values] of Object.entries(raw)) {
|
|
75586
75586
|
result.push(...values.map((value) => [name, value]));
|
|
@@ -75704,7 +75704,7 @@ var Headers = class extends URLSearchParams {
|
|
|
75704
75704
|
}
|
|
75705
75705
|
};
|
|
75706
75706
|
Object.defineProperties(
|
|
75707
|
-
|
|
75707
|
+
Headers2.prototype,
|
|
75708
75708
|
["get", "entries", "forEach", "values"].reduce((result, property) => {
|
|
75709
75709
|
result[property] = { enumerable: true };
|
|
75710
75710
|
return result;
|
|
@@ -75719,7 +75719,7 @@ var Response2 = class extends Body {
|
|
|
75719
75719
|
constructor(body = null, options = {}) {
|
|
75720
75720
|
super(body, options);
|
|
75721
75721
|
const status = options.status != null ? options.status : 200;
|
|
75722
|
-
const headers = new
|
|
75722
|
+
const headers = new Headers2(options.headers);
|
|
75723
75723
|
if (body !== null && !headers.has("Content-Type")) {
|
|
75724
75724
|
const contentType = extractContentType(body, this);
|
|
75725
75725
|
if (contentType) {
|
|
@@ -75794,7 +75794,7 @@ var Response2 = class extends Body {
|
|
|
75794
75794
|
if (body === void 0) {
|
|
75795
75795
|
throw new TypeError("data is not JSON serializable");
|
|
75796
75796
|
}
|
|
75797
|
-
const headers = new
|
|
75797
|
+
const headers = new Headers2(init && init.headers);
|
|
75798
75798
|
if (!headers.has("content-type")) {
|
|
75799
75799
|
headers.set("content-type", "application/json");
|
|
75800
75800
|
}
|
|
@@ -75870,7 +75870,7 @@ var Request2 = class extends Body {
|
|
|
75870
75870
|
super(inputBody, {
|
|
75871
75871
|
size: init.size || input.size || 0
|
|
75872
75872
|
});
|
|
75873
|
-
const headers = new
|
|
75873
|
+
const headers = new Headers2(init.headers || input.headers || {});
|
|
75874
75874
|
if (inputBody !== null && !headers.has("Content-Type")) {
|
|
75875
75875
|
const contentType = extractContentType(inputBody, this);
|
|
75876
75876
|
if (contentType) {
|
|
@@ -78406,7 +78406,7 @@ function exec(match, params) {
|
|
|
78406
78406
|
const result = {};
|
|
78407
78407
|
const values = match.slice(1);
|
|
78408
78408
|
let buffered = "";
|
|
78409
|
-
for (let i2 = 0; i2 < params.length; i2 += 1) {
|
|
78409
|
+
for (let i2 = 0; i2 < (params || []).length; i2 += 1) {
|
|
78410
78410
|
const param = params[i2];
|
|
78411
78411
|
let value = values[i2];
|
|
78412
78412
|
if (param.chained && param.rest && buffered) {
|
|
@@ -78620,7 +78620,8 @@ __export(conventions_exports, {
|
|
|
78620
78620
|
router_index_path: () => router_index_path,
|
|
78621
78621
|
router_path: () => router_path,
|
|
78622
78622
|
serialized_manifest_path: () => serialized_manifest_path,
|
|
78623
|
-
server_adapter_path: () => server_adapter_path
|
|
78623
|
+
server_adapter_path: () => server_adapter_path,
|
|
78624
|
+
vite_render_path: () => vite_render_path
|
|
78624
78625
|
});
|
|
78625
78626
|
function router_path(config2) {
|
|
78626
78627
|
return path_exports.join(base_dir(config2), "Router.jsx");
|
|
@@ -78634,6 +78635,9 @@ function server_adapter_path(config2, base) {
|
|
|
78634
78635
|
function adapter_config_path(config2, base) {
|
|
78635
78636
|
return path_exports.join(units_dir(config2, base), "render", "config.js");
|
|
78636
78637
|
}
|
|
78638
|
+
function vite_render_path(config2, base) {
|
|
78639
|
+
return path_exports.join(units_dir(config2, base), "render", "vite.js");
|
|
78640
|
+
}
|
|
78637
78641
|
function app_component_path(config2, base) {
|
|
78638
78642
|
return path_exports.join(units_dir(config2, base), "render", "App.jsx");
|
|
78639
78643
|
}
|
|
@@ -78942,12 +78946,19 @@ async function extractQueries(source) {
|
|
|
78942
78946
|
return props.filter((p) => p !== "children");
|
|
78943
78947
|
}
|
|
78944
78948
|
function isSecondaryBuild() {
|
|
78945
|
-
return process.env.
|
|
78949
|
+
return process.env.HOUDINI_SECONDARY_BUILD && process.env.HOUDINI_SECONDARY_BUILD !== "false";
|
|
78950
|
+
}
|
|
78951
|
+
function internalRoutes(config2) {
|
|
78952
|
+
const routes = [localApiEndpoint(config2)];
|
|
78953
|
+
if (config2.router?.auth && "redirect" in config2.router.auth) {
|
|
78954
|
+
routes.push(config2.router.auth.redirect);
|
|
78955
|
+
}
|
|
78956
|
+
return routes;
|
|
78946
78957
|
}
|
|
78947
78958
|
async function buildLocalSchema(config2) {
|
|
78948
|
-
const { build } = await import("vite");
|
|
78949
|
-
process.env.
|
|
78950
|
-
await
|
|
78959
|
+
const { build: build2 } = await import("vite");
|
|
78960
|
+
process.env.HOUDINI_SECONDARY_BUILD = "true";
|
|
78961
|
+
await build2({
|
|
78951
78962
|
logLevel: "silent",
|
|
78952
78963
|
build: {
|
|
78953
78964
|
outDir: path2.join(config2.rootDir, "temp"),
|
|
@@ -78968,7 +78979,7 @@ async function buildLocalSchema(config2) {
|
|
|
78968
78979
|
}
|
|
78969
78980
|
}
|
|
78970
78981
|
});
|
|
78971
|
-
process.env.
|
|
78982
|
+
process.env.HOUDINI_SECONDARY_BUILD = "false";
|
|
78972
78983
|
}
|
|
78973
78984
|
async function loadLocalSchema(config2) {
|
|
78974
78985
|
await buildLocalSchema(config2);
|
|
@@ -79207,16 +79218,103 @@ async function generate_renders({
|
|
|
79207
79218
|
config,
|
|
79208
79219
|
manifest: manifest3
|
|
79209
79220
|
}) {
|
|
79221
|
+
const adapter_path = conventions_exports.server_adapter_path(config);
|
|
79210
79222
|
await fs_exports.mkdirp(path_exports.dirname(conventions_exports.server_adapter_path(config)));
|
|
79211
79223
|
const app_index = `
|
|
79224
|
+
import { Router } from '$houdini/plugins/houdini-react/runtime'
|
|
79212
79225
|
import React from 'react'
|
|
79226
|
+
|
|
79213
79227
|
import Shell from '../../../../../src/+index'
|
|
79214
|
-
import { Router } from '$houdini'
|
|
79215
79228
|
|
|
79216
|
-
export default (props) =>
|
|
79229
|
+
export default (props) => (
|
|
79230
|
+
<Shell>
|
|
79231
|
+
<Router {...props} />
|
|
79232
|
+
</Shell>
|
|
79233
|
+
)
|
|
79234
|
+
`;
|
|
79235
|
+
let renderer = `
|
|
79236
|
+
import { Cache } from '$houdini/runtime/cache/cache'
|
|
79237
|
+
import { serverAdapterFactory, _serverHandler } from '$houdini/runtime/router/server'
|
|
79238
|
+
import { HoudiniClient } from '$houdini/runtime/client'
|
|
79239
|
+
import { renderToStream } from 'react-streaming/server'
|
|
79240
|
+
import React from 'react'
|
|
79241
|
+
|
|
79242
|
+
import { router_cache } from '../../runtime/routing'
|
|
79243
|
+
// @ts-expect-error
|
|
79244
|
+
import client from '../../../../../src/+client'
|
|
79245
|
+
// @ts-expect-error
|
|
79246
|
+
import App from "./App"
|
|
79247
|
+
import router_manifest from '$houdini/plugins/houdini-react/runtime/manifest'
|
|
79248
|
+
|
|
79249
|
+
export const on_render =
|
|
79250
|
+
({ assetPrefix, pipe, production, documentPremable }) =>
|
|
79251
|
+
async ({
|
|
79252
|
+
url,
|
|
79253
|
+
match,
|
|
79254
|
+
session,
|
|
79255
|
+
manifest,
|
|
79256
|
+
}) => {
|
|
79257
|
+
// instanitate a cache we can use for this request
|
|
79258
|
+
const cache = new Cache({ disabled: false })
|
|
79259
|
+
|
|
79260
|
+
if (!match) {
|
|
79261
|
+
return new Response('not found', { status: 404 })
|
|
79262
|
+
}
|
|
79263
|
+
|
|
79264
|
+
const {
|
|
79265
|
+
readable,
|
|
79266
|
+
injectToStream,
|
|
79267
|
+
pipe: pipeTo,
|
|
79268
|
+
} = await renderToStream(
|
|
79269
|
+
React.createElement(App, {
|
|
79270
|
+
initialURL: url,
|
|
79271
|
+
cache: cache,
|
|
79272
|
+
session: session,
|
|
79273
|
+
assetPrefix: assetPrefix,
|
|
79274
|
+
manifest: manifest,
|
|
79275
|
+
...router_cache()
|
|
79276
|
+
}),
|
|
79277
|
+
{
|
|
79278
|
+
userAgent: 'Vite',
|
|
79279
|
+
}
|
|
79280
|
+
)
|
|
79281
|
+
|
|
79282
|
+
// add the initial scripts to the page
|
|
79283
|
+
injectToStream(\`
|
|
79284
|
+
<script>
|
|
79285
|
+
window.__houdini__initial__cache__ = \${cache.serialize()};
|
|
79286
|
+
window.__houdini__initial__session__ = \${JSON.stringify(session)};
|
|
79287
|
+
<\/script>
|
|
79288
|
+
|
|
79289
|
+
\${documentPremable ?? ''}
|
|
79290
|
+
|
|
79291
|
+
<!--
|
|
79292
|
+
add a virtual module that hydrates the client and sets up the initial pending cache.
|
|
79293
|
+
the dynamic extension is to support dev which sees the raw jsx, and production which sees the bundled asset
|
|
79294
|
+
-->
|
|
79295
|
+
<script type="module" src="\${assetPrefix}/pages/\${match.id}.\${production ? 'js' : 'jsx'}" async=""><\/script>
|
|
79296
|
+
\`)
|
|
79297
|
+
|
|
79298
|
+
if (pipeTo && pipe) {
|
|
79299
|
+
pipeTo(pipe)
|
|
79300
|
+
return true
|
|
79301
|
+
} else {
|
|
79302
|
+
return new Response(readable)
|
|
79303
|
+
}
|
|
79304
|
+
}
|
|
79305
|
+
|
|
79306
|
+
export function createServerAdapter(options) {
|
|
79307
|
+
return serverAdapterFactory({
|
|
79308
|
+
client,
|
|
79309
|
+
production: true,
|
|
79310
|
+
manifest: router_manifest,
|
|
79311
|
+
on_render: on_render(options),
|
|
79312
|
+
...options,
|
|
79313
|
+
})
|
|
79314
|
+
}
|
|
79217
79315
|
`;
|
|
79218
79316
|
let adapter_config = `
|
|
79219
|
-
import createAdapter from './server'
|
|
79317
|
+
import { createServerAdapter as createAdapter } from './server'
|
|
79220
79318
|
|
|
79221
79319
|
export const endpoint = ${JSON.stringify(localApiEndpoint(config.configFile))}
|
|
79222
79320
|
|
|
@@ -79233,72 +79331,9 @@ export default (props) => <Shell><Router {...props} /></Shell>
|
|
|
79233
79331
|
})
|
|
79234
79332
|
}
|
|
79235
79333
|
`;
|
|
79236
|
-
const server_adapter = `
|
|
79237
|
-
import React from 'react'
|
|
79238
|
-
import { renderToStream } from 'react-streaming/server'
|
|
79239
|
-
import { Cache } from '$houdini/runtime/cache/cache'
|
|
79240
|
-
import { serverAdapterFactory } from '$houdini/runtime/router/server'
|
|
79241
|
-
|
|
79242
|
-
import { Router, router_cache } from '../../runtime'
|
|
79243
|
-
import manifest from '../../runtime/manifest'
|
|
79244
|
-
import App from './App'
|
|
79245
|
-
|
|
79246
|
-
import Shell from '../../../../../src/+index'
|
|
79247
|
-
|
|
79248
|
-
export default (options) => {
|
|
79249
|
-
return serverAdapterFactory({
|
|
79250
|
-
manifest,
|
|
79251
|
-
...options,
|
|
79252
|
-
on_render: async ({url, match, session, pipe , manifest }) => {
|
|
79253
|
-
// instanitate a cache we can use for this request
|
|
79254
|
-
const cache = new Cache({ disabled: false })
|
|
79255
|
-
|
|
79256
|
-
if (!match) {
|
|
79257
|
-
return new Response('not found', { status: 404 })
|
|
79258
|
-
}
|
|
79259
|
-
|
|
79260
|
-
const { readable, injectToStream, pipe: pipeTo } = await renderToStream(
|
|
79261
|
-
React.createElement(App, {
|
|
79262
|
-
initialURL: url,
|
|
79263
|
-
cache: cache,
|
|
79264
|
-
session: session,
|
|
79265
|
-
assetPrefix: options.assetPrefix,
|
|
79266
|
-
manifest: manifest,
|
|
79267
|
-
...router_cache()
|
|
79268
|
-
}),
|
|
79269
|
-
{
|
|
79270
|
-
userAgent: 'Vite',
|
|
79271
|
-
}
|
|
79272
|
-
)
|
|
79273
|
-
|
|
79274
|
-
// add the initial scripts to the page
|
|
79275
|
-
injectToStream(\`
|
|
79276
|
-
<script>
|
|
79277
|
-
window.__houdini__initial__cache__ = \${cache.serialize()};
|
|
79278
|
-
window.__houdini__initial__session__ = \${JSON.stringify(session)};
|
|
79279
|
-
<\/script>
|
|
79280
|
-
|
|
79281
|
-
<!--
|
|
79282
|
-
add a virtual module that hydrates the client and sets up the initial pending cache.
|
|
79283
|
-
the dynamic extension is to support dev which sees the raw jsx, and production which sees the bundled asset
|
|
79284
|
-
-->
|
|
79285
|
-
<script type="module" src="\${options.assetPrefix}/pages/\${match.id}.\${options.production ? 'js' : 'jsx'}" async=""><\/script>
|
|
79286
|
-
\`)
|
|
79287
|
-
|
|
79288
|
-
if (pipe && pipeTo) {
|
|
79289
|
-
// pipe the response to the client
|
|
79290
|
-
pipeTo(pipe)
|
|
79291
|
-
} else {
|
|
79292
|
-
// and deliver our Response while that's running.
|
|
79293
|
-
return new Response(readable)
|
|
79294
|
-
}
|
|
79295
|
-
},
|
|
79296
|
-
})
|
|
79297
|
-
}
|
|
79298
|
-
`;
|
|
79299
79334
|
await Promise.all([
|
|
79300
|
-
fs_exports.writeFile(conventions_exports.server_adapter_path(config), server_adapter),
|
|
79301
79335
|
fs_exports.writeFile(conventions_exports.adapter_config_path(config), adapter_config),
|
|
79336
|
+
fs_exports.writeFile(adapter_path, renderer),
|
|
79302
79337
|
fs_exports.writeFile(conventions_exports.app_component_path(config), app_index)
|
|
79303
79338
|
]);
|
|
79304
79339
|
}
|
|
@@ -79568,28 +79603,44 @@ async function transformFile(page) {
|
|
|
79568
79603
|
}
|
|
79569
79604
|
|
|
79570
79605
|
// src/plugin/vite.tsx
|
|
79606
|
+
import { build } from "vite";
|
|
79571
79607
|
var manifest;
|
|
79608
|
+
var devServer = false;
|
|
79572
79609
|
var vite_default = {
|
|
79573
79610
|
async config(config, env) {
|
|
79574
79611
|
manifest = await load_manifest({ config, includeArtifacts: env.mode === "production" });
|
|
79575
79612
|
setManifest(manifest);
|
|
79576
|
-
let
|
|
79577
|
-
|
|
79578
|
-
|
|
79613
|
+
let conf = {
|
|
79614
|
+
build: {
|
|
79615
|
+
rollupOptions: {}
|
|
79616
|
+
}
|
|
79617
|
+
};
|
|
79618
|
+
if (!isSecondaryBuild() || process.env.HOUDINI_SECONDARY_BUILD === "ssr") {
|
|
79619
|
+
if (!devServer) {
|
|
79620
|
+
conf.base = "/assets";
|
|
79621
|
+
}
|
|
79622
|
+
conf.build = {
|
|
79579
79623
|
rollupOptions: {
|
|
79580
79624
|
output: {
|
|
79581
|
-
|
|
79582
|
-
|
|
79625
|
+
assetFileNames: "assets/[name].js",
|
|
79626
|
+
entryFileNames: "[name].js"
|
|
79627
|
+
},
|
|
79628
|
+
external: ["react-streaming/server"]
|
|
79583
79629
|
}
|
|
79584
79630
|
};
|
|
79585
79631
|
await fs_exports.mkdirp(config.compiledAssetsDir);
|
|
79586
|
-
|
|
79587
|
-
|
|
79632
|
+
conf.build.rollupOptions.input = {
|
|
79633
|
+
"entries/app": conventions_exports.app_component_path(config),
|
|
79634
|
+
"entries/adapter": conventions_exports.adapter_config_path(config)
|
|
79635
|
+
};
|
|
79588
79636
|
for (const [id, page] of Object.entries(manifest.pages)) {
|
|
79589
|
-
|
|
79637
|
+
conf.build.rollupOptions.input[`pages/${id}`] = `virtual:houdini/pages/${page.id}@${page.queries}.jsx`;
|
|
79590
79638
|
}
|
|
79591
79639
|
for (const artifact of manifest.artifacts) {
|
|
79592
|
-
|
|
79640
|
+
conf.build.rollupOptions.input[`artifacts/${artifact}`] = `virtual:houdini/artifacts/${artifact}.js`;
|
|
79641
|
+
}
|
|
79642
|
+
if (process.env.HOUDINI_SECONDARY_BUILD !== "ssr") {
|
|
79643
|
+
conf.build.outDir = config.compiledAssetsDir;
|
|
79593
79644
|
}
|
|
79594
79645
|
}
|
|
79595
79646
|
return {
|
|
@@ -79601,7 +79652,7 @@ var vite_default = {
|
|
|
79601
79652
|
"~/*": path_exports.join(config.projectRoot, "src", "*")
|
|
79602
79653
|
}
|
|
79603
79654
|
},
|
|
79604
|
-
|
|
79655
|
+
...conf
|
|
79605
79656
|
};
|
|
79606
79657
|
},
|
|
79607
79658
|
resolveId(id) {
|
|
@@ -79613,6 +79664,20 @@ var vite_default = {
|
|
|
79613
79664
|
async buildStart({ houdiniConfig }) {
|
|
79614
79665
|
await writeTsconfig(houdiniConfig);
|
|
79615
79666
|
},
|
|
79667
|
+
async closeBundle(config) {
|
|
79668
|
+
if (isSecondaryBuild() || devServer) {
|
|
79669
|
+
return;
|
|
79670
|
+
}
|
|
79671
|
+
console.log("\u{1F3A9} Generating Server Assets...");
|
|
79672
|
+
process.env.HOUDINI_SECONDARY_BUILD = "ssr";
|
|
79673
|
+
await build({
|
|
79674
|
+
build: {
|
|
79675
|
+
ssr: true,
|
|
79676
|
+
outDir: path_exports.join(config.rootDir, "build", "ssr")
|
|
79677
|
+
}
|
|
79678
|
+
});
|
|
79679
|
+
process.env.HOUDINI_SECONDARY_BUILD = "false";
|
|
79680
|
+
},
|
|
79616
79681
|
async load(id, { config }) {
|
|
79617
79682
|
if (!id.startsWith("virtual:houdini")) {
|
|
79618
79683
|
return;
|
|
@@ -79635,7 +79700,6 @@ var vite_default = {
|
|
|
79635
79700
|
// if there is pending data (or artifacts) then we should prime the caches
|
|
79636
79701
|
let initialData = {}
|
|
79637
79702
|
let initialArtifacts = {}
|
|
79638
|
-
|
|
79639
79703
|
if (!window.__houdini__cache__) {
|
|
79640
79704
|
window.__houdini__cache__ = new Cache()
|
|
79641
79705
|
window.__houdini__hydration__layer__ = window.__houdini__cache__._internal_unstable.storage.createLayer(true)
|
|
@@ -79670,16 +79734,24 @@ var vite_default = {
|
|
|
79670
79734
|
})
|
|
79671
79735
|
}
|
|
79672
79736
|
|
|
79673
|
-
|
|
79674
|
-
|
|
79675
79737
|
// hydrate the cache with the information from the initial payload
|
|
79676
79738
|
window.__houdini__cache__?.hydrate(
|
|
79677
79739
|
window.__houdini__initial__cache__,
|
|
79678
79740
|
window.__houdini__hydration__layer__
|
|
79679
79741
|
)
|
|
79680
79742
|
|
|
79743
|
+
// get the initial url from the window
|
|
79744
|
+
const url = window.location.pathname
|
|
79745
|
+
|
|
79746
|
+
const app = <App
|
|
79747
|
+
initialURL={url}
|
|
79748
|
+
cache={window.__houdini__cache__}
|
|
79749
|
+
session={window.__houdini__initial__session__}
|
|
79750
|
+
{...window.__houdini__nav_caches__}
|
|
79751
|
+
/>
|
|
79752
|
+
|
|
79681
79753
|
// hydrate the application for interactivity
|
|
79682
|
-
hydrateRoot(document,
|
|
79754
|
+
hydrateRoot(document, app)
|
|
79683
79755
|
`;
|
|
79684
79756
|
}
|
|
79685
79757
|
if (which === "artifacts") {
|
|
@@ -79694,51 +79766,92 @@ if (window.__houdini__nav_caches__ && window.__houdini__nav_caches__.artifact_ca
|
|
|
79694
79766
|
}
|
|
79695
79767
|
},
|
|
79696
79768
|
async configureServer(server) {
|
|
79769
|
+
devServer = true;
|
|
79697
79770
|
await writeTsconfig(server.houdiniConfig);
|
|
79698
79771
|
server.middlewares.use(async (req, res, next) => {
|
|
79772
|
+
if (!req.url) {
|
|
79773
|
+
next();
|
|
79774
|
+
return;
|
|
79775
|
+
}
|
|
79699
79776
|
const { default: router_manifest } = await server.ssrLoadModule(
|
|
79700
79777
|
path_exports.join(
|
|
79701
79778
|
server.houdiniConfig.pluginRuntimeDirectory("houdini-react"),
|
|
79702
79779
|
"manifest.js"
|
|
79703
79780
|
)
|
|
79704
79781
|
);
|
|
79705
|
-
|
|
79706
|
-
|
|
79707
|
-
|
|
79708
|
-
|
|
79709
|
-
|
|
79710
|
-
|
|
79711
|
-
if (req.url !== localApiEndpoint(server.houdiniConfig.configFile)) {
|
|
79712
|
-
return next();
|
|
79713
|
-
}
|
|
79782
|
+
const [match] = find_match(router_manifest, req.url);
|
|
79783
|
+
if (!match && !internalRoutes(server.houdiniConfig.configFile).find(
|
|
79784
|
+
(route) => req.url?.startsWith(route)
|
|
79785
|
+
)) {
|
|
79786
|
+
next();
|
|
79787
|
+
return;
|
|
79714
79788
|
}
|
|
79715
79789
|
const project_manifest = await load_manifest({ config: server.houdiniConfig });
|
|
79716
79790
|
let schema = null;
|
|
79717
79791
|
if (project_manifest.local_schema) {
|
|
79718
79792
|
schema = await loadLocalSchema(server.houdiniConfig);
|
|
79719
79793
|
}
|
|
79720
|
-
const serverAdapter = (await server.ssrLoadModule(
|
|
79721
|
-
conventions_exports.server_adapter_path(server.houdiniConfig) + "?t=" + new Date().getTime()
|
|
79722
|
-
)).default;
|
|
79723
79794
|
let yoga = null;
|
|
79724
79795
|
if (project_manifest.local_yoga) {
|
|
79725
|
-
const yogaPath = path_exports.join(
|
|
79726
|
-
server.houdiniConfig.localApiDir,
|
|
79727
|
-
"+yoga?t=" + new Date().getTime()
|
|
79728
|
-
);
|
|
79796
|
+
const yogaPath = path_exports.join(server.houdiniConfig.localApiDir, "+yoga");
|
|
79729
79797
|
yoga = await server.ssrLoadModule(yogaPath);
|
|
79730
79798
|
}
|
|
79731
|
-
await
|
|
79799
|
+
const { createServerAdapter } = await server.ssrLoadModule(
|
|
79800
|
+
conventions_exports.server_adapter_path(server.houdiniConfig)
|
|
79801
|
+
);
|
|
79802
|
+
const requestHeaders = new Headers();
|
|
79803
|
+
for (const header of Object.entries(req.headers ?? {})) {
|
|
79804
|
+
requestHeaders.set(header[0], header[1]);
|
|
79805
|
+
}
|
|
79806
|
+
const request = new Request(
|
|
79807
|
+
"https://localhost:5173" + req.url,
|
|
79808
|
+
req.method === "POST" ? {
|
|
79809
|
+
method: req.method,
|
|
79810
|
+
headers: requestHeaders,
|
|
79811
|
+
body: await getBody(req)
|
|
79812
|
+
} : void 0
|
|
79813
|
+
);
|
|
79814
|
+
for (const [key, value] of Object.entries(req.headers)) {
|
|
79815
|
+
request.headers.set(key, value);
|
|
79816
|
+
}
|
|
79817
|
+
const result = await createServerAdapter({
|
|
79732
79818
|
schema,
|
|
79733
79819
|
yoga,
|
|
79734
|
-
assetPrefix: "/virtual:houdini",
|
|
79735
79820
|
production: false,
|
|
79736
79821
|
manifest: router_manifest,
|
|
79737
|
-
|
|
79738
|
-
|
|
79822
|
+
graphqlEndpoint: localApiEndpoint(server.houdiniConfig.configFile),
|
|
79823
|
+
assetPrefix: "/virtual:houdini",
|
|
79824
|
+
pipe: res,
|
|
79825
|
+
documentPremable: `<script type="module" src="/@vite/client" async=""><\/script>`
|
|
79826
|
+
})(request);
|
|
79827
|
+
if (result && result.status === 404) {
|
|
79828
|
+
next();
|
|
79829
|
+
}
|
|
79830
|
+
if (result && typeof result !== "boolean") {
|
|
79831
|
+
if (res.closed) {
|
|
79832
|
+
return;
|
|
79833
|
+
}
|
|
79834
|
+
for (const header of Object.entries(result.headers ?? {})) {
|
|
79835
|
+
res.setHeader(header[0], header[1]);
|
|
79836
|
+
}
|
|
79837
|
+
res.write(await result.text());
|
|
79838
|
+
res.end();
|
|
79839
|
+
}
|
|
79739
79840
|
});
|
|
79740
79841
|
}
|
|
79741
79842
|
};
|
|
79843
|
+
function getBody(request) {
|
|
79844
|
+
return new Promise((resolve2) => {
|
|
79845
|
+
const bodyParts = [];
|
|
79846
|
+
let body;
|
|
79847
|
+
request.on("data", (chunk) => {
|
|
79848
|
+
bodyParts.push(chunk);
|
|
79849
|
+
}).on("end", () => {
|
|
79850
|
+
body = Buffer.concat(bodyParts).toString();
|
|
79851
|
+
resolve2(body);
|
|
79852
|
+
});
|
|
79853
|
+
});
|
|
79854
|
+
}
|
|
79742
79855
|
|
|
79743
79856
|
// src/plugin/index.ts
|
|
79744
79857
|
var manifest2;
|
package/build/runtime/index.d.ts
CHANGED
|
@@ -1,27 +1,10 @@
|
|
|
1
1
|
import type { Cache } from '$houdini/runtime/cache/cache';
|
|
2
|
-
import {
|
|
3
|
-
import { LRUCache } from '$houdini/runtime/lib/lru';
|
|
4
|
-
import { GraphQLObject, GraphQLVariables, QueryArtifact } from '$houdini/runtime/lib/types';
|
|
5
|
-
import React from 'react';
|
|
6
|
-
import { SuspenseCache, type PendingCache } from './routing';
|
|
2
|
+
import { RouterCache } from './routing';
|
|
7
3
|
export * from './hooks';
|
|
4
|
+
export { router_cache } from './routing';
|
|
8
5
|
export declare function Router({ cache, initialURL, artifact_cache, component_cache, data_cache, pending_cache, last_variables, session, assetPrefix, }: {
|
|
9
6
|
initialURL: string;
|
|
10
7
|
cache: Cache;
|
|
11
8
|
session?: App.Session;
|
|
12
9
|
assetPrefix: string;
|
|
13
10
|
} & RouterCache): JSX.Element;
|
|
14
|
-
type RouterCache = {
|
|
15
|
-
artifact_cache: SuspenseCache<QueryArtifact>;
|
|
16
|
-
component_cache: SuspenseCache<(props: any) => React.ReactElement>;
|
|
17
|
-
data_cache: SuspenseCache<DocumentStore<GraphQLObject, GraphQLVariables>>;
|
|
18
|
-
last_variables: LRUCache<GraphQLVariables>;
|
|
19
|
-
pending_cache: PendingCache;
|
|
20
|
-
};
|
|
21
|
-
export declare function router_cache({ pending_queries, artifacts, components, initialData, initialArtifacts, }?: {
|
|
22
|
-
pending_queries?: string[];
|
|
23
|
-
artifacts?: Record<string, QueryArtifact>;
|
|
24
|
-
components?: Record<string, (props: any) => React.ReactElement>;
|
|
25
|
-
initialData?: Record<string, DocumentStore<GraphQLObject, GraphQLVariables>>;
|
|
26
|
-
initialArtifacts?: Record<string, QueryArtifact>;
|
|
27
|
-
}): RouterCache;
|
|
@@ -49,4 +49,18 @@ export declare function updateLocalSession(session: App.Session): void;
|
|
|
49
49
|
export declare function useSession(): App.Session;
|
|
50
50
|
export declare function useCurrentVariables(): GraphQLVariables;
|
|
51
51
|
export declare function useQueryResult<_Data extends GraphQLObject, _Input extends GraphQLVariables>(name: string): [_Data | null, DocumentStore<_Data, _Input>];
|
|
52
|
+
export type RouterCache = {
|
|
53
|
+
artifact_cache: SuspenseCache<QueryArtifact>;
|
|
54
|
+
component_cache: SuspenseCache<(props: any) => React.ReactElement>;
|
|
55
|
+
data_cache: SuspenseCache<DocumentStore<GraphQLObject, GraphQLVariables>>;
|
|
56
|
+
last_variables: LRUCache<GraphQLVariables>;
|
|
57
|
+
pending_cache: PendingCache;
|
|
58
|
+
};
|
|
59
|
+
export declare function router_cache({ pending_queries, artifacts, components, initialData, initialArtifacts, }?: {
|
|
60
|
+
pending_queries?: string[];
|
|
61
|
+
artifacts?: Record<string, QueryArtifact>;
|
|
62
|
+
components?: Record<string, (props: any) => React.ReactElement>;
|
|
63
|
+
initialData?: Record<string, DocumentStore<GraphQLObject, GraphQLVariables>>;
|
|
64
|
+
initialArtifacts?: Record<string, QueryArtifact>;
|
|
65
|
+
}): RouterCache;
|
|
52
66
|
export {};
|
|
@@ -1,27 +1,10 @@
|
|
|
1
1
|
import type { Cache } from '$houdini/runtime/cache/cache';
|
|
2
|
-
import {
|
|
3
|
-
import { LRUCache } from '$houdini/runtime/lib/lru';
|
|
4
|
-
import { GraphQLObject, GraphQLVariables, QueryArtifact } from '$houdini/runtime/lib/types';
|
|
5
|
-
import React from 'react';
|
|
6
|
-
import { SuspenseCache, type PendingCache } from './routing';
|
|
2
|
+
import { RouterCache } from './routing';
|
|
7
3
|
export * from './hooks';
|
|
4
|
+
export { router_cache } from './routing';
|
|
8
5
|
export declare function Router({ cache, initialURL, artifact_cache, component_cache, data_cache, pending_cache, last_variables, session, assetPrefix, }: {
|
|
9
6
|
initialURL: string;
|
|
10
7
|
cache: Cache;
|
|
11
8
|
session?: App.Session;
|
|
12
9
|
assetPrefix: string;
|
|
13
10
|
} & RouterCache): JSX.Element;
|
|
14
|
-
type RouterCache = {
|
|
15
|
-
artifact_cache: SuspenseCache<QueryArtifact>;
|
|
16
|
-
component_cache: SuspenseCache<(props: any) => React.ReactElement>;
|
|
17
|
-
data_cache: SuspenseCache<DocumentStore<GraphQLObject, GraphQLVariables>>;
|
|
18
|
-
last_variables: LRUCache<GraphQLVariables>;
|
|
19
|
-
pending_cache: PendingCache;
|
|
20
|
-
};
|
|
21
|
-
export declare function router_cache({ pending_queries, artifacts, components, initialData, initialArtifacts, }?: {
|
|
22
|
-
pending_queries?: string[];
|
|
23
|
-
artifacts?: Record<string, QueryArtifact>;
|
|
24
|
-
components?: Record<string, (props: any) => React.ReactElement>;
|
|
25
|
-
initialData?: Record<string, DocumentStore<GraphQLObject, GraphQLVariables>>;
|
|
26
|
-
initialArtifacts?: Record<string, QueryArtifact>;
|
|
27
|
-
}): RouterCache;
|
|
@@ -26,14 +26,15 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
26
26
|
var runtime_exports = {};
|
|
27
27
|
__export(runtime_exports, {
|
|
28
28
|
Router: () => Router,
|
|
29
|
-
router_cache: () => router_cache
|
|
29
|
+
router_cache: () => import_routing2.router_cache
|
|
30
30
|
});
|
|
31
31
|
module.exports = __toCommonJS(runtime_exports);
|
|
32
32
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
33
|
-
var
|
|
33
|
+
var import_client = __toESM(require("./client"));
|
|
34
34
|
var import_manifest = __toESM(require("./manifest"));
|
|
35
35
|
var import_routing = require("./routing");
|
|
36
36
|
__reExport(runtime_exports, require("./hooks"), module.exports);
|
|
37
|
+
var import_routing2 = require("./routing");
|
|
37
38
|
function Router({
|
|
38
39
|
cache,
|
|
39
40
|
initialURL,
|
|
@@ -48,7 +49,7 @@ function Router({
|
|
|
48
49
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
49
50
|
import_routing.RouterContextProvider,
|
|
50
51
|
{
|
|
51
|
-
client: (0,
|
|
52
|
+
client: (0, import_client.default)(),
|
|
52
53
|
cache,
|
|
53
54
|
artifact_cache,
|
|
54
55
|
component_cache,
|
|
@@ -60,46 +61,6 @@ function Router({
|
|
|
60
61
|
}
|
|
61
62
|
);
|
|
62
63
|
}
|
|
63
|
-
function router_cache({
|
|
64
|
-
pending_queries = [],
|
|
65
|
-
artifacts = {},
|
|
66
|
-
components = {},
|
|
67
|
-
initialData = {},
|
|
68
|
-
initialArtifacts = {}
|
|
69
|
-
} = {}) {
|
|
70
|
-
const result = {
|
|
71
|
-
artifact_cache: (0, import_routing.suspense_cache)(initialArtifacts),
|
|
72
|
-
component_cache: (0, import_routing.suspense_cache)(),
|
|
73
|
-
data_cache: (0, import_routing.suspense_cache)(initialData),
|
|
74
|
-
pending_cache: (0, import_routing.suspense_cache)(),
|
|
75
|
-
last_variables: (0, import_routing.suspense_cache)()
|
|
76
|
-
};
|
|
77
|
-
for (const query of pending_queries) {
|
|
78
|
-
result.pending_cache.set(query, signal_promise());
|
|
79
|
-
}
|
|
80
|
-
for (const [name, artifact] of Object.entries(artifacts)) {
|
|
81
|
-
result.artifact_cache.set(name, artifact);
|
|
82
|
-
}
|
|
83
|
-
for (const [name, component] of Object.entries(components)) {
|
|
84
|
-
result.component_cache.set(name, component);
|
|
85
|
-
}
|
|
86
|
-
return result;
|
|
87
|
-
}
|
|
88
|
-
function signal_promise() {
|
|
89
|
-
let resolve = () => {
|
|
90
|
-
};
|
|
91
|
-
let reject = () => {
|
|
92
|
-
};
|
|
93
|
-
const promise = new Promise((res, rej) => {
|
|
94
|
-
resolve = res;
|
|
95
|
-
reject = rej;
|
|
96
|
-
});
|
|
97
|
-
return {
|
|
98
|
-
...promise,
|
|
99
|
-
resolve,
|
|
100
|
-
reject
|
|
101
|
-
};
|
|
102
|
-
}
|
|
103
64
|
// Annotate the CommonJS export names for ESM import in node:
|
|
104
65
|
0 && (module.exports = {
|
|
105
66
|
Router,
|