houdini 2.0.0-next.0 → 2.0.0-next.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/build/cmd-cjs/index.js +91 -14
- package/build/cmd-esm/index.js +91 -14
- package/build/codegen/generators/runtime/pluginRuntime.d.ts +3 -0
- package/build/codegen-cjs/index.js +50 -0
- package/build/codegen-esm/index.js +50 -0
- package/build/lib/config.d.ts +3 -0
- package/build/lib/introspection.d.ts +1 -1
- package/build/lib-cjs/index.js +39 -9
- package/build/lib-esm/index.js +39 -9
- package/build/runtime/lib/config.d.ts +7 -0
- package/build/runtime-cjs/lib/config.d.ts +7 -0
- package/build/runtime-esm/lib/config.d.ts +7 -0
- package/build/test-cjs/index.js +28 -3
- package/build/test-esm/index.js +28 -3
- package/build/vite-cjs/index.js +91 -10
- package/build/vite-esm/index.js +91 -10
- package/package.json +1 -1
package/build/cmd-cjs/index.js
CHANGED
|
@@ -75256,7 +75256,7 @@ function fixResponseChunkedTransferBadEnding(request, errorCallback) {
|
|
|
75256
75256
|
}
|
|
75257
75257
|
|
|
75258
75258
|
// src/lib/introspection.ts
|
|
75259
|
-
async function pullSchema(url, fetchTimeout, schemaPath, headers,
|
|
75259
|
+
async function pullSchema(url, fetchTimeout, schemaPath, headers, writeToDisk = true) {
|
|
75260
75260
|
let content = "";
|
|
75261
75261
|
try {
|
|
75262
75262
|
const fetchWithTimeout = (url2, timeoutMs, options) => {
|
|
@@ -75294,8 +75294,15 @@ async function pullSchema(url, fetchTimeout, schemaPath, headers, skipWriting) {
|
|
|
75294
75294
|
} else {
|
|
75295
75295
|
fileData = JSON.stringify(jsonSchema);
|
|
75296
75296
|
}
|
|
75297
|
-
if (
|
|
75298
|
-
|
|
75297
|
+
if (writeToDisk) {
|
|
75298
|
+
try {
|
|
75299
|
+
await writeFile(schemaPath, fileData);
|
|
75300
|
+
} catch (e3) {
|
|
75301
|
+
console.warn(
|
|
75302
|
+
`\u26A0\uFE0F Couldn't write your pulled schema to disk: ${e3.message}
|
|
75303
|
+
If this is expected, please set watchSchema.writePolledSchema to false in your config file.`
|
|
75304
|
+
);
|
|
75305
|
+
}
|
|
75299
75306
|
}
|
|
75300
75307
|
return fileData;
|
|
75301
75308
|
} catch (e3) {
|
|
@@ -78083,6 +78090,7 @@ var Config = class {
|
|
|
78083
78090
|
routesDir;
|
|
78084
78091
|
schemaPollInterval;
|
|
78085
78092
|
schemaPollTimeout;
|
|
78093
|
+
schemaPollWriteToDisk = false;
|
|
78086
78094
|
schemaPollHeaders;
|
|
78087
78095
|
pluginMode = false;
|
|
78088
78096
|
plugins = [];
|
|
@@ -78159,6 +78167,7 @@ var Config = class {
|
|
|
78159
78167
|
this.routesDir = join2(this.projectRoot, "src", "routes");
|
|
78160
78168
|
this.schemaPollInterval = watchSchema?.interval === void 0 ? 2e3 : watchSchema.interval;
|
|
78161
78169
|
this.schemaPollTimeout = watchSchema?.timeout ?? 3e4;
|
|
78170
|
+
this.schemaPollWriteToDisk = watchSchema?.writePolledSchema ?? true;
|
|
78162
78171
|
this.schemaPollHeaders = watchSchema?.headers ?? {};
|
|
78163
78172
|
this.rootDir = join2(this.projectRoot, this.runtimeDir);
|
|
78164
78173
|
this.persistedQueriesPath = persistedQueriesPath ?? join2(this.rootDir, "persisted_queries.json");
|
|
@@ -78191,11 +78200,17 @@ var Config = class {
|
|
|
78191
78200
|
const include = [`src/**/*{${extensions.join(",")}}`];
|
|
78192
78201
|
for (const plugin2 of this.plugins) {
|
|
78193
78202
|
const runtimeDir = this.pluginRuntimeSource(plugin2);
|
|
78194
|
-
|
|
78203
|
+
const staticDir = this.pluginStaticRuntimeSource(plugin2);
|
|
78204
|
+
if (!runtimeDir && !staticDir) {
|
|
78195
78205
|
continue;
|
|
78196
78206
|
}
|
|
78197
|
-
const
|
|
78198
|
-
|
|
78207
|
+
for (const dir of [runtimeDir, staticDir]) {
|
|
78208
|
+
if (!dir) {
|
|
78209
|
+
continue;
|
|
78210
|
+
}
|
|
78211
|
+
const includePath = relative(this.projectRoot, dir);
|
|
78212
|
+
include.push(`${includePath}/**/*{${extensions.join(",")}}`);
|
|
78213
|
+
}
|
|
78199
78214
|
}
|
|
78200
78215
|
return include;
|
|
78201
78216
|
}
|
|
@@ -78249,6 +78264,15 @@ var Config = class {
|
|
|
78249
78264
|
typeof plugin2.includeRuntime === "string" ? plugin2.includeRuntime : plugin2.includeRuntime?.[this.module]
|
|
78250
78265
|
);
|
|
78251
78266
|
}
|
|
78267
|
+
pluginStaticRuntimeSource(plugin2) {
|
|
78268
|
+
if (!plugin2.staticRuntime) {
|
|
78269
|
+
return null;
|
|
78270
|
+
}
|
|
78271
|
+
return join2(
|
|
78272
|
+
dirname(plugin2.filepath),
|
|
78273
|
+
typeof plugin2.staticRuntime === "string" ? plugin2.staticRuntime : plugin2.staticRuntime?.[this.module]
|
|
78274
|
+
);
|
|
78275
|
+
}
|
|
78252
78276
|
async sourceFiles() {
|
|
78253
78277
|
return [
|
|
78254
78278
|
...new Set(
|
|
@@ -78445,6 +78469,9 @@ var Config = class {
|
|
|
78445
78469
|
pluginRuntimeDirectory(name) {
|
|
78446
78470
|
return join2(this.pluginDirectory(name), "runtime");
|
|
78447
78471
|
}
|
|
78472
|
+
pluginStaticRuntimeDirectory(name) {
|
|
78473
|
+
return join2(this.pluginDirectory(name), "static");
|
|
78474
|
+
}
|
|
78448
78475
|
get pluginRootDirectory() {
|
|
78449
78476
|
return houdini_mode.is_testing ? "../../../" : join2(this.rootDir, "plugins");
|
|
78450
78477
|
}
|
|
@@ -78822,17 +78849,20 @@ async function getConfig({
|
|
|
78822
78849
|
if (!_config.localSchema && _config.schemaPath && !_config.schema) {
|
|
78823
78850
|
let schemaOk = true;
|
|
78824
78851
|
if (apiURL) {
|
|
78825
|
-
if (glob2.hasMagic(_config.schemaPath)) {
|
|
78852
|
+
if (glob2.hasMagic(_config.schemaPath) && _config.schemaPollWriteToDisk) {
|
|
78826
78853
|
console.log(
|
|
78827
78854
|
`\u26A0\uFE0F Your houdini configuration contains an apiUrl and a path pointing to multiple files.
|
|
78828
|
-
This will prevent your schema from being
|
|
78855
|
+
This will prevent your schema from being written to disk. If this is expected, please set the writePolledSchema value to false.`
|
|
78829
78856
|
);
|
|
78857
|
+
_config.schemaPollWriteToDisk = false;
|
|
78830
78858
|
} else if (!await readFile(_config.schemaPath)) {
|
|
78831
78859
|
console.log("\u231B Pulling schema from api");
|
|
78832
78860
|
schemaOk = await pullSchema(
|
|
78833
78861
|
apiURL,
|
|
78834
78862
|
_config.schemaPollTimeout,
|
|
78835
|
-
_config.schemaPath
|
|
78863
|
+
_config.schemaPath,
|
|
78864
|
+
{},
|
|
78865
|
+
_config.schemaPollWriteToDisk
|
|
78836
78866
|
) !== null;
|
|
78837
78867
|
}
|
|
78838
78868
|
}
|
|
@@ -82172,6 +82202,50 @@ function moduleStatments(config) {
|
|
|
82172
82202
|
exportStarStatement
|
|
82173
82203
|
};
|
|
82174
82204
|
}
|
|
82205
|
+
async function generateStaticRuntimes({ config }) {
|
|
82206
|
+
if (houdini_mode.is_testing) {
|
|
82207
|
+
return;
|
|
82208
|
+
}
|
|
82209
|
+
const { importStatement, exportDefaultStatement, exportStarStatement } = moduleStatments(config);
|
|
82210
|
+
await Promise.all(
|
|
82211
|
+
config.plugins.filter((plugin2) => plugin2.staticRuntime).map(async (plugin2) => {
|
|
82212
|
+
const runtime_path = config.pluginStaticRuntimeSource(plugin2);
|
|
82213
|
+
if (!runtime_path) {
|
|
82214
|
+
return;
|
|
82215
|
+
}
|
|
82216
|
+
try {
|
|
82217
|
+
await stat(runtime_path);
|
|
82218
|
+
} catch {
|
|
82219
|
+
throw new HoudiniError({
|
|
82220
|
+
message: "Cannot find runtime to generate for " + plugin2.name,
|
|
82221
|
+
description: "Maybe it was bundled?"
|
|
82222
|
+
});
|
|
82223
|
+
}
|
|
82224
|
+
const pluginDir = config.pluginStaticRuntimeDirectory(plugin2.name);
|
|
82225
|
+
let transformMap = plugin2.transformRuntime ?? {};
|
|
82226
|
+
if (transformMap && typeof transformMap === "function") {
|
|
82227
|
+
transformMap = transformMap([], { config });
|
|
82228
|
+
}
|
|
82229
|
+
await mkdirp(pluginDir);
|
|
82230
|
+
await recursiveCopy(
|
|
82231
|
+
runtime_path,
|
|
82232
|
+
pluginDir,
|
|
82233
|
+
Object.fromEntries(
|
|
82234
|
+
Object.entries(transformMap).map(([key, value]) => [
|
|
82235
|
+
join2(runtime_path, key),
|
|
82236
|
+
(content) => value({
|
|
82237
|
+
config,
|
|
82238
|
+
content,
|
|
82239
|
+
importStatement,
|
|
82240
|
+
exportDefaultStatement,
|
|
82241
|
+
exportStarStatement
|
|
82242
|
+
})
|
|
82243
|
+
])
|
|
82244
|
+
)
|
|
82245
|
+
);
|
|
82246
|
+
})
|
|
82247
|
+
);
|
|
82248
|
+
}
|
|
82175
82249
|
async function generatePluginRuntimes({
|
|
82176
82250
|
config,
|
|
82177
82251
|
docs
|
|
@@ -83773,6 +83847,11 @@ async function writeIndexFile2(config, docs) {
|
|
|
83773
83847
|
module: relative2(config.pluginRuntimeDirectory(plugin2.name))
|
|
83774
83848
|
});
|
|
83775
83849
|
}
|
|
83850
|
+
if (plugin2.staticRuntime) {
|
|
83851
|
+
body += exportStar({
|
|
83852
|
+
module: relative2(config.pluginStaticRuntimeDirectory(plugin2.name))
|
|
83853
|
+
});
|
|
83854
|
+
}
|
|
83776
83855
|
}
|
|
83777
83856
|
await fs_exports.writeFile(path_exports.join(config.rootDir, "index.js"), body);
|
|
83778
83857
|
}
|
|
@@ -87690,6 +87769,7 @@ async function componentFields2(config, docs) {
|
|
|
87690
87769
|
|
|
87691
87770
|
// src/codegen/index.ts
|
|
87692
87771
|
async function compile(config) {
|
|
87772
|
+
await generateStaticRuntimes({ config });
|
|
87693
87773
|
const documents = await collectDocuments(config);
|
|
87694
87774
|
return await runPipeline2(config, documents);
|
|
87695
87775
|
}
|
|
@@ -88725,9 +88805,6 @@ async function init2(_path, args) {
|
|
|
88725
88805
|
);
|
|
88726
88806
|
schemaPath = answers.schema_path;
|
|
88727
88807
|
}
|
|
88728
|
-
if (is_remote_endpoint && pullSchema_content) {
|
|
88729
|
-
await fs_exports.writeFile(path_exports.join(targetPath, schemaPath), pullSchema_content);
|
|
88730
|
-
}
|
|
88731
88808
|
const { frameworkInfo, typescript, module: module2, package_manager } = await detectTools(targetPath);
|
|
88732
88809
|
const found_to_log = [];
|
|
88733
88810
|
if (frameworkInfo.framework === "svelte") {
|
|
@@ -89100,12 +89177,12 @@ async function packageJSON(targetPath, frameworkInfo) {
|
|
|
89100
89177
|
}
|
|
89101
89178
|
packageJSON2.devDependencies = {
|
|
89102
89179
|
...packageJSON2.devDependencies,
|
|
89103
|
-
houdini: "^2.0.0-next.
|
|
89180
|
+
houdini: "^2.0.0-next.1"
|
|
89104
89181
|
};
|
|
89105
89182
|
if (frameworkInfo.framework === "svelte" || frameworkInfo.framework === "kit") {
|
|
89106
89183
|
packageJSON2.devDependencies = {
|
|
89107
89184
|
...packageJSON2.devDependencies,
|
|
89108
|
-
"houdini-svelte": "^2.2.0-next.
|
|
89185
|
+
"houdini-svelte": "^2.2.0-next.2"
|
|
89109
89186
|
};
|
|
89110
89187
|
} else {
|
|
89111
89188
|
throw new Error(`Unmanaged framework: "${JSON.stringify(frameworkInfo)}"`);
|
package/build/cmd-esm/index.js
CHANGED
|
@@ -75261,7 +75261,7 @@ function fixResponseChunkedTransferBadEnding(request, errorCallback) {
|
|
|
75261
75261
|
}
|
|
75262
75262
|
|
|
75263
75263
|
// src/lib/introspection.ts
|
|
75264
|
-
async function pullSchema(url, fetchTimeout, schemaPath, headers,
|
|
75264
|
+
async function pullSchema(url, fetchTimeout, schemaPath, headers, writeToDisk = true) {
|
|
75265
75265
|
let content = "";
|
|
75266
75266
|
try {
|
|
75267
75267
|
const fetchWithTimeout = (url2, timeoutMs, options) => {
|
|
@@ -75299,8 +75299,15 @@ async function pullSchema(url, fetchTimeout, schemaPath, headers, skipWriting) {
|
|
|
75299
75299
|
} else {
|
|
75300
75300
|
fileData = JSON.stringify(jsonSchema);
|
|
75301
75301
|
}
|
|
75302
|
-
if (
|
|
75303
|
-
|
|
75302
|
+
if (writeToDisk) {
|
|
75303
|
+
try {
|
|
75304
|
+
await writeFile(schemaPath, fileData);
|
|
75305
|
+
} catch (e3) {
|
|
75306
|
+
console.warn(
|
|
75307
|
+
`\u26A0\uFE0F Couldn't write your pulled schema to disk: ${e3.message}
|
|
75308
|
+
If this is expected, please set watchSchema.writePolledSchema to false in your config file.`
|
|
75309
|
+
);
|
|
75310
|
+
}
|
|
75304
75311
|
}
|
|
75305
75312
|
return fileData;
|
|
75306
75313
|
} catch (e3) {
|
|
@@ -78087,6 +78094,7 @@ var Config = class {
|
|
|
78087
78094
|
routesDir;
|
|
78088
78095
|
schemaPollInterval;
|
|
78089
78096
|
schemaPollTimeout;
|
|
78097
|
+
schemaPollWriteToDisk = false;
|
|
78090
78098
|
schemaPollHeaders;
|
|
78091
78099
|
pluginMode = false;
|
|
78092
78100
|
plugins = [];
|
|
@@ -78163,6 +78171,7 @@ var Config = class {
|
|
|
78163
78171
|
this.routesDir = join2(this.projectRoot, "src", "routes");
|
|
78164
78172
|
this.schemaPollInterval = watchSchema?.interval === void 0 ? 2e3 : watchSchema.interval;
|
|
78165
78173
|
this.schemaPollTimeout = watchSchema?.timeout ?? 3e4;
|
|
78174
|
+
this.schemaPollWriteToDisk = watchSchema?.writePolledSchema ?? true;
|
|
78166
78175
|
this.schemaPollHeaders = watchSchema?.headers ?? {};
|
|
78167
78176
|
this.rootDir = join2(this.projectRoot, this.runtimeDir);
|
|
78168
78177
|
this.persistedQueriesPath = persistedQueriesPath ?? join2(this.rootDir, "persisted_queries.json");
|
|
@@ -78195,11 +78204,17 @@ var Config = class {
|
|
|
78195
78204
|
const include = [`src/**/*{${extensions.join(",")}}`];
|
|
78196
78205
|
for (const plugin2 of this.plugins) {
|
|
78197
78206
|
const runtimeDir = this.pluginRuntimeSource(plugin2);
|
|
78198
|
-
|
|
78207
|
+
const staticDir = this.pluginStaticRuntimeSource(plugin2);
|
|
78208
|
+
if (!runtimeDir && !staticDir) {
|
|
78199
78209
|
continue;
|
|
78200
78210
|
}
|
|
78201
|
-
const
|
|
78202
|
-
|
|
78211
|
+
for (const dir of [runtimeDir, staticDir]) {
|
|
78212
|
+
if (!dir) {
|
|
78213
|
+
continue;
|
|
78214
|
+
}
|
|
78215
|
+
const includePath = relative(this.projectRoot, dir);
|
|
78216
|
+
include.push(`${includePath}/**/*{${extensions.join(",")}}`);
|
|
78217
|
+
}
|
|
78203
78218
|
}
|
|
78204
78219
|
return include;
|
|
78205
78220
|
}
|
|
@@ -78253,6 +78268,15 @@ var Config = class {
|
|
|
78253
78268
|
typeof plugin2.includeRuntime === "string" ? plugin2.includeRuntime : plugin2.includeRuntime?.[this.module]
|
|
78254
78269
|
);
|
|
78255
78270
|
}
|
|
78271
|
+
pluginStaticRuntimeSource(plugin2) {
|
|
78272
|
+
if (!plugin2.staticRuntime) {
|
|
78273
|
+
return null;
|
|
78274
|
+
}
|
|
78275
|
+
return join2(
|
|
78276
|
+
dirname(plugin2.filepath),
|
|
78277
|
+
typeof plugin2.staticRuntime === "string" ? plugin2.staticRuntime : plugin2.staticRuntime?.[this.module]
|
|
78278
|
+
);
|
|
78279
|
+
}
|
|
78256
78280
|
async sourceFiles() {
|
|
78257
78281
|
return [
|
|
78258
78282
|
...new Set(
|
|
@@ -78449,6 +78473,9 @@ var Config = class {
|
|
|
78449
78473
|
pluginRuntimeDirectory(name) {
|
|
78450
78474
|
return join2(this.pluginDirectory(name), "runtime");
|
|
78451
78475
|
}
|
|
78476
|
+
pluginStaticRuntimeDirectory(name) {
|
|
78477
|
+
return join2(this.pluginDirectory(name), "static");
|
|
78478
|
+
}
|
|
78452
78479
|
get pluginRootDirectory() {
|
|
78453
78480
|
return houdini_mode.is_testing ? "../../../" : join2(this.rootDir, "plugins");
|
|
78454
78481
|
}
|
|
@@ -78826,17 +78853,20 @@ async function getConfig({
|
|
|
78826
78853
|
if (!_config.localSchema && _config.schemaPath && !_config.schema) {
|
|
78827
78854
|
let schemaOk = true;
|
|
78828
78855
|
if (apiURL) {
|
|
78829
|
-
if (glob2.hasMagic(_config.schemaPath)) {
|
|
78856
|
+
if (glob2.hasMagic(_config.schemaPath) && _config.schemaPollWriteToDisk) {
|
|
78830
78857
|
console.log(
|
|
78831
78858
|
`\u26A0\uFE0F Your houdini configuration contains an apiUrl and a path pointing to multiple files.
|
|
78832
|
-
This will prevent your schema from being
|
|
78859
|
+
This will prevent your schema from being written to disk. If this is expected, please set the writePolledSchema value to false.`
|
|
78833
78860
|
);
|
|
78861
|
+
_config.schemaPollWriteToDisk = false;
|
|
78834
78862
|
} else if (!await readFile(_config.schemaPath)) {
|
|
78835
78863
|
console.log("\u231B Pulling schema from api");
|
|
78836
78864
|
schemaOk = await pullSchema(
|
|
78837
78865
|
apiURL,
|
|
78838
78866
|
_config.schemaPollTimeout,
|
|
78839
|
-
_config.schemaPath
|
|
78867
|
+
_config.schemaPath,
|
|
78868
|
+
{},
|
|
78869
|
+
_config.schemaPollWriteToDisk
|
|
78840
78870
|
) !== null;
|
|
78841
78871
|
}
|
|
78842
78872
|
}
|
|
@@ -82176,6 +82206,50 @@ function moduleStatments(config) {
|
|
|
82176
82206
|
exportStarStatement
|
|
82177
82207
|
};
|
|
82178
82208
|
}
|
|
82209
|
+
async function generateStaticRuntimes({ config }) {
|
|
82210
|
+
if (houdini_mode.is_testing) {
|
|
82211
|
+
return;
|
|
82212
|
+
}
|
|
82213
|
+
const { importStatement, exportDefaultStatement, exportStarStatement } = moduleStatments(config);
|
|
82214
|
+
await Promise.all(
|
|
82215
|
+
config.plugins.filter((plugin2) => plugin2.staticRuntime).map(async (plugin2) => {
|
|
82216
|
+
const runtime_path = config.pluginStaticRuntimeSource(plugin2);
|
|
82217
|
+
if (!runtime_path) {
|
|
82218
|
+
return;
|
|
82219
|
+
}
|
|
82220
|
+
try {
|
|
82221
|
+
await stat(runtime_path);
|
|
82222
|
+
} catch {
|
|
82223
|
+
throw new HoudiniError({
|
|
82224
|
+
message: "Cannot find runtime to generate for " + plugin2.name,
|
|
82225
|
+
description: "Maybe it was bundled?"
|
|
82226
|
+
});
|
|
82227
|
+
}
|
|
82228
|
+
const pluginDir = config.pluginStaticRuntimeDirectory(plugin2.name);
|
|
82229
|
+
let transformMap = plugin2.transformRuntime ?? {};
|
|
82230
|
+
if (transformMap && typeof transformMap === "function") {
|
|
82231
|
+
transformMap = transformMap([], { config });
|
|
82232
|
+
}
|
|
82233
|
+
await mkdirp(pluginDir);
|
|
82234
|
+
await recursiveCopy(
|
|
82235
|
+
runtime_path,
|
|
82236
|
+
pluginDir,
|
|
82237
|
+
Object.fromEntries(
|
|
82238
|
+
Object.entries(transformMap).map(([key, value]) => [
|
|
82239
|
+
join2(runtime_path, key),
|
|
82240
|
+
(content) => value({
|
|
82241
|
+
config,
|
|
82242
|
+
content,
|
|
82243
|
+
importStatement,
|
|
82244
|
+
exportDefaultStatement,
|
|
82245
|
+
exportStarStatement
|
|
82246
|
+
})
|
|
82247
|
+
])
|
|
82248
|
+
)
|
|
82249
|
+
);
|
|
82250
|
+
})
|
|
82251
|
+
);
|
|
82252
|
+
}
|
|
82179
82253
|
async function generatePluginRuntimes({
|
|
82180
82254
|
config,
|
|
82181
82255
|
docs
|
|
@@ -83777,6 +83851,11 @@ async function writeIndexFile2(config, docs) {
|
|
|
83777
83851
|
module: relative2(config.pluginRuntimeDirectory(plugin2.name))
|
|
83778
83852
|
});
|
|
83779
83853
|
}
|
|
83854
|
+
if (plugin2.staticRuntime) {
|
|
83855
|
+
body += exportStar({
|
|
83856
|
+
module: relative2(config.pluginStaticRuntimeDirectory(plugin2.name))
|
|
83857
|
+
});
|
|
83858
|
+
}
|
|
83780
83859
|
}
|
|
83781
83860
|
await fs_exports.writeFile(path_exports.join(config.rootDir, "index.js"), body);
|
|
83782
83861
|
}
|
|
@@ -87694,6 +87773,7 @@ async function componentFields2(config, docs) {
|
|
|
87694
87773
|
|
|
87695
87774
|
// src/codegen/index.ts
|
|
87696
87775
|
async function compile(config) {
|
|
87776
|
+
await generateStaticRuntimes({ config });
|
|
87697
87777
|
const documents = await collectDocuments(config);
|
|
87698
87778
|
return await runPipeline2(config, documents);
|
|
87699
87779
|
}
|
|
@@ -88729,9 +88809,6 @@ async function init2(_path, args) {
|
|
|
88729
88809
|
);
|
|
88730
88810
|
schemaPath = answers.schema_path;
|
|
88731
88811
|
}
|
|
88732
|
-
if (is_remote_endpoint && pullSchema_content) {
|
|
88733
|
-
await fs_exports.writeFile(path_exports.join(targetPath, schemaPath), pullSchema_content);
|
|
88734
|
-
}
|
|
88735
88812
|
const { frameworkInfo, typescript, module, package_manager } = await detectTools(targetPath);
|
|
88736
88813
|
const found_to_log = [];
|
|
88737
88814
|
if (frameworkInfo.framework === "svelte") {
|
|
@@ -89104,12 +89181,12 @@ async function packageJSON(targetPath, frameworkInfo) {
|
|
|
89104
89181
|
}
|
|
89105
89182
|
packageJSON2.devDependencies = {
|
|
89106
89183
|
...packageJSON2.devDependencies,
|
|
89107
|
-
houdini: "^2.0.0-next.
|
|
89184
|
+
houdini: "^2.0.0-next.1"
|
|
89108
89185
|
};
|
|
89109
89186
|
if (frameworkInfo.framework === "svelte" || frameworkInfo.framework === "kit") {
|
|
89110
89187
|
packageJSON2.devDependencies = {
|
|
89111
89188
|
...packageJSON2.devDependencies,
|
|
89112
|
-
"houdini-svelte": "^2.2.0-next.
|
|
89189
|
+
"houdini-svelte": "^2.2.0-next.2"
|
|
89113
89190
|
};
|
|
89114
89191
|
} else {
|
|
89115
89192
|
throw new Error(`Unmanaged framework: "${JSON.stringify(frameworkInfo)}"`);
|
|
@@ -6,6 +6,9 @@ export declare function moduleStatments(config: Config): {
|
|
|
6
6
|
exportDefaultStatement: typeof exportDefault;
|
|
7
7
|
exportStarStatement: typeof exportStarFrom;
|
|
8
8
|
};
|
|
9
|
+
export declare function generateStaticRuntimes({ config }: {
|
|
10
|
+
config: Config;
|
|
11
|
+
}): Promise<void>;
|
|
9
12
|
export declare function generatePluginRuntimes({ config, docs, }: {
|
|
10
13
|
config: Config;
|
|
11
14
|
docs: Document[];
|
|
@@ -68733,6 +68733,50 @@ function moduleStatments(config) {
|
|
|
68733
68733
|
exportStarStatement
|
|
68734
68734
|
};
|
|
68735
68735
|
}
|
|
68736
|
+
async function generateStaticRuntimes({ config }) {
|
|
68737
|
+
if (houdini_mode.is_testing) {
|
|
68738
|
+
return;
|
|
68739
|
+
}
|
|
68740
|
+
const { importStatement, exportDefaultStatement, exportStarStatement } = moduleStatments(config);
|
|
68741
|
+
await Promise.all(
|
|
68742
|
+
config.plugins.filter((plugin2) => plugin2.staticRuntime).map(async (plugin2) => {
|
|
68743
|
+
const runtime_path = config.pluginStaticRuntimeSource(plugin2);
|
|
68744
|
+
if (!runtime_path) {
|
|
68745
|
+
return;
|
|
68746
|
+
}
|
|
68747
|
+
try {
|
|
68748
|
+
await stat(runtime_path);
|
|
68749
|
+
} catch {
|
|
68750
|
+
throw new HoudiniError({
|
|
68751
|
+
message: "Cannot find runtime to generate for " + plugin2.name,
|
|
68752
|
+
description: "Maybe it was bundled?"
|
|
68753
|
+
});
|
|
68754
|
+
}
|
|
68755
|
+
const pluginDir = config.pluginStaticRuntimeDirectory(plugin2.name);
|
|
68756
|
+
let transformMap = plugin2.transformRuntime ?? {};
|
|
68757
|
+
if (transformMap && typeof transformMap === "function") {
|
|
68758
|
+
transformMap = transformMap([], { config });
|
|
68759
|
+
}
|
|
68760
|
+
await mkdirp(pluginDir);
|
|
68761
|
+
await recursiveCopy(
|
|
68762
|
+
runtime_path,
|
|
68763
|
+
pluginDir,
|
|
68764
|
+
Object.fromEntries(
|
|
68765
|
+
Object.entries(transformMap).map(([key, value]) => [
|
|
68766
|
+
join(runtime_path, key),
|
|
68767
|
+
(content) => value({
|
|
68768
|
+
config,
|
|
68769
|
+
content,
|
|
68770
|
+
importStatement,
|
|
68771
|
+
exportDefaultStatement,
|
|
68772
|
+
exportStarStatement
|
|
68773
|
+
})
|
|
68774
|
+
])
|
|
68775
|
+
)
|
|
68776
|
+
);
|
|
68777
|
+
})
|
|
68778
|
+
);
|
|
68779
|
+
}
|
|
68736
68780
|
async function generatePluginRuntimes({
|
|
68737
68781
|
config,
|
|
68738
68782
|
docs
|
|
@@ -70334,6 +70378,11 @@ async function writeIndexFile2(config, docs) {
|
|
|
70334
70378
|
module: relative2(config.pluginRuntimeDirectory(plugin2.name))
|
|
70335
70379
|
});
|
|
70336
70380
|
}
|
|
70381
|
+
if (plugin2.staticRuntime) {
|
|
70382
|
+
body += exportStar({
|
|
70383
|
+
module: relative2(config.pluginStaticRuntimeDirectory(plugin2.name))
|
|
70384
|
+
});
|
|
70385
|
+
}
|
|
70337
70386
|
}
|
|
70338
70387
|
await fs_exports.writeFile(path_exports.join(config.rootDir, "index.js"), body);
|
|
70339
70388
|
}
|
|
@@ -74251,6 +74300,7 @@ async function componentFields2(config, docs) {
|
|
|
74251
74300
|
|
|
74252
74301
|
// src/codegen/index.ts
|
|
74253
74302
|
async function compile(config) {
|
|
74303
|
+
await generateStaticRuntimes({ config });
|
|
74254
74304
|
const documents = await collectDocuments(config);
|
|
74255
74305
|
return await runPipeline2(config, documents);
|
|
74256
74306
|
}
|
|
@@ -68732,6 +68732,50 @@ function moduleStatments(config) {
|
|
|
68732
68732
|
exportStarStatement
|
|
68733
68733
|
};
|
|
68734
68734
|
}
|
|
68735
|
+
async function generateStaticRuntimes({ config }) {
|
|
68736
|
+
if (houdini_mode.is_testing) {
|
|
68737
|
+
return;
|
|
68738
|
+
}
|
|
68739
|
+
const { importStatement, exportDefaultStatement, exportStarStatement } = moduleStatments(config);
|
|
68740
|
+
await Promise.all(
|
|
68741
|
+
config.plugins.filter((plugin2) => plugin2.staticRuntime).map(async (plugin2) => {
|
|
68742
|
+
const runtime_path = config.pluginStaticRuntimeSource(plugin2);
|
|
68743
|
+
if (!runtime_path) {
|
|
68744
|
+
return;
|
|
68745
|
+
}
|
|
68746
|
+
try {
|
|
68747
|
+
await stat(runtime_path);
|
|
68748
|
+
} catch {
|
|
68749
|
+
throw new HoudiniError({
|
|
68750
|
+
message: "Cannot find runtime to generate for " + plugin2.name,
|
|
68751
|
+
description: "Maybe it was bundled?"
|
|
68752
|
+
});
|
|
68753
|
+
}
|
|
68754
|
+
const pluginDir = config.pluginStaticRuntimeDirectory(plugin2.name);
|
|
68755
|
+
let transformMap = plugin2.transformRuntime ?? {};
|
|
68756
|
+
if (transformMap && typeof transformMap === "function") {
|
|
68757
|
+
transformMap = transformMap([], { config });
|
|
68758
|
+
}
|
|
68759
|
+
await mkdirp(pluginDir);
|
|
68760
|
+
await recursiveCopy(
|
|
68761
|
+
runtime_path,
|
|
68762
|
+
pluginDir,
|
|
68763
|
+
Object.fromEntries(
|
|
68764
|
+
Object.entries(transformMap).map(([key, value]) => [
|
|
68765
|
+
join(runtime_path, key),
|
|
68766
|
+
(content) => value({
|
|
68767
|
+
config,
|
|
68768
|
+
content,
|
|
68769
|
+
importStatement,
|
|
68770
|
+
exportDefaultStatement,
|
|
68771
|
+
exportStarStatement
|
|
68772
|
+
})
|
|
68773
|
+
])
|
|
68774
|
+
)
|
|
68775
|
+
);
|
|
68776
|
+
})
|
|
68777
|
+
);
|
|
68778
|
+
}
|
|
68735
68779
|
async function generatePluginRuntimes({
|
|
68736
68780
|
config,
|
|
68737
68781
|
docs
|
|
@@ -70333,6 +70377,11 @@ async function writeIndexFile2(config, docs) {
|
|
|
70333
70377
|
module: relative2(config.pluginRuntimeDirectory(plugin2.name))
|
|
70334
70378
|
});
|
|
70335
70379
|
}
|
|
70380
|
+
if (plugin2.staticRuntime) {
|
|
70381
|
+
body += exportStar({
|
|
70382
|
+
module: relative2(config.pluginStaticRuntimeDirectory(plugin2.name))
|
|
70383
|
+
});
|
|
70384
|
+
}
|
|
70336
70385
|
}
|
|
70337
70386
|
await fs_exports.writeFile(path_exports.join(config.rootDir, "index.js"), body);
|
|
70338
70387
|
}
|
|
@@ -74250,6 +74299,7 @@ async function componentFields2(config, docs) {
|
|
|
74250
74299
|
|
|
74251
74300
|
// src/codegen/index.ts
|
|
74252
74301
|
async function compile(config) {
|
|
74302
|
+
await generateStaticRuntimes({ config });
|
|
74253
74303
|
const documents = await collectDocuments(config);
|
|
74254
74304
|
return await runPipeline2(config, documents);
|
|
74255
74305
|
}
|
package/build/lib/config.d.ts
CHANGED
|
@@ -36,6 +36,7 @@ export declare class Config {
|
|
|
36
36
|
routesDir: string;
|
|
37
37
|
schemaPollInterval: number | null;
|
|
38
38
|
schemaPollTimeout: number;
|
|
39
|
+
schemaPollWriteToDisk: boolean;
|
|
39
40
|
schemaPollHeaders: ((env: any) => Record<string, string>) | Record<string, string | ((env: any) => string)>;
|
|
40
41
|
pluginMode: boolean;
|
|
41
42
|
plugins: PluginMeta[];
|
|
@@ -58,6 +59,7 @@ export declare class Config {
|
|
|
58
59
|
processEnvValues(env: Record<string, string | undefined>, value: string | ((env: any) => string)): string | undefined;
|
|
59
60
|
pullHeaders(): Promise<any>;
|
|
60
61
|
pluginRuntimeSource(plugin: PluginMeta): string | null;
|
|
62
|
+
pluginStaticRuntimeSource(plugin: PluginMeta): string | null;
|
|
61
63
|
sourceFiles(): Promise<string[]>;
|
|
62
64
|
get componentScalar(): string;
|
|
63
65
|
schemaString: string;
|
|
@@ -99,6 +101,7 @@ export declare class Config {
|
|
|
99
101
|
ignore_plugins?: boolean;
|
|
100
102
|
}): boolean;
|
|
101
103
|
pluginRuntimeDirectory(name: string): string;
|
|
104
|
+
pluginStaticRuntimeDirectory(name: string): string;
|
|
102
105
|
get pluginRootDirectory(): string;
|
|
103
106
|
pluginDirectory(name: string): string;
|
|
104
107
|
get loadDirective(): string;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export declare function pullSchema(url: string, fetchTimeout: number, schemaPath: string, headers?: Record<string, string>,
|
|
1
|
+
export declare function pullSchema(url: string, fetchTimeout: number, schemaPath: string, headers?: Record<string, string>, writeToDisk?: boolean): Promise<string | null>;
|
|
2
2
|
export declare function extractHeadersStr(str: string | undefined): Record<string, string>;
|
|
3
3
|
export declare function extractHeaders(headers?: string[] | undefined): {};
|