@live-change/image-frontend 0.0.3
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/LICENSE +21 -0
- package/front/index.html +11 -0
- package/front/public/favicon.ico +0 -0
- package/front/public/images/empty-photo.svg +38 -0
- package/front/public/images/empty-user-photo.svg +33 -0
- package/front/public/images/logo.svg +34 -0
- package/front/public/images/logo128.png +0 -0
- package/front/src/App.vue +32 -0
- package/front/src/EditorTest.vue +28 -0
- package/front/src/Image.vue +137 -0
- package/front/src/ImageCrop.vue +382 -0
- package/front/src/ImageEditor.vue +211 -0
- package/front/src/ImageUpload.js +132 -0
- package/front/src/NavBar.vue +105 -0
- package/front/src/UploadTest.vue +57 -0
- package/front/src/dom.js +82 -0
- package/front/src/entry-client.js +6 -0
- package/front/src/entry-server.js +6 -0
- package/front/src/imageResizer.js +5 -0
- package/front/src/imageUploads.js +29 -0
- package/front/src/imageUtils.js +438 -0
- package/front/src/preprocessImageFile.js +122 -0
- package/front/src/router.js +41 -0
- package/front/vite.config.js +18 -0
- package/index.js +7 -0
- package/package.json +76 -0
- package/server/init.js +5 -0
- package/server/services.config.js +17 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2021 Michał Łaszczewski
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/front/index.html
ADDED
|
Binary file
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
|
2
|
+
<!-- Generator: Adobe Illustrator 16.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
|
3
|
+
|
|
4
|
+
<svg
|
|
5
|
+
version="1.1"
|
|
6
|
+
id="Layer_1"
|
|
7
|
+
x="0px"
|
|
8
|
+
y="0px"
|
|
9
|
+
width="512px"
|
|
10
|
+
height="512px"
|
|
11
|
+
viewBox="0 0 512 512"
|
|
12
|
+
enable-background="new 0 0 512 512"
|
|
13
|
+
xml:space="preserve"
|
|
14
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
15
|
+
xmlns:svg="http://www.w3.org/2000/svg"
|
|
16
|
+
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
|
17
|
+
xmlns:cc="http://creativecommons.org/ns#"
|
|
18
|
+
xmlns:dc="http://purl.org/dc/elements/1.1/"><metadata
|
|
19
|
+
id="metadata9"><rdf:RDF><cc:Work
|
|
20
|
+
rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
|
|
21
|
+
rdf:resource="http://purl.org/dc/dcmitype/StillImage" /></cc:Work></rdf:RDF></metadata><defs
|
|
22
|
+
id="defs7" />
|
|
23
|
+
<rect
|
|
24
|
+
style="fill:#dbdbdb;fill-opacity:1;stroke:none;stroke-width:1.88976383;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
|
25
|
+
id="rect821"
|
|
26
|
+
width="512.54236"
|
|
27
|
+
height="512.54236"
|
|
28
|
+
x="0.54237288"
|
|
29
|
+
y="0.54237235" />
|
|
30
|
+
<path
|
|
31
|
+
style="fill:#f6f6f6;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
|
|
32
|
+
d="M 0.54237288,470.23729 125.83051,306.44068 l 60.20339,70.50847 130.71186,-174.10169 195.79661,261.42373 0.54235,48.81353 H 0.54237288 Z"
|
|
33
|
+
id="path816" /><circle
|
|
34
|
+
style="fill:#f6f6f6;fill-opacity:1;stroke:none;stroke-width:4.80000019;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
|
35
|
+
id="path818"
|
|
36
|
+
cx="118.50848"
|
|
37
|
+
cy="106.57627"
|
|
38
|
+
r="57.762711" /></svg>
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
|
2
|
+
<!-- Generator: Adobe Illustrator 16.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
|
3
|
+
|
|
4
|
+
<svg
|
|
5
|
+
version="1.1"
|
|
6
|
+
id="Layer_1"
|
|
7
|
+
x="0px"
|
|
8
|
+
y="0px"
|
|
9
|
+
width="512px"
|
|
10
|
+
height="512px"
|
|
11
|
+
viewBox="0 0 512 512"
|
|
12
|
+
enable-background="new 0 0 512 512"
|
|
13
|
+
xml:space="preserve"
|
|
14
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
15
|
+
xmlns:svg="http://www.w3.org/2000/svg"
|
|
16
|
+
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
|
17
|
+
xmlns:cc="http://creativecommons.org/ns#"
|
|
18
|
+
xmlns:dc="http://purl.org/dc/elements/1.1/"><metadata
|
|
19
|
+
id="metadata9"><rdf:RDF><cc:Work
|
|
20
|
+
rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
|
|
21
|
+
rdf:resource="http://purl.org/dc/dcmitype/StillImage" /></cc:Work></rdf:RDF></metadata><defs
|
|
22
|
+
id="defs7" />
|
|
23
|
+
<rect
|
|
24
|
+
style="fill:#dbdbdb;fill-opacity:1;stroke:none;stroke-width:1.88976383;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
|
25
|
+
id="rect821"
|
|
26
|
+
width="512.54236"
|
|
27
|
+
height="512.54236"
|
|
28
|
+
x="0.54237288"
|
|
29
|
+
y="0.54237235" /><path
|
|
30
|
+
d="m 313.14122,310.64877 c 9.02181,-8.85097 12.15686,-31.23733 20.41627,-39.3056 11.69771,-11.43183 24.39381,-25.50218 27.98588,-43.06851 4.82003,-23.34203 -4.96846,-26.30516 -4.96846,-34.3713 0,-16.90002 -0.15376,-44.65739 -5.43081,-62.68607 -0.30326,-23.7809 -4.20499,-34.123578 -12.38858,-43.031138 -7.72017,-8.33522 -26.68637,-6.366203 -36.59125,-11.85361 C 286.83605,67.825407 274.23818,64.594254 258.15823,64.17461 v -0.09503 c -0.47624,0 -0.93539,0.05659 -1.41162,0.05659 -0.78484,0 -1.53123,-0.05659 -2.35343,-0.05659 l 0.0395,0.151627 c -39.17105,1.472492 -80.84608,26.170627 -95.16524,65.895863 -5.31335,14.71958 -3.28881,46.87521 -3.28881,63.77522 0,8.06721 -9.78742,11.02927 -4.96846,34.37131 3.61129,17.56632 16.28817,31.63668 27.98588,43.06851 8.26048,8.06827 11.39446,30.45462 20.39705,39.30559 1.96902,13.0378 2.1986,9.31012 2.12278,21.23954 -0.0203,4.03307 0.11426,10.28502 -6.32669,16.4398 -12.17822,11.6614 -40.14595,36.95324 -63.08756,46.79832 -30.24,12.98014 -79.41203,33.74237 -90.746691,39.59069 -11.334661,5.84833 -41.2532541,21.69763 -41.2532541,31.79045 0,10.11417 0,47.33542 0,47.33542 h 253.3742451 5.79494 253.37318 c 0,0 0,-37.22125 0,-47.33542 0,-10.09282 -29.89723,-25.94212 -41.25645,-31.79045 -11.35389,-5.84938 -60.48321,-26.61055 -90.72641,-39.59069 -22.32976,-9.57707 -49.43685,-33.81712 -62.09344,-45.84158 -4.2808,-4.05228 -7.3016,-8.29784 -7.3411,-18.62023 -0.0737,-12.00417 0.23278,-7.41692 2.14306,-20.01478"
|
|
31
|
+
id="path2"
|
|
32
|
+
style="clip-rule:evenodd;fill-rule:evenodd;stroke-width:1.06779659;fill:#f6f6f6;fill-opacity:1" />
|
|
33
|
+
</svg>
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
|
2
|
+
<svg
|
|
3
|
+
width="512"
|
|
4
|
+
height="512"
|
|
5
|
+
viewBox="0 0 135.46667 135.46667"
|
|
6
|
+
version="1.1"
|
|
7
|
+
id="svg977"
|
|
8
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
9
|
+
xmlns:svg="http://www.w3.org/2000/svg"
|
|
10
|
+
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
|
11
|
+
xmlns:cc="http://creativecommons.org/ns#"
|
|
12
|
+
xmlns:dc="http://purl.org/dc/elements/1.1/">
|
|
13
|
+
<defs
|
|
14
|
+
id="defs971" />
|
|
15
|
+
<metadata
|
|
16
|
+
id="metadata974">
|
|
17
|
+
<rdf:RDF>
|
|
18
|
+
<cc:Work
|
|
19
|
+
rdf:about="">
|
|
20
|
+
<dc:format>image/svg+xml</dc:format>
|
|
21
|
+
<dc:type
|
|
22
|
+
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
|
23
|
+
</cc:Work>
|
|
24
|
+
</rdf:RDF>
|
|
25
|
+
</metadata>
|
|
26
|
+
<g
|
|
27
|
+
id="layer1"
|
|
28
|
+
style="fill:#666666">
|
|
29
|
+
<path
|
|
30
|
+
style="fill:#666666;fill-opacity:1;stroke:none;stroke-width:2.70907px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
|
|
31
|
+
d="M 54.181439,13.558436 67.726801,0.01304296 135.45359,67.739804 67.726801,135.46667 29.799793,97.539626 V 65.030766 L 13.545362,81.285197 0,67.739804 40.636077,27.103727 81.272154,67.739804 67.726801,81.285197 51.472371,65.030766 V 92.12155 l 16.25443,16.25433 40.636069,-40.636076 z"
|
|
32
|
+
id="path892" />
|
|
33
|
+
</g>
|
|
34
|
+
</svg>
|
|
Binary file
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<view-root>
|
|
3
|
+
<template #navbar>
|
|
4
|
+
<NavBar />
|
|
5
|
+
</template>
|
|
6
|
+
</view-root>
|
|
7
|
+
</template>
|
|
8
|
+
|
|
9
|
+
<script setup>
|
|
10
|
+
import 'primevue/resources/themes/saga-green/theme.css'
|
|
11
|
+
import "@fortawesome/fontawesome-free/css/all.min.css"
|
|
12
|
+
|
|
13
|
+
import ViewRoot from "@live-change/frontend-base/ViewRoot.vue"
|
|
14
|
+
import NavBar from "./NavBar.vue"
|
|
15
|
+
|
|
16
|
+
import { useMeta } from 'vue-meta'
|
|
17
|
+
const { meta } = useMeta({
|
|
18
|
+
title: 'Title',
|
|
19
|
+
htmlAttrs: {
|
|
20
|
+
lang: 'en',
|
|
21
|
+
amp: true
|
|
22
|
+
}
|
|
23
|
+
})
|
|
24
|
+
|
|
25
|
+
import { watch } from 'vue'
|
|
26
|
+
import { client as useClient } from '@live-change/vue3-ssr'
|
|
27
|
+
const client = useClient()
|
|
28
|
+
watch(client, (newClient, oldClient) => {
|
|
29
|
+
console.log("WATCH CLIENT", oldClient, '=>', newClient)
|
|
30
|
+
})
|
|
31
|
+
|
|
32
|
+
</script>
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="w-full">
|
|
3
|
+
<div class="w-full surface-0">
|
|
4
|
+
<h2 class="p-4">Editor:</h2>
|
|
5
|
+
<ImageEditor v-model="image" />
|
|
6
|
+
<!-- :source-image="'[Wc6P55MDs.0@1V6ZJBwyF_1I98X_]'"-->
|
|
7
|
+
</div>
|
|
8
|
+
<div v-if="image">
|
|
9
|
+
<h2>Preview:</h2>
|
|
10
|
+
<Image :image="image" width="200" height="200" :key="image" />
|
|
11
|
+
</div>
|
|
12
|
+
</div>
|
|
13
|
+
</template>
|
|
14
|
+
|
|
15
|
+
<script setup>
|
|
16
|
+
|
|
17
|
+
import ImageEditor from "./ImageEditor.vue";
|
|
18
|
+
import Image from "./Image.vue"
|
|
19
|
+
|
|
20
|
+
import { ref } from 'vue'
|
|
21
|
+
|
|
22
|
+
const image = ref()
|
|
23
|
+
|
|
24
|
+
</script>
|
|
25
|
+
|
|
26
|
+
<style scoped>
|
|
27
|
+
|
|
28
|
+
</style>
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<img
|
|
3
|
+
:src="url"
|
|
4
|
+
@load="ev => $emit('load', ev)"
|
|
5
|
+
:title="title"
|
|
6
|
+
ref="element">
|
|
7
|
+
</template>
|
|
8
|
+
|
|
9
|
+
<script setup>
|
|
10
|
+
|
|
11
|
+
import { api as useApi } from '@live-change/vue3-ssr'
|
|
12
|
+
const api = useApi()
|
|
13
|
+
|
|
14
|
+
import { ref, computed, watch } from 'vue'
|
|
15
|
+
import { useResizeObserver, refDebounced } from '@vueuse/core'
|
|
16
|
+
import { imageUploads } from "./imageUploads.js";
|
|
17
|
+
|
|
18
|
+
const props = defineProps({
|
|
19
|
+
image: {
|
|
20
|
+
type: String,
|
|
21
|
+
required: true
|
|
22
|
+
},
|
|
23
|
+
imageData: {
|
|
24
|
+
type: Object
|
|
25
|
+
},
|
|
26
|
+
width: {
|
|
27
|
+
},
|
|
28
|
+
height: {
|
|
29
|
+
},
|
|
30
|
+
noResize: {
|
|
31
|
+
},
|
|
32
|
+
domResize: {
|
|
33
|
+
default: false
|
|
34
|
+
},
|
|
35
|
+
empty: {
|
|
36
|
+
type: String,
|
|
37
|
+
default: "/static/images/empty-photo.svg"
|
|
38
|
+
},
|
|
39
|
+
title: {
|
|
40
|
+
type: String,
|
|
41
|
+
default: null
|
|
42
|
+
}
|
|
43
|
+
})
|
|
44
|
+
|
|
45
|
+
const upload = computed(() => {
|
|
46
|
+
return imageUploads.value.find(upload => upload.id == props.image)
|
|
47
|
+
})
|
|
48
|
+
|
|
49
|
+
const imageData = ref(props.imageData)
|
|
50
|
+
const reloadImageDataTimeout = 500
|
|
51
|
+
let tryCount = 0
|
|
52
|
+
|
|
53
|
+
let loadImagePromise = null
|
|
54
|
+
async function loadImageData() {
|
|
55
|
+
if(!loadImagePromise) loadImagePromise = (async () => {
|
|
56
|
+
const loaded = await api.get(['image', 'image', { image: props.image }])
|
|
57
|
+
//console.log("IM", props.image, "DATA", loaded)
|
|
58
|
+
loadImagePromise = null
|
|
59
|
+
if(loaded) {
|
|
60
|
+
const { width, height } = loaded
|
|
61
|
+
size.value = { width, height }
|
|
62
|
+
imageData.value = loaded
|
|
63
|
+
}
|
|
64
|
+
if(!imageData.value && !upload.value) {
|
|
65
|
+
tryCount ++
|
|
66
|
+
const wait = reloadImageDataTimeout * Math.pow(2, tryCount)
|
|
67
|
+
//console.log("IM WAIT", wait)
|
|
68
|
+
if(typeof window != 'undefined') setTimeout(loadImageData, wait)
|
|
69
|
+
}
|
|
70
|
+
})()
|
|
71
|
+
return loadImagePromise
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
const url = ref("/images/empty-photo.svg")
|
|
75
|
+
const size = ref()
|
|
76
|
+
|
|
77
|
+
const emit = defineEmits(['size'])
|
|
78
|
+
watch(() => size.value, () => emit('size', size.value))
|
|
79
|
+
|
|
80
|
+
const dpr = (typeof window == 'undefined') ? 1.0 : window.devicePixelRatio
|
|
81
|
+
|
|
82
|
+
const domSize = ref()
|
|
83
|
+
const stableDomSize = refDebounced(domSize, 500)
|
|
84
|
+
const element = ref()
|
|
85
|
+
|
|
86
|
+
console.log("DR", props.domResize)
|
|
87
|
+
if(props.domResize) {
|
|
88
|
+
useResizeObserver(element, (entries) => {
|
|
89
|
+
const entry = entries[0]
|
|
90
|
+
const {width, height} = entry.contentRect
|
|
91
|
+
domSize.value = {width, height}
|
|
92
|
+
})
|
|
93
|
+
}
|
|
94
|
+
watch(() => stableDomSize.value, size => updateUrl())
|
|
95
|
+
|
|
96
|
+
function getSuffix() {
|
|
97
|
+
if(props.noResize) return ''
|
|
98
|
+
const domSize = stableDomSize.value
|
|
99
|
+
if(props.domResize && domSize) {
|
|
100
|
+
console.log("DOM SIZE", domSize)
|
|
101
|
+
if(props.domResize == 'width') {
|
|
102
|
+
return `/width-${(domSize.width * dpr)|0}`
|
|
103
|
+
} else if(props.domResize == 'height') {
|
|
104
|
+
return `/height-${(domSize.height * dpr)|0}`
|
|
105
|
+
} else {
|
|
106
|
+
return `/rect-${(domSize.width * dpr)|0}-${(domSize.height * dpr)|0}`
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
if(props.width && props.height) return `/rect-${(props.width*dpr)|0}-${(props.height*dpr)|0}`
|
|
110
|
+
if(props.width) return `/width-${(props.width*dpr)|0}`
|
|
111
|
+
if(props.height) return `/height-${(props.height*dpr)|0}`
|
|
112
|
+
return ''
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
function updateUrl() {
|
|
116
|
+
console.log("UPDATE URL!", upload.value)
|
|
117
|
+
if(upload.value && upload.value.url) { // available upload
|
|
118
|
+
size.value = { ...upload.value.size }
|
|
119
|
+
url.value = upload.value.url
|
|
120
|
+
return
|
|
121
|
+
}
|
|
122
|
+
if(!imageData.value) {
|
|
123
|
+
tryCount = 0
|
|
124
|
+
loadImageData()
|
|
125
|
+
return
|
|
126
|
+
} else {
|
|
127
|
+
const suffix = getSuffix()
|
|
128
|
+
url.value = `/api/image/image/${props.image}${suffix}`
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
if(!imageData.value) updateUrl()
|
|
133
|
+
|
|
134
|
+
watch(() => upload.value && upload.value.url, () => updateUrl())
|
|
135
|
+
watch(() => imageData.value, () => updateUrl())
|
|
136
|
+
|
|
137
|
+
</script>
|