grantthomas-nuxt 1.0.29 → 1.0.31
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/dist/module.json +1 -1
- package/dist/module.mjs +0 -1
- package/dist/runtime/components/CrudImageCropper.d.vue.ts +9 -0
- package/dist/runtime/components/CrudImageCropper.vue +12 -1
- package/dist/runtime/components/CrudImageCropper.vue.d.ts +9 -0
- package/dist/runtime/components/CrudUploadField.vue +7 -50
- package/package.json +1 -1
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -22,7 +22,6 @@ const module$1 = defineNuxtModule({
|
|
|
22
22
|
const resolver = createResolver(import.meta.url);
|
|
23
23
|
nuxt.options.runtimeConfig.public.grantThomasNuxt = options;
|
|
24
24
|
nuxt.options.build.transpile.push("qs");
|
|
25
|
-
nuxt.options.build.transpile.push("heic2any");
|
|
26
25
|
addServerHandler({
|
|
27
26
|
route: "/api/maps/autocomplete",
|
|
28
27
|
handler: resolver.resolve("runtime/server/api/maps/autocomplete")
|
|
@@ -36,6 +36,10 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
|
|
|
36
36
|
type: StringConstructor;
|
|
37
37
|
default: null;
|
|
38
38
|
};
|
|
39
|
+
hideAspectRatioSelector: {
|
|
40
|
+
type: BooleanConstructor;
|
|
41
|
+
default: boolean;
|
|
42
|
+
};
|
|
39
43
|
}>, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
40
44
|
error: (...args: any[]) => void;
|
|
41
45
|
cancel: (...args: any[]) => void;
|
|
@@ -78,6 +82,10 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
|
|
|
78
82
|
type: StringConstructor;
|
|
79
83
|
default: null;
|
|
80
84
|
};
|
|
85
|
+
hideAspectRatioSelector: {
|
|
86
|
+
type: BooleanConstructor;
|
|
87
|
+
default: boolean;
|
|
88
|
+
};
|
|
81
89
|
}>> & Readonly<{
|
|
82
90
|
onError?: ((...args: any[]) => any) | undefined;
|
|
83
91
|
onCancel?: ((...args: any[]) => any) | undefined;
|
|
@@ -93,4 +101,5 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
|
|
|
93
101
|
outputMimeType: string;
|
|
94
102
|
quality: number;
|
|
95
103
|
fileName: string;
|
|
104
|
+
hideAspectRatioSelector: boolean;
|
|
96
105
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
@@ -35,6 +35,10 @@ const props = defineProps({
|
|
|
35
35
|
fileName: {
|
|
36
36
|
type: String,
|
|
37
37
|
default: null
|
|
38
|
+
},
|
|
39
|
+
hideAspectRatioSelector: {
|
|
40
|
+
type: Boolean,
|
|
41
|
+
default: false
|
|
38
42
|
}
|
|
39
43
|
});
|
|
40
44
|
const emit = defineEmits(["crop", "cancel", "ready", "change", "error"]);
|
|
@@ -54,7 +58,7 @@ const aspectRatioOptions = [
|
|
|
54
58
|
];
|
|
55
59
|
const selectedAspectRatio = ref(props.defaultAspectRatio || null);
|
|
56
60
|
const showAspectRatioSelector = computed(() => {
|
|
57
|
-
return props.aspectRatio === null;
|
|
61
|
+
return props.aspectRatio === null && !props.hideAspectRatioSelector;
|
|
58
62
|
});
|
|
59
63
|
const parsedAspectRatio = computed(() => {
|
|
60
64
|
const ratioString = props.aspectRatio || selectedAspectRatio.value;
|
|
@@ -78,6 +82,12 @@ const stencilProps = computed(() => {
|
|
|
78
82
|
}
|
|
79
83
|
return props2;
|
|
80
84
|
});
|
|
85
|
+
const defaultSize = ({ imageSize, visibleArea }) => {
|
|
86
|
+
return {
|
|
87
|
+
width: imageSize.width,
|
|
88
|
+
height: imageSize.height
|
|
89
|
+
};
|
|
90
|
+
};
|
|
81
91
|
const finalOutputMimeType = computed(() => {
|
|
82
92
|
const type = props.outputMimeType || actualMimeType.value || props.mimeType || "image/png";
|
|
83
93
|
const supportedTypes = ["image/png", "image/jpeg", "image/webp"];
|
|
@@ -240,6 +250,7 @@ const onError = (error) => {
|
|
|
240
250
|
ref="cropper"
|
|
241
251
|
:src="processedImageUrl"
|
|
242
252
|
:stencil-props="stencilProps"
|
|
253
|
+
:default-size="defaultSize"
|
|
243
254
|
class="cropper"
|
|
244
255
|
@ready="onReady"
|
|
245
256
|
@change="onChange"
|
|
@@ -36,6 +36,10 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
|
|
|
36
36
|
type: StringConstructor;
|
|
37
37
|
default: null;
|
|
38
38
|
};
|
|
39
|
+
hideAspectRatioSelector: {
|
|
40
|
+
type: BooleanConstructor;
|
|
41
|
+
default: boolean;
|
|
42
|
+
};
|
|
39
43
|
}>, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
40
44
|
error: (...args: any[]) => void;
|
|
41
45
|
cancel: (...args: any[]) => void;
|
|
@@ -78,6 +82,10 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
|
|
|
78
82
|
type: StringConstructor;
|
|
79
83
|
default: null;
|
|
80
84
|
};
|
|
85
|
+
hideAspectRatioSelector: {
|
|
86
|
+
type: BooleanConstructor;
|
|
87
|
+
default: boolean;
|
|
88
|
+
};
|
|
81
89
|
}>> & Readonly<{
|
|
82
90
|
onError?: ((...args: any[]) => any) | undefined;
|
|
83
91
|
onCancel?: ((...args: any[]) => any) | undefined;
|
|
@@ -93,4 +101,5 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
|
|
|
93
101
|
outputMimeType: string;
|
|
94
102
|
quality: number;
|
|
95
103
|
fileName: string;
|
|
104
|
+
hideAspectRatioSelector: boolean;
|
|
96
105
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
<script setup>
|
|
2
2
|
import { ref, computed, watch } from "vue";
|
|
3
|
+
import { heicTo } from "heic-to";
|
|
3
4
|
import { useCrudApi } from "../composables/useCrudApi";
|
|
4
5
|
import { useCrudConverters } from "../composables/useCrudConverters";
|
|
5
6
|
import CrudErrorDisplay from "../components/CrudErrorDisplay.vue";
|
|
@@ -165,69 +166,25 @@ const isHeicFile = (file) => {
|
|
|
165
166
|
if (!file) return false;
|
|
166
167
|
return file.type === "image/heic" || file.type === "image/heic-sequence" || file.name.toLowerCase().endsWith(".heic") || file.name.toLowerCase().endsWith(".heics");
|
|
167
168
|
};
|
|
168
|
-
let heic2anyConverter = null;
|
|
169
|
-
const loadHeic2any = async () => {
|
|
170
|
-
if (!heic2anyConverter) {
|
|
171
|
-
try {
|
|
172
|
-
let module;
|
|
173
|
-
try {
|
|
174
|
-
module = await import("heic2any");
|
|
175
|
-
} catch (e) {
|
|
176
|
-
console.warn("Dynamic import failed:", e);
|
|
177
|
-
throw new Error("heic2any module not found. Please ensure it is installed in your project.");
|
|
178
|
-
}
|
|
179
|
-
if (typeof module.default === "function") {
|
|
180
|
-
heic2anyConverter = module.default;
|
|
181
|
-
} else if (typeof module.heic2any === "function") {
|
|
182
|
-
heic2anyConverter = module.heic2any;
|
|
183
|
-
} else if (typeof module === "function") {
|
|
184
|
-
heic2anyConverter = module;
|
|
185
|
-
} else if (typeof window !== "undefined" && typeof window.heic2any === "function") {
|
|
186
|
-
heic2anyConverter = window.heic2any;
|
|
187
|
-
} else if (module.default && typeof module.default === "object") {
|
|
188
|
-
const possibleKeys = ["default", "heic2any", "convert", "convertHeic"];
|
|
189
|
-
for (const key of possibleKeys) {
|
|
190
|
-
if (typeof module.default[key] === "function") {
|
|
191
|
-
heic2anyConverter = module.default[key];
|
|
192
|
-
break;
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
if (typeof heic2anyConverter !== "function") {
|
|
197
|
-
throw new Error("heic2any function not found in module");
|
|
198
|
-
}
|
|
199
|
-
} catch (error) {
|
|
200
|
-
console.error("Failed to load heic2any:", error);
|
|
201
|
-
throw new Error("Failed to load HEIC converter. Please ensure heic2any is installed: npm install heic2any");
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
return heic2anyConverter;
|
|
205
|
-
};
|
|
206
169
|
const convertHeicToJpeg = async (file) => {
|
|
207
170
|
try {
|
|
208
171
|
convertingHeic.value = true;
|
|
209
|
-
const
|
|
210
|
-
const convertedBlob = await heic2any({
|
|
172
|
+
const convertedBlob = await heicTo({
|
|
211
173
|
blob: file,
|
|
212
|
-
|
|
174
|
+
type: "image/jpeg",
|
|
213
175
|
quality: 0.9
|
|
214
176
|
});
|
|
215
|
-
const blob = Array.isArray(convertedBlob) ? convertedBlob[0] : convertedBlob;
|
|
216
177
|
return new File(
|
|
217
|
-
[
|
|
178
|
+
[convertedBlob],
|
|
218
179
|
file.name.replace(/\.heic$/i, ".jpg"),
|
|
219
180
|
{ type: "image/jpeg" }
|
|
220
181
|
);
|
|
221
182
|
} catch (error) {
|
|
222
183
|
console.error("HEIC conversion failed:", error);
|
|
223
|
-
if (error
|
|
224
|
-
throw new Error(
|
|
225
|
-
} else if (error.code === 1 || error.message?.includes("corrupt")) {
|
|
226
|
-
throw new Error("This HEIC file appears to be corrupted. Please try a different file.");
|
|
227
|
-
} else if (error.message?.includes("load HEIC converter") || error.message?.includes("installed") || error.message?.includes("not found")) {
|
|
228
|
-
throw error;
|
|
184
|
+
if (error && error.message) {
|
|
185
|
+
throw new Error(`HEIC conversion failed: ${error.message}`);
|
|
229
186
|
} else {
|
|
230
|
-
throw new Error("Failed to convert HEIC image.
|
|
187
|
+
throw new Error("Failed to convert HEIC image. The file may be corrupted or use an unsupported format.");
|
|
231
188
|
}
|
|
232
189
|
} finally {
|
|
233
190
|
convertingHeic.value = false;
|