houdini 2.0.0-next.0 → 2.0.0-next.2
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 +127 -43
- package/build/cmd-esm/index.js +127 -43
- package/build/codegen/generators/runtime/pluginRuntime.d.ts +3 -0
- package/build/codegen-cjs/index.js +86 -29
- package/build/codegen-esm/index.js +86 -29
- package/build/lib/config.d.ts +3 -0
- package/build/lib/introspection.d.ts +1 -1
- package/build/lib-cjs/index.js +75 -38
- package/build/lib-esm/index.js +75 -38
- package/build/runtime/lib/config.d.ts +7 -0
- package/build/runtime-cjs/cache/cache.js +36 -29
- package/build/runtime-cjs/lib/config.d.ts +7 -0
- package/build/runtime-esm/cache/cache.js +36 -29
- package/build/runtime-esm/lib/config.d.ts +7 -0
- package/build/test-cjs/index.js +64 -32
- package/build/test-esm/index.js +64 -32
- package/build/vite-cjs/index.js +127 -39
- package/build/vite-esm/index.js +127 -39
- 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) {
|
|
@@ -77339,20 +77346,21 @@ var CacheInternal = class {
|
|
|
77339
77346
|
} else if (Array.isArray(value) && // make typescript happy
|
|
77340
77347
|
(typeof previousValue === "undefined" || previousValue === null || Array.isArray(previousValue))) {
|
|
77341
77348
|
let oldIDs = [...previousValue || []];
|
|
77342
|
-
|
|
77343
|
-
|
|
77344
|
-
|
|
77345
|
-
|
|
77346
|
-
|
|
77347
|
-
|
|
77348
|
-
|
|
77349
|
-
|
|
77350
|
-
|
|
77351
|
-
|
|
77352
|
-
|
|
77353
|
-
|
|
77354
|
-
|
|
77355
|
-
|
|
77349
|
+
if (updates?.includes("append") || updates?.includes("prepend")) {
|
|
77350
|
+
oldIDs = oldIDs.filter((id) => {
|
|
77351
|
+
for (const layer2 of this.storage.data) {
|
|
77352
|
+
for (const operation of Object.values(layer2.operations)) {
|
|
77353
|
+
if (operation.fields?.[key])
|
|
77354
|
+
for (const listOperation of operation.fields[key]) {
|
|
77355
|
+
if ("id" in listOperation && listOperation.id === id) {
|
|
77356
|
+
return false;
|
|
77357
|
+
}
|
|
77358
|
+
}
|
|
77359
|
+
}
|
|
77360
|
+
}
|
|
77361
|
+
return true;
|
|
77362
|
+
});
|
|
77363
|
+
}
|
|
77356
77364
|
let linkedIDs = [];
|
|
77357
77365
|
const { newIDs, nestedIDs } = this.extractNestedListIDs({
|
|
77358
77366
|
value,
|
|
@@ -77371,39 +77379,45 @@ var CacheInternal = class {
|
|
|
77371
77379
|
layer.writeLink(parent2, key, linkedIDs);
|
|
77372
77380
|
};
|
|
77373
77381
|
if (applyUpdates && updates) {
|
|
77374
|
-
|
|
77375
|
-
const
|
|
77376
|
-
for (const id of
|
|
77382
|
+
const filterIDs = (keep, insert) => {
|
|
77383
|
+
const existingIDs = /* @__PURE__ */ new Set();
|
|
77384
|
+
for (const id of keep) {
|
|
77377
77385
|
if (!id) {
|
|
77378
77386
|
continue;
|
|
77379
77387
|
}
|
|
77380
77388
|
const { value: node } = this.storage.get(id, "node");
|
|
77381
|
-
if (
|
|
77389
|
+
if (!node) {
|
|
77382
77390
|
continue;
|
|
77383
77391
|
}
|
|
77384
|
-
|
|
77392
|
+
const nodeID = this.storage.get(node, "id");
|
|
77393
|
+
if (!nodeID) {
|
|
77385
77394
|
continue;
|
|
77386
77395
|
}
|
|
77387
|
-
|
|
77396
|
+
existingIDs.add(nodeID.value);
|
|
77388
77397
|
}
|
|
77389
|
-
|
|
77398
|
+
return insert.filter((id) => {
|
|
77390
77399
|
if (!id) {
|
|
77391
77400
|
return true;
|
|
77392
77401
|
}
|
|
77393
|
-
const { value:
|
|
77394
|
-
|
|
77395
|
-
|
|
77396
|
-
return false;
|
|
77402
|
+
const { value: node } = this.storage.get(id, "node");
|
|
77403
|
+
if (!node) {
|
|
77404
|
+
return true;
|
|
77397
77405
|
}
|
|
77398
|
-
|
|
77406
|
+
const nodeID = this.storage.get(node, "id");
|
|
77407
|
+
if (!nodeID) {
|
|
77408
|
+
return true;
|
|
77409
|
+
}
|
|
77410
|
+
return !existingIDs.has(nodeID.value);
|
|
77399
77411
|
});
|
|
77400
|
-
}
|
|
77412
|
+
};
|
|
77401
77413
|
for (const update of applyUpdates) {
|
|
77402
77414
|
if (update !== "replace" && !updates.includes(update)) {
|
|
77403
77415
|
continue;
|
|
77404
77416
|
}
|
|
77405
77417
|
if (update === "prepend") {
|
|
77406
|
-
linkedIDs = newIDs.concat(
|
|
77418
|
+
linkedIDs = newIDs.concat(
|
|
77419
|
+
filterIDs(newIDs, oldIDs)
|
|
77420
|
+
);
|
|
77407
77421
|
if (layer?.optimistic) {
|
|
77408
77422
|
action = () => {
|
|
77409
77423
|
for (const id of newIDs) {
|
|
@@ -77414,7 +77428,7 @@ var CacheInternal = class {
|
|
|
77414
77428
|
};
|
|
77415
77429
|
}
|
|
77416
77430
|
} else if (update === "append") {
|
|
77417
|
-
linkedIDs = oldIDs.concat(newIDs);
|
|
77431
|
+
linkedIDs = filterIDs(newIDs, oldIDs).concat(newIDs);
|
|
77418
77432
|
if (layer?.optimistic) {
|
|
77419
77433
|
action = () => {
|
|
77420
77434
|
for (const id of newIDs) {
|
|
@@ -78083,6 +78097,7 @@ var Config = class {
|
|
|
78083
78097
|
routesDir;
|
|
78084
78098
|
schemaPollInterval;
|
|
78085
78099
|
schemaPollTimeout;
|
|
78100
|
+
schemaPollWriteToDisk = false;
|
|
78086
78101
|
schemaPollHeaders;
|
|
78087
78102
|
pluginMode = false;
|
|
78088
78103
|
plugins = [];
|
|
@@ -78159,6 +78174,7 @@ var Config = class {
|
|
|
78159
78174
|
this.routesDir = join2(this.projectRoot, "src", "routes");
|
|
78160
78175
|
this.schemaPollInterval = watchSchema?.interval === void 0 ? 2e3 : watchSchema.interval;
|
|
78161
78176
|
this.schemaPollTimeout = watchSchema?.timeout ?? 3e4;
|
|
78177
|
+
this.schemaPollWriteToDisk = watchSchema?.writePolledSchema ?? true;
|
|
78162
78178
|
this.schemaPollHeaders = watchSchema?.headers ?? {};
|
|
78163
78179
|
this.rootDir = join2(this.projectRoot, this.runtimeDir);
|
|
78164
78180
|
this.persistedQueriesPath = persistedQueriesPath ?? join2(this.rootDir, "persisted_queries.json");
|
|
@@ -78191,11 +78207,17 @@ var Config = class {
|
|
|
78191
78207
|
const include = [`src/**/*{${extensions.join(",")}}`];
|
|
78192
78208
|
for (const plugin2 of this.plugins) {
|
|
78193
78209
|
const runtimeDir = this.pluginRuntimeSource(plugin2);
|
|
78194
|
-
|
|
78210
|
+
const staticDir = this.pluginStaticRuntimeSource(plugin2);
|
|
78211
|
+
if (!runtimeDir && !staticDir) {
|
|
78195
78212
|
continue;
|
|
78196
78213
|
}
|
|
78197
|
-
const
|
|
78198
|
-
|
|
78214
|
+
for (const dir of [runtimeDir, staticDir]) {
|
|
78215
|
+
if (!dir) {
|
|
78216
|
+
continue;
|
|
78217
|
+
}
|
|
78218
|
+
const includePath = relative(this.projectRoot, dir);
|
|
78219
|
+
include.push(`${includePath}/**/*{${extensions.join(",")}}`);
|
|
78220
|
+
}
|
|
78199
78221
|
}
|
|
78200
78222
|
return include;
|
|
78201
78223
|
}
|
|
@@ -78249,6 +78271,15 @@ var Config = class {
|
|
|
78249
78271
|
typeof plugin2.includeRuntime === "string" ? plugin2.includeRuntime : plugin2.includeRuntime?.[this.module]
|
|
78250
78272
|
);
|
|
78251
78273
|
}
|
|
78274
|
+
pluginStaticRuntimeSource(plugin2) {
|
|
78275
|
+
if (!plugin2.staticRuntime) {
|
|
78276
|
+
return null;
|
|
78277
|
+
}
|
|
78278
|
+
return join2(
|
|
78279
|
+
dirname(plugin2.filepath),
|
|
78280
|
+
typeof plugin2.staticRuntime === "string" ? plugin2.staticRuntime : plugin2.staticRuntime?.[this.module]
|
|
78281
|
+
);
|
|
78282
|
+
}
|
|
78252
78283
|
async sourceFiles() {
|
|
78253
78284
|
return [
|
|
78254
78285
|
...new Set(
|
|
@@ -78445,6 +78476,9 @@ var Config = class {
|
|
|
78445
78476
|
pluginRuntimeDirectory(name) {
|
|
78446
78477
|
return join2(this.pluginDirectory(name), "runtime");
|
|
78447
78478
|
}
|
|
78479
|
+
pluginStaticRuntimeDirectory(name) {
|
|
78480
|
+
return join2(this.pluginDirectory(name), "static");
|
|
78481
|
+
}
|
|
78448
78482
|
get pluginRootDirectory() {
|
|
78449
78483
|
return houdini_mode.is_testing ? "../../../" : join2(this.rootDir, "plugins");
|
|
78450
78484
|
}
|
|
@@ -78822,17 +78856,20 @@ async function getConfig({
|
|
|
78822
78856
|
if (!_config.localSchema && _config.schemaPath && !_config.schema) {
|
|
78823
78857
|
let schemaOk = true;
|
|
78824
78858
|
if (apiURL) {
|
|
78825
|
-
if (glob2.hasMagic(_config.schemaPath)) {
|
|
78859
|
+
if (glob2.hasMagic(_config.schemaPath) && _config.schemaPollWriteToDisk) {
|
|
78826
78860
|
console.log(
|
|
78827
78861
|
`\u26A0\uFE0F Your houdini configuration contains an apiUrl and a path pointing to multiple files.
|
|
78828
|
-
This will prevent your schema from being
|
|
78862
|
+
This will prevent your schema from being written to disk. If this is expected, please set the writePolledSchema value to false.`
|
|
78829
78863
|
);
|
|
78864
|
+
_config.schemaPollWriteToDisk = false;
|
|
78830
78865
|
} else if (!await readFile(_config.schemaPath)) {
|
|
78831
78866
|
console.log("\u231B Pulling schema from api");
|
|
78832
78867
|
schemaOk = await pullSchema(
|
|
78833
78868
|
apiURL,
|
|
78834
78869
|
_config.schemaPollTimeout,
|
|
78835
|
-
_config.schemaPath
|
|
78870
|
+
_config.schemaPath,
|
|
78871
|
+
{},
|
|
78872
|
+
_config.schemaPollWriteToDisk
|
|
78836
78873
|
) !== null;
|
|
78837
78874
|
}
|
|
78838
78875
|
}
|
|
@@ -82172,6 +82209,50 @@ function moduleStatments(config) {
|
|
|
82172
82209
|
exportStarStatement
|
|
82173
82210
|
};
|
|
82174
82211
|
}
|
|
82212
|
+
async function generateStaticRuntimes({ config }) {
|
|
82213
|
+
if (houdini_mode.is_testing) {
|
|
82214
|
+
return;
|
|
82215
|
+
}
|
|
82216
|
+
const { importStatement, exportDefaultStatement, exportStarStatement } = moduleStatments(config);
|
|
82217
|
+
await Promise.all(
|
|
82218
|
+
config.plugins.filter((plugin2) => plugin2.staticRuntime).map(async (plugin2) => {
|
|
82219
|
+
const runtime_path = config.pluginStaticRuntimeSource(plugin2);
|
|
82220
|
+
if (!runtime_path) {
|
|
82221
|
+
return;
|
|
82222
|
+
}
|
|
82223
|
+
try {
|
|
82224
|
+
await stat(runtime_path);
|
|
82225
|
+
} catch {
|
|
82226
|
+
throw new HoudiniError({
|
|
82227
|
+
message: "Cannot find runtime to generate for " + plugin2.name,
|
|
82228
|
+
description: "Maybe it was bundled?"
|
|
82229
|
+
});
|
|
82230
|
+
}
|
|
82231
|
+
const pluginDir = config.pluginStaticRuntimeDirectory(plugin2.name);
|
|
82232
|
+
let transformMap = plugin2.transformRuntime ?? {};
|
|
82233
|
+
if (transformMap && typeof transformMap === "function") {
|
|
82234
|
+
transformMap = transformMap([], { config });
|
|
82235
|
+
}
|
|
82236
|
+
await mkdirp(pluginDir);
|
|
82237
|
+
await recursiveCopy(
|
|
82238
|
+
runtime_path,
|
|
82239
|
+
pluginDir,
|
|
82240
|
+
Object.fromEntries(
|
|
82241
|
+
Object.entries(transformMap).map(([key, value]) => [
|
|
82242
|
+
join2(runtime_path, key),
|
|
82243
|
+
(content) => value({
|
|
82244
|
+
config,
|
|
82245
|
+
content,
|
|
82246
|
+
importStatement,
|
|
82247
|
+
exportDefaultStatement,
|
|
82248
|
+
exportStarStatement
|
|
82249
|
+
})
|
|
82250
|
+
])
|
|
82251
|
+
)
|
|
82252
|
+
);
|
|
82253
|
+
})
|
|
82254
|
+
);
|
|
82255
|
+
}
|
|
82175
82256
|
async function generatePluginRuntimes({
|
|
82176
82257
|
config,
|
|
82177
82258
|
docs
|
|
@@ -83773,6 +83854,11 @@ async function writeIndexFile2(config, docs) {
|
|
|
83773
83854
|
module: relative2(config.pluginRuntimeDirectory(plugin2.name))
|
|
83774
83855
|
});
|
|
83775
83856
|
}
|
|
83857
|
+
if (plugin2.staticRuntime) {
|
|
83858
|
+
body += exportStar({
|
|
83859
|
+
module: relative2(config.pluginStaticRuntimeDirectory(plugin2.name))
|
|
83860
|
+
});
|
|
83861
|
+
}
|
|
83776
83862
|
}
|
|
83777
83863
|
await fs_exports.writeFile(path_exports.join(config.rootDir, "index.js"), body);
|
|
83778
83864
|
}
|
|
@@ -87690,6 +87776,7 @@ async function componentFields2(config, docs) {
|
|
|
87690
87776
|
|
|
87691
87777
|
// src/codegen/index.ts
|
|
87692
87778
|
async function compile(config) {
|
|
87779
|
+
await generateStaticRuntimes({ config });
|
|
87693
87780
|
const documents = await collectDocuments(config);
|
|
87694
87781
|
return await runPipeline2(config, documents);
|
|
87695
87782
|
}
|
|
@@ -88725,9 +88812,6 @@ async function init2(_path, args) {
|
|
|
88725
88812
|
);
|
|
88726
88813
|
schemaPath = answers.schema_path;
|
|
88727
88814
|
}
|
|
88728
|
-
if (is_remote_endpoint && pullSchema_content) {
|
|
88729
|
-
await fs_exports.writeFile(path_exports.join(targetPath, schemaPath), pullSchema_content);
|
|
88730
|
-
}
|
|
88731
88815
|
const { frameworkInfo, typescript, module: module2, package_manager } = await detectTools(targetPath);
|
|
88732
88816
|
const found_to_log = [];
|
|
88733
88817
|
if (frameworkInfo.framework === "svelte") {
|
|
@@ -89100,12 +89184,12 @@ async function packageJSON(targetPath, frameworkInfo) {
|
|
|
89100
89184
|
}
|
|
89101
89185
|
packageJSON2.devDependencies = {
|
|
89102
89186
|
...packageJSON2.devDependencies,
|
|
89103
|
-
houdini: "^2.0.0-next.
|
|
89187
|
+
houdini: "^2.0.0-next.2"
|
|
89104
89188
|
};
|
|
89105
89189
|
if (frameworkInfo.framework === "svelte" || frameworkInfo.framework === "kit") {
|
|
89106
89190
|
packageJSON2.devDependencies = {
|
|
89107
89191
|
...packageJSON2.devDependencies,
|
|
89108
|
-
"houdini-svelte": "^2.2.0-next.
|
|
89192
|
+
"houdini-svelte": "^2.2.0-next.4"
|
|
89109
89193
|
};
|
|
89110
89194
|
} else {
|
|
89111
89195
|
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) {
|
|
@@ -77344,20 +77351,21 @@ var CacheInternal = class {
|
|
|
77344
77351
|
} else if (Array.isArray(value) && // make typescript happy
|
|
77345
77352
|
(typeof previousValue === "undefined" || previousValue === null || Array.isArray(previousValue))) {
|
|
77346
77353
|
let oldIDs = [...previousValue || []];
|
|
77347
|
-
|
|
77348
|
-
|
|
77349
|
-
|
|
77350
|
-
|
|
77351
|
-
|
|
77352
|
-
|
|
77353
|
-
|
|
77354
|
-
|
|
77355
|
-
|
|
77356
|
-
|
|
77357
|
-
|
|
77358
|
-
|
|
77359
|
-
|
|
77360
|
-
|
|
77354
|
+
if (updates?.includes("append") || updates?.includes("prepend")) {
|
|
77355
|
+
oldIDs = oldIDs.filter((id) => {
|
|
77356
|
+
for (const layer2 of this.storage.data) {
|
|
77357
|
+
for (const operation of Object.values(layer2.operations)) {
|
|
77358
|
+
if (operation.fields?.[key])
|
|
77359
|
+
for (const listOperation of operation.fields[key]) {
|
|
77360
|
+
if ("id" in listOperation && listOperation.id === id) {
|
|
77361
|
+
return false;
|
|
77362
|
+
}
|
|
77363
|
+
}
|
|
77364
|
+
}
|
|
77365
|
+
}
|
|
77366
|
+
return true;
|
|
77367
|
+
});
|
|
77368
|
+
}
|
|
77361
77369
|
let linkedIDs = [];
|
|
77362
77370
|
const { newIDs, nestedIDs } = this.extractNestedListIDs({
|
|
77363
77371
|
value,
|
|
@@ -77376,39 +77384,45 @@ var CacheInternal = class {
|
|
|
77376
77384
|
layer.writeLink(parent2, key, linkedIDs);
|
|
77377
77385
|
};
|
|
77378
77386
|
if (applyUpdates && updates) {
|
|
77379
|
-
|
|
77380
|
-
const
|
|
77381
|
-
for (const id of
|
|
77387
|
+
const filterIDs = (keep, insert) => {
|
|
77388
|
+
const existingIDs = /* @__PURE__ */ new Set();
|
|
77389
|
+
for (const id of keep) {
|
|
77382
77390
|
if (!id) {
|
|
77383
77391
|
continue;
|
|
77384
77392
|
}
|
|
77385
77393
|
const { value: node } = this.storage.get(id, "node");
|
|
77386
|
-
if (
|
|
77394
|
+
if (!node) {
|
|
77387
77395
|
continue;
|
|
77388
77396
|
}
|
|
77389
|
-
|
|
77397
|
+
const nodeID = this.storage.get(node, "id");
|
|
77398
|
+
if (!nodeID) {
|
|
77390
77399
|
continue;
|
|
77391
77400
|
}
|
|
77392
|
-
|
|
77401
|
+
existingIDs.add(nodeID.value);
|
|
77393
77402
|
}
|
|
77394
|
-
|
|
77403
|
+
return insert.filter((id) => {
|
|
77395
77404
|
if (!id) {
|
|
77396
77405
|
return true;
|
|
77397
77406
|
}
|
|
77398
|
-
const { value:
|
|
77399
|
-
|
|
77400
|
-
|
|
77401
|
-
return false;
|
|
77407
|
+
const { value: node } = this.storage.get(id, "node");
|
|
77408
|
+
if (!node) {
|
|
77409
|
+
return true;
|
|
77402
77410
|
}
|
|
77403
|
-
|
|
77411
|
+
const nodeID = this.storage.get(node, "id");
|
|
77412
|
+
if (!nodeID) {
|
|
77413
|
+
return true;
|
|
77414
|
+
}
|
|
77415
|
+
return !existingIDs.has(nodeID.value);
|
|
77404
77416
|
});
|
|
77405
|
-
}
|
|
77417
|
+
};
|
|
77406
77418
|
for (const update of applyUpdates) {
|
|
77407
77419
|
if (update !== "replace" && !updates.includes(update)) {
|
|
77408
77420
|
continue;
|
|
77409
77421
|
}
|
|
77410
77422
|
if (update === "prepend") {
|
|
77411
|
-
linkedIDs = newIDs.concat(
|
|
77423
|
+
linkedIDs = newIDs.concat(
|
|
77424
|
+
filterIDs(newIDs, oldIDs)
|
|
77425
|
+
);
|
|
77412
77426
|
if (layer?.optimistic) {
|
|
77413
77427
|
action = () => {
|
|
77414
77428
|
for (const id of newIDs) {
|
|
@@ -77419,7 +77433,7 @@ var CacheInternal = class {
|
|
|
77419
77433
|
};
|
|
77420
77434
|
}
|
|
77421
77435
|
} else if (update === "append") {
|
|
77422
|
-
linkedIDs = oldIDs.concat(newIDs);
|
|
77436
|
+
linkedIDs = filterIDs(newIDs, oldIDs).concat(newIDs);
|
|
77423
77437
|
if (layer?.optimistic) {
|
|
77424
77438
|
action = () => {
|
|
77425
77439
|
for (const id of newIDs) {
|
|
@@ -78087,6 +78101,7 @@ var Config = class {
|
|
|
78087
78101
|
routesDir;
|
|
78088
78102
|
schemaPollInterval;
|
|
78089
78103
|
schemaPollTimeout;
|
|
78104
|
+
schemaPollWriteToDisk = false;
|
|
78090
78105
|
schemaPollHeaders;
|
|
78091
78106
|
pluginMode = false;
|
|
78092
78107
|
plugins = [];
|
|
@@ -78163,6 +78178,7 @@ var Config = class {
|
|
|
78163
78178
|
this.routesDir = join2(this.projectRoot, "src", "routes");
|
|
78164
78179
|
this.schemaPollInterval = watchSchema?.interval === void 0 ? 2e3 : watchSchema.interval;
|
|
78165
78180
|
this.schemaPollTimeout = watchSchema?.timeout ?? 3e4;
|
|
78181
|
+
this.schemaPollWriteToDisk = watchSchema?.writePolledSchema ?? true;
|
|
78166
78182
|
this.schemaPollHeaders = watchSchema?.headers ?? {};
|
|
78167
78183
|
this.rootDir = join2(this.projectRoot, this.runtimeDir);
|
|
78168
78184
|
this.persistedQueriesPath = persistedQueriesPath ?? join2(this.rootDir, "persisted_queries.json");
|
|
@@ -78195,11 +78211,17 @@ var Config = class {
|
|
|
78195
78211
|
const include = [`src/**/*{${extensions.join(",")}}`];
|
|
78196
78212
|
for (const plugin2 of this.plugins) {
|
|
78197
78213
|
const runtimeDir = this.pluginRuntimeSource(plugin2);
|
|
78198
|
-
|
|
78214
|
+
const staticDir = this.pluginStaticRuntimeSource(plugin2);
|
|
78215
|
+
if (!runtimeDir && !staticDir) {
|
|
78199
78216
|
continue;
|
|
78200
78217
|
}
|
|
78201
|
-
const
|
|
78202
|
-
|
|
78218
|
+
for (const dir of [runtimeDir, staticDir]) {
|
|
78219
|
+
if (!dir) {
|
|
78220
|
+
continue;
|
|
78221
|
+
}
|
|
78222
|
+
const includePath = relative(this.projectRoot, dir);
|
|
78223
|
+
include.push(`${includePath}/**/*{${extensions.join(",")}}`);
|
|
78224
|
+
}
|
|
78203
78225
|
}
|
|
78204
78226
|
return include;
|
|
78205
78227
|
}
|
|
@@ -78253,6 +78275,15 @@ var Config = class {
|
|
|
78253
78275
|
typeof plugin2.includeRuntime === "string" ? plugin2.includeRuntime : plugin2.includeRuntime?.[this.module]
|
|
78254
78276
|
);
|
|
78255
78277
|
}
|
|
78278
|
+
pluginStaticRuntimeSource(plugin2) {
|
|
78279
|
+
if (!plugin2.staticRuntime) {
|
|
78280
|
+
return null;
|
|
78281
|
+
}
|
|
78282
|
+
return join2(
|
|
78283
|
+
dirname(plugin2.filepath),
|
|
78284
|
+
typeof plugin2.staticRuntime === "string" ? plugin2.staticRuntime : plugin2.staticRuntime?.[this.module]
|
|
78285
|
+
);
|
|
78286
|
+
}
|
|
78256
78287
|
async sourceFiles() {
|
|
78257
78288
|
return [
|
|
78258
78289
|
...new Set(
|
|
@@ -78449,6 +78480,9 @@ var Config = class {
|
|
|
78449
78480
|
pluginRuntimeDirectory(name) {
|
|
78450
78481
|
return join2(this.pluginDirectory(name), "runtime");
|
|
78451
78482
|
}
|
|
78483
|
+
pluginStaticRuntimeDirectory(name) {
|
|
78484
|
+
return join2(this.pluginDirectory(name), "static");
|
|
78485
|
+
}
|
|
78452
78486
|
get pluginRootDirectory() {
|
|
78453
78487
|
return houdini_mode.is_testing ? "../../../" : join2(this.rootDir, "plugins");
|
|
78454
78488
|
}
|
|
@@ -78826,17 +78860,20 @@ async function getConfig({
|
|
|
78826
78860
|
if (!_config.localSchema && _config.schemaPath && !_config.schema) {
|
|
78827
78861
|
let schemaOk = true;
|
|
78828
78862
|
if (apiURL) {
|
|
78829
|
-
if (glob2.hasMagic(_config.schemaPath)) {
|
|
78863
|
+
if (glob2.hasMagic(_config.schemaPath) && _config.schemaPollWriteToDisk) {
|
|
78830
78864
|
console.log(
|
|
78831
78865
|
`\u26A0\uFE0F Your houdini configuration contains an apiUrl and a path pointing to multiple files.
|
|
78832
|
-
This will prevent your schema from being
|
|
78866
|
+
This will prevent your schema from being written to disk. If this is expected, please set the writePolledSchema value to false.`
|
|
78833
78867
|
);
|
|
78868
|
+
_config.schemaPollWriteToDisk = false;
|
|
78834
78869
|
} else if (!await readFile(_config.schemaPath)) {
|
|
78835
78870
|
console.log("\u231B Pulling schema from api");
|
|
78836
78871
|
schemaOk = await pullSchema(
|
|
78837
78872
|
apiURL,
|
|
78838
78873
|
_config.schemaPollTimeout,
|
|
78839
|
-
_config.schemaPath
|
|
78874
|
+
_config.schemaPath,
|
|
78875
|
+
{},
|
|
78876
|
+
_config.schemaPollWriteToDisk
|
|
78840
78877
|
) !== null;
|
|
78841
78878
|
}
|
|
78842
78879
|
}
|
|
@@ -82176,6 +82213,50 @@ function moduleStatments(config) {
|
|
|
82176
82213
|
exportStarStatement
|
|
82177
82214
|
};
|
|
82178
82215
|
}
|
|
82216
|
+
async function generateStaticRuntimes({ config }) {
|
|
82217
|
+
if (houdini_mode.is_testing) {
|
|
82218
|
+
return;
|
|
82219
|
+
}
|
|
82220
|
+
const { importStatement, exportDefaultStatement, exportStarStatement } = moduleStatments(config);
|
|
82221
|
+
await Promise.all(
|
|
82222
|
+
config.plugins.filter((plugin2) => plugin2.staticRuntime).map(async (plugin2) => {
|
|
82223
|
+
const runtime_path = config.pluginStaticRuntimeSource(plugin2);
|
|
82224
|
+
if (!runtime_path) {
|
|
82225
|
+
return;
|
|
82226
|
+
}
|
|
82227
|
+
try {
|
|
82228
|
+
await stat(runtime_path);
|
|
82229
|
+
} catch {
|
|
82230
|
+
throw new HoudiniError({
|
|
82231
|
+
message: "Cannot find runtime to generate for " + plugin2.name,
|
|
82232
|
+
description: "Maybe it was bundled?"
|
|
82233
|
+
});
|
|
82234
|
+
}
|
|
82235
|
+
const pluginDir = config.pluginStaticRuntimeDirectory(plugin2.name);
|
|
82236
|
+
let transformMap = plugin2.transformRuntime ?? {};
|
|
82237
|
+
if (transformMap && typeof transformMap === "function") {
|
|
82238
|
+
transformMap = transformMap([], { config });
|
|
82239
|
+
}
|
|
82240
|
+
await mkdirp(pluginDir);
|
|
82241
|
+
await recursiveCopy(
|
|
82242
|
+
runtime_path,
|
|
82243
|
+
pluginDir,
|
|
82244
|
+
Object.fromEntries(
|
|
82245
|
+
Object.entries(transformMap).map(([key, value]) => [
|
|
82246
|
+
join2(runtime_path, key),
|
|
82247
|
+
(content) => value({
|
|
82248
|
+
config,
|
|
82249
|
+
content,
|
|
82250
|
+
importStatement,
|
|
82251
|
+
exportDefaultStatement,
|
|
82252
|
+
exportStarStatement
|
|
82253
|
+
})
|
|
82254
|
+
])
|
|
82255
|
+
)
|
|
82256
|
+
);
|
|
82257
|
+
})
|
|
82258
|
+
);
|
|
82259
|
+
}
|
|
82179
82260
|
async function generatePluginRuntimes({
|
|
82180
82261
|
config,
|
|
82181
82262
|
docs
|
|
@@ -83777,6 +83858,11 @@ async function writeIndexFile2(config, docs) {
|
|
|
83777
83858
|
module: relative2(config.pluginRuntimeDirectory(plugin2.name))
|
|
83778
83859
|
});
|
|
83779
83860
|
}
|
|
83861
|
+
if (plugin2.staticRuntime) {
|
|
83862
|
+
body += exportStar({
|
|
83863
|
+
module: relative2(config.pluginStaticRuntimeDirectory(plugin2.name))
|
|
83864
|
+
});
|
|
83865
|
+
}
|
|
83780
83866
|
}
|
|
83781
83867
|
await fs_exports.writeFile(path_exports.join(config.rootDir, "index.js"), body);
|
|
83782
83868
|
}
|
|
@@ -87694,6 +87780,7 @@ async function componentFields2(config, docs) {
|
|
|
87694
87780
|
|
|
87695
87781
|
// src/codegen/index.ts
|
|
87696
87782
|
async function compile(config) {
|
|
87783
|
+
await generateStaticRuntimes({ config });
|
|
87697
87784
|
const documents = await collectDocuments(config);
|
|
87698
87785
|
return await runPipeline2(config, documents);
|
|
87699
87786
|
}
|
|
@@ -88729,9 +88816,6 @@ async function init2(_path, args) {
|
|
|
88729
88816
|
);
|
|
88730
88817
|
schemaPath = answers.schema_path;
|
|
88731
88818
|
}
|
|
88732
|
-
if (is_remote_endpoint && pullSchema_content) {
|
|
88733
|
-
await fs_exports.writeFile(path_exports.join(targetPath, schemaPath), pullSchema_content);
|
|
88734
|
-
}
|
|
88735
88819
|
const { frameworkInfo, typescript, module, package_manager } = await detectTools(targetPath);
|
|
88736
88820
|
const found_to_log = [];
|
|
88737
88821
|
if (frameworkInfo.framework === "svelte") {
|
|
@@ -89104,12 +89188,12 @@ async function packageJSON(targetPath, frameworkInfo) {
|
|
|
89104
89188
|
}
|
|
89105
89189
|
packageJSON2.devDependencies = {
|
|
89106
89190
|
...packageJSON2.devDependencies,
|
|
89107
|
-
houdini: "^2.0.0-next.
|
|
89191
|
+
houdini: "^2.0.0-next.2"
|
|
89108
89192
|
};
|
|
89109
89193
|
if (frameworkInfo.framework === "svelte" || frameworkInfo.framework === "kit") {
|
|
89110
89194
|
packageJSON2.devDependencies = {
|
|
89111
89195
|
...packageJSON2.devDependencies,
|
|
89112
|
-
"houdini-svelte": "^2.2.0-next.
|
|
89196
|
+
"houdini-svelte": "^2.2.0-next.4"
|
|
89113
89197
|
};
|
|
89114
89198
|
} else {
|
|
89115
89199
|
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[];
|