@monkeyplus/flow 6.0.6 → 6.0.8
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/module.mjs +17 -2
- package/modules/content/query.d.ts +25 -0
- package/modules/content/query.mjs +105 -19
- package/modules/content/runtime/client.d.ts +2 -0
- package/modules/content/runtime/client.mjs +1 -0
- package/modules/images/ipx.d.ts +2 -0
- package/modules/images/ipx.mjs +55 -0
- package/modules/images/module.d.ts +4 -0
- package/modules/images/module.mjs +146 -0
- package/modules/images/runtime/build.d.ts +6 -0
- package/modules/images/runtime/build.mjs +174 -0
- package/modules/images/runtime/helpers.d.ts +16 -0
- package/modules/images/runtime/helpers.mjs +45 -0
- package/modules/images/runtime/image.d.ts +7 -0
- package/modules/images/runtime/image.mjs +252 -0
- package/modules/images/runtime/renames.d.ts +2 -0
- package/modules/images/runtime/renames.mjs +79 -0
- package/modules/images/runtime/server.d.ts +3 -0
- package/modules/images/runtime/server.mjs +80 -0
- package/modules/images/runtime/types.d.ts +79 -0
- package/modules/images/runtime/types.mjs +0 -0
- package/modules/sitemap/handler.mjs +6 -7
- package/modules/sitemap/module.mjs +236 -22
- package/modules/sitemap/xml.d.ts +7 -0
- package/modules/sitemap/xml.mjs +87 -0
- package/package.json +7 -1
- package/server/lib/pages.mjs +20 -21
- package/server/lib/render.mjs +16 -0
- package/server/renderer.d.ts +1 -1
- package/server/renderer.mjs +2 -1
- package/src/public/components.d.ts +3 -0
- package/src/public/components.mjs +3 -0
- package/src/public/index.d.ts +5 -3
- package/src/public/index.mjs +1 -0
- package/src/public/modules/images.d.ts +2 -0
- package/src/public/modules/images.mjs +1 -0
- package/src/public/nitro.mjs +4 -1
- package/src/public/query-content.d.ts +7 -0
- package/src/public/query-content.mjs +130 -0
- package/src/public/vite.mjs +18 -2
- package/src/runtime/components/MkImage.d.ts +188 -0
- package/src/runtime/components/MkImage.mjs +131 -0
- package/src/runtime/components/MkLink.d.ts +22 -0
- package/src/runtime/components/MkLink.mjs +72 -0
- package/src/runtime/components/MkPicture.d.ts +199 -0
- package/src/runtime/components/MkPicture.mjs +172 -0
- package/src/runtime/components/image-shared.d.ts +28 -0
- package/src/runtime/components/image-shared.mjs +68 -0
- package/src/runtime/config.d.ts +22 -0
- package/src/runtime/config.mjs +5 -2
- package/src/runtime/locale-routing.d.ts +12 -0
- package/src/runtime/locale-routing.mjs +93 -0
- package/src/runtime/modules.mjs +1 -0
- package/src/runtime/page-discovery.mjs +8 -15
- package/src/runtime/pages.d.ts +16 -0
- package/src/runtime/virtual.d.ts +17 -0
- package/src/runtime/vue.mjs +6 -0
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
declare const _default: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
2
|
+
src: {
|
|
3
|
+
type: StringConstructor;
|
|
4
|
+
required: true;
|
|
5
|
+
};
|
|
6
|
+
rename: StringConstructor;
|
|
7
|
+
thumb: (StringConstructor | BooleanConstructor)[];
|
|
8
|
+
thumbnail: {
|
|
9
|
+
type: (StringConstructor | BooleanConstructor)[];
|
|
10
|
+
default: undefined;
|
|
11
|
+
};
|
|
12
|
+
classImg: StringConstructor;
|
|
13
|
+
format: {
|
|
14
|
+
type: StringConstructor;
|
|
15
|
+
default: undefined;
|
|
16
|
+
};
|
|
17
|
+
quality: {
|
|
18
|
+
type: (StringConstructor | NumberConstructor)[];
|
|
19
|
+
default: undefined;
|
|
20
|
+
};
|
|
21
|
+
background: {
|
|
22
|
+
type: StringConstructor;
|
|
23
|
+
default: undefined;
|
|
24
|
+
};
|
|
25
|
+
fit: {
|
|
26
|
+
type: StringConstructor;
|
|
27
|
+
default: undefined;
|
|
28
|
+
};
|
|
29
|
+
modifiers: {
|
|
30
|
+
type: () => Record<string, any>;
|
|
31
|
+
default: undefined;
|
|
32
|
+
};
|
|
33
|
+
preset: {
|
|
34
|
+
type: StringConstructor;
|
|
35
|
+
default: undefined;
|
|
36
|
+
};
|
|
37
|
+
provider: {
|
|
38
|
+
type: StringConstructor;
|
|
39
|
+
default: undefined;
|
|
40
|
+
};
|
|
41
|
+
sizes: {
|
|
42
|
+
type: () => string | Record<string, any>;
|
|
43
|
+
default: undefined;
|
|
44
|
+
};
|
|
45
|
+
sync: BooleanConstructor;
|
|
46
|
+
eWidth: (StringConstructor | NumberConstructor)[];
|
|
47
|
+
eHeight: (StringConstructor | NumberConstructor)[];
|
|
48
|
+
width: {
|
|
49
|
+
type: (StringConstructor | NumberConstructor)[];
|
|
50
|
+
default: undefined;
|
|
51
|
+
};
|
|
52
|
+
height: {
|
|
53
|
+
type: (StringConstructor | NumberConstructor)[];
|
|
54
|
+
default: undefined;
|
|
55
|
+
};
|
|
56
|
+
alt: {
|
|
57
|
+
type: StringConstructor;
|
|
58
|
+
default: undefined;
|
|
59
|
+
};
|
|
60
|
+
title: {
|
|
61
|
+
type: StringConstructor;
|
|
62
|
+
default: undefined;
|
|
63
|
+
};
|
|
64
|
+
referrerpolicy: {
|
|
65
|
+
type: StringConstructor;
|
|
66
|
+
default: undefined;
|
|
67
|
+
};
|
|
68
|
+
usemap: {
|
|
69
|
+
type: StringConstructor;
|
|
70
|
+
default: undefined;
|
|
71
|
+
};
|
|
72
|
+
longdesc: {
|
|
73
|
+
type: StringConstructor;
|
|
74
|
+
default: undefined;
|
|
75
|
+
};
|
|
76
|
+
ismap: {
|
|
77
|
+
type: BooleanConstructor;
|
|
78
|
+
default: undefined;
|
|
79
|
+
};
|
|
80
|
+
loading: {
|
|
81
|
+
type: StringConstructor;
|
|
82
|
+
default: undefined;
|
|
83
|
+
};
|
|
84
|
+
legacyFormat: {
|
|
85
|
+
type: StringConstructor;
|
|
86
|
+
default: null;
|
|
87
|
+
};
|
|
88
|
+
}>, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
89
|
+
[key: string]: any;
|
|
90
|
+
}>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
91
|
+
src: {
|
|
92
|
+
type: StringConstructor;
|
|
93
|
+
required: true;
|
|
94
|
+
};
|
|
95
|
+
rename: StringConstructor;
|
|
96
|
+
thumb: (StringConstructor | BooleanConstructor)[];
|
|
97
|
+
thumbnail: {
|
|
98
|
+
type: (StringConstructor | BooleanConstructor)[];
|
|
99
|
+
default: undefined;
|
|
100
|
+
};
|
|
101
|
+
classImg: StringConstructor;
|
|
102
|
+
format: {
|
|
103
|
+
type: StringConstructor;
|
|
104
|
+
default: undefined;
|
|
105
|
+
};
|
|
106
|
+
quality: {
|
|
107
|
+
type: (StringConstructor | NumberConstructor)[];
|
|
108
|
+
default: undefined;
|
|
109
|
+
};
|
|
110
|
+
background: {
|
|
111
|
+
type: StringConstructor;
|
|
112
|
+
default: undefined;
|
|
113
|
+
};
|
|
114
|
+
fit: {
|
|
115
|
+
type: StringConstructor;
|
|
116
|
+
default: undefined;
|
|
117
|
+
};
|
|
118
|
+
modifiers: {
|
|
119
|
+
type: () => Record<string, any>;
|
|
120
|
+
default: undefined;
|
|
121
|
+
};
|
|
122
|
+
preset: {
|
|
123
|
+
type: StringConstructor;
|
|
124
|
+
default: undefined;
|
|
125
|
+
};
|
|
126
|
+
provider: {
|
|
127
|
+
type: StringConstructor;
|
|
128
|
+
default: undefined;
|
|
129
|
+
};
|
|
130
|
+
sizes: {
|
|
131
|
+
type: () => string | Record<string, any>;
|
|
132
|
+
default: undefined;
|
|
133
|
+
};
|
|
134
|
+
sync: BooleanConstructor;
|
|
135
|
+
eWidth: (StringConstructor | NumberConstructor)[];
|
|
136
|
+
eHeight: (StringConstructor | NumberConstructor)[];
|
|
137
|
+
width: {
|
|
138
|
+
type: (StringConstructor | NumberConstructor)[];
|
|
139
|
+
default: undefined;
|
|
140
|
+
};
|
|
141
|
+
height: {
|
|
142
|
+
type: (StringConstructor | NumberConstructor)[];
|
|
143
|
+
default: undefined;
|
|
144
|
+
};
|
|
145
|
+
alt: {
|
|
146
|
+
type: StringConstructor;
|
|
147
|
+
default: undefined;
|
|
148
|
+
};
|
|
149
|
+
title: {
|
|
150
|
+
type: StringConstructor;
|
|
151
|
+
default: undefined;
|
|
152
|
+
};
|
|
153
|
+
referrerpolicy: {
|
|
154
|
+
type: StringConstructor;
|
|
155
|
+
default: undefined;
|
|
156
|
+
};
|
|
157
|
+
usemap: {
|
|
158
|
+
type: StringConstructor;
|
|
159
|
+
default: undefined;
|
|
160
|
+
};
|
|
161
|
+
longdesc: {
|
|
162
|
+
type: StringConstructor;
|
|
163
|
+
default: undefined;
|
|
164
|
+
};
|
|
165
|
+
ismap: {
|
|
166
|
+
type: BooleanConstructor;
|
|
167
|
+
default: undefined;
|
|
168
|
+
};
|
|
169
|
+
loading: {
|
|
170
|
+
type: StringConstructor;
|
|
171
|
+
default: undefined;
|
|
172
|
+
};
|
|
173
|
+
legacyFormat: {
|
|
174
|
+
type: StringConstructor;
|
|
175
|
+
default: null;
|
|
176
|
+
};
|
|
177
|
+
}>> & Readonly<{}>, {
|
|
178
|
+
width: string | number;
|
|
179
|
+
height: string | number;
|
|
180
|
+
fit: string;
|
|
181
|
+
format: string;
|
|
182
|
+
provider: string;
|
|
183
|
+
preset: string;
|
|
184
|
+
modifiers: Record<string, any>;
|
|
185
|
+
sizes: string | Record<string, any>;
|
|
186
|
+
alt: string;
|
|
187
|
+
referrerpolicy: string;
|
|
188
|
+
usemap: string;
|
|
189
|
+
longdesc: string;
|
|
190
|
+
ismap: boolean;
|
|
191
|
+
loading: string;
|
|
192
|
+
quality: string | number;
|
|
193
|
+
background: string;
|
|
194
|
+
title: string;
|
|
195
|
+
sync: boolean;
|
|
196
|
+
thumbnail: string | boolean;
|
|
197
|
+
legacyFormat: string;
|
|
198
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
199
|
+
export default _default;
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
import { computed, defineComponent, h } from "vue";
|
|
2
|
+
import { getFileExtension, screens } from "../../../modules/images/runtime/helpers.mjs";
|
|
3
|
+
import { useImage, useLazySizes } from "./image-shared.mjs";
|
|
4
|
+
function getLocalSource(src) {
|
|
5
|
+
return src.startsWith("http") ? "" : src;
|
|
6
|
+
}
|
|
7
|
+
function isRuntimeLambda() {
|
|
8
|
+
const runtimeProcess = typeof globalThis === "object" ? Reflect.get(globalThis, "process") : void 0;
|
|
9
|
+
return !!(runtimeProcess?.env?.LAMBDA_TASK_ROOT || runtimeProcess?.env?.AWS_LAMBDA_FUNCTION_VERSION);
|
|
10
|
+
}
|
|
11
|
+
function resolveThumbnailValue(value, fallback) {
|
|
12
|
+
return value !== void 0 ? value : fallback;
|
|
13
|
+
}
|
|
14
|
+
export default defineComponent({
|
|
15
|
+
name: "MkPicture",
|
|
16
|
+
inheritAttrs: false,
|
|
17
|
+
props: {
|
|
18
|
+
src: {
|
|
19
|
+
type: String,
|
|
20
|
+
required: true
|
|
21
|
+
},
|
|
22
|
+
rename: String,
|
|
23
|
+
thumb: [Boolean, String],
|
|
24
|
+
thumbnail: { type: [Boolean, String], default: void 0 },
|
|
25
|
+
classImg: String,
|
|
26
|
+
format: { type: String, default: void 0 },
|
|
27
|
+
quality: { type: [Number, String], default: void 0 },
|
|
28
|
+
background: { type: String, default: void 0 },
|
|
29
|
+
fit: { type: String, default: void 0 },
|
|
30
|
+
modifiers: {
|
|
31
|
+
type: Object,
|
|
32
|
+
default: void 0
|
|
33
|
+
},
|
|
34
|
+
preset: { type: String, default: void 0 },
|
|
35
|
+
provider: { type: String, default: void 0 },
|
|
36
|
+
sizes: {
|
|
37
|
+
type: [Object, String],
|
|
38
|
+
default: void 0
|
|
39
|
+
},
|
|
40
|
+
sync: Boolean,
|
|
41
|
+
eWidth: [String, Number],
|
|
42
|
+
eHeight: [String, Number],
|
|
43
|
+
width: { type: [String, Number], default: void 0 },
|
|
44
|
+
height: { type: [String, Number], default: void 0 },
|
|
45
|
+
alt: { type: String, default: void 0 },
|
|
46
|
+
title: { type: String, default: void 0 },
|
|
47
|
+
referrerpolicy: { type: String, default: void 0 },
|
|
48
|
+
usemap: { type: String, default: void 0 },
|
|
49
|
+
longdesc: { type: String, default: void 0 },
|
|
50
|
+
ismap: { type: Boolean, default: void 0 },
|
|
51
|
+
loading: { type: String, default: void 0 },
|
|
52
|
+
legacyFormat: { type: String, default: null }
|
|
53
|
+
},
|
|
54
|
+
setup(props, { attrs }) {
|
|
55
|
+
const { imageUtils, image, nImgAttrs, nModifiers, nOption } = useImage(props);
|
|
56
|
+
const options = computed(() => imageUtils.getImageOptions?.() || {
|
|
57
|
+
lazy: true,
|
|
58
|
+
screens: {},
|
|
59
|
+
domains: {},
|
|
60
|
+
presets: {},
|
|
61
|
+
baseURL: "/_ipx",
|
|
62
|
+
dirImages: "/images"
|
|
63
|
+
});
|
|
64
|
+
const originalFormat = () => getFileExtension(props.src);
|
|
65
|
+
const isTransparent = () => ["png", "webp", "gif"].includes(originalFormat());
|
|
66
|
+
const nFormat = () => {
|
|
67
|
+
if (props.format) {
|
|
68
|
+
return props.format;
|
|
69
|
+
}
|
|
70
|
+
if (originalFormat() === "svg") {
|
|
71
|
+
return "svg";
|
|
72
|
+
}
|
|
73
|
+
return "webp";
|
|
74
|
+
};
|
|
75
|
+
const nLegacyFormat = () => {
|
|
76
|
+
if (props.legacyFormat) {
|
|
77
|
+
return props.legacyFormat;
|
|
78
|
+
}
|
|
79
|
+
const formats = {
|
|
80
|
+
webp: isTransparent() ? "png" : "jpeg",
|
|
81
|
+
svg: "png"
|
|
82
|
+
};
|
|
83
|
+
return formats[nFormat()] || originalFormat();
|
|
84
|
+
};
|
|
85
|
+
const nSources = computed(() => {
|
|
86
|
+
if (nFormat() === "svg" || !imageUtils.getImage?.getSizes) {
|
|
87
|
+
return [{ src: props.src, srcset: props.src }];
|
|
88
|
+
}
|
|
89
|
+
const formats = nLegacyFormat() !== nFormat() ? [nLegacyFormat(), nFormat()] : [nFormat()];
|
|
90
|
+
return formats.map((format) => {
|
|
91
|
+
const result = imageUtils.getImage.getSizes(props.src, {
|
|
92
|
+
...nOption.value,
|
|
93
|
+
modifiers: {
|
|
94
|
+
...nModifiers.value,
|
|
95
|
+
format
|
|
96
|
+
},
|
|
97
|
+
sizes: props.sizes || options.value.screens || screens
|
|
98
|
+
});
|
|
99
|
+
return {
|
|
100
|
+
src: result.src,
|
|
101
|
+
type: `image/${format}`,
|
|
102
|
+
sizes: result.sizes,
|
|
103
|
+
srcset: result.srcset
|
|
104
|
+
};
|
|
105
|
+
});
|
|
106
|
+
});
|
|
107
|
+
const nThumbnail = computed(() => {
|
|
108
|
+
const thumb = resolveThumbnailValue(props.thumbnail, props.thumb);
|
|
109
|
+
if (typeof thumb === "string") {
|
|
110
|
+
return thumb;
|
|
111
|
+
}
|
|
112
|
+
if (!thumb) {
|
|
113
|
+
return void 0;
|
|
114
|
+
}
|
|
115
|
+
const thumbnail = imageUtils.getImage?.(props.src, {
|
|
116
|
+
quality: 10,
|
|
117
|
+
width: 60
|
|
118
|
+
}, nOption.value);
|
|
119
|
+
return typeof thumbnail === "string" ? thumbnail : props.src;
|
|
120
|
+
});
|
|
121
|
+
useLazySizes(() => !isRuntimeLambda() && !!nThumbnail.value);
|
|
122
|
+
return () => {
|
|
123
|
+
if (isRuntimeLambda()) {
|
|
124
|
+
return h("img", {
|
|
125
|
+
...attrs,
|
|
126
|
+
...nImgAttrs.value,
|
|
127
|
+
"src": props.src,
|
|
128
|
+
"alt": props.alt || image.value.alt,
|
|
129
|
+
"title": props.title || image.value.title,
|
|
130
|
+
"width": props.eWidth || nImgAttrs.value.width,
|
|
131
|
+
"height": props.eHeight || nImgAttrs.value.height,
|
|
132
|
+
"x-src": getLocalSource(props.src)
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
const primarySource = nSources.value[0] || { src: props.src, srcset: props.src };
|
|
136
|
+
const fallbackSource = nSources.value[1];
|
|
137
|
+
const compatibilityThumb = nThumbnail.value;
|
|
138
|
+
const sourceSrcsetProp = compatibilityThumb ? "data-srcset" : "srcset";
|
|
139
|
+
const sourceSizesProp = compatibilityThumb ? "data-sizes" : "sizes";
|
|
140
|
+
const imgAttrs = {
|
|
141
|
+
...attrs,
|
|
142
|
+
...nImgAttrs.value,
|
|
143
|
+
"src": compatibilityThumb || primarySource.src,
|
|
144
|
+
"srcset": compatibilityThumb ? void 0 : primarySource.srcset,
|
|
145
|
+
"sizes": compatibilityThumb ? void 0 : primarySource.sizes,
|
|
146
|
+
"data-src": compatibilityThumb ? primarySource.src : void 0,
|
|
147
|
+
"data-srcset": compatibilityThumb ? primarySource.srcset : void 0,
|
|
148
|
+
"data-sizes": compatibilityThumb ? primarySource.sizes : void 0,
|
|
149
|
+
"data-thumb": compatibilityThumb,
|
|
150
|
+
"alt": props.alt || image.value.alt,
|
|
151
|
+
"title": props.title || image.value.title,
|
|
152
|
+
"width": props.eWidth || nImgAttrs.value.width,
|
|
153
|
+
"height": props.eHeight || nImgAttrs.value.height,
|
|
154
|
+
"class": compatibilityThumb ? [attrs.class, "lazyload", props.classImg] : [attrs.class, props.classImg],
|
|
155
|
+
"x-src": getLocalSource(props.src)
|
|
156
|
+
};
|
|
157
|
+
if (options.value.lazy && !props.sync && !imgAttrs.loading) {
|
|
158
|
+
imgAttrs.loading = "lazy";
|
|
159
|
+
}
|
|
160
|
+
const children = [];
|
|
161
|
+
if (fallbackSource) {
|
|
162
|
+
children.push(h("source", {
|
|
163
|
+
type: fallbackSource.type,
|
|
164
|
+
[sourceSrcsetProp]: fallbackSource.srcset,
|
|
165
|
+
[sourceSizesProp]: fallbackSource.sizes
|
|
166
|
+
}));
|
|
167
|
+
}
|
|
168
|
+
children.push(h("img", imgAttrs));
|
|
169
|
+
return h("picture", { key: primarySource.src }, children);
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
});
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { FlowImageMeta, FlowImageOptions, GetImageFunction } from '../../../modules/images/runtime/types.ts';
|
|
2
|
+
export interface InjectedImageUtils {
|
|
3
|
+
getImage?: GetImageFunction;
|
|
4
|
+
getImageMeta?: (src: string) => FlowImageMeta | undefined;
|
|
5
|
+
getImageOptions?: () => FlowImageOptions | undefined;
|
|
6
|
+
}
|
|
7
|
+
export declare function useInjectedImageUtils(): InjectedImageUtils;
|
|
8
|
+
export declare function useLazySizes(enabled: () => unknown): void;
|
|
9
|
+
export declare function useImage(props: Record<string, any>): {
|
|
10
|
+
imageUtils: InjectedImageUtils;
|
|
11
|
+
image: import("vue").ComputedRef<FlowImageMeta>;
|
|
12
|
+
nImgAttrs: import("vue").ComputedRef<{
|
|
13
|
+
width: number | undefined;
|
|
14
|
+
height: number | undefined;
|
|
15
|
+
alt: any;
|
|
16
|
+
referrerpolicy: any;
|
|
17
|
+
usemap: any;
|
|
18
|
+
longdesc: any;
|
|
19
|
+
ismap: any;
|
|
20
|
+
loading: any;
|
|
21
|
+
}>;
|
|
22
|
+
nModifiers: import("vue").ComputedRef<any>;
|
|
23
|
+
nOption: import("vue").ComputedRef<{
|
|
24
|
+
provider: any;
|
|
25
|
+
preset: any;
|
|
26
|
+
rename: any;
|
|
27
|
+
}>;
|
|
28
|
+
};
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { computed, inject } from "vue";
|
|
2
|
+
import { watchEffect } from "vue";
|
|
3
|
+
import { getNormalName, parseSize } from "../../../modules/images/runtime/helpers.mjs";
|
|
4
|
+
let lazySizesLoadPromise;
|
|
5
|
+
function loadLazySizes() {
|
|
6
|
+
if (lazySizesLoadPromise) {
|
|
7
|
+
return lazySizesLoadPromise;
|
|
8
|
+
}
|
|
9
|
+
lazySizesLoadPromise = import("lazysizes");
|
|
10
|
+
return lazySizesLoadPromise;
|
|
11
|
+
}
|
|
12
|
+
export function useInjectedImageUtils() {
|
|
13
|
+
return inject("utils", {});
|
|
14
|
+
}
|
|
15
|
+
export function useLazySizes(enabled) {
|
|
16
|
+
watchEffect(() => {
|
|
17
|
+
if (typeof window === "undefined" || !enabled()) {
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
void loadLazySizes();
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
export function useImage(props) {
|
|
24
|
+
const imageUtils = useInjectedImageUtils();
|
|
25
|
+
const nImgAttrs = computed(() => ({
|
|
26
|
+
width: parseSize(props.width),
|
|
27
|
+
height: parseSize(props.height),
|
|
28
|
+
alt: props.alt,
|
|
29
|
+
referrerpolicy: props.referrerpolicy,
|
|
30
|
+
usemap: props.usemap,
|
|
31
|
+
longdesc: props.longdesc,
|
|
32
|
+
ismap: props.ismap,
|
|
33
|
+
loading: props.loading
|
|
34
|
+
}));
|
|
35
|
+
const nModifiers = computed(() => ({
|
|
36
|
+
...props.modifiers,
|
|
37
|
+
width: parseSize(props.width),
|
|
38
|
+
height: parseSize(props.height),
|
|
39
|
+
format: props.format,
|
|
40
|
+
quality: props.quality,
|
|
41
|
+
background: props.background,
|
|
42
|
+
fit: props.fit
|
|
43
|
+
}));
|
|
44
|
+
const nOption = computed(() => ({
|
|
45
|
+
provider: props.provider,
|
|
46
|
+
preset: props.preset,
|
|
47
|
+
rename: props.rename
|
|
48
|
+
}));
|
|
49
|
+
const image = computed(() => {
|
|
50
|
+
const meta = {
|
|
51
|
+
...imageUtils.getImageMeta?.(props.src) || { name: props.src }
|
|
52
|
+
};
|
|
53
|
+
if (!meta.alt) {
|
|
54
|
+
meta.alt = getNormalName(meta.name);
|
|
55
|
+
}
|
|
56
|
+
if (!meta.title) {
|
|
57
|
+
meta.title = getNormalName(meta.name);
|
|
58
|
+
}
|
|
59
|
+
return meta;
|
|
60
|
+
});
|
|
61
|
+
return {
|
|
62
|
+
imageUtils,
|
|
63
|
+
image,
|
|
64
|
+
nImgAttrs,
|
|
65
|
+
nModifiers,
|
|
66
|
+
nOption
|
|
67
|
+
};
|
|
68
|
+
}
|
package/src/runtime/config.d.ts
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import type { Options as AutoimportOptions } from 'unplugin-auto-import/types';
|
|
2
|
+
import type { Options as ComponentOptions } from 'unplugin-vue-components/types';
|
|
3
|
+
import type { FlowImagesModuleOptions } from '../../modules/images/runtime/types.ts';
|
|
1
4
|
export interface FlowDirEntry {
|
|
2
5
|
dir: string;
|
|
3
6
|
}
|
|
@@ -23,6 +26,18 @@ export interface FlowLocaleConfig {
|
|
|
23
26
|
locales: string[];
|
|
24
27
|
location: string;
|
|
25
28
|
language: string;
|
|
29
|
+
prefixStrategy?: 'auto' | 'manual';
|
|
30
|
+
prefixFormat?: 'compact' | 'nested';
|
|
31
|
+
}
|
|
32
|
+
export interface FlowServerConfig extends Record<string, unknown> {
|
|
33
|
+
host?: string | boolean;
|
|
34
|
+
port?: number;
|
|
35
|
+
strictPort?: boolean;
|
|
36
|
+
open?: boolean;
|
|
37
|
+
https?: Record<string, unknown>;
|
|
38
|
+
watch?: Record<string, unknown> & {
|
|
39
|
+
additionalPaths?: string[];
|
|
40
|
+
};
|
|
26
41
|
}
|
|
27
42
|
export interface FlowConfig {
|
|
28
43
|
modules: FlowModuleInput[];
|
|
@@ -31,6 +46,8 @@ export interface FlowConfig {
|
|
|
31
46
|
};
|
|
32
47
|
build: FlowBuildConfig;
|
|
33
48
|
locale: FlowLocaleConfig;
|
|
49
|
+
images?: Partial<FlowImagesModuleOptions>;
|
|
50
|
+
server?: FlowServerConfig;
|
|
34
51
|
siteUrl?: string;
|
|
35
52
|
nitro?: Record<string, unknown>;
|
|
36
53
|
[key: string]: unknown;
|
|
@@ -41,9 +58,14 @@ export type UserFlowConfig = Partial<FlowConfig> & Record<string, unknown> & {
|
|
|
41
58
|
pages?: FlowDirEntry[];
|
|
42
59
|
};
|
|
43
60
|
locale?: Partial<FlowLocaleConfig>;
|
|
61
|
+
images?: Partial<FlowImagesModuleOptions>;
|
|
62
|
+
server?: FlowServerConfig;
|
|
44
63
|
siteUrl?: string;
|
|
64
|
+
components?: Partial<ComponentOptions>;
|
|
65
|
+
autoImport?: Partial<AutoimportOptions>;
|
|
45
66
|
};
|
|
46
67
|
export interface FlowModuleNitroConfig extends Record<string, unknown> {
|
|
68
|
+
hooks: Record<string, unknown>;
|
|
47
69
|
plugins: string[];
|
|
48
70
|
handlers: Array<Record<string, unknown>>;
|
|
49
71
|
routeRules: Record<string, Record<string, unknown>>;
|
package/src/runtime/config.mjs
CHANGED
|
@@ -20,7 +20,10 @@ export function resolveFlowConfig(userFlowConfig = {}) {
|
|
|
20
20
|
locale: {
|
|
21
21
|
locales: userFlowConfig.locale?.locales?.length ? userFlowConfig.locale.locales : ["es-ec"],
|
|
22
22
|
location: userFlowConfig.locale?.location || "ec",
|
|
23
|
-
language: userFlowConfig.locale?.language || "es"
|
|
24
|
-
|
|
23
|
+
language: userFlowConfig.locale?.language || "es",
|
|
24
|
+
prefixStrategy: userFlowConfig.locale?.prefixStrategy || "auto",
|
|
25
|
+
prefixFormat: userFlowConfig.locale?.prefixFormat || "compact"
|
|
26
|
+
},
|
|
27
|
+
server: userFlowConfig.server
|
|
25
28
|
};
|
|
26
29
|
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { FlowConfig, FlowLocaleConfig } from './config';
|
|
2
|
+
export type FlowLocalePrefixStrategy = 'auto' | 'manual';
|
|
3
|
+
export type FlowLocalePrefixFormat = 'compact' | 'nested';
|
|
4
|
+
interface FlowLocaleConfigInput {
|
|
5
|
+
locale?: Partial<FlowLocaleConfig>;
|
|
6
|
+
}
|
|
7
|
+
export declare function normalizePath(value: string): string;
|
|
8
|
+
export declare function getDefaultLocaleCode(config?: FlowLocaleConfigInput): string;
|
|
9
|
+
export declare function getLocalePrefix(config: FlowLocaleConfigInput | undefined, localeCode: string): string;
|
|
10
|
+
export declare function localizeRoutePattern(config: FlowConfig | FlowLocaleConfigInput | undefined, localeCode: string, route: string): string;
|
|
11
|
+
export declare function toPublicRoute(config: FlowConfig | FlowLocaleConfigInput | undefined, localeCode: string, route: string): string;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
function ensureLeadingSlash(value) {
|
|
2
|
+
if (!value) {
|
|
3
|
+
return "/";
|
|
4
|
+
}
|
|
5
|
+
return value.startsWith("/") ? value : `/${value}`;
|
|
6
|
+
}
|
|
7
|
+
function ensureTrailingSlash(value) {
|
|
8
|
+
if (value === "/" || value.endsWith("/")) {
|
|
9
|
+
return value;
|
|
10
|
+
}
|
|
11
|
+
return `${value}/`;
|
|
12
|
+
}
|
|
13
|
+
function preserveTrailingSlash(value, source) {
|
|
14
|
+
return source.endsWith("/") ? ensureTrailingSlash(value) : value;
|
|
15
|
+
}
|
|
16
|
+
function resolveLocaleConfig(config) {
|
|
17
|
+
return {
|
|
18
|
+
locales: config?.locale?.locales?.length ? config.locale.locales : ["es-ec"],
|
|
19
|
+
location: config?.locale?.location || "ec",
|
|
20
|
+
language: config?.locale?.language || "es",
|
|
21
|
+
prefixStrategy: config?.locale?.prefixStrategy || "auto",
|
|
22
|
+
prefixFormat: config?.locale?.prefixFormat || "compact"
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
function resolveLocaleParts(config, code) {
|
|
26
|
+
const localeConfig = resolveLocaleConfig(config);
|
|
27
|
+
const [lang = localeConfig.language, loc = localeConfig.location] = code.split("-");
|
|
28
|
+
return {
|
|
29
|
+
lang,
|
|
30
|
+
loc
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
function routeHasPrefix(route, prefix) {
|
|
34
|
+
return route === prefix || route === `${prefix}/` || route.startsWith(`${prefix}/`);
|
|
35
|
+
}
|
|
36
|
+
function getLocalePrefixVariants(config, localeCode) {
|
|
37
|
+
const localeConfig = resolveLocaleConfig(config);
|
|
38
|
+
const { lang, loc } = resolveLocaleParts(config, localeCode);
|
|
39
|
+
const prefixes = /* @__PURE__ */ new Set();
|
|
40
|
+
if (loc === localeConfig.location) {
|
|
41
|
+
prefixes.add(`/${lang}`);
|
|
42
|
+
return [...prefixes];
|
|
43
|
+
}
|
|
44
|
+
prefixes.add(`/${lang}-${loc}`);
|
|
45
|
+
prefixes.add(`/${lang}/${loc}`);
|
|
46
|
+
return [...prefixes];
|
|
47
|
+
}
|
|
48
|
+
export function normalizePath(value) {
|
|
49
|
+
if (!value || value === "/") {
|
|
50
|
+
return "/";
|
|
51
|
+
}
|
|
52
|
+
return value.length > 1 && value.endsWith("/") ? value.slice(0, -1) : value;
|
|
53
|
+
}
|
|
54
|
+
export function getDefaultLocaleCode(config) {
|
|
55
|
+
const localeConfig = resolveLocaleConfig(config);
|
|
56
|
+
return `${localeConfig.language}-${localeConfig.location}`;
|
|
57
|
+
}
|
|
58
|
+
export function getLocalePrefix(config, localeCode) {
|
|
59
|
+
const localeConfig = resolveLocaleConfig(config);
|
|
60
|
+
if (localeConfig.prefixStrategy === "manual") {
|
|
61
|
+
return "";
|
|
62
|
+
}
|
|
63
|
+
if (localeCode === getDefaultLocaleCode(config)) {
|
|
64
|
+
return "";
|
|
65
|
+
}
|
|
66
|
+
const { lang, loc } = resolveLocaleParts(config, localeCode);
|
|
67
|
+
if (loc === localeConfig.location) {
|
|
68
|
+
return `/${lang}`;
|
|
69
|
+
}
|
|
70
|
+
if (localeConfig.prefixFormat === "nested") {
|
|
71
|
+
return `/${lang}/${loc}`;
|
|
72
|
+
}
|
|
73
|
+
return `/${lang}-${loc}`;
|
|
74
|
+
}
|
|
75
|
+
export function localizeRoutePattern(config, localeCode, route) {
|
|
76
|
+
const normalizedRoute = ensureLeadingSlash(route || "/");
|
|
77
|
+
const prefix = getLocalePrefix(config, localeCode);
|
|
78
|
+
if (!prefix) {
|
|
79
|
+
return normalizedRoute;
|
|
80
|
+
}
|
|
81
|
+
if (getLocalePrefixVariants(config, localeCode).some((candidate) => routeHasPrefix(normalizedRoute, candidate))) {
|
|
82
|
+
return normalizedRoute;
|
|
83
|
+
}
|
|
84
|
+
if (normalizedRoute === "/") {
|
|
85
|
+
return ensureTrailingSlash(prefix);
|
|
86
|
+
}
|
|
87
|
+
return preserveTrailingSlash(`${normalizePath(prefix)}${normalizedRoute}`, normalizedRoute);
|
|
88
|
+
}
|
|
89
|
+
export function toPublicRoute(config, localeCode, route) {
|
|
90
|
+
const localizedRoute = localizeRoutePattern(config, localeCode, route);
|
|
91
|
+
const publicRoute = localizedRoute.replaceAll("*", "");
|
|
92
|
+
return preserveTrailingSlash(normalizePath(publicRoute), localizedRoute);
|
|
93
|
+
}
|