@pisell/lowcode-renderer 1.0.102 → 1.0.104
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/es/ReactRenderer/index.js +31 -64
- package/es/Render/index.d.ts +20 -0
- package/es/Render/index.js +145 -242
- package/es/_virtual/_@oxc-project_runtime@0.108.0/helpers/asyncToGenerator.js +28 -0
- package/es/_virtual/_@oxc-project_runtime@0.108.0/helpers/defineProperty.js +14 -0
- package/es/_virtual/_@oxc-project_runtime@0.108.0/helpers/objectSpread2.js +27 -0
- package/es/_virtual/_@oxc-project_runtime@0.108.0/helpers/objectWithoutProperties.js +15 -0
- package/es/_virtual/_@oxc-project_runtime@0.108.0/helpers/objectWithoutPropertiesLoose.js +13 -0
- package/es/_virtual/_@oxc-project_runtime@0.108.0/helpers/toPrimitive.js +16 -0
- package/es/_virtual/_@oxc-project_runtime@0.108.0/helpers/toPropertyKey.js +11 -0
- package/es/_virtual/_@oxc-project_runtime@0.108.0/helpers/typeof.js +12 -0
- package/es/api/index.js +11 -6
- package/es/api/report/URL.js +42 -71
- package/es/api/report/index.js +75 -111
- package/es/api/utils/index.js +5 -1
- package/es/appHelper/index.js +28 -26
- package/es/appHelper/others.js +10 -8
- package/es/config/index.d.ts +14 -0
- package/es/config/index.js +13 -14
- package/es/index.d.ts +3 -4
- package/es/index.js +8 -4
- package/lib/ReactRenderer/index.js +40 -75
- package/lib/Render/index.d.ts +20 -0
- package/lib/Render/index.js +152 -187
- package/lib/_virtual/_@oxc-project_runtime@0.108.0/helpers/asyncToGenerator.js +29 -0
- package/lib/_virtual/_@oxc-project_runtime@0.108.0/helpers/defineProperty.js +14 -0
- package/lib/_virtual/_@oxc-project_runtime@0.108.0/helpers/objectSpread2.js +27 -0
- package/lib/_virtual/_@oxc-project_runtime@0.108.0/helpers/objectWithoutProperties.js +15 -0
- package/lib/_virtual/_@oxc-project_runtime@0.108.0/helpers/objectWithoutPropertiesLoose.js +14 -0
- package/lib/_virtual/_@oxc-project_runtime@0.108.0/helpers/toPrimitive.js +16 -0
- package/lib/_virtual/_@oxc-project_runtime@0.108.0/helpers/toPropertyKey.js +11 -0
- package/lib/_virtual/_@oxc-project_runtime@0.108.0/helpers/typeof.js +18 -0
- package/lib/_virtual/rolldown_runtime.js +29 -0
- package/lib/api/index.js +8 -37
- package/lib/api/report/URL.js +40 -98
- package/lib/api/report/index.js +83 -115
- package/lib/api/utils/index.js +4 -23
- package/lib/appHelper/index.js +27 -58
- package/lib/appHelper/others.js +17 -48
- package/lib/config/index.d.ts +14 -0
- package/lib/config/index.js +21 -46
- package/lib/index.d.ts +3 -4
- package/lib/index.js +9 -41
- package/package.json +2 -2
- package/es/api/index.d.ts +0 -7
- package/es/api/report/index.d.ts +0 -5
- package/es/api/utils/index.d.ts +0 -2
- package/es/appHelper/others.d.ts +0 -1
- package/lib/api/index.d.ts +0 -7
- package/lib/api/report/index.d.ts +0 -5
- package/lib/api/utils/index.d.ts +0 -2
- package/lib/appHelper/others.d.ts +0 -1
|
@@ -1,75 +1,42 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
6
|
-
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
7
|
-
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
8
|
-
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
|
9
|
-
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
10
|
-
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
11
|
-
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
12
|
-
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
13
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
14
|
-
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
15
|
-
import React, { Component, PureComponent, createElement, createContext, forwardRef } from 'react';
|
|
16
|
-
import ReactDOM from 'react-dom';
|
|
17
|
-
import { adapter, pageRendererFactory, componentRendererFactory, blockRendererFactory, addonRendererFactory, tempRendererFactory, rendererFactory } from '@alilc/lowcode-renderer-core';
|
|
18
|
-
import ConfigProvider from '@alifd/next/lib/config-provider';
|
|
1
|
+
import React, { Component, PureComponent, createContext, createElement, forwardRef } from "react";
|
|
2
|
+
import ReactDOM from "react-dom";
|
|
3
|
+
import { adapter, addonRendererFactory, blockRendererFactory, componentRendererFactory, pageRendererFactory, rendererFactory, tempRendererFactory } from "@alilc/lowcode-renderer-core";
|
|
4
|
+
import ConfigProvider from "@alifd/next/lib/config-provider";
|
|
19
5
|
|
|
20
|
-
|
|
21
|
-
// 此处进行改造旨在解决低代码引擎在渲染时React和React DOM版本不匹配的问题
|
|
22
|
-
// 在shop的externals中添加React和React DOM可以解决这个问题,但会出现以下警告
|
|
23
|
-
// 为了避免在生产环境中出现问题,我们在此处使用统一React 和 React DOM
|
|
24
|
-
// Warning: ReactDOM.render is no longer supported in React 18. Use createRoot instead. Until you switch to the new API, your app will behave as if it's running React 17.
|
|
6
|
+
//#region src/ReactRenderer/index.tsx
|
|
25
7
|
window.React = React;
|
|
26
8
|
window.ReactDom = ReactDOM;
|
|
27
9
|
window.ReactDOM = ReactDOM;
|
|
28
10
|
adapter.setRuntime({
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
11
|
+
Component,
|
|
12
|
+
PureComponent,
|
|
13
|
+
createContext,
|
|
14
|
+
createElement,
|
|
15
|
+
forwardRef,
|
|
16
|
+
findDOMNode: ReactDOM === null || ReactDOM === void 0 ? void 0 : ReactDOM.findDOMNode
|
|
35
17
|
});
|
|
36
18
|
adapter.setRenderers({
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
19
|
+
PageRenderer: pageRendererFactory(),
|
|
20
|
+
ComponentRenderer: componentRendererFactory(),
|
|
21
|
+
BlockRenderer: blockRendererFactory(),
|
|
22
|
+
AddonRenderer: addonRendererFactory(),
|
|
23
|
+
TempRenderer: tempRendererFactory(),
|
|
24
|
+
DivRenderer: blockRendererFactory()
|
|
43
25
|
});
|
|
44
26
|
adapter.setConfigProvider(ConfigProvider);
|
|
45
27
|
function factory() {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
_defineProperty(_assertThisInitialized(_this), "context", void 0);
|
|
57
|
-
// @ts-ignore
|
|
58
|
-
_defineProperty(_assertThisInitialized(_this), "setState", void 0);
|
|
59
|
-
// @ts-ignore
|
|
60
|
-
_defineProperty(_assertThisInitialized(_this), "forceUpdate", void 0);
|
|
61
|
-
// @ts-ignore
|
|
62
|
-
_defineProperty(_assertThisInitialized(_this), "refs", void 0);
|
|
63
|
-
return _this;
|
|
64
|
-
}
|
|
65
|
-
_createClass(ReactRenderer, [{
|
|
66
|
-
key: "isValidComponent",
|
|
67
|
-
value: function isValidComponent(obj) {
|
|
68
|
-
var _obj$prototype;
|
|
69
|
-
return (obj === null || obj === void 0 || (_obj$prototype = obj.prototype) === null || _obj$prototype === void 0 ? void 0 : _obj$prototype.isReactComponent) || (obj === null || obj === void 0 ? void 0 : obj.prototype) instanceof Component;
|
|
70
|
-
}
|
|
71
|
-
}]);
|
|
72
|
-
return ReactRenderer;
|
|
73
|
-
}(Renderer);
|
|
28
|
+
const Renderer = rendererFactory();
|
|
29
|
+
return class ReactRenderer extends Renderer {
|
|
30
|
+
constructor(props, context) {
|
|
31
|
+
super(props, context);
|
|
32
|
+
}
|
|
33
|
+
isValidComponent(obj) {
|
|
34
|
+
var _obj$prototype;
|
|
35
|
+
return (obj === null || obj === void 0 || (_obj$prototype = obj.prototype) === null || _obj$prototype === void 0 ? void 0 : _obj$prototype.isReactComponent) || (obj === null || obj === void 0 ? void 0 : obj.prototype) instanceof Component;
|
|
36
|
+
}
|
|
37
|
+
};
|
|
74
38
|
}
|
|
75
|
-
|
|
39
|
+
var ReactRenderer_default = factory();
|
|
40
|
+
|
|
41
|
+
//#endregion
|
|
42
|
+
export { ReactRenderer_default as default };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import "./index.less";
|
|
2
|
+
import * as react_jsx_runtime0 from "react/jsx-runtime";
|
|
3
|
+
import { IRendererAppHelper } from "@alilc/lowcode-renderer-core/lib/types";
|
|
4
|
+
|
|
5
|
+
//#region src/Render/index.d.ts
|
|
6
|
+
interface RenderProps {
|
|
7
|
+
packages: Record<string, any>;
|
|
8
|
+
projectSchema?: Record<string, any> | null;
|
|
9
|
+
className?: string;
|
|
10
|
+
appHelper?: IRendererAppHelper;
|
|
11
|
+
locale?: string;
|
|
12
|
+
isShowSkeleton?: boolean;
|
|
13
|
+
isLoadedAssets?: boolean;
|
|
14
|
+
loadingType?: "spin" | "skeleton";
|
|
15
|
+
isRender?: boolean;
|
|
16
|
+
[key: string]: any;
|
|
17
|
+
}
|
|
18
|
+
declare const Render: (props: RenderProps) => react_jsx_runtime0.JSX.Element | null;
|
|
19
|
+
//#endregion
|
|
20
|
+
export { Render };
|
package/es/Render/index.js
CHANGED
|
@@ -1,250 +1,153 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
7
|
-
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
8
|
-
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
|
|
9
|
-
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
10
|
-
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
11
|
-
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
12
|
-
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
13
|
-
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
14
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
15
|
-
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
16
|
-
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
17
|
-
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
18
|
-
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
1
|
+
import ReactRenderer_default from "../ReactRenderer/index.js";
|
|
2
|
+
import { _objectWithoutProperties } from "../_virtual/_@oxc-project_runtime@0.108.0/helpers/objectWithoutProperties.js";
|
|
3
|
+
import { _objectSpread2 } from "../_virtual/_@oxc-project_runtime@0.108.0/helpers/objectSpread2.js";
|
|
4
|
+
import { _asyncToGenerator } from "../_virtual/_@oxc-project_runtime@0.108.0/helpers/asyncToGenerator.js";
|
|
5
|
+
import appHelper_default from "../appHelper/index.js";
|
|
19
6
|
import { injectComponents } from "@alilc/lowcode-plugin-inject";
|
|
20
7
|
import { AssetLoader, buildComponents } from "@alilc/lowcode-utils";
|
|
21
8
|
import { Skeleton, Spin } from "antd";
|
|
22
|
-
import { isArray, mergeWith
|
|
23
|
-
import React, { useEffect,
|
|
24
|
-
import ReactRenderer from "../ReactRenderer";
|
|
25
|
-
import appHelper from "../appHelper";
|
|
9
|
+
import { cloneDeep, isArray, mergeWith } from "lodash-es";
|
|
10
|
+
import React, { useEffect, useMemo, useState } from "react";
|
|
26
11
|
import { generateUniqueIdByObj } from "@pisell/utils";
|
|
27
12
|
import "./index.less";
|
|
28
|
-
import { jsx
|
|
29
|
-
/**
|
|
30
|
-
* 缓存处理后的data信息 二次访问时
|
|
31
|
-
* 直接从缓存中获取
|
|
32
|
-
*/
|
|
33
|
-
var cacheDataMap = new Map();
|
|
13
|
+
import { jsx } from "react/jsx-runtime";
|
|
34
14
|
|
|
15
|
+
//#region src/Render/index.tsx
|
|
16
|
+
const _excluded = [
|
|
17
|
+
"packages",
|
|
18
|
+
"projectSchema",
|
|
19
|
+
"className",
|
|
20
|
+
"appHelper",
|
|
21
|
+
"locale",
|
|
22
|
+
"isShowSkeleton",
|
|
23
|
+
"isLoadedAssets",
|
|
24
|
+
"loadingType",
|
|
25
|
+
"isRender"
|
|
26
|
+
];
|
|
35
27
|
/**
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
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
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
}))();
|
|
158
|
-
|
|
159
|
-
// 缓存Promise(无论是pending还是resolved,都可以被await)
|
|
160
|
-
assetPromiseCache.set(assetKey, loadingPromise);
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
// 等待加载完成(新创建的或已存在的Promise)
|
|
164
|
-
_context2.next = 19;
|
|
165
|
-
return loadingPromise;
|
|
166
|
-
case 19:
|
|
167
|
-
console.timeEnd('lowcode-isLoadedAssets');
|
|
168
|
-
console.time('lowcode-injectComponents');
|
|
169
|
-
_context2.next = 23;
|
|
170
|
-
return injectComponents(
|
|
171
|
-
// @ts-ignore
|
|
172
|
-
buildComponents(libraryMap, componentsMap));
|
|
173
|
-
case 23:
|
|
174
|
-
components = _context2.sent;
|
|
175
|
-
console.timeEnd('lowcode-injectComponents');
|
|
176
|
-
_data = {
|
|
177
|
-
schema: pageSchema,
|
|
178
|
-
components: components,
|
|
179
|
-
i18n: i18n,
|
|
180
|
-
projectDataSource: projectDataSource
|
|
181
|
-
};
|
|
182
|
-
cacheDataMap.set(schemaHash, _data);
|
|
183
|
-
setData(_data);
|
|
184
|
-
case 28:
|
|
185
|
-
case "end":
|
|
186
|
-
return _context2.stop();
|
|
187
|
-
}
|
|
188
|
-
}, _callee2);
|
|
189
|
-
}));
|
|
190
|
-
return _init.apply(this, arguments);
|
|
191
|
-
}
|
|
192
|
-
var _ref2 = data,
|
|
193
|
-
schema = _ref2.schema,
|
|
194
|
-
components = _ref2.components,
|
|
195
|
-
_ref2$i18n = _ref2.i18n,
|
|
196
|
-
i18n = _ref2$i18n === void 0 ? {} : _ref2$i18n,
|
|
197
|
-
_ref2$projectDataSour = _ref2.projectDataSource,
|
|
198
|
-
projectDataSource = _ref2$projectDataSour === void 0 ? {} : _ref2$projectDataSour;
|
|
199
|
-
if (!schema || !components) {
|
|
200
|
-
init();
|
|
201
|
-
}
|
|
202
|
-
}, [data, projectSchema, schemaHash]);
|
|
203
|
-
useEffect(function () {
|
|
204
|
-
console.log(performance.now(), 'schema components', schema, components);
|
|
205
|
-
}, [schema, components]);
|
|
206
|
-
if (!schema || !components) {
|
|
207
|
-
if (!isShowSkeleton) {
|
|
208
|
-
return null;
|
|
209
|
-
}
|
|
210
|
-
if (loadingType === "spin") {
|
|
211
|
-
return /*#__PURE__*/_jsx("div", {
|
|
212
|
-
style: {
|
|
213
|
-
height: '100%',
|
|
214
|
-
width: '100%',
|
|
215
|
-
display: 'flex',
|
|
216
|
-
justifyContent: 'center',
|
|
217
|
-
alignItems: 'center'
|
|
218
|
-
},
|
|
219
|
-
children: /*#__PURE__*/_jsx(Spin, {})
|
|
220
|
-
});
|
|
221
|
-
}
|
|
222
|
-
return /*#__PURE__*/_jsx("div", {
|
|
223
|
-
style: {
|
|
224
|
-
padding: 20
|
|
225
|
-
},
|
|
226
|
-
children: /*#__PURE__*/_jsx(Skeleton, {
|
|
227
|
-
loading: true,
|
|
228
|
-
active: true,
|
|
229
|
-
round: true
|
|
230
|
-
})
|
|
231
|
-
});
|
|
232
|
-
}
|
|
233
|
-
function customizer(objValue, srcValue) {
|
|
234
|
-
if (isArray(objValue)) {
|
|
235
|
-
return objValue.concat(srcValue || []);
|
|
236
|
-
}
|
|
237
|
-
}
|
|
238
|
-
if (!isRender) return null;
|
|
239
|
-
return /*#__PURE__*/_jsx(ReactRenderer, _objectSpread(_objectSpread({}, others), {}, {
|
|
240
|
-
className: "lowcode-plugin-sample-preview-content ".concat(className),
|
|
241
|
-
schema: _objectSpread(_objectSpread({}, schema), {}, {
|
|
242
|
-
dataSource: mergeWith(schema.dataSource, projectDataSource, customizer)
|
|
243
|
-
}),
|
|
244
|
-
appHelper: mergeWith(cloneDeep(appHelper), propsAppHelper),
|
|
245
|
-
components: components,
|
|
246
|
-
messages: i18n,
|
|
247
|
-
locale: locale
|
|
248
|
-
}));
|
|
28
|
+
* 缓存处理后的data信息 二次访问时
|
|
29
|
+
* 直接从缓存中获取
|
|
30
|
+
*/
|
|
31
|
+
const cacheDataMap = /* @__PURE__ */ new Map();
|
|
32
|
+
/**
|
|
33
|
+
* 资产加载Promise缓存,用于避免竞态问题
|
|
34
|
+
* - 正在加载:存储 pending Promise,后续请求等待同一个 Promise
|
|
35
|
+
* - 已加载完成:存储 resolved Promise,后续请求直接通过
|
|
36
|
+
* - 加载失败:删除缓存,允许重试
|
|
37
|
+
*/
|
|
38
|
+
const assetPromiseCache = /* @__PURE__ */ new Map();
|
|
39
|
+
const Render = (props) => {
|
|
40
|
+
const { packages, projectSchema, className, appHelper: propsAppHelper, locale, isShowSkeleton = true, isLoadedAssets, loadingType = "skeleton", isRender = true } = props, others = _objectWithoutProperties(props, _excluded);
|
|
41
|
+
const schemaHash = useMemo(() => {
|
|
42
|
+
if (projectSchema) return generateUniqueIdByObj(projectSchema);
|
|
43
|
+
return null;
|
|
44
|
+
}, [projectSchema]);
|
|
45
|
+
const [data, setData] = useState(schemaHash ? cacheDataMap.get(schemaHash) || {} : {});
|
|
46
|
+
const { schema, components, i18n = {}, projectDataSource = {} } = data;
|
|
47
|
+
useEffect(() => {
|
|
48
|
+
document.body.id = "body";
|
|
49
|
+
}, []);
|
|
50
|
+
useEffect(() => {
|
|
51
|
+
function init() {
|
|
52
|
+
return _init.apply(this, arguments);
|
|
53
|
+
}
|
|
54
|
+
function _init() {
|
|
55
|
+
_init = _asyncToGenerator(function* () {
|
|
56
|
+
if (!projectSchema) return;
|
|
57
|
+
console.log(performance.now(), "init");
|
|
58
|
+
console.time("lowcode-init");
|
|
59
|
+
const { componentsMap: componentsMapArray, componentsTree, i18n: i18n$2, dataSource: projectDataSource$2 } = projectSchema;
|
|
60
|
+
const componentsMap = {};
|
|
61
|
+
const packagesMap = {};
|
|
62
|
+
componentsMapArray.forEach((component) => {
|
|
63
|
+
packagesMap[component.package] = true;
|
|
64
|
+
componentsMap[component.componentName] = component;
|
|
65
|
+
});
|
|
66
|
+
const pageSchema = componentsTree[0];
|
|
67
|
+
const libraryMap = {};
|
|
68
|
+
const libraryAsset = [];
|
|
69
|
+
packages.forEach(({ package: _package, library, urls, renderUrls }) => {
|
|
70
|
+
libraryMap[_package] = library;
|
|
71
|
+
if (renderUrls) libraryAsset.push(renderUrls);
|
|
72
|
+
else if (urls) libraryAsset.push(urls);
|
|
73
|
+
});
|
|
74
|
+
console.timeEnd("lowcode-init");
|
|
75
|
+
if (!isLoadedAssets) {
|
|
76
|
+
const assetKey = JSON.stringify(libraryAsset);
|
|
77
|
+
let loadingPromise = assetPromiseCache.get(assetKey);
|
|
78
|
+
if (!loadingPromise) {
|
|
79
|
+
loadingPromise = _asyncToGenerator(function* () {
|
|
80
|
+
try {
|
|
81
|
+
yield new AssetLoader().load(libraryAsset);
|
|
82
|
+
} catch (error) {
|
|
83
|
+
assetPromiseCache.delete(assetKey);
|
|
84
|
+
throw error;
|
|
85
|
+
}
|
|
86
|
+
})();
|
|
87
|
+
assetPromiseCache.set(assetKey, loadingPromise);
|
|
88
|
+
}
|
|
89
|
+
yield loadingPromise;
|
|
90
|
+
}
|
|
91
|
+
console.timeEnd("lowcode-isLoadedAssets");
|
|
92
|
+
console.time("lowcode-injectComponents");
|
|
93
|
+
const components$2 = yield injectComponents(buildComponents(libraryMap, componentsMap));
|
|
94
|
+
console.timeEnd("lowcode-injectComponents");
|
|
95
|
+
const _data = {
|
|
96
|
+
schema: pageSchema,
|
|
97
|
+
components: components$2,
|
|
98
|
+
i18n: i18n$2,
|
|
99
|
+
projectDataSource: projectDataSource$2
|
|
100
|
+
};
|
|
101
|
+
cacheDataMap.set(schemaHash, _data);
|
|
102
|
+
setData(_data);
|
|
103
|
+
});
|
|
104
|
+
return _init.apply(this, arguments);
|
|
105
|
+
}
|
|
106
|
+
const { schema: schema$1, components: components$1, i18n: i18n$1 = {}, projectDataSource: projectDataSource$1 = {} } = data;
|
|
107
|
+
if (!schema$1 || !components$1) init();
|
|
108
|
+
}, [
|
|
109
|
+
data,
|
|
110
|
+
projectSchema,
|
|
111
|
+
schemaHash
|
|
112
|
+
]);
|
|
113
|
+
useEffect(() => {
|
|
114
|
+
console.log(performance.now(), "schema components", schema, components);
|
|
115
|
+
}, [schema, components]);
|
|
116
|
+
if (!schema || !components) {
|
|
117
|
+
if (!isShowSkeleton) return null;
|
|
118
|
+
if (loadingType === "spin") return /* @__PURE__ */ jsx("div", {
|
|
119
|
+
style: {
|
|
120
|
+
height: "100%",
|
|
121
|
+
width: "100%",
|
|
122
|
+
display: "flex",
|
|
123
|
+
justifyContent: "center",
|
|
124
|
+
alignItems: "center"
|
|
125
|
+
},
|
|
126
|
+
children: /* @__PURE__ */ jsx(Spin, {})
|
|
127
|
+
});
|
|
128
|
+
return /* @__PURE__ */ jsx("div", {
|
|
129
|
+
style: { padding: 20 },
|
|
130
|
+
children: /* @__PURE__ */ jsx(Skeleton, {
|
|
131
|
+
loading: true,
|
|
132
|
+
active: true,
|
|
133
|
+
round: true
|
|
134
|
+
})
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
function customizer(objValue, srcValue) {
|
|
138
|
+
if (isArray(objValue)) return objValue.concat(srcValue || []);
|
|
139
|
+
}
|
|
140
|
+
if (!isRender) return null;
|
|
141
|
+
return /* @__PURE__ */ jsx(ReactRenderer_default, _objectSpread2(_objectSpread2({}, others), {}, {
|
|
142
|
+
className: `lowcode-plugin-sample-preview-content ${className}`,
|
|
143
|
+
schema: _objectSpread2(_objectSpread2({}, schema), {}, { dataSource: mergeWith(schema.dataSource, projectDataSource, customizer) }),
|
|
144
|
+
appHelper: mergeWith(cloneDeep(appHelper_default), propsAppHelper),
|
|
145
|
+
components,
|
|
146
|
+
messages: i18n,
|
|
147
|
+
locale
|
|
148
|
+
}));
|
|
249
149
|
};
|
|
250
|
-
|
|
150
|
+
var Render_default = Render;
|
|
151
|
+
|
|
152
|
+
//#endregion
|
|
153
|
+
export { Render_default as default };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
//#region \0@oxc-project+runtime@0.108.0/helpers/asyncToGenerator.js
|
|
2
|
+
function asyncGeneratorStep(n, t, e, r, o, a, c) {
|
|
3
|
+
try {
|
|
4
|
+
var i = n[a](c), u = i.value;
|
|
5
|
+
} catch (n$1) {
|
|
6
|
+
e(n$1);
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
9
|
+
i.done ? t(u) : Promise.resolve(u).then(r, o);
|
|
10
|
+
}
|
|
11
|
+
function _asyncToGenerator(n) {
|
|
12
|
+
return function() {
|
|
13
|
+
var t = this, e = arguments;
|
|
14
|
+
return new Promise(function(r, o) {
|
|
15
|
+
var a = n.apply(t, e);
|
|
16
|
+
function _next(n$1) {
|
|
17
|
+
asyncGeneratorStep(a, r, o, _next, _throw, "next", n$1);
|
|
18
|
+
}
|
|
19
|
+
function _throw(n$1) {
|
|
20
|
+
asyncGeneratorStep(a, r, o, _next, _throw, "throw", n$1);
|
|
21
|
+
}
|
|
22
|
+
_next(void 0);
|
|
23
|
+
});
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
//#endregion
|
|
28
|
+
export { _asyncToGenerator };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { toPropertyKey } from "./toPropertyKey.js";
|
|
2
|
+
|
|
3
|
+
//#region \0@oxc-project+runtime@0.108.0/helpers/defineProperty.js
|
|
4
|
+
function _defineProperty(e, r, t) {
|
|
5
|
+
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
6
|
+
value: t,
|
|
7
|
+
enumerable: !0,
|
|
8
|
+
configurable: !0,
|
|
9
|
+
writable: !0
|
|
10
|
+
}) : e[r] = t, e;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
//#endregion
|
|
14
|
+
export { _defineProperty };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { _defineProperty } from "./defineProperty.js";
|
|
2
|
+
|
|
3
|
+
//#region \0@oxc-project+runtime@0.108.0/helpers/objectSpread2.js
|
|
4
|
+
function ownKeys(e, r) {
|
|
5
|
+
var t = Object.keys(e);
|
|
6
|
+
if (Object.getOwnPropertySymbols) {
|
|
7
|
+
var o = Object.getOwnPropertySymbols(e);
|
|
8
|
+
r && (o = o.filter(function(r$1) {
|
|
9
|
+
return Object.getOwnPropertyDescriptor(e, r$1).enumerable;
|
|
10
|
+
})), t.push.apply(t, o);
|
|
11
|
+
}
|
|
12
|
+
return t;
|
|
13
|
+
}
|
|
14
|
+
function _objectSpread2(e) {
|
|
15
|
+
for (var r = 1; r < arguments.length; r++) {
|
|
16
|
+
var t = null != arguments[r] ? arguments[r] : {};
|
|
17
|
+
r % 2 ? ownKeys(Object(t), !0).forEach(function(r$1) {
|
|
18
|
+
_defineProperty(e, r$1, t[r$1]);
|
|
19
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function(r$1) {
|
|
20
|
+
Object.defineProperty(e, r$1, Object.getOwnPropertyDescriptor(t, r$1));
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
return e;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
//#endregion
|
|
27
|
+
export { _objectSpread2 };
|