vatts 2.0.2 → 2.1.0-canary.1

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 (40) hide show
  1. package/LICENSE +12 -12
  2. package/README.md +63 -63
  3. package/dist/api/console.d.ts +28 -5
  4. package/dist/api/console.js +305 -137
  5. package/dist/api/native-server.js +25 -4
  6. package/dist/bin/vatts.js +192 -4
  7. package/dist/builder.js +70 -69
  8. package/dist/core-go/core-linux-arm64.node +0 -0
  9. package/dist/core-go/core-linux-x64.node +0 -0
  10. package/dist/core-go/core-win-x64.node +0 -0
  11. package/dist/global/global.d.ts +176 -176
  12. package/dist/helpers.d.ts +2 -2
  13. package/dist/helpers.js +20 -41
  14. package/dist/hotReload.js +205 -205
  15. package/dist/index.d.ts +2 -1
  16. package/dist/index.js +104 -19
  17. package/dist/loaders.js +15 -15
  18. package/dist/react/BuildingPage.js +202 -202
  19. package/dist/react/DefaultNotFound.js +16 -16
  20. package/dist/react/DevIndicator.js +101 -101
  21. package/dist/react/entry.client.js +7 -8
  22. package/dist/react/image/Image.js +1 -1
  23. package/dist/react/renderer-react.js +270 -33
  24. package/dist/react/server-error.d.ts +8 -0
  25. package/dist/react/server-error.js +346 -0
  26. package/dist/router.js +1 -65
  27. package/dist/types.d.ts +1 -5
  28. package/dist/utils/utils.d.ts +1 -0
  29. package/dist/utils/utils.js +68 -0
  30. package/dist/vue/App.vue +191 -191
  31. package/dist/vue/BuildingPage.vue +280 -280
  32. package/dist/vue/DefaultNotFound.vue +328 -328
  33. package/dist/vue/DevIndicator.vue +225 -225
  34. package/dist/vue/ErrorModal.vue +316 -316
  35. package/dist/vue/Link.vue +38 -38
  36. package/dist/vue/entry.client.js +7 -7
  37. package/dist/vue/image/Image.vue +106 -106
  38. package/dist/vue/renderer.vue.js +266 -46
  39. package/dist/vue/server-error.vue +351 -0
  40. package/package.json +1 -1
package/dist/vue/Link.vue CHANGED
@@ -1,39 +1,39 @@
1
- <!--
2
- This file is part of the Vatts.js Project.
3
- Copyright (c) 2026 mfraz
4
-
5
- Licensed under the Apache License, Version 2.0 (the "License");
6
- you may not use this file except in compliance with the License.
7
- You may obtain a copy of the License at
8
-
9
- http://www.apache.org/licenses/LICENSE-2.0
10
-
11
- Unless required by applicable law or agreed to in writing, software
12
- distributed under the License is distributed on an "AS IS" BASIS,
13
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- See the License for the specific language governing permissions and
15
- limitations under the License.
16
- -->
17
- <script setup>
18
- import { router } from '../client/clientRouter';
19
-
20
- const props = defineProps({
21
- href: {
22
- type: String,
23
- required: true
24
- }
25
- });
26
-
27
- const handleClick = async (e) => {
28
- e.preventDefault();
29
-
30
- // Usa o novo sistema de router
31
- await router.push(props.href);
32
- };
33
- </script>
34
-
35
- <template>
36
- <a :href="href" @click="handleClick">
37
- <slot></slot>
38
- </a>
1
+ <!--
2
+ This file is part of the Vatts.js Project.
3
+ Copyright (c) 2026 mfraz
4
+
5
+ Licensed under the Apache License, Version 2.0 (the "License");
6
+ you may not use this file except in compliance with the License.
7
+ You may obtain a copy of the License at
8
+
9
+ http://www.apache.org/licenses/LICENSE-2.0
10
+
11
+ Unless required by applicable law or agreed to in writing, software
12
+ distributed under the License is distributed on an "AS IS" BASIS,
13
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ See the License for the specific language governing permissions and
15
+ limitations under the License.
16
+ -->
17
+ <script setup>
18
+ import { router } from '../client/clientRouter';
19
+
20
+ const props = defineProps({
21
+ href: {
22
+ type: String,
23
+ required: true
24
+ }
25
+ });
26
+
27
+ const handleClick = async (e) => {
28
+ e.preventDefault();
29
+
30
+ // Usa o novo sistema de router
31
+ await router.push(props.href);
32
+ };
33
+ </script>
34
+
35
+ <template>
36
+ <a :href="href" @click="handleClick">
37
+ <slot></slot>
38
+ </a>
39
39
  </template>
@@ -91,13 +91,13 @@ function initializeClient() {
91
91
  catch (error) {
92
92
  console.error('[Vatts] Critical Error rendering application:', error);
93
93
  if (typeof document !== 'undefined') {
94
- document.body.innerHTML = `
95
- <div style="font-family: monospace; padding: 20px; color: #ff4444; background: #1a1a1a; min-height: 100vh;">
96
- <h1>Vatts Client Error (Vue)</h1>
97
- <p>A critical error occurred while initializing the application.</p>
98
- <pre style="background: #000; padding: 15px; border-radius: 5px; overflow: auto;">${error?.message || error}</pre>
99
- <pre style="color: #666; font-size: 12px; margin-top: 10px;">${error?.stack || ''}</pre>
100
- </div>
94
+ document.body.innerHTML = `
95
+ <div style="font-family: monospace; padding: 20px; color: #ff4444; background: #1a1a1a; min-height: 100vh;">
96
+ <h1>Vatts Client Error (Vue)</h1>
97
+ <p>A critical error occurred while initializing the application.</p>
98
+ <pre style="background: #000; padding: 15px; border-radius: 5px; overflow: auto;">${error?.message || error}</pre>
99
+ <pre style="color: #666; font-size: 12px; margin-top: 10px;">${error?.stack || ''}</pre>
100
+ </div>
101
101
  `;
102
102
  }
103
103
  }
@@ -1,107 +1,107 @@
1
- <!--
2
- * This file is part of the Vatts.js Project.
3
- * Copyright (c) 2026 mfraz
4
- *
5
- * Licensed under the Apache License, Version 2.0 (the "License");
6
- * you may not use this file except in compliance with the License.
7
- * You may obtain a copy of the License at
8
- *
9
- * http://www.apache.org/licenses/LICENSE-2.0
10
- *
11
- * Unless required by applicable law or agreed to in writing, software
12
- * distributed under the License is distributed on an "AS IS" BASIS,
13
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- * See the License for the specific language governing permissions and
15
- * limitations under the License.
16
- -->
17
-
18
- <script setup>
19
- import { computed } from 'vue';
20
-
21
- const props = defineProps({
22
- src: {
23
- type: String,
24
- required: true
25
- },
26
- width: [Number, String],
27
- height: [Number, String],
28
- quality: {
29
- type: Number,
30
- default: 75
31
- },
32
- priority: {
33
- type: Boolean,
34
- default: false
35
- },
36
- alt: {
37
- type: String,
38
- default: ""
39
- }
40
- });
41
-
42
- const getBaseUrl = () => {
43
- if (typeof window === "undefined") return null;
44
- return window.location.origin;
45
- };
46
-
47
- const optimizedSrc = computed(() => {
48
- const baseUrl = getBaseUrl();
49
- const { src, quality, width, height } = props;
50
-
51
- // Se a imagem for Base64 (pequena) ou externa (http), não otimizamos via backend local
52
- const isOptimizable = src && typeof src === 'string' && !src.startsWith('data:') &&
53
- ((baseUrl && src.startsWith(baseUrl)) || !src.startsWith('http'));
54
-
55
- if (!isOptimizable) return src;
56
-
57
- let path = src;
58
- if (baseUrl && path.startsWith(baseUrl)) {
59
- path = path.slice(baseUrl.length) || '/';
60
- }
61
-
62
- const params = new URLSearchParams();
63
- params.set('url', path);
64
-
65
- // Tratamento para remover "px" se o usuário passar string
66
- if (width) {
67
- const w = String(width).replace('px', '');
68
- if (!isNaN(Number(w))) params.set('w', w);
69
- }
70
-
71
- if (height) {
72
- const h = String(height).replace('px', '');
73
- if (!isNaN(Number(h))) params.set('h', h);
74
- }
75
-
76
- if (quality) params.set('q', quality.toString());
77
-
78
- return `/_vatts/image?${params.toString()}`;
79
- });
80
-
81
- const baseStyle = computed(() => {
82
- return {
83
- width: props.width ? (typeof props.width === 'number' ? `${props.width}px` : props.width) : 'auto',
84
- height: props.height ? (typeof props.height === 'number' ? `${props.height}px` : props.height) : 'auto',
85
- };
86
- });
87
-
88
- // Remove "px" para os atributos nativos width/height da tag img
89
- const cleanDimension = (val) => {
90
- if (typeof val === 'string') return val.replace('px', '');
91
- return val;
92
- };
93
- </script>
94
-
95
- <template>
96
- <img
97
- v-bind="$attrs"
98
- :src="optimizedSrc"
99
- :alt="alt"
100
- :loading="priority ? 'eager' : 'lazy'"
101
- :decoding="priority ? 'sync' : 'async'"
102
- :width="cleanDimension(width)"
103
- :height="cleanDimension(height)"
104
- :style="baseStyle"
105
- class="vatts-image"
106
- />
1
+ <!--
2
+ * This file is part of the Vatts.js Project.
3
+ * Copyright (c) 2026 mfraz
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ -->
17
+
18
+ <script setup>
19
+ import { computed } from 'vue';
20
+
21
+ const props = defineProps({
22
+ src: {
23
+ type: String,
24
+ required: true
25
+ },
26
+ width: [Number, String],
27
+ height: [Number, String],
28
+ quality: {
29
+ type: Number,
30
+ default: 75
31
+ },
32
+ priority: {
33
+ type: Boolean,
34
+ default: false
35
+ },
36
+ alt: {
37
+ type: String,
38
+ default: ""
39
+ }
40
+ });
41
+
42
+ const getBaseUrl = () => {
43
+ if (typeof window === "undefined") return null;
44
+ return window.location.origin;
45
+ };
46
+
47
+ const optimizedSrc = computed(() => {
48
+ const baseUrl = getBaseUrl();
49
+ const { src, quality, width, height } = props;
50
+
51
+ // Se a imagem for Base64 (pequena) ou externa (http), não otimizamos via backend local
52
+ const isOptimizable = src && typeof src === 'string' && !src.startsWith('data:') &&
53
+ ((baseUrl && src.startsWith(baseUrl)) || !src.startsWith('http'));
54
+
55
+ if (!isOptimizable) return src;
56
+
57
+ let path = src;
58
+ if (baseUrl && path.startsWith(baseUrl)) {
59
+ path = path.slice(baseUrl.length) || '/';
60
+ }
61
+
62
+ const params = new URLSearchParams();
63
+ params.set('url', path);
64
+
65
+ // Tratamento para remover "px" se o usuário passar string
66
+ if (width) {
67
+ const w = String(width).replace('px', '');
68
+ if (!isNaN(Number(w))) params.set('w', w);
69
+ }
70
+
71
+ if (height) {
72
+ const h = String(height).replace('px', '');
73
+ if (!isNaN(Number(h))) params.set('h', h);
74
+ }
75
+
76
+ if (quality) params.set('q', quality.toString());
77
+
78
+ return `/_vatts/image?${params.toString()}`;
79
+ });
80
+
81
+ const baseStyle = computed(() => {
82
+ return {
83
+ width: props.width ? (typeof props.width === 'number' ? `${props.width}px` : props.width) : 'auto',
84
+ height: props.height ? (typeof props.height === 'number' ? `${props.height}px` : props.height) : 'auto',
85
+ };
86
+ });
87
+
88
+ // Remove "px" para os atributos nativos width/height da tag img
89
+ const cleanDimension = (val) => {
90
+ if (typeof val === 'string') return val.replace('px', '');
91
+ return val;
92
+ };
93
+ </script>
94
+
95
+ <template>
96
+ <img
97
+ v-bind="$attrs"
98
+ :src="optimizedSrc"
99
+ :alt="alt"
100
+ :loading="priority ? 'eager' : 'lazy'"
101
+ :decoding="priority ? 'sync' : 'async'"
102
+ :width="cleanDimension(width)"
103
+ :height="cleanDimension(height)"
104
+ :style="baseStyle"
105
+ class="vatts-image"
106
+ />
107
107
  </template>