UNPKG

@vtj/renderer

Version:

VTJ 是一款基于 Vue3 + Typescript 的低代码页面可视化设计器。内置低代码引擎、渲染器和代码生成器,面向前端开发者,开箱即用。 无缝嵌入本地开发工程,不改变前端开发流程和编码习惯。

1,837 lines (1,836 loc) 67.9 kB
import { Base as Xe, BUILT_IN_COMPONENTS as Ye, ProjectModel as K, HistoryModel as Ce } from "@vtj/core"; import { url as O, isUrl as ae, dedupArray as Ze, isFunction as z, isString as I, logger as M, storage as se, cookie as ne, toArray as Se, unRSA as $e, delay as G, createRequest as Pe, jsonp as Ae, merge as et, pathToRegexp as tt, pathToRegexpMatch as st, formDataToJson as nt, isEqual as rt, Queue as it, cloneDeep as Ee, camelCase as P, upperFirstCamelCase as ot, pick as at, request as ce, loadScript as be, debounce as ct, Storage as lt, mapToObject as me } from "@vtj/utils"; import * as W from "vue"; import { inject as Ie, defineComponent as Fe, h as le, ref as ue, watchEffect as ut, defineAsyncComponent as je } from "vue"; import { useRoute as Oe } from "vue-router"; /**! * Copyright (c) 2026, VTJ.PRO All rights reserved. * @name @vtj/renderer * @author CHC chenhuachun1549@dingtalk.com * @version 0.16.36 * @license <a href="https://vtj.pro/license.html">MIT License</a> */ const H = "0.16.36"; var y = /* @__PURE__ */ ((n) => (n.Runtime = "Runtime", n.Design = "Design", n.Raw = "Raw", n.VNode = "VNode", n))(y || {}); const Re = [ "$el", "$emit", "$nextTick", "$parent", "$root", "$attrs", "$slots", "$watch", "$props", "$options", "$forceUpdate" ], Ms = [ "beforeCreate", "created", "beforeMount", "mounted", "beforeUpdate", "updated", "beforeUnmount", "unmounted", "errorCaptured", "renderTracked", "renderTriggered", "activated", "deactivated" ], ft = [ "vIf", "vElseIf", "vElse", "vShow", "vModel", "vFor", "vBind", "vHtml" ], pt = { String, Number, Boolean, Array, Object, Function, Date }, k = "VtjPage", J = "VtjHomepage", Me = "html,body,base,head,link,meta,style,title,address,article,aside,footer,header,hgroup,h1,h2,h3,h4,h5,h6,nav,section,div,dd,dl,dt,figcaption,figure,picture,hr,img,li,main,ol,p,pre,ul,a,b,abbr,bdi,bdo,br,cite,code,data,dfn,em,i,kbd,mark,q,rp,rt,ruby,s,samp,small,span,strong,sub,sup,time,u,var,wbr,area,audio,map,track,video,embed,object,param,source,canvas,script,noscript,del,ins,caption,col,colgroup,table,thead,tbody,td,th,tr,button,datalist,fieldset,form,input,label,legend,meter,optgroup,option,output,progress,select,textarea,details,dialog,menu,summary,template,blockquote,iframe,tfoot,svg".split( "," ), dt = "component,slot".split(","), Ts = [ "h", "t", "t", "p", "s", ":", "/", "/", "a", "p", "p", ".", "v", "t", "j", ".", "p", "r", "o" ].join(""), xs = { auth: [ "h", "t", "t", "p", "s", ":", "/", "/", "a", "p", "p", ".", "v", "t", "j", ".", "p", "r", "o", "/", "a", "u", "t", "h", ".", "h", "t", "m", "l" ].join(""), storageKey: [ "R", "R", "O", "_", "I", "D", "E", "_", "A", "C", "C", "E", "S", "S", "_", "S", "T", "O", "R", "A", "G", "E", "_", "_" ].join(""), privateKey: "MIIBOgIBAAJBAKoIzmn1FYQ1YOhOBw9EhABxZ+PySAIaydI+zdhoKflrdgJ4A5E4/5gbQmRpk09hPWG8nvX7h+l/QLU8kXxAIBECAwEAAQJAAlgpxQY6sByLsXqzJcthC8LSGsLf2JEJkHwlnpwFqlEV8UCkoINpuZ2Wzl+aftURu5rIfAzRCQBvHmeOTW9/zQIhAO5ufWDmnSLyfAAsNo5JRNpVuLFCFodR8Xm+ulDlosR/AiEAtpAltyP9wmCABKG/v/hrtTr3mcvFNGCjoGa9bUAok28CIHbrVs9w1ijrBlvTsXYwJw46uP539uKRRT4ymZzlm9QjAiB+1KH/G9f9pEEL9rtaSOG7JF5D0JcOjlze4MGVFs+ZrQIhALKOUFBNr2zEsyJIjw2PlvEucdlG77UniszjXTROHSPd" }; function q(n, e) { return n.map((t) => ae(t) || t.startsWith("/") ? t : `${e}${t}`); } function Q(n) { return /\.css$/.test(n); } function X(n) { return /\.js$/.test(n); } function ht(n) { return /\.json$/.test(n); } function Ds(n) { return n.map( (e) => `<script src="${O.append(e, { v: H })}"><\/script>` ).join(""); } function Hs(n = []) { return n.map( (e) => `<link rel="stylesheet" href="${O.append(e, { v: H })}" />` ).join(""); } function mt(n, e = !1) { return e && n.endsWith(".prod.js") ? n.replace(".prod.js", ".js") : n; } function gt(n, e, t = !1) { const s = n.filter((p) => !!p.enabled), r = [], i = [], o = [], a = [], u = {}, c = {}, l = [], f = {}; return s.forEach( ({ urls: p, assetsUrl: d, library: m, assetsLibrary: h, localeLibrary: g }) => { p?.forEach((v) => { X(v) && r.push(mt(v, t)), Q(v) && i.push(v); }), m && (a.push(m), u[m] = q(p || [], e), g && (c[m] = g)), d && o.push(d), h && l.push(h), m && h && (f[h] = m); } ), { scripts: q(r, e), css: q(i, e), materials: q(o, e), libraryExports: a, materialExports: Ze(l), materialMapLibrary: f, libraryMap: u, libraryLocaleMap: c }; } function _t(n, e) { const { name: t, parent: s, alias: r } = n; return s ? e[s]?.[r || t] : e[r || t]; } function vt(n = []) { const e = n.filter((s) => Q(s)), t = n.filter((s) => X(s)); return { css: e, js: t }; } function yt(n, e) { const t = (c) => { const l = []; let f = 0; for (; f < c.length; ) { if (/\s/.test(c[f])) { f++; continue; } if (c.substring(f, f + 2) === "/*") { const v = c.indexOf("*/", f + 2); if (v !== -1) { f = v + 2; continue; } } if (c[f] === "@") { const v = f; for (; f < c.length && c[f] !== "{" && c[f] !== ";"; ) f++; const w = c.substring(v, f).trim(), b = w.includes("@keyframes"); if (c[f] === ";") l.push({ type: "simple-at-rule", content: c.substring(v, f + 1) }), f++; else if (c[f] === "{") { const _ = f + 1; let C = 1; for (f++; f < c.length && C > 0; ) c[f] === "{" ? C++ : c[f] === "}" && C--, f++; const Y = c.substring(v, f), Z = c.substring(_, f - 1); l.push({ type: b ? "keyframes" : "at-rule", rule: w, content: Y, inner: Z }); } continue; } const p = f; for (; f < c.length && c[f] !== "{"; ) f++; if (f >= c.length) break; const d = c.substring(p, f).trim(); if (!d) { f++; continue; } const m = f + 1; let h = 1; for (f++; f < c.length && h > 0; ) c[f] === "{" ? h++ : c[f] === "}" && h--, f++; const g = c.substring(m, f - 1); l.push({ type: "rule", selector: d, content: g.trim() }); } return l; }, s = (c) => { const l = c.trim(); return /^(from|to|\d+(\.\d+)?%)$/.test(l); }, r = (c) => c.replace(/::v-deep\(/g, ":deep(").replace(/::v-deep\s+/g, ":deep(").replace(/\/deep\//g, " ").replace(/>>>/g, " ").replace(/(.*?):deep\(([^)]+)\)/g, (l, f, p) => { const d = f.trim(), m = p.trim(); return d ? `${d}[${e}] ${m}` : m; }), i = (c) => { const l = c.trim(); if (!l || l.includes(`[${e}]`) || /^(:root|:host|html|body)(\s|$|:|\.|\#|\[)/.test(l) || s(l)) return l; const f = l.match(/^(.+?)((?:::?[\w-]+(?:\([^)]*\))?)*)\s*$/); if (f) { const [, p, d = ""] = f, m = p.trim(); return m ? `${m}[${e}]${d}` : l; } return `${l}[${e}]`; }, o = (c) => r(c).split(",").map((f) => i(f)).filter((f) => f.trim()).join(", "), a = (c) => c.map((l) => { switch (l.type) { case "simple-at-rule": return l.content; case "keyframes": return l.content; case "at-rule": try { const p = t(l.inner), d = a(p); return `${l.rule} { ${d} }`; } catch { return l.content; } case "rule": if (!l.selector || !l.content) return ""; const f = o(l.selector); return f.trim() ? `${f} { ${l.content} }` : ""; default: return ""; } }).filter((l) => l.trim()).join(" "), u = (c) => c.replace(/\s*{\s*/g, " { ").replace(/\s*}\s*/g, " } ").replace(/\s*;\s*/g, "; ").replace(/\s*,\s*/g, ", ").replace(/\s+/g, " ").replace(/^\s+|\s+$/g, "").replace(/\s*}\s*}/g, " } }").trim(); try { const c = n.replace(/\/\*(?!\s*!)[\s\S]*?\*\//g, "").replace(/^\s+|\s+$/gm, "").replace(/\n\s*\n/g, ` `), l = t(c), f = a(l); return u(f); } catch (c) { return console.error("CSS scoping failed:", c), console.error("Input CSS:", n), n.replace(/\/\*[\s\S]*?\*\//g, "").replace( /(@keyframes\s+[^{]+\s*{[^{}]*(?:{[^}]*}[^{}]*)*})/g, (l) => l ).replace(/([^{}@]+)(?=\s*{)/g, (l) => { const f = l.trim(); return !f || f.startsWith("@") || f.includes(`[${e}]`) || s(f) ? l : `${f}[${e}]`; }); } } const wt = 750; function St(n, e, t) { let s; typeof n < "u" ? s = n.innerWidth || n.document.documentElement.clientWidth : (console.warn("无法获取屏幕宽度,使用默认值375"), s = 375); const r = t || wt; return e * s / r; } function $t(n, e) { let t = !1, s = !1, r = !1, i = ""; for (let o = 0; o < e.length; o++) { const a = e[o]; if (a === "'" && !s && !r ? t = !t : a === '"' && !t && !r ? s = !s : e.substr(o, 4).toLowerCase() === "url(" && !t && !s ? r = !0 : a === ")" && r && (r = !1), !t && !s && !r) { const u = e.substr(o).match(/^(-?\d+(?:\.\d+)?)\s*rpx/); if (u) { const c = u[1], l = parseFloat(c), p = `${St(n, l).toFixed(6).replace(/\.?0+$/, "")}px`; i += p, o += u[0].length - 1; continue; } } i += a; } return i; } function Te(n) { return I(n) ? n : JSON.stringify(n); } function ge(n, e, t, s = !1) { const r = n.CSSStyleSheet, i = s ? `data-v-${e}` : e, o = n.__uniConfig ? $t(n, t) : t, a = s ? yt(o, i) : o, u = !!n.__uniConfig; if (r.prototype.replaceSync && !u) { const c = new r(); c.id = e, c.replaceSync(a); const l = n.document, f = l.adoptedStyleSheets, p = Array.from(f).filter( (d) => d.id !== e ); l.adoptedStyleSheets = [...p, c]; } else { const c = n.document; let l = c.getElementById(e); l ? l.innerHTML = a : (l = c.createElement("style"), l.id = e, l.innerHTML = a, c.head.appendChild(l)); } } function ks(n) { const e = n.adoptedStyleSheets || []; let t = ""; if (e.forEach((s) => { try { for (const r of s.cssRules) t += r.cssText + ` `; } catch (r) { console.error("Failed to read cssRules from adopted stylesheet:", r); } }), t) { const s = n.createElement("style"); s.textContent = t, n.head.appendChild(s); } } async function Et(n, e) { const t = await window.fetch(e).then((s) => s.text()).catch(() => ""); t && ge(window, n, t); } function xe(n, e = window) { const t = e.document, s = e.document.head; for (const r of n) if (!t.getElementById(r)) { const o = t.createElement("link"); o.rel = "stylesheet", o.id = r, o.href = r, s.appendChild(o); } } async function De(n, e, t = window) { const s = t.document, r = t.document.head; let i = t[e]; return i ? i.default || i : new Promise((o, a) => { for (const u of n) { const c = s.createElement("script"); c.src = u, c.onload = () => { i = t[e], i ? o(i.default || i) : a(null); }, c.onerror = (l) => { a(l); }, r.appendChild(c); } }); } function bt(n) { return z(n) && Object.getOwnPropertyNames(n.prototype || {}).length === 0 || z(n?.install); } function jt(n) { return dt.includes(n); } function Rt(n) { return Me.includes(n); } function N(n = window) { const e = window?.Mock; if (e) return e; const t = n?.Mock; if (t && window) return window.Mock = t, t; } function Ns(n, e, t) { Object.assign(e.meta, t.meta); const s = n?._container; t?.type === "page" && s.classList.add("is-page"), t?.pure && s.classList.add("is-pure"); } function Ct(n) { return /^\([\s\S]*\)/.test(n.trim()); } function Pt(n) { return /\w+\([\s\S]*\)$/.test(n.trim()); } function At(n) { return n.includes("="); } function It(n) { if (typeof window > "u") return; const e = window[0] || window; if (e.__simulator__) try { const t = e.__simulator__.engine.provider.errorHandler; t && t(n); } catch { } } function B(n, e, t = !1, s = !1, r = !1) { try { const i = ['"use strict";', "var __self = arguments[0];"]; i.push("return "); let o = (n.value || "").trim(); r || (o = o.replace(/this(\W|$)/g, (u, c) => `__self${c}`)), o = i.join(` `) + o; const a = r ? ` ${o} ` : `with(${t ? "{}" : "$scope || {}"}) { ${o} }`; return new Function("$scope", a)(e); } catch (i) { if (M.error("parseExpression.error", i, n, e?.__self ?? e), It(i), s) throw i; } } function R(n, e, t = !1, s = !1, r = !1) { const i = B(n, e, t, s, r); if (typeof i != "function" && (M.error( "parseFunction.error", "not a function", n, e?.__self ?? e ), s)) throw new Error(`"${n.value}" not a function`); return i; } function E(n) { return n && n.type === "JSExpression"; } function $(n) { return typeof n == "object" && n && n.type === "JSFunction"; } function Ft(n) { return E(n) || $(n); } function Bs(n) { return Ft(n) ? n.value : JSON.stringify(n); } const Ot = { session: !1, authKey: "Authorization", storageKey: "ACCESS_STORAGE", storagePrefix: "__VTJ_", unauthorized: void 0, auth: "/#/login", redirectParam: "r", unauthorizedCode: 401, unauthorizedMessage: "登录已经失效,请重新登录!", noPermissionMessage: "无权限访问该页面", appName: "", statusKey: "code" }, He = Symbol("access"); class _e { options; data = null; mode = y.Raw; interceptResponse = !0; isTipShowing = !1; constructor(e) { this.options = Object.assign({}, Ot, e), this.loadData(); } enableIntercept() { this.interceptResponse = !0; } disableIntercept() { this.interceptResponse = !1; } connect(e) { const { mode: t, router: s, request: r } = e; this.mode = t, s && this.mode !== y.Design && this.setGuard(s), r && this.setRequest(r); } login(e) { const { storageKey: t, storagePrefix: s, session: r, authKey: i } = this.options; this.setData(e), this.data && (se.save(t, e, { type: "local", prefix: s }), r && ne.set(i, this.data.token)); } clear() { const { storageKey: e, storagePrefix: t, session: s, authKey: r } = this.options; this.data = null, se.remove(e, { type: "local", prefix: t }), s && ne.remove(r); } logout() { this.clear(), this.toLogin(); } getData() { return this.data ? this.data : (this.loadData(), this.data); } getToken() { return this.data || this.loadData(), this.data?.token; } can(e) { const { appName: t } = this.options, { permissions: s = {} } = this.data || {}; return typeof e == "function" ? e(s) : Se(e).every((i) => s[i] || s[t + "." + i]); } some(e) { const { appName: t } = this.options, { permissions: s = {} } = this.data || {}; return Se(e).some((i) => s[i] || s[t + "." + i]); } install(e) { e.config.globalProperties.$access = this, e.provide(He, this); } isAuthPath(e) { const { auth: t, isAuth: s } = this.options; if (s) return s(e); if (e.path && typeof t == "string") { const r = t.split("#")[1] || t; return e.path === r; } return !1; } toLogin() { const { auth: e, redirectParam: t } = this.options; if (!e) return; const s = t ? `?${t}=${encodeURIComponent(location.href)}` : ""; typeof e == "function" ? e(s) : location.href = t ? `${e}${s}` : e; } setData(e) { const { privateKey: t } = this.options; if (Array.isArray(e) && t) { const s = e.map((r) => $e(r, t)); try { this.data = JSON.parse(s.join("")); } catch (r) { console.warn(r); } return; } if (typeof e == "string") try { const s = t ? $e(e, t) : e; s ? this.data = JSON.parse(s) : console.warn("RSA解密失败或登录信息缺失"); } catch (s) { console.warn(s); } else this.data = e; } loadData() { const { storageKey: e, storagePrefix: t } = this.options, s = se.get(e, { type: "local", prefix: t }); this.setData(s || null); } isLogined() { const { session: e, authKey: t } = this.options; return e && t ? !!ne.get(t) : !!this.getToken(); } hasRoutePermission(e) { if (e.name === k) { const t = e.params.id; return t && this.can(t); } return e.meta.__vtj__ ? this.can(e.meta.__vtj__) : e.meta.permission ? this.can(e.meta.permission) : !0; } setGuard(e) { e.beforeEach((t, s, r) => this.guard(t, r)); } async guard(e, t) { if (this.isWhiteList(e) || this.isAuthPath(e)) return t(); if (this.isLogined()) { if (this.hasRoutePermission(e)) return t(); { const { noPermissionMessage: s = "无权限访问", unauthorized: r = !1 } = this.options; return await this.showTip(s), z(r) ? (r(), t(!1)) : I(r) ? t(r) : t(!1); } } t(!1), await G(0), this.toLogin(); } isWhiteList(e) { const { whiteList: t } = this.options; return t ? Array.isArray(t) ? t.some((s) => e.fullPath.startsWith(s)) : t(e) : !1; } isUnauthorized(e) { const { unauthorizedCode: t = 401, statusKey: s = "code" } = this.options; return e.status === t || e.data?.[s] === t; } async showUnauthorizedAlert(e) { const { unauthorizedMessage: t = "登录已失效" } = this.options; this.isUnauthorized(e) && await this.showTip(t) && this.toLogin(); } async showTip(e) { const { alert: t } = this.options; return this.isTipShowing ? !1 : t ? (this.isTipShowing = !0, await G(150), await t(e, { title: "提示", type: "warning" })?.catch(() => !0)?.finally(() => { this.isTipShowing = !1; })) : (window.alert(e), !0); } setRequest(e) { e.useRequest((t) => (this.data?.token && (t.headers[this.options.authKey] = this.data?.token), t)), e.useResponse( async (t) => (this.interceptResponse && await this.showUnauthorizedAlert(t), t), async (t) => { if (!this.interceptResponse) return Promise.reject(t); const s = t.response || t || {}; return await this.showUnauthorizedAlert(s), Promise.reject(t); } ); } } function Mt() { return Ie(He, null); } function Ls(n = {}) { const { notify: e, loading: t, settings: s = {}, Startup: r, access: i, useTitle: o, alert: a } = n; let u = null; return { request: Pe({ settings: { type: "form", validSuccess: !0, originResponse: !1, loading: !0, validate: (l) => l.data?.code === 0 || !!l.data?.success, failMessage: !0, showError: (l) => { e && e(l || "未知错误"); }, showLoading: () => { u && u.close(), t && (u = t()); }, hideLoading: () => { u && (u.close(), u = null); }, ...s } }), jsonp: Ae, notify: e, loading: t, useTitle: o, alert: a, startupComponent: r, access: i ? new _e({ alert: a, ...i }) : void 0 }; } function qs(n = {}) { return new _e(n); } function Tt(n, e) { const { jsonp: t, request: s } = e; if (n.method === "jsonp") return (r = {}) => t(n.url, { ...n.jsonpOptions, query: r }); { const r = n.headers ? B(n.headers, {}, !0) : void 0, i = { url: n.url, method: n.method, settings: { ...n.settings, headers: r } }; return (o, a) => (delete i.data, s.send(et(i, a || {}, { data: o }))); } } function xt(n, e) { const { metaQuery: t } = e; if (!t) return; const { code: s, queryCode: r } = n; return (i, o) => { if (!t) { console.warn("adapter.metaQuery is not defined!"); return; } return t(s, r, i, o); }; } function Dt(n = [], e = [], t) { const s = {}; for (const r of n) { const i = Tt(r, t); s[r.id] = i, s[r.name] = i; } for (const r of e) s[r.id] = xt(r, t); return s; } async function Ht(n = [], e = window) { const t = N(e); t && (ke(e), n.forEach((s) => Nt(t, s))); } function kt(n, e = window) { const t = $(n.mockTemplate) && n.mockTemplate.value ? R(n.mockTemplate, {}, !0) : void 0, s = N(e); return async (...r) => { let i = {}; if (t) try { i = await t.apply(t, r); } catch (o) { M.warn("模拟数据模版异常", o); } return s?.mock(i); }; } function Nt(n, e) { if (!e.mock) return; const { url: t, mockTemplate: s } = e; if (t && s) try { const r = ae(t) ? new URL(t).pathname : t, i = tt(`(.*)${r}(.*)`), o = st(r, { decode: decodeURIComponent }), a = B(s, {}, !0); n.mock(i, (u) => { const c = O.parse(u.url) || {}, l = u.body instanceof FormData ? nt(u.body) : u.body, f = ae(u.url) ? new URL(u.url).pathname : u.url.split("?")[0], p = o(f)?.params; Object.assign(u, { data: l, params: p, query: c }); try { return n.mock(a(u)); } catch (d) { return console.warn("[mockApi]", i, u, d), null; } }); } catch (r) { console.warn("mockApi", r); } } function ke(n = window) { const e = N(n); e && (e._mocked = {}); } class Bt { __id = null; __mode; __instance = null; __contextRefs = {}; __refs = {}; __refCaches = {}; context = {}; state = {}; props = {}; $props = {}; $refs = {}; $el = null; $emit = null; $nextTick = null; $parent = null; $root = null; $attrs = null; $slots = null; $watch = null; $options = null; $forceUpdate = null; $components = {}; $libs = {}; $apis = {}; $provider = null; __transform = {}; constructor(e) { const { mode: t, dsl: s, attrs: r } = e; this.__mode = t, s && (this.__id = s.id || null, this.__transform = s.transform || {}), r && Object.assign(this, r); } setup(e, t = W) { const s = t.getCurrentInstance(); if (!s) return; this.__refs = {}, this.__refCaches = {}, this.$refs = {}, this.context = {}, this.__contextRefs = {}, this.__instance = s.proxy; const r = s.appContext.config.globalProperties; Object.assign(this, r), Object.assign(this, e || {}), this.__proxy(), t.onMounted(() => { this.__proxy(); }), t.onUnmounted(() => { this.__cleanup(); }), t.onBeforeUpdate(() => { this.__reset(); }); } __proxy() { if (!this.__instance) return; const e = this.__instance; Re.forEach((t) => { this[t] = e[t] || e._?.[t.replace("$", "")] || null; }); } __cleanup() { Re.forEach((e) => { this[e] = null; }), this.__reset(); } __reset() { this.__refs = {}, this.__refCaches = {}, this.$refs = {}, this.__contextRefs = {}, this.context = {}; } __parseFunction(e) { if (e) if (this.__mode === y.Runtime) { const { id: t, type: s } = e, r = t ? this.__transform[t] ?? e.value : e.value; return R({ type: s, value: r }, this); } else return R(e, this); } __parseExpression(e) { if (e) if (this.__mode === y.Runtime) { const { id: t, type: s } = e, r = t ? this.__transform[t] ?? e.value : e.value; return B({ type: s, value: r }, this); } else return B(e, this); } __ref(e = null, t) { if (this.__mode === y.VNode) return; e && e !== this.__id && (this.__contextRefs[e] = this); let s = e ? this.__refCaches[e] : null; return s || (s = async (r) => { await G(0); let i = r?.$vtjEl || r?.$el || r?._?.vnode?.el || r; if (!i) { typeof t == "string" && (delete this.$refs[t], e && delete this.__refs[e]); return; } return i.nodeType === 3 && i.nextSibling && (i = i.nextSibling), i.__vtj__ = e, y.Design === this.__mode && (i.__context__ = this, i.draggable = !0), e && (this.__refs[e] = this.__getRefEl(this.__refs, e, r)), typeof t == "function" ? t(r) : t && (this.$refs[t] = this.__getRefEl(this.$refs, t, r)), r; }, e && (this.__refCaches[e] = s), s); } __getRefEl(e, t, s) { const r = e[t]; if (r && s !== r) { const i = new Set([].concat(r, s)); return Array.from(i); } else return s; } __clone(e = {}) { const t = { ...this.context, ...e }, s = { ...t, context: t }; return s.context.__proto__ = this.context, s.__proto__ = this, s; } } function fe(n) { const { Vue: e = W, mode: t = y.Runtime, components: s = {}, libs: r = {}, apis: i = {}, loader: o } = n, a = e.computed(() => n.dsl), u = { $components: s, $libs: r, $apis: i }, c = new Bt({ mode: t, dsl: a.value, attrs: u }), l = e.defineComponent({ name: a.value.name, __scopeId: a.value.id ? `data-v-${a.value.id}` : void 0, props: { ...qt(a.value.props ?? [], c) }, async setup(f = {}) { c.$props = f, c.props = f, a.value.id && ge( n.window || window, a.value.id, a.value.css || "", !0 ), c.state = Ut(e, a.value.state ?? {}, c); const p = Jt(e, a.value.computed ?? {}, c), d = Kt(a.value.methods ?? {}, c), m = zt(e, a.value.inject, c); for (const [v, w] of Object.entries(m || {})) m[v] = e.inject(v, w); const h = Gt( a.value.dataSources || {}, c ), g = { ...m, ...p, ...d, ...h }; return c.setup(g, e), Vt(e, a.value.watch ?? [], c), { vtj: c, state: c.state, ...f, ...p, ...d }; }, emits: Lt(a.value.emits), expose: ["vtj", ...a.value.expose || []], render() { if (!a.value.nodes) return null; const f = a.value.nodes || []; if (f.length === 1) return T(f[0], c, e, o, f); { const p = f.map( (d) => T(d, c, e, o, f) ); return e.createVNode("div", {}, p); } }, ...Wt(a.value.lifeCycles ?? {}, c) }); return { renderer: e.markRaw(l), context: c }; } function Lt(n = []) { return n.map((e) => I(e) ? e : e.name); } function qt(n = [], e) { const t = (s) => s ? (Array.isArray(s) ? s : [s]).map((i) => pt[i]) : void 0; return n.map((s) => I(s) ? { name: s } : { name: s.name, type: s.type, required: s.required, default: E(s.default) ? e.__parseExpression(s.default) : s.default }).reduce( (s, r) => (s[r.name] = { type: t(r.type), required: r.required, default: r.default }, s), {} ); } function Ut(n, e, t) { return n.reactive( Object.keys(e || {}).reduce( (s, r) => { let i = e[r]; return E(i) ? i = t.__parseExpression(i) : $(i) && (i = t.__parseFunction(i)), s[r] = i, s; }, {} ) ); } function Jt(n, e, t) { return Object.entries(e ?? {}).reduce( (s, [r, i]) => (s[r] = n.computed(t.__parseFunction(i)), s), {} ); } function Kt(n, e) { return Object.entries(n ?? {}).reduce( (t, [s, r]) => (t[s] = e.__parseFunction(r), t), {} ); } function zt(n, e = [], t) { return e.reduce( (s, r) => { const { name: i, from: o } = r || {}; r.default; const a = E(o) ? t.__parseExpression(o) || i : o ?? i, u = E(r.default) ? t.__parseExpression(r.default) : r.default ?? null; return s[i] = n.inject(a, u), s; }, {} ); } function Gt(n, e) { return Object.keys(n).reduce( (t, s) => { const r = n[s]; if (r.type === "mock") t[s] = kt(r); else if (r.ref) { const i = e.$apis[r.ref], o = $(r.transform) ? r.transform.value ? e.__parseFunction(r.transform) : void 0 : r.transform; t[s] = async (...a) => { const u = await i.apply(e, a); return o ? o(u) : u; }; } return t; }, {} ); } function Vt(n, e = [], t) { e.forEach((s) => { n.watch( t.__parseExpression(s.source), t.__parseFunction(s.handler), { deep: s.deep, immediate: s.immediate } ); }); } function Wt(n, e) { return Object.entries(n ?? {}).reduce( (t, [s, r]) => { const i = e.__parseFunction(r); return t[s] = async () => { z(i) && (await G(0), await i()); }, t; }, {} ); } class Qt { __props = {}; __events = {}; __nodes = {}; constructor() { } setProps(e, t) { this.__props[e] = t; } getProps(e) { return this.__props[e]; } loadProps(e, t) { const s = e ? this.getProps(e) : null; return s || (e && this.setProps(e, t), t); } setEvents(e, t) { } getEvents(e) { return this.__events[e]; } loadEvents(e, t) { const s = e ? this.getEvents(e) : null; return s || (e && this.setEvents(e, t), t); } setNode(e, t) { this.__nodes[e] = t; } getNode(e) { return this.__nodes[e]; } loadNode(e, t) { const s = e ? this.getNode(e) : null; return s || (e && this.setNode(e, t), t); } isEqual(e, t) { return rt(e, t); } clear() { this.__props = {}, this.__events = {}, this.__nodes = {}; } } const x = new Qt(), Ne = new it(); let re = [], F = {}, D = {}; const Xt = (n, e) => e; async function Be(n, e = window) { const { urls: t = [], library: s } = n, r = t.filter((a) => X(a)); if (r.length === 0 || !s) return null; const i = t.filter((a) => Q(a)); return i.length && xe(i, e), await De(r, s, e).catch( (a) => (console.warn("loadScriptUrl error", r, s, a), null) ); } function pe(n) { const { getDsl: e, getDslByUrl: t, options: s } = n; return s.window && (re.forEach((r) => { delete s.window[r]; }), re = []), (r, i, o, a = W) => { if (!o || typeof o == "string") return i; let u = ""; if (o.type === "Schema" && o.id) return u = o.id + "_" + r, D[u] || (D[u] = a.defineAsyncComponent(async () => { const c = F[o.id] || await Ne.add( o.id, () => e(o.id) ); return c && (c.name = i, F[o.id] = c), c ? fe({ Vue: a, mode: y.Runtime, ...s, dsl: Ee(c), loader: pe(n) }).renderer : null; })); if (o.type === "UrlSchema" && o.url) return u = o.url + "_" + r, D[u] || (D[u] = a.defineAsyncComponent(async () => { const c = F[o.url] || await t(o.url); return c && (c.name = i, F[o.url] = c), c ? fe({ ...s, Vue: a, dsl: Ee(c), mode: y.Runtime, loader: pe(n) }).renderer : null; })); if (o.type === "Plugin") { let c = o.library ? F[o.library] : null; return c || (o.library && re.push(o.library), c = F[o.library || Symbol()] = a.defineAsyncComponent( async () => { const l = await Be(o, s.window); return l || (console.warn("getPlugin result is null", o), null); } ), c); } return i; }; } function Us() { F = {}, D = {}, Ne.clearAllCache(), x.clear(); } function T(n, e, t = W, s = Xt, r = [], i = !1, o = 0) { if (!n || !n.name || n.invisible) return null; const a = t.getCurrentInstance()?.appContext, { id: u = null, directives: c = [] } = n, { vIf: l, vElseIf: f, vElse: p, vFor: d, vShow: m, vModels: h, vBind: g, vHtml: v, others: w } = Le(c); if (!i && (f || p)) return null; if (l && !Zt(l, e)) return is(n, e, t, s, r); const b = (_, C = 0) => { const Y = _.$components, Z = (() => { if (n.name === "component") return es(_, n.props?.is); if (n.name === "slot") return n.name; const j = s(`${n.id}_${C}`, n.name, n.from, t); return I(j) ? jt(j) || Rt(j) ? j : Y[j] ?? a?.app?.component(j) ?? j : j; })(), A = ts(u, n.props ?? {}, _), Ge = rs( t, n.id, n.events ?? {}, _ ); if (n.name === "slot") return os(t, n, A, _, s); g && Object.assign(A, _.__parseExpression(g.value)), m && (A.style = Object.assign( A.style ?? {}, cs(m, _) )), v && Object.assign(A, ls(v, _)), h.forEach((j) => { Me.includes(n.name) ? Object.assign(A, us(j, _)) : Object.assign(A, fs(t, j, _)); }); const Ve = ps( t, n.children ?? [], _, s, n ), ye = _?.__id ? `data-v-${_.__id}` : void 0, We = ye ? { [ye]: "" } : {}, Qe = _.__mode === y.Design ? { "data-vtj": u } : {}, L = `${u}_${C}`, ee = { key: L, ...We, ...Qe, ...A, ...Ge }; x.isEqual(ee, x.getNode(L)) || x.setNode(L, ee); let te = t.createVNode( Z, x.getNode(L) || ee || {}, Ve ); const we = a ? Yt(a, w, _) : []; return we.length && (te = t.withDirectives(te, we)), te; }; return d ? ms(d, b, e) : b(e, o); } function Yt(n, e, t) { const s = n.app; return e.map((r) => { const i = typeof r.name == "string" ? s.directive(r.name) : t.__parseExpression(r.name); if (!i) return null; const o = [i]; return r.value && o.push(t.__parseExpression(r.value)), r.arg && o.push(r.arg), r.modifiers && o.push(r.modifiers), o; }).filter((r) => !!r); } function Le(n = []) { const e = n.find((l) => P(l.name) === "vIf"), t = n.find( (l) => P(l.name) === "vElseIf" ), s = n.find((l) => P(l.name) === "vElse"), r = n.find((l) => P(l.name) === "vFor"), i = n.find((l) => P(l.name) === "vShow"), o = n.find((l) => P(l.name) === "vBind"), a = n.find((l) => P(l.name) === "vHtml"), u = n.filter( (l) => P(l.name) === "vModel" ), c = n.filter( (l) => !ft.includes(P(l.name)) ); return { vIf: e, vElseIf: t, vElse: s, vFor: r, vShow: i, vModels: u, vBind: o, others: c, vHtml: a }; } function Zt(n, e) { return !!e.__parseExpression(n.value); } function es(n, e) { return e ? E(e) ? n.__parseExpression(e) : e : "div"; } function ts(n, e, t) { const s = de(e, t); return s.ref = t.__ref(n, s.ref), s; } function de(n, e) { return E(n) ? e.__parseExpression(n) : $(n) ? e.__parseFunction(n) : Array.isArray(n) ? n.map((t) => de(t, e)) : typeof n == "object" ? Object.keys(n || {}).reduce( (t, s) => { let r = n[s]; return t[s] = de(r, e), t; }, {} ) : n; } function ss(n, e) { return (t) => { t?.key?.toLowerCase() === e.toLowerCase() && n(t); }; } function ns(n) { return Ct(n.value) ? n : Pt(n.value) ? { type: "JSFunction", value: `(...args) => (() => { return (($event) => { ${n.value} }).apply(this, args); })()` } : At(n.value) ? { type: "JSFunction", value: `() => { ${n.value}}` } : n; } function rs(n, e, t, s) { const r = ["passive", "capture", "once"], i = { capture: "Capture", once: "Once", passive: "OnceCapture" }; return Object.keys(t || {}).reduce( (a, u) => { const c = t[u], l = qe(c.modifiers), f = l.find((m) => r.includes(m)), p = "on" + ot(u) + (f && i[f] || ""), d = c.handler ? s.__parseFunction(ns(c.handler)) : null; return d && (a[p] = n.withModifiers( l.includes("enter") ? ss(d, "enter") : d, l )), a; }, {} ); } function is(n, e, t, s, r = []) { let i = r.findIndex((o) => o.id === n.id); for (let o = ++i; o < r.length; o++) { const { directives: a = [] } = r[o], { vElseIf: u, vElse: c } = Le(a); if (u) { if (e.__parseExpression(u.value)) return T(r[o], e, t, s, r, !0); continue; } if (c) return T(r[o], e, t, s, r, !0); } return null; } function qe(n = {}, e = !1) { const t = Object.keys(n); return e ? t.map((s) => "." + s) : t; } function os(n, e, t, s, r) { const { children: i } = e, o = as(e, s), a = s.$slots?.[o.name]; return a ? a(t) : i ? I(i) ? n.createTextVNode(i) : E(i) ? n.createTextVNode( Te(s.__parseExpression(i)) ) : Array.isArray(i) ? i.map( (u, c) => T(u, s, n, r, i, !1, c) ) : null : null; } function as(n, e) { const { props: t } = n, s = t?.name || "default"; return { name: E(s) ? e.__parseExpression(s) : s, params: [] }; } function cs(n, e) { return e.__parseExpression(n.value) ? {} : { display: "none" }; } function ls(n, e) { return { innerHTML: e.__parseExpression(n.value) || "" }; } function us(n, e) { const t = { type: "JSFunction", value: n.value?.value ? `(v) => { ${n.value.value} = v?.target.value; }` : "(v) => {}" }; return { [E(n.arg) ? e.__parseExpression(n.arg) : n.arg || "value"]: e.__parseExpression(n.value), onInput: e.__parseFunction(t) }; } function fs(n, e, t) { const s = { type: "JSFunction", value: e.value?.value ? `(v) => { ${e.value.value} = v; }` : "(v) => {}" }, r = t.__parseFunction(s), i = qe( E(e.modifiers) ? t.__parseExpression(e.modifiers) : e.modifiers ), o = E(e.arg) ? t.__parseExpression(e.arg) : e.arg || "modelValue"; return { [o]: t.__parseExpression(e.value), [`onUpdate:${o}`]: i.length && r ? n.withModifiers(r, i) : r }; } function ps(n, e, t, s, r) { if (!e) return null; if (I(e)) return { default: () => e }; if (E(e)) return { default: () => Te(t.__parseExpression(e)) }; if (Array.isArray(e) && e.length > 0) { const i = ds(e), o = (a, u) => !a || !r ? {} : r?.id && Object.keys(a).length ? u ? { [u]: a } : { [`scope_${r.id}`]: a } : u ? { [u]: /* @__PURE__ */ Object.create(null) } : {}; return Object.entries(i).reduce( (a, [u, { nodes: c, params: l, scope: f }]) => (a[u] = (p) => { const d = l.length ? at(p ?? {}, l) : o(p, f); return c.map( (m, h) => T( m, t.__clone(d), n, s, c, !1, h ) ); }, a), {} ); } return null; } function ds(n) { const e = {}; for (const t of n) { const s = hs(t.slot), r = s.name; e[r] ? (e[r].nodes.push(t), e[r].params = e[r].params.concat(s.params), e[r].scope = s.scope || "") : e[r] = { nodes: [t], params: s.params, scope: s.scope || "" }; } return e; } function hs(n = "default") { return I(n) ? { name: n, params: [], scope: "" } : { params: [], scope: "", ...n }; } function ms(n, e, t) { const { value: s, iterator: r } = n, { item: i = "item", index: o = "index" } = r || {}; let a = t.__parseExpression(s) || []; return Number.isInteger(a) && (a = new Array(a).fill(!0).map((u, c) => c + 1)), Array.isArray(a) ? a.map((u, c) => e(t.__clone({ [i]: u, [o]: c }), c)) : (console.warn("[vForRender]:", `${s?.value} is not a Arrary`), []); } const ie = Fe({ name: "VtjPageContainer", async setup() { const n = Ke(), e = Oe(), t = e.meta.__vtj__ || e.params.id, s = t ? n.getPage(t) : n.getHomepage(), r = s ? await n.getRenderComponent(s.id) : null, i = ue(Symbol()); if (s) { Object.assign(e.meta, s.meta || {}, { cache: s.cache }); const { useTitle: o } = n?.adapter; if (o) { const a = e.meta.title || s.title || "VTJ.PRO"; o(a); } } return { provider: n, component: r, file: s, query: e.query, meta: e.meta, sid: i, route: e }; }, render() { const { component: n, query: e, sid: t } = this; return n ? le(n, { ...e, key: t }) : le( "div", { style: { padding: "10px" } }, "找不到组件,组件不存在或未发布!" ); }, activated() { this.meta.cache === !1 && (this.sid = Symbol()); } }), gs = Fe({ name: "VtjStartupContainer", render() { return le("div", "page not found!"); } }); function V(n, e, t = []) { const s = []; for (const r of t) { const { id: i, title: o, icon: a, children: u, hidden: c, layout: l } = r; if (l) { const f = V(n, e, u || []); s.push(...f); } else { const f = { id: i, title: o, icon: a, hidden: c, url: `${n}/${e}/${i}`, children: u && u.length ? V(n, e, u) : void 0 }; s.push(f); } } return s; } function Ue(n, e) { if (!e) return n; let t = []; for (const s of n) if (s.children && s.children.length) { const r = Ue(s.children, e); r.length && (s.children = r, t.push(s)); } else e.can(s.id.toString()) && t.push(s); return t; } function Js(n) { const { menuPathPrefix: e = "", pageRouteName: t = "page", disableMenusFilter: s = !1 } = n || {}, r = Ke(), i = Oe(), o = Mt(), a = ue(!1), u = ue(!1), c = r.project, l = (d, m) => { a.value = !d?.mask, u.value = m?.pure ?? !!d?.pure; }; ut(() => { const { name: d, params: m, meta: h } = i; if (d === k) { const g = r.getPage(m.id); l(g, h); } else if (d === J) { const g = r.getHomepage(); l(g, h); } else { const g = h.__vtj__; if (g) { const v = r.getPage(g); l(v, h); } else a.value = !h.mask, u.value = !!h.pure; } }); const f = V( e, t, c?.pages ), p = c?.config; return { disabled: a, logo: p?.logo, themeSwitchable: p?.themeSwitchable, title: p?.title || c?.description || c?.name || "VTJ App", menus: s ? f : Ue(f, o), pure: u }; } function oe(n, e) { const { id: t, title: s, meta: r } = n, { name: i = "page", prefix: o = "", component: a, routeMeta: u } = e; return { name: t, path: `${o}${i}/${t}`, component: a, meta: { title: s, ...u, ...r, __vtj__: t } }; } function he(n) { const { name: e = "page", prefix: t = "", pages: s = [], component: r, loader: i, routeMeta: o, homepage: a } = n, u = []; for (const c of s) { const { id: l, title: f, dir: p, layout: d, children: m, meta: h } = c; if (p) { const g = he({ name: e, prefix: t, component: r, routeMeta: o, homepage: a, loader: i, pages: m || [] }); u.push(...g); } else if (d) { const g = he({ name: e, prefix: t, component: r, routeMeta: o, homepage: a, loader: i, pages: m || [] }), v = { name: `layout_${l}`, path: t, component: () => i(l), meta: { title: f, ...o, ...h, __vtj__: l }, children: g }; u.push(v), u.push(oe(c, n)); } else if (u.push(oe(c, n)), a === l) { const g = oe(c, n); g.path = "", g.name = `home_${l}`, u.push(g); } } return u; } function _s(n = {}, e) { const { css: t, store: s, enhance: r } = n, { window: i, app: o, library: a = {}, adapter: u, mode: c } = e, { Pinia: l } = a; o.config.globalProperties.$libs = a, ge(i, "global-css", t || ""), l && s && vs(s, o, l), ws(o, u, n), !u.access && n.access && ys(n.access, o, c, u), Ss(o, n), r && $s(r, o, a); } function vs(n, e, t) { const s = t.createPinia(); if (e.use(s), $(n) && n.value) { const r = R(n, {}, !1, !1, !0), i = t.defineStore("$store", r(e) || {}); e.config.globalProperties.$store = i(); } } function ys(n, e, t, s) { if ($(n) && n.value) { const r = R(n, {}, !1, !1, !0), { alert: i, request: o } = s, a = new _e({ alert: i, storagePrefix: "__VTJ_APP_", ...r(e) }), u = e.config.globalProperties.$router; a.connect({ mode: t, router: u, request: o }), e.use(a); } } function ws(n, e, t) { if (!e.request) return; const { axios: s, request: r, response: i } = t; if (s && $(s) && s.value) { const o = R(s, {}, !1, !1, !0); e.request.setConfig(o(n)); } if (r && $(r) && r.value) { const o = R(r, {}, !1, !1, !0), a = e.request; a.__unReq && a.__unReq(), a.__unReq = e.request.useRequest((u) => o(u, n)); } if (i && $(i) && i.value) { const o = R(i, {}, !1, !1, !0), a = e.request; a.__unRes && a.__unRes(), a.__unRes = e.request.useResponse((u) => o(u, n)); } } function Ss(n, e) { const { beforeEach: t, afterEach: s } = e, r = n.config.globalProperties.$router; if (t && $(t) && t.value) { const i = R(t, {}, !1, !1, !0); r && r.beforeEach((o, a, u) => i(o, a, u, n)); } if (s && $(s) && s.value) { const i = R(s, {}, !1, !1, !0); r && r.afterEach((o, a, u) => i(o, a, u, n)); } } function $s(n, e, t = {}) { $(n) && n.value && R(n, {}, !1, !1, !0)(e, t); } function Es(n, e, t) { if (!n || !e || !t) return; const { VueI18n: s } = e; if (s) { const { locale: r, fallbackLocale: i, messages: o = [] } = t, a = {}; for (let c of o) { const l = Object.keys(c).filter((f) => f !== "key"); for (const f of l) a[f] || (a[f] = {}), a[f][c.key] = c[f]; } const u = s.createI18n({ legacy: !1, locale: r, fallbackLocale: i, messages: a }); n.use(u); } } const Je = Symbol("Provider"); var bs = /* @__PURE__ */ ((n) => (n.Production = "production", n.Development = "development", n))(bs || {}); class js extends Xe { /** * 创建Provider实例 * @param options 配置选项 */ constructor(e) { super(), this.options = e; const { service: t, mode: s = y.Raw, dependencies: r, materials: i, project: o = {}, adapter: a = {}, globals: u = {}, modules: c = {}, router: l = null, materialPath: f = "./", nodeEnv: p = "development" /* Development */ } = e; this.mode = s, this.modules = c, this.service = t, this.router = l, this.materialPath = f, this.nodeEnv = p, r && (this.dependencies = r), i && (this.materials = i), Object.assign(this.globals, u), Object.assign(this.adapter, a); const { access: d, request: m } = this.adapter; d && d.connect({ mode: s, router: l, request: m }), o && s !== y.Design ? this.load(o) : this.project = o; } mode; // 当前运行模式(设计/源码/预览等) globals = {}; // 全局变量 modules = {}; // 异步模块加载器 adapter = { request: ce, jsonp: Ae }; // 适配器接口 apis = {}; // API集合 dependencies = {}; // 依赖项 materials = {}; // 物料资源 library = {}; // 第三方库 libraryLocales = {}; // 第三方库语言包 libraryLocaleMap = {}; // 库名称->语言包映射 service; // 核心服务 project = null; // 当前项目配置 components = {}; // 组件集合 nodeEnv = "development"; // 运行环境 env = {}; // 环境变量 router = null; // 路由实例 materialPath = "./"; // 物料路径 urlDslCaches = {}; // DSL缓存 errorHandler = null; createMock(e) { return async (...t) => { let s = {}; if (e) try { s = await e.apply(e, t); } catch (i) { M.warn("模拟数据模版异常", i); } return N()?.mock(s); }; } /** * 加载项目配置并初始化 * 1. 从模块或服务加载项目配置 * 2. 根据运行模式加载依赖或资源 * 3. 初始化Mock数据 * 4. 创建API接口 * 5. 初始化路由(非uniapp平台) * @param project 项目配置 */ async load(e) { const { vtjDir: t = ".vtj" } = this.options, s = this.modules[`${t}/projects/${e.id}.json`] || this.modules[`/src/${t}/projects/${e.id}.json`]; if (this.project = s ? await s() : await this.service.init(e), !this.project) throw new Error("project is null"); const { apis: r = [], meta: i = [], env: o = [] } = this.project, a = window; a && (a.CKEDITOR_VERSION = void 0), this.initEnv(o), this.mode === y.Raw ? await this.loadDependencies(a) : await this.loadAssets(a), this.initMock(a), this.apis = Dt(r, i, this.adapter), ke(a), Ht(r, a), e.platform !== "uniapp" && this.initRouter(), this.triggerReady(); } initMock(e) { const t = N(e); t && t.setup({ timeout: "50-500" }); } async loadDependencies(e = {}) { const t = Object.entries(this.dependencies); for (const [s, r] of t) e[s] || (e[s] = this.library[s] = await r()); } async loadAssets(e = {}) { const { dependencies: t = [] } = this.project, { dependencies: s, library: r, components: i, materialPath: o, nodeEnv: a, libraryLocales: u } = this, { libraryExports: c, libraryMap: l, materials: f, materialExports: p, materialMapLibrary: d, libraryLocaleMap: m } = gt( t, o, a === "development" /* Development */ ); Object.assign(this.libraryLocaleMap, m); for (const h of c) { const g = s[h], v = e[h]; if (v) r[h] = v; else if (g) e[h] = r[h] = await g(); else { const b = l[h] || []; for (const _ of b) Q(_) && await Et(_, O.append(_, { v: H })), X(_) && await be(O.append(_, { v: H })); r[h] = e[h]; } const w = m[h]; if (w) { const b = s[w]; u[w] = b ? await b() : e[w]; } } if (a === "development") { for (const g of f) await be(O.append(g, { v: H })); const h = this.materials || {}; for (const g of p) { const v = e[d[g]], w = v?.default || v, b = Ye[g]; if (b) w && b.forEach((_) => { i[_] = w[_]; }); else { const _ = h[g] ? (await h[g]()).default : e[g]; _ && w && (_.components || []).forEach((C) => { i[C.name] = _t(C, w); }); } } } } initRouter() { const { router: e, project: t, options: s, adapter: r } = this; if (!e) return; const i = t?.platform === "uniapp" ? "pages" : "page", { routeAppendTo: o, pageRouteName: a = i, routeMeta: u } = s, c = o ? "" : "/", l = { path: `${c}${a}/:id`, name: k, component: ie }, f = this.getHomepage(), p = { path: c, name: J, component: f ? ie : r.startupComponent || gs, meta: u }; if (e.hasRoute(k) && e.removeRoute(k), e.hasRoute(J) && e.removeRoute(J), s.enableStaticRoute) { const d = t?.pages || []; he({ name: a, prefix: c, pages: d, component: ie, loader: this.getRenderComponent.bind(this), homepage: f?.id }).forEach((h) => { o ? e.addRoute(o, h) : e.addRoute(h); }), f || (o ? e.addRoute(o, p) : e.addRoute(p)); } else