@monkeyplus/flow 6.0.5 → 6.0.7

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.
Files changed (53) hide show
  1. package/modules/content/module.mjs +17 -2
  2. package/modules/content/query.d.ts +25 -0
  3. package/modules/content/query.mjs +105 -19
  4. package/modules/content/runtime/client.d.ts +2 -0
  5. package/modules/content/runtime/client.mjs +1 -0
  6. package/modules/images/ipx.d.ts +5 -0
  7. package/modules/images/ipx.mjs +31 -0
  8. package/modules/images/module.d.ts +4 -0
  9. package/modules/images/module.mjs +96 -0
  10. package/modules/images/plugin.d.ts +2 -0
  11. package/modules/images/plugin.mjs +19 -0
  12. package/modules/images/runtime/build.d.ts +6 -0
  13. package/modules/images/runtime/build.mjs +142 -0
  14. package/modules/images/runtime/helpers.d.ts +16 -0
  15. package/modules/images/runtime/helpers.mjs +45 -0
  16. package/modules/images/runtime/image.d.ts +7 -0
  17. package/modules/images/runtime/image.mjs +235 -0
  18. package/modules/images/runtime/renames.d.ts +2 -0
  19. package/modules/images/runtime/renames.mjs +79 -0
  20. package/modules/images/runtime/server.d.ts +3 -0
  21. package/modules/images/runtime/server.mjs +68 -0
  22. package/modules/images/runtime/types.d.ts +77 -0
  23. package/modules/images/runtime/types.mjs +0 -0
  24. package/package.json +7 -1
  25. package/server/lib/pages.mjs +20 -21
  26. package/server/lib/render.mjs +28 -10
  27. package/server/renderer.d.ts +1 -1
  28. package/server/renderer.mjs +2 -1
  29. package/src/public/components.d.ts +3 -0
  30. package/src/public/components.mjs +3 -0
  31. package/src/public/index.d.ts +5 -3
  32. package/src/public/index.mjs +1 -0
  33. package/src/public/modules/images.d.ts +2 -0
  34. package/src/public/modules/images.mjs +1 -0
  35. package/src/public/query-content.d.ts +7 -0
  36. package/src/public/query-content.mjs +127 -0
  37. package/src/public/vite.mjs +18 -2
  38. package/src/runtime/components/MkImage.d.ts +188 -0
  39. package/src/runtime/components/MkImage.mjs +130 -0
  40. package/src/runtime/components/MkLink.d.ts +22 -0
  41. package/src/runtime/components/MkLink.mjs +72 -0
  42. package/src/runtime/components/MkPicture.d.ts +199 -0
  43. package/src/runtime/components/MkPicture.mjs +171 -0
  44. package/src/runtime/components/image-shared.d.ts +27 -0
  45. package/src/runtime/components/image-shared.mjs +51 -0
  46. package/src/runtime/config.d.ts +18 -0
  47. package/src/runtime/config.mjs +5 -2
  48. package/src/runtime/locale-routing.d.ts +12 -0
  49. package/src/runtime/locale-routing.mjs +93 -0
  50. package/src/runtime/page-discovery.mjs +8 -15
  51. package/src/runtime/pages.d.ts +16 -0
  52. package/src/runtime/virtual.d.ts +17 -0
  53. package/src/runtime/vue.mjs +6 -0
@@ -5,7 +5,9 @@ import bases from "virtual:flow/bases";
5
5
  import layouts from "virtual:flow/layouts";
6
6
  import templates from "virtual:flow/templates";
7
7
  import { createSSRApp, defineComponent, h } from "vue";
8
+ import { getFlowImageRuntimeUtils } from "../../modules/images/runtime/server.mjs";
8
9
  import { installFlowVuePlugins } from "../../src/runtime/vue";
10
+ import { getUrl, getUrls } from "./pages.mjs";
9
11
  function escapeHtml(value) {
10
12
  return value.replaceAll("&", "&amp;").replaceAll("<", "&lt;").replaceAll(">", "&gt;").replaceAll('"', "&quot;").replaceAll("'", "&#39;");
11
13
  }
@@ -95,18 +97,32 @@ async function renderBody(page) {
95
97
  head: head2
96
98
  };
97
99
  }
100
+ const context = {
101
+ page: page.definition,
102
+ context: page.context,
103
+ head: page.head,
104
+ seo: page.seo,
105
+ locale: page.locale,
106
+ params: page.params,
107
+ path: page.pathname
108
+ };
109
+ const imageUtils = getFlowImageRuntimeUtils();
110
+ const utils = {
111
+ getLocale() {
112
+ return page.locale;
113
+ },
114
+ async getUrl(namePage, localeCode, options) {
115
+ return await getUrl(namePage, localeCode || page.locale.code, options);
116
+ },
117
+ async getUrls(withLocale, omitNoPublish) {
118
+ return await getUrls(withLocale, omitNoPublish);
119
+ },
120
+ ...imageUtils || {}
121
+ };
98
122
  const TemplateRoot = defineComponent({
99
123
  render() {
100
- const viewNode = h(TemplateComponent, {
101
- page: page.definition,
102
- context: page.context,
103
- head: page.head,
104
- seo: page.seo,
105
- locale: page.locale,
106
- params: page.params,
107
- path: page.pathname
108
- });
109
- const content = LayoutComponent ? h(LayoutComponent, {}, {
124
+ const viewNode = h(TemplateComponent, context);
125
+ const content = LayoutComponent ? h(LayoutComponent, context, {
110
126
  default: () => viewNode
111
127
  }) : viewNode;
112
128
  return h(UApp, {}, {
@@ -115,6 +131,8 @@ async function renderBody(page) {
115
131
  }
116
132
  });
117
133
  const app = createSSRApp(TemplateRoot);
134
+ app.provide("context", context);
135
+ app.provide("utils", utils);
118
136
  const head = createHead();
119
137
  head.push(normalizeSeoToHead(page.head, fallbackTitle, fallbackDescription));
120
138
  app.use(head);
@@ -1,3 +1,3 @@
1
1
  export default function renderPage(input: Request | {
2
2
  req?: Request;
3
- }): Promise<Response | undefined>;
3
+ }): Promise<any>;
@@ -38,7 +38,8 @@ async function resolvePrerenderFetchHandler() {
38
38
  export default async function renderPage(input) {
39
39
  const viteEnvs = globalThis.__nitro_vite_envs__;
40
40
  const request = resolveRequest(input);
41
- const viteFetchHandler = viteEnvs?.ssr?.fetch;
41
+ const viteEnv = viteEnvs?.ssr;
42
+ const viteFetchHandler = typeof viteEnv?.fetch === "function" ? viteEnv.fetch.bind(viteEnv) : void 0;
42
43
  if (!request) {
43
44
  return new Response("Not Found", { status: 404 });
44
45
  }
@@ -1 +1,4 @@
1
1
  export { default as FlowIsland } from '../runtime/components/FlowIsland.ts';
2
+ export { default as MkImage } from '../runtime/components/MkImage.ts';
3
+ export { default as MkLink } from '../runtime/components/MkLink.ts';
4
+ export { default as MkPicture } from '../runtime/components/MkPicture.ts';
@@ -1 +1,4 @@
1
1
  export { default as FlowIsland } from "../runtime/components/FlowIsland.mjs";
2
+ export { default as MkImage } from "../runtime/components/MkImage.mjs";
3
+ export { default as MkLink } from "../runtime/components/MkLink.mjs";
4
+ export { default as MkPicture } from "../runtime/components/MkPicture.mjs";
@@ -1,5 +1,7 @@
1
+ export type { ContentDirectoryNode, ContentEntry, ContentFileNode, ContentTreeNode, } from '../../modules/content/query.ts';
2
+ export type { FlowBootPayload } from '../runtime/boot.ts';
1
3
  export { defineFlowConfig, defineFlowModule, resolveFlowConfig } from '../runtime/config.ts';
4
+ export type { FlowConfig, UserFlowConfig, } from '../runtime/config.ts';
2
5
  export { definePage } from '../runtime/pages.ts';
3
- export type { FlowConfig, FlowLocale, HeadDefinition, PageContextInput, UserFlowConfig, } from '../runtime/config.ts';
4
- export type { FlowBootPayload } from '../runtime/boot.ts';
5
- export type { FlowHydrationMode, PageDefinition, PageLocaleDefinition, PageViewDefinition, } from '../runtime/pages.ts';
6
+ export type { FlowHydrationMode, FlowLocale, HeadDefinition, PageContextInput, PageDefinition, PageLocaleDefinition, PageViewDefinition, } from '../runtime/pages.ts';
7
+ export { queryContent } from './query-content.ts';
@@ -1,2 +1,3 @@
1
1
  export { defineFlowConfig, defineFlowModule, resolveFlowConfig } from "../runtime/config.mjs";
2
2
  export { definePage } from "../runtime/pages.mjs";
3
+ export { queryContent } from "./query-content.mjs";
@@ -0,0 +1,2 @@
1
+ export { default } from '../../../modules/images/module.ts';
2
+ export type { ImagesModuleOptions } from '../../../modules/images/module.ts';
@@ -0,0 +1 @@
1
+ export { default } from "../../../modules/images/module.mjs";
@@ -0,0 +1,7 @@
1
+ import type { ContentEntry, ContentTreeNode } from '../../modules/content/query.ts';
2
+ export interface QueryContentBuilder {
3
+ find: () => Promise<ContentEntry[]>;
4
+ findOne: () => Promise<ContentEntry | null>;
5
+ tree: () => Promise<ContentTreeNode[]>;
6
+ }
7
+ export declare function queryContent(path?: string): QueryContentBuilder;
@@ -0,0 +1,127 @@
1
+ const defaultContentConfig = {
2
+ apiBase: "/api/_content"
3
+ };
4
+ function getGlobalFetch() {
5
+ const candidate = globalThis.$fetch;
6
+ return typeof candidate === "function" ? candidate : void 0;
7
+ }
8
+ function withLeadingSlash(value) {
9
+ return value.startsWith("/") ? value : `/${value}`;
10
+ }
11
+ function withoutTrailingSlash(value) {
12
+ return value.endsWith("/") ? value.slice(0, -1) : value;
13
+ }
14
+ function normalizeQueryPath(path = "") {
15
+ if (!path) {
16
+ return "/";
17
+ }
18
+ const normalized = `/${path}`.replace(/\/+/g, "/");
19
+ return normalized.length > 1 && normalized.endsWith("/") ? normalized.slice(0, -1) : normalized;
20
+ }
21
+ function joinUrl(base, path = "") {
22
+ const normalizedBase = withoutTrailingSlash(base);
23
+ const normalizedPath = path ? withLeadingSlash(path) : "";
24
+ return `${normalizedBase}${normalizedPath}`;
25
+ }
26
+ function withQuery(url, params) {
27
+ if (!params || Object.keys(params).length === 0) {
28
+ return url;
29
+ }
30
+ const origin = typeof window !== "undefined" ? window.location.origin : "http://localhost:3000";
31
+ const target = new URL(url, origin);
32
+ Object.entries(params).forEach(([key, value]) => {
33
+ if (value == null || value === "") {
34
+ return;
35
+ }
36
+ target.searchParams.set(key, String(value));
37
+ });
38
+ return target.toString();
39
+ }
40
+ async function getRuntimeConfig() {
41
+ if (typeof window !== "undefined") {
42
+ return void 0;
43
+ }
44
+ try {
45
+ const loadRuntimeModule = new Function("specifier", "return import(specifier);");
46
+ const runtime = await loadRuntimeModule("nitro/runtime-config");
47
+ return typeof runtime.useRuntimeConfig === "function" ? runtime.useRuntimeConfig() : void 0;
48
+ } catch {
49
+ return void 0;
50
+ }
51
+ }
52
+ async function getNitroFetch() {
53
+ if (typeof window !== "undefined") {
54
+ return void 0;
55
+ }
56
+ try {
57
+ const loadNitroModule = new Function("specifier", "return import(specifier);");
58
+ const runtime = await loadNitroModule("nitro/app");
59
+ return typeof runtime.fetch === "function" ? runtime.fetch : void 0;
60
+ } catch {
61
+ return void 0;
62
+ }
63
+ }
64
+ async function resolveContentApiBase() {
65
+ const runtimeConfig = await getRuntimeConfig();
66
+ return runtimeConfig?.flow?.content?.apiBase || runtimeConfig?.public?.flow?.content?.apiBase || defaultContentConfig.apiBase;
67
+ }
68
+ async function resolveAbsoluteContentApiBase() {
69
+ const runtimeConfig = await getRuntimeConfig();
70
+ const apiBase = await resolveContentApiBase();
71
+ if (typeof window !== "undefined") {
72
+ return apiBase;
73
+ }
74
+ if (runtimeConfig?.flow?.siteUrl) {
75
+ return joinUrl(runtimeConfig.flow.siteUrl, apiBase);
76
+ }
77
+ return joinUrl("http://localhost:3000", apiBase);
78
+ }
79
+ async function fetchContent(route, path) {
80
+ const apiBase = await resolveContentApiBase();
81
+ const query = path && path !== "/" ? { path } : void 0;
82
+ const localFetch = getGlobalFetch();
83
+ const nitroFetch = await getNitroFetch();
84
+ if (typeof window === "undefined" && localFetch) {
85
+ return await localFetch(joinUrl(apiBase, route), {
86
+ headers: {
87
+ accept: "application/json"
88
+ },
89
+ query
90
+ });
91
+ }
92
+ if (typeof window === "undefined" && nitroFetch) {
93
+ return await nitroFetch(joinUrl(apiBase, route), {
94
+ headers: {
95
+ accept: "application/json"
96
+ },
97
+ query
98
+ });
99
+ }
100
+ const absoluteBase = await resolveAbsoluteContentApiBase();
101
+ const target = withQuery(joinUrl(absoluteBase, route), query);
102
+ const response = await fetch(target, {
103
+ headers: {
104
+ accept: "application/json"
105
+ }
106
+ });
107
+ if (!response.ok) {
108
+ const details = await response.text();
109
+ throw new Error(`Content request failed (${response.status} ${response.statusText}): ${details}`);
110
+ }
111
+ return await response.json();
112
+ }
113
+ export function queryContent(path = "") {
114
+ const normalizedPath = normalizeQueryPath(path);
115
+ return {
116
+ async find() {
117
+ return await fetchContent("query", normalizedPath);
118
+ },
119
+ async findOne() {
120
+ const entries = await this.find();
121
+ return entries[0] || null;
122
+ },
123
+ async tree() {
124
+ return await fetchContent("tree", normalizedPath);
125
+ }
126
+ };
127
+ }
@@ -210,6 +210,10 @@ export function createFlowViteConfig(options = {}) {
210
210
  const flowNitroHooks = flowNitroConfig.hooks || {};
211
211
  const flowPackagePattern = /^@monkeyplus\/flow(?:\/.*)?$/;
212
212
  const userPrerenderRoutesHook = typeof flowNitroHooks["prerender:routes"] === "function" ? flowNitroHooks["prerender:routes"] : void 0;
213
+ const configuredServer = flowConfig.server || {};
214
+ const moduleServer = flowModules.vite.server || { watch: { additionalPaths: [] } };
215
+ const configuredWatch = typeof configuredServer.watch === "object" && configuredServer.watch ? configuredServer.watch : {};
216
+ const moduleWatch = typeof moduleServer.watch === "object" && moduleServer.watch ? moduleServer.watch : {};
213
217
  return defineConfig({
214
218
  plugins: [
215
219
  createFlowVirtualServerModules(projectRoot, flowConfig),
@@ -224,10 +228,14 @@ export function createFlowViteConfig(options = {}) {
224
228
  ui({
225
229
  router: false,
226
230
  components: {
231
+ ...options.userFlowConfig?.components,
227
232
  resolvers: [
228
- IconsResolver()
233
+ IconsResolver(),
234
+ ...options.userFlowConfig?.components?.resolvers || []
229
235
  ]
230
- }
236
+ // dirs: [],
237
+ },
238
+ autoImport: options.userFlowConfig?.autoImport
231
239
  }),
232
240
  nitro({
233
241
  ...flowNitroConfig,
@@ -270,6 +278,14 @@ export function createFlowViteConfig(options = {}) {
270
278
  ...flowModules.vite.resolve.alias
271
279
  }
272
280
  },
281
+ server: {
282
+ ...configuredServer,
283
+ ...moduleServer,
284
+ watch: {
285
+ ...configuredWatch,
286
+ ...moduleWatch
287
+ }
288
+ },
273
289
  ssr: {
274
290
  noExternal: [flowPackagePattern]
275
291
  }
@@ -0,0 +1,188 @@
1
+ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
2
+ src: {
3
+ type: StringConstructor;
4
+ required: true;
5
+ };
6
+ rename: StringConstructor;
7
+ eWidth: (StringConstructor | NumberConstructor)[];
8
+ eHeight: (StringConstructor | NumberConstructor)[];
9
+ sync: BooleanConstructor;
10
+ thumb: (StringConstructor | BooleanConstructor)[];
11
+ thumbnail: {
12
+ type: (StringConstructor | BooleanConstructor)[];
13
+ default: undefined;
14
+ };
15
+ format: {
16
+ type: StringConstructor;
17
+ default: undefined;
18
+ };
19
+ quality: {
20
+ type: (StringConstructor | NumberConstructor)[];
21
+ default: undefined;
22
+ };
23
+ background: {
24
+ type: StringConstructor;
25
+ default: undefined;
26
+ };
27
+ fit: {
28
+ type: StringConstructor;
29
+ default: undefined;
30
+ };
31
+ modifiers: {
32
+ type: () => Record<string, any>;
33
+ default: undefined;
34
+ };
35
+ preset: {
36
+ type: StringConstructor;
37
+ default: undefined;
38
+ };
39
+ provider: {
40
+ type: StringConstructor;
41
+ default: undefined;
42
+ };
43
+ sizes: {
44
+ type: () => string | Record<string, any>;
45
+ default: undefined;
46
+ };
47
+ width: {
48
+ type: (StringConstructor | NumberConstructor)[];
49
+ default: undefined;
50
+ };
51
+ height: {
52
+ type: (StringConstructor | NumberConstructor)[];
53
+ default: undefined;
54
+ };
55
+ alt: {
56
+ type: StringConstructor;
57
+ default: undefined;
58
+ };
59
+ title: {
60
+ type: StringConstructor;
61
+ default: undefined;
62
+ };
63
+ referrerpolicy: {
64
+ type: StringConstructor;
65
+ default: undefined;
66
+ };
67
+ usemap: {
68
+ type: StringConstructor;
69
+ default: undefined;
70
+ };
71
+ longdesc: {
72
+ type: StringConstructor;
73
+ default: undefined;
74
+ };
75
+ ismap: {
76
+ type: BooleanConstructor;
77
+ default: undefined;
78
+ };
79
+ loading: {
80
+ type: StringConstructor;
81
+ default: undefined;
82
+ };
83
+ }>, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
84
+ [key: string]: any;
85
+ }>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
86
+ src: {
87
+ type: StringConstructor;
88
+ required: true;
89
+ };
90
+ rename: StringConstructor;
91
+ eWidth: (StringConstructor | NumberConstructor)[];
92
+ eHeight: (StringConstructor | NumberConstructor)[];
93
+ sync: BooleanConstructor;
94
+ thumb: (StringConstructor | BooleanConstructor)[];
95
+ thumbnail: {
96
+ type: (StringConstructor | BooleanConstructor)[];
97
+ default: undefined;
98
+ };
99
+ format: {
100
+ type: StringConstructor;
101
+ default: undefined;
102
+ };
103
+ quality: {
104
+ type: (StringConstructor | NumberConstructor)[];
105
+ default: undefined;
106
+ };
107
+ background: {
108
+ type: StringConstructor;
109
+ default: undefined;
110
+ };
111
+ fit: {
112
+ type: StringConstructor;
113
+ default: undefined;
114
+ };
115
+ modifiers: {
116
+ type: () => Record<string, any>;
117
+ default: undefined;
118
+ };
119
+ preset: {
120
+ type: StringConstructor;
121
+ default: undefined;
122
+ };
123
+ provider: {
124
+ type: StringConstructor;
125
+ default: undefined;
126
+ };
127
+ sizes: {
128
+ type: () => string | Record<string, any>;
129
+ default: undefined;
130
+ };
131
+ width: {
132
+ type: (StringConstructor | NumberConstructor)[];
133
+ default: undefined;
134
+ };
135
+ height: {
136
+ type: (StringConstructor | NumberConstructor)[];
137
+ default: undefined;
138
+ };
139
+ alt: {
140
+ type: StringConstructor;
141
+ default: undefined;
142
+ };
143
+ title: {
144
+ type: StringConstructor;
145
+ default: undefined;
146
+ };
147
+ referrerpolicy: {
148
+ type: StringConstructor;
149
+ default: undefined;
150
+ };
151
+ usemap: {
152
+ type: StringConstructor;
153
+ default: undefined;
154
+ };
155
+ longdesc: {
156
+ type: StringConstructor;
157
+ default: undefined;
158
+ };
159
+ ismap: {
160
+ type: BooleanConstructor;
161
+ default: undefined;
162
+ };
163
+ loading: {
164
+ type: StringConstructor;
165
+ default: undefined;
166
+ };
167
+ }>> & Readonly<{}>, {
168
+ width: string | number;
169
+ height: string | number;
170
+ fit: string;
171
+ format: string;
172
+ provider: string;
173
+ preset: string;
174
+ modifiers: Record<string, any>;
175
+ sizes: string | Record<string, any>;
176
+ alt: string;
177
+ referrerpolicy: string;
178
+ usemap: string;
179
+ longdesc: string;
180
+ ismap: boolean;
181
+ loading: string;
182
+ quality: string | number;
183
+ background: string;
184
+ title: string;
185
+ sync: boolean;
186
+ thumbnail: string | boolean;
187
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
188
+ export default _default;
@@ -0,0 +1,130 @@
1
+ import { computed, defineComponent, h } from "vue";
2
+ import { parseSize } from "../../../modules/images/runtime/helpers.mjs";
3
+ import { useImage } from "./image-shared.mjs";
4
+ function resolveImageSource(value, fallback) {
5
+ if (typeof value === "string" && value.length) {
6
+ return value;
7
+ }
8
+ if (value && typeof value === "object" && typeof value.url === "string") {
9
+ return value.url;
10
+ }
11
+ return fallback;
12
+ }
13
+ function getLocalSource(src) {
14
+ return src.startsWith("http") ? "" : src;
15
+ }
16
+ function isRuntimeLambda() {
17
+ const runtimeProcess = typeof globalThis === "object" ? Reflect.get(globalThis, "process") : void 0;
18
+ return !!(runtimeProcess?.env?.LAMBDA_TASK_ROOT || runtimeProcess?.env?.AWS_LAMBDA_FUNCTION_VERSION);
19
+ }
20
+ function resolveThumbnailValue(value, fallback) {
21
+ return value !== void 0 ? value : fallback;
22
+ }
23
+ export default defineComponent({
24
+ name: "MkImage",
25
+ inheritAttrs: false,
26
+ props: {
27
+ src: {
28
+ type: String,
29
+ required: true
30
+ },
31
+ rename: String,
32
+ eWidth: [String, Number],
33
+ eHeight: [String, Number],
34
+ sync: Boolean,
35
+ thumb: [Boolean, String],
36
+ thumbnail: { type: [Boolean, String], default: void 0 },
37
+ format: { type: String, default: void 0 },
38
+ quality: { type: [Number, String], default: void 0 },
39
+ background: { type: String, default: void 0 },
40
+ fit: { type: String, default: void 0 },
41
+ modifiers: {
42
+ type: Object,
43
+ default: void 0
44
+ },
45
+ preset: { type: String, default: void 0 },
46
+ provider: { type: String, default: void 0 },
47
+ sizes: {
48
+ type: [Object, String],
49
+ default: void 0
50
+ },
51
+ width: { type: [String, Number], default: void 0 },
52
+ height: { type: [String, Number], default: void 0 },
53
+ alt: { type: String, default: void 0 },
54
+ title: { type: String, default: void 0 },
55
+ referrerpolicy: { type: String, default: void 0 },
56
+ usemap: { type: String, default: void 0 },
57
+ longdesc: { type: String, default: void 0 },
58
+ ismap: { type: Boolean, default: void 0 },
59
+ loading: { type: String, default: void 0 }
60
+ },
61
+ setup(props, { attrs }) {
62
+ const { imageUtils, image, nImgAttrs, nModifiers, nOption } = useImage(props);
63
+ const options = computed(() => imageUtils.getImageOptions?.() || {
64
+ lazy: true,
65
+ screens: {},
66
+ domains: {},
67
+ presets: {},
68
+ baseURL: "/_ipx",
69
+ dirImages: "/images"
70
+ });
71
+ const nSizes = computed(() => {
72
+ if (!props.sizes || !imageUtils.getImage?.getSizes) {
73
+ return void 0;
74
+ }
75
+ return imageUtils.getImage.getSizes(props.src, {
76
+ ...nOption.value,
77
+ sizes: props.sizes,
78
+ modifiers: {
79
+ ...nModifiers.value,
80
+ width: parseSize(props.width),
81
+ height: parseSize(props.height)
82
+ }
83
+ });
84
+ });
85
+ const nAttrs = computed(() => {
86
+ const resolvedAttrs = {
87
+ ...nImgAttrs.value
88
+ };
89
+ if (nSizes.value) {
90
+ resolvedAttrs.sizes = nSizes.value.sizes;
91
+ resolvedAttrs.srcset = nSizes.value.srcset;
92
+ }
93
+ if (options.value.lazy && !props.sync && !resolvedAttrs.loading) {
94
+ resolvedAttrs.loading = "lazy";
95
+ }
96
+ return resolvedAttrs;
97
+ });
98
+ const nSrc = computed(() => {
99
+ const normal = nSizes.value?.src || resolveImageSource(
100
+ imageUtils.getImage?.(props.src, nModifiers.value, nOption.value),
101
+ props.src
102
+ );
103
+ const thumb = resolveThumbnailValue(props.thumbnail, props.thumb);
104
+ const thumbnail = typeof thumb === "string" ? thumb : thumb ? resolveImageSource(
105
+ imageUtils.getImage?.(props.src, { quality: 10, width: 60 }, nOption.value),
106
+ props.src
107
+ ) : void 0;
108
+ return {
109
+ normal,
110
+ thumbnail
111
+ };
112
+ });
113
+ return () => {
114
+ const compatibilityThumb = !isRuntimeLambda() && nSrc.value.thumbnail;
115
+ return h("img", {
116
+ ...attrs,
117
+ ...nAttrs.value,
118
+ "src": isRuntimeLambda() ? props.src : compatibilityThumb || nSrc.value.normal,
119
+ "data-src": compatibilityThumb ? nSrc.value.normal : void 0,
120
+ "data-thumb": compatibilityThumb,
121
+ "alt": props.alt || image.value.alt,
122
+ "title": props.title || image.value.title,
123
+ "class": compatibilityThumb ? [attrs.class, "lazyload"] : attrs.class,
124
+ "width": props.eWidth || nAttrs.value.width,
125
+ "height": props.eHeight || nAttrs.value.height,
126
+ "x-src": getLocalSource(props.src)
127
+ });
128
+ };
129
+ }
130
+ });
@@ -0,0 +1,22 @@
1
+ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
2
+ isSlot: BooleanConstructor;
3
+ to: {
4
+ type: StringConstructor;
5
+ required: true;
6
+ };
7
+ locale: StringConstructor;
8
+ }>, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
9
+ [key: string]: any;
10
+ }> | import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
11
+ [key: string]: any;
12
+ }>[] | null, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
13
+ isSlot: BooleanConstructor;
14
+ to: {
15
+ type: StringConstructor;
16
+ required: true;
17
+ };
18
+ locale: StringConstructor;
19
+ }>> & Readonly<{}>, {
20
+ isSlot: boolean;
21
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
22
+ export default _default;