renusify 2.5.2 → 3.0.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.
- package/components/app/index.vue +74 -22
- package/components/app/toast/index.vue +76 -71
- package/components/app/toast/toast.vue +62 -44
- package/components/avatar/index.vue +207 -84
- package/components/button/buttonConfirm.vue +53 -26
- package/components/button/buttonGroup.js +0 -2
- package/components/button/buttonGroup.vue +310 -62
- package/components/button/index.vue +584 -100
- package/components/calendar/index.js +0 -2
- package/components/calendar/index.vue +326 -262
- package/components/calendar/month.vue +64 -55
- package/components/calendar/year.vue +30 -25
- package/components/card/index.vue +139 -59
- package/components/codeEditor/highlightCss.vue +38 -39
- package/components/codeEditor/highlightHtml.vue +64 -64
- package/components/codeEditor/highlightJs.vue +37 -38
- package/components/codeEditor/index.vue +129 -79
- package/components/codeEditor/run.vue +225 -39
- package/components/codeEditor/useCodeFormatter.js +150 -0
- package/components/confirm/index.vue +139 -80
- package/components/container/col.vue +5 -4
- package/components/container/divider.vue +28 -19
- package/components/container/index.vue +34 -15
- package/components/container/row.vue +26 -9
- package/components/container/spacer.vue +2 -4
- package/components/container/style.scss +3 -0
- package/components/content/index.vue +49 -32
- package/components/cropper/index.vue +401 -244
- package/components/float/index.vue +542 -415
- package/components/form/addressInput/index.vue +184 -109
- package/components/form/camInput/index.vue +370 -244
- package/components/form/checkInput/index.vue +138 -71
- package/components/form/checkboxInput/index.vue +93 -49
- package/components/form/colorInput/Alpha.vue +81 -83
- package/components/form/colorInput/Hue.vue +91 -68
- package/components/form/colorInput/Preview.vue +43 -47
- package/components/form/colorInput/Saturation.vue +101 -86
- package/components/form/colorInput/index.vue +71 -39
- package/components/form/colorInput/picker.vue +111 -106
- package/components/form/colorInput/useColor.js +153 -0
- package/components/form/dateInput/index.vue +691 -356
- package/components/form/dateInput/month.vue +63 -54
- package/components/form/dateInput/year.vue +35 -25
- package/components/form/fileInput/index.js +0 -1
- package/components/form/fileInput/index.vue +263 -106
- package/components/form/fileInput/single.vue +332 -168
- package/components/form/groupInput/index.vue +199 -101
- package/components/form/index.vue +189 -83
- package/components/form/input/index.vue +416 -377
- package/components/form/jsonInput/JsonView.vue +54 -56
- package/components/form/jsonInput/index.vue +247 -165
- package/components/form/maskInput/index.vue +252 -132
- package/components/form/numberInput/index.js +0 -1
- package/components/form/numberInput/index.vue +226 -117
- package/components/form/passwordInput/index.js +2 -1
- package/components/form/passwordInput/index.vue +269 -102
- package/components/form/radioInput/index.vue +143 -72
- package/components/form/rangeInput/index.vue +280 -167
- package/components/form/ratingInput/index.vue +57 -57
- package/components/form/selectInput/index.js +1 -3
- package/components/form/selectInput/index.vue +584 -296
- package/components/form/switchInput/index.vue +73 -59
- package/components/form/telInput/index.js +0 -1
- package/components/form/telInput/index.vue +238 -135
- package/components/form/textArea/index.vue +72 -35
- package/components/form/textEditor/index.vue +739 -0
- package/components/form/{text-editor → textEditor}/style.scss +8 -16
- package/components/form/textInput/index.vue +54 -32
- package/components/form/timeInput/index.vue +82 -55
- package/components/form/timeInput/range.vue +115 -94
- package/components/form/timeInput/timepicker.vue +382 -449
- package/components/form/uniqueInput/index.vue +105 -48
- package/components/form/unitInput/index.vue +139 -84
- package/components/formCreator/index.js +0 -1
- package/components/formCreator/index.vue +314 -148
- package/components/highlight/index.vue +41 -25
- package/components/highlight/style.scss +2 -2
- package/components/highlight/{mixin.js → useHighlight.js} +181 -160
- package/components/icon/index.vue +79 -33
- package/components/img/index.vue +250 -147
- package/components/img/preview.vue +180 -198
- package/components/img/svgImg.vue +42 -39
- package/components/index.js +5 -20
- package/components/infinite/index.js +3 -3
- package/components/infinite/index.vue +290 -66
- package/components/map/index.vue +428 -261
- package/components/map/route.vue +794 -487
- package/components/map/select.vue +118 -58
- package/components/menu/index.vue +206 -94
- package/components/meta/meta.js +26 -3
- package/components/modal/index.vue +382 -156
- package/components/notify/index.vue +204 -86
- package/components/notify/notification.vue +38 -55
- package/components/progress/circle.vue +189 -70
- package/components/progress/line.vue +266 -46
- package/components/searchBox/index.js +1 -3
- package/components/searchBox/index.vue +194 -101
- package/components/skeleton/index.vue +45 -20
- package/components/slider/index.vue +319 -156
- package/components/swiper/index.vue +237 -108
- package/components/table/crud/footer.vue +77 -53
- package/components/table/crud/header.vue +71 -72
- package/components/table/crud/index.vue +629 -399
- package/components/table/index.vue +721 -278
- package/components/timeAgo/index.vue +145 -96
- package/components/tour/index.vue +338 -235
- package/components/tree/index.vue +235 -89
- package/components/tree/tree-element.vue +106 -106
- package/directive/animate/index.js +77 -0
- package/directive/clickOutSide/index.js +98 -0
- package/directive/drag/index.js +153 -0
- package/directive/index.js +11 -13
- package/directive/intersect/index.js +263 -0
- package/directive/mask/index.js +67 -0
- package/directive/parallax/index.js +78 -0
- package/directive/ripple/index.js +14 -0
- package/directive/scroll/index.js +272 -24
- package/directive/sortable/index.js +274 -0
- package/directive/title/index.js +75 -0
- package/directive/touch/index.js +268 -0
- package/index.js +11 -19
- package/package.json +5 -2
- package/plugins/validation/Validate.js +88 -79
- package/scripts/generate-docs.mjs +226 -0
- package/scripts/menu.mjs +240 -0
- package/scripts/parser.mjs +1086 -0
- package/style/_index.scss +7 -0
- package/style/app.scss +13 -65
- package/style/colors.scss +5 -22
- package/style/functions/index.scss +8 -0
- package/style/mixins/index.scss +17 -5
- package/style/variables/base.scss +155 -178
- package/style/variables/color.scss +0 -12
- package/style/variables/utilities.scss +0 -180
- package/tools/helper.js +0 -8
- package/tools/icons.js +7 -2
- package/tools/root.js +71 -0
- package/components/app/style.scss +0 -41
- package/components/app/toast/style.scss +0 -20
- package/components/avatar/style.scss +0 -32
- package/components/bar/bottomNav.js +0 -1
- package/components/bar/bottomNav.vue +0 -28
- package/components/bar/bottomNavigationCircle.js +0 -2
- package/components/bar/bottomNavigationCircle.vue +0 -99
- package/components/bar/scss/bottomNav.scss +0 -67
- package/components/bar/scss/toolbar.scss +0 -174
- package/components/bar/toolbar/index.js +0 -8
- package/components/bar/toolbar/index.vue +0 -35
- package/components/bar/toolbar/laptop.vue +0 -33
- package/components/bar/toolbar/menuChilds.vue +0 -41
- package/components/bar/toolbar/menuLaptop.vue +0 -41
- package/components/bar/toolbar/menuMob.vue +0 -39
- package/components/bar/toolbar/mixin.js +0 -43
- package/components/bar/toolbar/mobile.vue +0 -34
- package/components/breadcrumb/bredcrumbItem.vue +0 -39
- package/components/breadcrumb/index.js +0 -3
- package/components/breadcrumb/index.vue +0 -71
- package/components/breadcrumb/style.scss +0 -51
- package/components/button/style.scss +0 -411
- package/components/card/style.scss +0 -86
- package/components/chart/chart.js +0 -1
- package/components/chart/chart.vue +0 -69
- package/components/chart/worldMap.js +0 -2
- package/components/chart/worldMap.vue +0 -1112
- package/components/chat/MessageList.vue +0 -163
- package/components/chat/chatInput.vue +0 -150
- package/components/chat/chatMsg.vue +0 -276
- package/components/chat/index.js +0 -11
- package/components/chat/index.vue +0 -113
- package/components/chip/index.js +0 -3
- package/components/chip/index.vue +0 -77
- package/components/chip/style.scss +0 -199
- package/components/codeEditor/mixin.js +0 -145
- package/components/countdown/index.js +0 -1
- package/components/countdown/index.vue +0 -105
- package/components/form/colorInput/mixin.js +0 -132
- package/components/form/fileInput/file.js +0 -148
- package/components/form/telInput/assets/flags.png +0 -0
- package/components/form/telInput/assets/flags@2x.png +0 -0
- package/components/form/text-editor/index.vue +0 -705
- package/components/icon/style.scss +0 -17
- package/components/infinite/div.js +0 -6
- package/components/infinite/div.vue +0 -193
- package/components/infinite/page.js +0 -3
- package/components/infinite/page.vue +0 -105
- package/components/list/index.js +0 -3
- package/components/list/index.vue +0 -122
- package/components/list/style.scss +0 -66
- package/components/message/index.js +0 -4
- package/components/message/index.vue +0 -40
- package/components/modal/style.scss +0 -146
- package/components/nestable/NestableItem.vue +0 -307
- package/components/nestable/editable.js +0 -44
- package/components/nestable/index.js +0 -1
- package/components/nestable/index.vue +0 -226
- package/components/nestable/methods.js +0 -416
- package/components/progress/style.scss +0 -229
- package/components/table/style.scss +0 -338
- package/components/tabs/index.js +0 -3
- package/components/tabs/index.vue +0 -151
- package/components/timeline/index.js +0 -6
- package/components/timeline/index.vue +0 -76
- package/directive/resize/index.js +0 -30
- package/directive/skeleton/index.js +0 -27
- package/directive/skeleton/style.scss +0 -37
- package/plugins/request/Request.js +0 -68
- package/style/animation.scss +0 -94
- package/style/style.scss +0 -8
- package/tools/rootable.js +0 -75
- /package/components/form/{text-editor → textEditor}/index.js +0 -0
- /package/components/form/{text-editor → textEditor}/preview.js +0 -0
- /package/components/form/{text-editor → textEditor}/preview.vue +0 -0
|
@@ -12,44 +12,43 @@
|
|
|
12
12
|
</div>
|
|
13
13
|
</template>
|
|
14
14
|
|
|
15
|
-
<script>
|
|
16
|
-
import
|
|
17
|
-
import
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
modelValue: function () {
|
|
38
|
-
this.d = this.modelValue;
|
|
39
|
-
},
|
|
40
|
-
d: async function () {
|
|
41
|
-
await this.build_code()
|
|
42
|
-
this.$emit("update:modelValue", this.d);
|
|
43
|
-
},
|
|
44
|
-
},
|
|
45
|
-
methods: {
|
|
46
|
-
async build_code() {
|
|
47
|
-
this.code = await this.highlight(this.d, "js", true)
|
|
48
|
-
}
|
|
15
|
+
<script setup>
|
|
16
|
+
import {ref, watch, onMounted} from 'vue'
|
|
17
|
+
import {useHighlight} from '../highlight/useHighlight.js'
|
|
18
|
+
import {useCodeFormatter} from './useCodeFormatter.js'
|
|
19
|
+
|
|
20
|
+
const props = defineProps({
|
|
21
|
+
modelValue: String
|
|
22
|
+
})
|
|
23
|
+
|
|
24
|
+
const emit = defineEmits(['update:modelValue'])
|
|
25
|
+
|
|
26
|
+
const {highlight} = useHighlight()
|
|
27
|
+
const {setTab} = useCodeFormatter()
|
|
28
|
+
|
|
29
|
+
const d = ref(props.modelValue || '')
|
|
30
|
+
const code = ref('')
|
|
31
|
+
|
|
32
|
+
const build_code = async () => {
|
|
33
|
+
if (d.value) {
|
|
34
|
+
code.value = await highlight(d.value, "js", true)
|
|
35
|
+
} else {
|
|
36
|
+
code.value = ''
|
|
49
37
|
}
|
|
50
|
-
}
|
|
51
|
-
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
watch(() => props.modelValue, (newValue) => {
|
|
41
|
+
d.value = newValue
|
|
42
|
+
})
|
|
52
43
|
|
|
53
|
-
|
|
44
|
+
watch(d, async (newValue) => {
|
|
45
|
+
await build_code()
|
|
46
|
+
emit('update:modelValue', newValue)
|
|
47
|
+
}, {immediate: true})
|
|
54
48
|
|
|
55
|
-
|
|
49
|
+
onMounted(async () => {
|
|
50
|
+
if (props.modelValue) {
|
|
51
|
+
await build_code()
|
|
52
|
+
}
|
|
53
|
+
})
|
|
54
|
+
</script>
|
|
@@ -32,6 +32,7 @@
|
|
|
32
32
|
:css="sty"
|
|
33
33
|
:script="scr"
|
|
34
34
|
:template="temp"
|
|
35
|
+
:scriptSetup="scriptSetup"
|
|
35
36
|
></r-code-editor-run>
|
|
36
37
|
</div>
|
|
37
38
|
<div v-show="show !== 'run'" ref="codeView" class="code-wrapper">
|
|
@@ -42,10 +43,11 @@
|
|
|
42
43
|
</div>
|
|
43
44
|
<div>
|
|
44
45
|
<span v-show="scriptShow" class="highlight-syn-class"
|
|
45
|
-
><script
|
|
46
|
+
><script <span class="highlight-syn-str" v-if="scriptSetup">setup</span>><br/>
|
|
47
|
+
<template v-if="!scriptSetup">export default {</template></span
|
|
46
48
|
>
|
|
47
49
|
<highlight-script ref="h-js" v-model="scr"></highlight-script>
|
|
48
|
-
<span v-show="scriptShow" class="highlight-syn-class">}
|
|
50
|
+
<span v-show="scriptShow" class="highlight-syn-class"><template v-if="!scriptSetup">}</template><br/></script></span>
|
|
49
51
|
</div>
|
|
50
52
|
<div>
|
|
51
53
|
<span v-show="cssShow" class="highlight-syn-class"
|
|
@@ -58,87 +60,135 @@
|
|
|
58
60
|
</div>
|
|
59
61
|
</template>
|
|
60
62
|
|
|
61
|
-
<script>
|
|
62
|
-
import {defineAsyncComponent} from 'vue'
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
},
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
63
|
+
<script setup>
|
|
64
|
+
import {ref, watch, defineAsyncComponent, inject} from 'vue'
|
|
65
|
+
import {useCodeFormatter} from "./useCodeFormatter"
|
|
66
|
+
|
|
67
|
+
const {pretty_html, pretty_js} = useCodeFormatter()
|
|
68
|
+
const HighlightCss = defineAsyncComponent(() => import("./highlightCss.vue"))
|
|
69
|
+
const HighlightScript = defineAsyncComponent(() => import("./highlightJs.vue"))
|
|
70
|
+
const HighlightHtml = defineAsyncComponent(() => import("./highlightHtml.vue"))
|
|
71
|
+
const RCodeEditorRun = defineAsyncComponent(() => import("./run.vue"))
|
|
72
|
+
|
|
73
|
+
const props = defineProps({
|
|
74
|
+
/**
|
|
75
|
+
* Enables run functionality for the code editor
|
|
76
|
+
* @type {Boolean}
|
|
77
|
+
*/
|
|
78
|
+
runnable: Boolean,
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Shows/hides the template section
|
|
82
|
+
* @type {Boolean}
|
|
83
|
+
* @default true
|
|
84
|
+
*/
|
|
85
|
+
templateShow: {type: Boolean, default: true},
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Shows/hides the script section
|
|
89
|
+
* @type {Boolean}
|
|
90
|
+
* @default true
|
|
91
|
+
*/
|
|
92
|
+
scriptShow: {type: Boolean, default: true},
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Shows/hides the CSS section
|
|
96
|
+
* @type {Boolean}
|
|
97
|
+
* @default true
|
|
98
|
+
*/
|
|
99
|
+
cssShow: {type: Boolean, default: true},
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Template code content
|
|
103
|
+
* @type {String}
|
|
104
|
+
*/
|
|
105
|
+
template: String,
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Script code content
|
|
109
|
+
* @type {String}
|
|
110
|
+
*/
|
|
111
|
+
script: String,
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* CSS code content
|
|
115
|
+
* @type {String}
|
|
116
|
+
*/
|
|
117
|
+
css: String,
|
|
118
|
+
/**
|
|
119
|
+
* Script code content is setup.
|
|
120
|
+
*/
|
|
121
|
+
scriptSetup: Boolean
|
|
122
|
+
})
|
|
123
|
+
|
|
124
|
+
const emit = defineEmits([
|
|
125
|
+
/**
|
|
126
|
+
* Emitted when template content changes
|
|
127
|
+
* @param {String} template - Updated template code
|
|
128
|
+
*/
|
|
129
|
+
"update:template",
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* Emitted when script content changes
|
|
133
|
+
* @param {String} script - Updated script code
|
|
134
|
+
*/
|
|
135
|
+
"update:script",
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* Emitted when CSS content changes
|
|
139
|
+
* @param {String} css - Updated CSS code
|
|
140
|
+
*/
|
|
141
|
+
"update:css"
|
|
142
|
+
])
|
|
143
|
+
|
|
144
|
+
const renusify = inject('renusify')
|
|
145
|
+
const $r = renusify.$r
|
|
146
|
+
const $helper = renusify.$helper
|
|
147
|
+
|
|
148
|
+
const show = ref("code")
|
|
149
|
+
const temp = ref(props.template || "")
|
|
150
|
+
const scr = ref(props.script || "")
|
|
151
|
+
const sty = ref(props.css || "")
|
|
152
|
+
const id = ref($helper?.uniqueId() || Math.random().toString(36).substr(2, 9))
|
|
153
|
+
|
|
154
|
+
watch(() => props.template, (newValue) => {
|
|
155
|
+
temp.value = newValue
|
|
156
|
+
})
|
|
157
|
+
|
|
158
|
+
watch(() => props.script, (newValue) => {
|
|
159
|
+
scr.value = newValue
|
|
160
|
+
})
|
|
161
|
+
|
|
162
|
+
watch(() => props.css, (newValue) => {
|
|
163
|
+
sty.value = newValue
|
|
164
|
+
})
|
|
165
|
+
|
|
166
|
+
watch(temp, (newValue) => {
|
|
167
|
+
emit("update:template", newValue)
|
|
168
|
+
})
|
|
169
|
+
|
|
170
|
+
watch(scr, (newValue) => {
|
|
171
|
+
emit("update:script", newValue)
|
|
172
|
+
})
|
|
173
|
+
|
|
174
|
+
watch(sty, (newValue) => {
|
|
175
|
+
emit("update:css", newValue)
|
|
176
|
+
})
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* Formats all code sections (template, script, CSS) to make them prettier
|
|
180
|
+
*/
|
|
181
|
+
const pretty = () => {
|
|
182
|
+
temp.value = pretty_html(temp.value)
|
|
183
|
+
scr.value = pretty_js(scr.value)
|
|
184
|
+
sty.value = pretty_js(sty.value)
|
|
185
|
+
}
|
|
136
186
|
</script>
|
|
137
187
|
|
|
138
188
|
<style lang="scss">
|
|
139
|
-
@use "../../style
|
|
189
|
+
@use "../../style" as *;
|
|
140
190
|
|
|
141
|
-
.#{
|
|
191
|
+
.#{$prefix}code-editor {
|
|
142
192
|
position: relative;
|
|
143
193
|
white-space: break-spaces;
|
|
144
194
|
caret-color: #f8f8f2;
|
|
@@ -1,46 +1,232 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<component :is="page"></component>
|
|
3
3
|
</template>
|
|
4
|
-
<script>
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
4
|
+
<script setup>
|
|
5
|
+
import {
|
|
6
|
+
computed,
|
|
7
|
+
inject,
|
|
8
|
+
onMounted,
|
|
9
|
+
onUnmounted,
|
|
10
|
+
onUpdated,
|
|
11
|
+
provide,
|
|
12
|
+
reactive,
|
|
13
|
+
ref,
|
|
14
|
+
toRef,
|
|
15
|
+
toRefs,
|
|
16
|
+
watch,
|
|
17
|
+
watchEffect
|
|
18
|
+
} from 'vue'
|
|
19
|
+
|
|
20
|
+
import {defineAsyncComponent, defineComponent} from 'vue/dist/vue.esm-bundler.js'
|
|
21
|
+
|
|
22
|
+
const props = defineProps({
|
|
23
|
+
template: String,
|
|
24
|
+
script: String,
|
|
25
|
+
css: String,
|
|
26
|
+
id: String,
|
|
27
|
+
scriptSetup: Boolean,
|
|
28
|
+
})
|
|
29
|
+
const addStyleToHead = () => {
|
|
30
|
+
if (props.css && props.id) {
|
|
31
|
+
const existingStyles = document.querySelectorAll(`[f='${props.id}']`)
|
|
32
|
+
existingStyles.forEach(style => style.remove())
|
|
33
|
+
|
|
34
|
+
const style = document.createElement("style")
|
|
35
|
+
style.textContent = props.css
|
|
36
|
+
style.setAttribute("f", props.id)
|
|
37
|
+
style.setAttribute("type", "text/css")
|
|
38
|
+
document.head.appendChild(style)
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const removeStyleFromHead = () => {
|
|
43
|
+
if (props.id) {
|
|
44
|
+
const existingStyles = document.querySelectorAll(`[f='${props.id}']`)
|
|
45
|
+
existingStyles.forEach(style => style.remove())
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const page = computed(() => {
|
|
50
|
+
addStyleToHead()
|
|
51
|
+
|
|
52
|
+
const temp = props.template || ""
|
|
53
|
+
const scr = props.script || ''
|
|
54
|
+
|
|
55
|
+
return defineAsyncComponent(() =>
|
|
56
|
+
new Promise((resolve) => {
|
|
57
|
+
try {
|
|
58
|
+
if (props.scriptSetup) {
|
|
59
|
+
// Create the component with script setup
|
|
60
|
+
const componentObj = defineComponent({
|
|
61
|
+
template: temp,
|
|
62
|
+
setup() {
|
|
63
|
+
// Create a context object with all Vue APIs
|
|
64
|
+
const vueContext = {
|
|
65
|
+
// Reactivity
|
|
66
|
+
ref,
|
|
67
|
+
reactive,
|
|
68
|
+
computed,
|
|
69
|
+
watch,
|
|
70
|
+
watchEffect,
|
|
71
|
+
|
|
72
|
+
// Lifecycle
|
|
73
|
+
onMounted,
|
|
74
|
+
onUnmounted,
|
|
75
|
+
onUpdated,
|
|
76
|
+
|
|
77
|
+
// Dependency Injection
|
|
78
|
+
inject,
|
|
79
|
+
provide,
|
|
80
|
+
|
|
81
|
+
// Refs
|
|
82
|
+
toRefs,
|
|
83
|
+
toRef
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
try {
|
|
87
|
+
// Process the script to remove imports and handle setup
|
|
88
|
+
const processedScript = processScriptForSetup(scr)
|
|
89
|
+
|
|
90
|
+
// Create the setup function with all Vue APIs available
|
|
91
|
+
const setupCode = `
|
|
92
|
+
// Make Vue APIs available
|
|
93
|
+
${Object.entries(vueContext).map(([key, value]) =>
|
|
94
|
+
`const ${key} = arguments[0]['${key}'];`
|
|
95
|
+
).join('\n')}
|
|
96
|
+
|
|
97
|
+
// User's script
|
|
98
|
+
${processedScript}
|
|
99
|
+
|
|
100
|
+
// Collect and return declared variables
|
|
101
|
+
const result = {};
|
|
102
|
+
const declaredVars = ${JSON.stringify(extractDeclaredVariables(processedScript))};
|
|
103
|
+
declaredVars.forEach(varName => {
|
|
104
|
+
try {
|
|
105
|
+
if (typeof eval(varName) !== 'undefined') {
|
|
106
|
+
result[varName] = eval(varName);
|
|
107
|
+
}
|
|
108
|
+
} catch(e) {}
|
|
109
|
+
});
|
|
110
|
+
return result;
|
|
111
|
+
`
|
|
112
|
+
|
|
113
|
+
const setupFunction = new Function(setupCode)
|
|
114
|
+
return setupFunction(vueContext)
|
|
115
|
+
|
|
116
|
+
} catch (error) {
|
|
117
|
+
console.error('Error executing user script:', error)
|
|
118
|
+
return {
|
|
119
|
+
__error: ref(`Script execution error: ${error.message}`)
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
})
|
|
124
|
+
|
|
125
|
+
resolve(componentObj)
|
|
126
|
+
|
|
127
|
+
} else {
|
|
128
|
+
// For Options API
|
|
129
|
+
const scriptObj = eval(`(function() {
|
|
130
|
+
return { ${scr} }
|
|
131
|
+
})()`)
|
|
132
|
+
|
|
133
|
+
const componentObj = defineComponent({
|
|
134
|
+
template: temp,
|
|
135
|
+
...scriptObj
|
|
136
|
+
})
|
|
137
|
+
|
|
138
|
+
resolve(componentObj)
|
|
139
|
+
}
|
|
140
|
+
} catch (error) {
|
|
141
|
+
console.error('Error creating component:', error)
|
|
142
|
+
resolve(createErrorComponent(error))
|
|
25
143
|
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
144
|
+
})
|
|
145
|
+
)
|
|
146
|
+
})
|
|
147
|
+
|
|
148
|
+
// Process script to remove imports and prepare for setup
|
|
149
|
+
function processScriptForSetup(script) {
|
|
150
|
+
let processed = script
|
|
151
|
+
|
|
152
|
+
// Remove Vue imports since we provide them
|
|
153
|
+
processed = processed.replace(/import\s*{[^}]*}\s*from\s*['"]vue['"][\s;]*/g, '')
|
|
154
|
+
|
|
155
|
+
// Remove other imports (for now, could handle them differently)
|
|
156
|
+
processed = processed.replace(/import\s+.*?\s+from\s+['"][^'"]+['"][\s;]*/g, '// [import removed]')
|
|
157
|
+
|
|
158
|
+
// Handle defineProps and defineEmits
|
|
159
|
+
processed = processed.replace(/defineProps\s*\(/g, 'const props = defineProps(')
|
|
160
|
+
processed = processed.replace(/defineEmits\s*\(/g, 'const emit = defineEmits(')
|
|
161
|
+
|
|
162
|
+
return processed.trim()
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
// Extract variable names that should be returned
|
|
166
|
+
function extractDeclaredVariables(script) {
|
|
167
|
+
const variables = []
|
|
168
|
+
|
|
169
|
+
// Match variable declarations
|
|
170
|
+
const varPatterns = [
|
|
171
|
+
/(?:const|let|var)\s+(\w+)\s*=/g,
|
|
172
|
+
/function\s+(\w+)\s*\(/g,
|
|
173
|
+
/(\w+)\s*:\s*\(\)\s*=>/g // Arrow functions
|
|
174
|
+
]
|
|
175
|
+
|
|
176
|
+
varPatterns.forEach(pattern => {
|
|
177
|
+
let match
|
|
178
|
+
while ((match = pattern.exec(script)) !== null) {
|
|
179
|
+
if (match[1] && !match[1].startsWith('_')) {
|
|
180
|
+
variables.push(match[1])
|
|
31
181
|
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
182
|
+
}
|
|
183
|
+
})
|
|
184
|
+
|
|
185
|
+
// Also look for ref, reactive, computed declarations
|
|
186
|
+
const reactivePatterns = [
|
|
187
|
+
/(\w+)\s*=\s*ref\(/,
|
|
188
|
+
/(\w+)\s*=\s*reactive\(/,
|
|
189
|
+
/(\w+)\s*=\s*computed\(/
|
|
190
|
+
]
|
|
191
|
+
|
|
192
|
+
script.split('\n').forEach(line => {
|
|
193
|
+
reactivePatterns.forEach(pattern => {
|
|
194
|
+
const match = line.match(pattern)
|
|
195
|
+
if (match && match[1]) {
|
|
196
|
+
variables.push(match[1])
|
|
197
|
+
}
|
|
198
|
+
})
|
|
199
|
+
})
|
|
200
|
+
|
|
201
|
+
return [...new Set(variables)] // Remove duplicates
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
function createErrorComponent(error) {
|
|
205
|
+
return defineComponent({
|
|
206
|
+
name: 'ErrorComponent',
|
|
207
|
+
setup() {
|
|
208
|
+
const errorMsg = ref(error.message)
|
|
209
|
+
return {errorMsg}
|
|
43
210
|
},
|
|
44
|
-
|
|
45
|
-
|
|
211
|
+
template: `
|
|
212
|
+
<div style="color: #f44336; padding: 20px; background: #ffebee; border-radius: 4px; font-family: 'Courier New', monospace;">
|
|
213
|
+
<div style="font-weight: bold; margin-bottom: 8px;">Script Error:</div>
|
|
214
|
+
<div>{{ errorMsg }}</div>
|
|
215
|
+
</div>
|
|
216
|
+
`
|
|
217
|
+
})
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
onMounted(() => {
|
|
221
|
+
addStyleToHead()
|
|
222
|
+
})
|
|
223
|
+
|
|
224
|
+
onUnmounted(() => {
|
|
225
|
+
removeStyleFromHead()
|
|
226
|
+
})
|
|
227
|
+
|
|
228
|
+
watch(() => props.css, () => {
|
|
229
|
+
addStyleToHead()
|
|
230
|
+
})
|
|
46
231
|
</script>
|
|
232
|
+
|