@monkeyplus/flow 6.0.51 → 6.0.53
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/modules/content/query.mjs +20 -7
- package/package.json +1 -1
- package/src/public/vite.mjs +5 -2
- package/src/runtime/config.d.ts +2 -0
|
@@ -311,37 +311,50 @@ export function processContentQuery(entries, query, allEntries) {
|
|
|
311
311
|
if (query.with) {
|
|
312
312
|
try {
|
|
313
313
|
const withRelations = JSON.parse(query.with);
|
|
314
|
-
const hydrateValue = (val, instruction) => {
|
|
314
|
+
const hydrateValue = (val, instruction, isRootEntry = false) => {
|
|
315
315
|
if (Array.isArray(val)) {
|
|
316
|
-
return val.map((v) => hydrateValue(v, instruction));
|
|
316
|
+
return val.map((v) => hydrateValue(v, instruction, isRootEntry));
|
|
317
317
|
}
|
|
318
318
|
if (typeof val === "string") {
|
|
319
319
|
const found = allEntries.find((e) => e.path === val);
|
|
320
320
|
if (!found) return val;
|
|
321
321
|
let hydratedFound = { ...found, data: JSON.parse(JSON.stringify(found.data)) };
|
|
322
322
|
if (typeof instruction === "object" && instruction !== null && instruction.with) {
|
|
323
|
-
hydratedFound = hydrateEntry(hydratedFound, instruction.with);
|
|
323
|
+
hydratedFound = hydrateEntry(hydratedFound, instruction.with, true);
|
|
324
324
|
}
|
|
325
325
|
if (instruction === "raw" || typeof instruction === "object" && instruction !== null && instruction.raw) {
|
|
326
326
|
return hydratedFound;
|
|
327
327
|
}
|
|
328
328
|
return hydratedFound.data;
|
|
329
329
|
}
|
|
330
|
+
if (typeof val === "object" && val !== null) {
|
|
331
|
+
if (typeof instruction === "object" && instruction !== null && instruction.with) {
|
|
332
|
+
const hydratedObj = { ...val };
|
|
333
|
+
for (const [field, subInstruction] of Object.entries(instruction.with)) {
|
|
334
|
+
if (!subInstruction) continue;
|
|
335
|
+
const actualField = isRootEntry && !field.startsWith("data.") ? `data.${field}` : field;
|
|
336
|
+
const rawValue = getField(hydratedObj, actualField);
|
|
337
|
+
const resolved = hydrateValue(rawValue, subInstruction, false);
|
|
338
|
+
setField(hydratedObj, actualField, resolved);
|
|
339
|
+
}
|
|
340
|
+
return hydratedObj;
|
|
341
|
+
}
|
|
342
|
+
}
|
|
330
343
|
return val;
|
|
331
344
|
};
|
|
332
|
-
const hydrateEntry = (entry, relations) => {
|
|
345
|
+
const hydrateEntry = (entry, relations, isRootEntry = true) => {
|
|
333
346
|
for (const [field, instruction] of Object.entries(relations)) {
|
|
334
347
|
if (!instruction) continue;
|
|
335
|
-
const actualField = field.startsWith("data.") ?
|
|
348
|
+
const actualField = isRootEntry && !field.startsWith("data.") ? `data.${field}` : field;
|
|
336
349
|
const rawValue = getField(entry, actualField);
|
|
337
|
-
const resolved = hydrateValue(rawValue, instruction);
|
|
350
|
+
const resolved = hydrateValue(rawValue, instruction, false);
|
|
338
351
|
setField(entry, actualField, resolved);
|
|
339
352
|
}
|
|
340
353
|
return entry;
|
|
341
354
|
};
|
|
342
355
|
entries = entries.map((entry) => {
|
|
343
356
|
const hydratedEntry = { ...entry, data: JSON.parse(JSON.stringify(entry.data)) };
|
|
344
|
-
return hydrateEntry(hydratedEntry, withRelations);
|
|
357
|
+
return hydrateEntry(hydratedEntry, withRelations, true);
|
|
345
358
|
});
|
|
346
359
|
} catch {
|
|
347
360
|
}
|
package/package.json
CHANGED
package/src/public/vite.mjs
CHANGED
|
@@ -341,6 +341,7 @@ export function createFlowViteConfig(options = {}) {
|
|
|
341
341
|
}
|
|
342
342
|
}
|
|
343
343
|
const { imports: userImports, ...userAutoImport } = options.userFlowConfig?.autoImport || {};
|
|
344
|
+
const uiOptions = options.userFlowConfig?.ui || {};
|
|
344
345
|
return defineConfig({
|
|
345
346
|
plugins: [
|
|
346
347
|
createFlowVirtualServerModules(projectRoot, flowConfig),
|
|
@@ -354,7 +355,8 @@ export function createFlowViteConfig(options = {}) {
|
|
|
354
355
|
createFlowEmptyFileFallback(),
|
|
355
356
|
Vue(),
|
|
356
357
|
ui({
|
|
357
|
-
|
|
358
|
+
...uiOptions,
|
|
359
|
+
router: uiOptions.router || false,
|
|
358
360
|
components: {
|
|
359
361
|
dts: resolve(projectRoot, ".flow/types/components.d.ts"),
|
|
360
362
|
...options.userFlowConfig?.components,
|
|
@@ -364,7 +366,7 @@ export function createFlowViteConfig(options = {}) {
|
|
|
364
366
|
...options.userFlowConfig?.components?.resolvers || []
|
|
365
367
|
]
|
|
366
368
|
},
|
|
367
|
-
prose: true,
|
|
369
|
+
prose: uiOptions.prose || true,
|
|
368
370
|
autoImport: {
|
|
369
371
|
dts: resolve(projectRoot, ".flow/types/auto-imports.d.ts"),
|
|
370
372
|
imports: [
|
|
@@ -391,6 +393,7 @@ export function createFlowViteConfig(options = {}) {
|
|
|
391
393
|
],
|
|
392
394
|
...userAutoImport
|
|
393
395
|
}
|
|
396
|
+
// colorMode:
|
|
394
397
|
}),
|
|
395
398
|
nitro({
|
|
396
399
|
...flowNitroConfig,
|
package/src/runtime/config.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { NuxtUIOptions } from '@nuxt/ui/unplugin';
|
|
1
2
|
import type { NitroConfig } from 'nitro/types';
|
|
2
3
|
import type { Options as AutoimportOptions } from 'unplugin-auto-import/types';
|
|
3
4
|
import type { Options as ComponentOptions } from 'unplugin-vue-components/types';
|
|
@@ -66,6 +67,7 @@ export type UserFlowConfig = Partial<FlowConfig> & Record<string, unknown> & {
|
|
|
66
67
|
siteUrl?: string;
|
|
67
68
|
components?: Partial<ComponentOptions>;
|
|
68
69
|
autoImport?: Partial<AutoimportOptions>;
|
|
70
|
+
ui?: Omit<NuxtUIOptions, 'components' | 'autoImport'>;
|
|
69
71
|
};
|
|
70
72
|
export type FlowModuleNitroConfig = NitroConfig & {
|
|
71
73
|
runtimeConfig: any;
|