@wavemaker-ai/react-runtime 1.0.0-rc.309 → 1.0.0-rc.312
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/container/index.js +10 -1
- package/core/util/index.d.ts +5 -0
- package/core/util/index.js +7 -1
- package/core/util/utils.d.ts +4 -0
- package/core/util/utils.js +65 -2
- package/higherOrder/BaseApp.js +11 -9
- package/package-lock.json +148 -126
- package/package.json +3 -3
- package/runtime-dynamic/app-initializer.js +44 -19
- package/runtime-dynamic/components/partial-content.js +1 -4
- package/runtime-dynamic/factories/utils.js +1 -2
- package/runtime-dynamic/services/css-scoping.js +6 -2
- package/runtime-dynamic/services/prefab-resources.js +4 -14
- package/runtime-dynamic/utils/index.d.ts +2 -0
- package/runtime-dynamic/utils/index.js +14 -1
- package/tsconfig.declaration.tsbuildinfo +1 -1
- package/utils/style-utils.d.ts +2 -0
- package/utils/style-utils.js +6 -1
|
@@ -12,6 +12,7 @@ exports.getProjectConfig = getProjectConfig;
|
|
|
12
12
|
exports.initializeApp = initializeApp;
|
|
13
13
|
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
14
14
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
15
|
+
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
15
16
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
16
17
|
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
17
18
|
var _axios = _interopRequireDefault(require("axios"));
|
|
@@ -21,7 +22,8 @@ var _appConfigSlice = require("@wavemaker-ai/react-runtime/store/slices/appConfi
|
|
|
21
22
|
var _authSlice = require("@wavemaker-ai/react-runtime/store/slices/authSlice");
|
|
22
23
|
var _app = require("@wavemaker-ai/react-runtime/core/app.service");
|
|
23
24
|
var _i18nSlice = require("@wavemaker-ai/react-runtime/store/slices/i18nSlice");
|
|
24
|
-
var _utils = require("
|
|
25
|
+
var _utils = require("@wavemaker-ai/react-runtime/core/util/utils");
|
|
26
|
+
var _utils2 = require("./utils");
|
|
25
27
|
var _previewMode = require("./preview-mode");
|
|
26
28
|
var _variableRegistry = require("./services/variable-registry");
|
|
27
29
|
var _previewResourceBase = require("./preview-resource-base");
|
|
@@ -100,13 +102,13 @@ function getProjectConfig() {
|
|
|
100
102
|
* CDN base: deployUrl meta, else cdnUrl meta, else `ng-bundle/`.
|
|
101
103
|
*/
|
|
102
104
|
function initializeProjectDetails() {
|
|
103
|
-
var deployUrlMeta = (0,
|
|
105
|
+
var deployUrlMeta = (0, _utils2.getMetaContent)("deployUrl").trim();
|
|
104
106
|
var isPreview = !deployUrlMeta;
|
|
105
|
-
var resolvedCdn = deployUrlMeta || (0,
|
|
107
|
+
var resolvedCdn = deployUrlMeta || (0, _utils2.getMetaContent)("cdnUrl").trim();
|
|
106
108
|
var cdnUrl = resolvedCdn || "ng-bundle/";
|
|
107
109
|
projectConfig = {
|
|
108
110
|
cdnUrl: cdnUrl,
|
|
109
|
-
apiUrl: (0,
|
|
111
|
+
apiUrl: (0, _utils2.getMetaContent)("apiUrl") || "./services",
|
|
110
112
|
deployUrl: deployUrlMeta || "./",
|
|
111
113
|
isPreview: isPreview,
|
|
112
114
|
fontConfig: undefined
|
|
@@ -402,46 +404,69 @@ function _initializeApp() {
|
|
|
402
404
|
while (1) switch (_context9.prev = _context9.next) {
|
|
403
405
|
case 0:
|
|
404
406
|
initializeProjectDetails();
|
|
407
|
+
(0, _utils.initAppModes)();
|
|
405
408
|
(0, _app.setupAxiosInterceptors)();
|
|
406
|
-
_context9.next =
|
|
409
|
+
_context9.next = 5;
|
|
407
410
|
return dispatchInitialConfig();
|
|
408
|
-
case
|
|
411
|
+
case 5:
|
|
409
412
|
isPrefabPreview = (0, _previewMode.isRuntimePreviewPrefab)();
|
|
410
413
|
syncAppstoreCommonPartial(isPrefabPreview);
|
|
411
414
|
|
|
412
415
|
// Prefab preview bundles do not ship `font.config.js` (Angular parity); skip the fetch.
|
|
413
416
|
if (isPrefabPreview) {
|
|
414
|
-
_context9.next =
|
|
417
|
+
_context9.next = 11;
|
|
415
418
|
break;
|
|
416
419
|
}
|
|
417
|
-
_context9.next =
|
|
420
|
+
_context9.next = 10;
|
|
418
421
|
return loadFontConfig();
|
|
419
|
-
case
|
|
420
|
-
|
|
422
|
+
case 10:
|
|
423
|
+
loadPreviewCustomIcons();
|
|
424
|
+
case 11:
|
|
425
|
+
_context9.next = 13;
|
|
421
426
|
return Promise.all([loadAppVariables(), loadAppScript(), isPrefabPreview ? Promise.resolve({}) : loadCustomFormatters()
|
|
422
427
|
// loadAppExtensions(),
|
|
423
428
|
]);
|
|
424
|
-
case
|
|
429
|
+
case 13:
|
|
425
430
|
_yield$Promise$all = _context9.sent;
|
|
426
431
|
_yield$Promise$all2 = (0, _slicedToArray2["default"])(_yield$Promise$all, 3);
|
|
427
432
|
loadedVariables = _yield$Promise$all2[0];
|
|
428
433
|
loadedFormatters = _yield$Promise$all2[2];
|
|
429
434
|
appVariablesJson = loadedVariables;
|
|
430
435
|
customFormatters = loadedFormatters;
|
|
431
|
-
_context9.prev =
|
|
432
|
-
_context9.next =
|
|
436
|
+
_context9.prev = 19;
|
|
437
|
+
_context9.next = 22;
|
|
433
438
|
return _store.store.dispatch((0, _i18nSlice.loadLocaleBundle)()).unwrap();
|
|
434
|
-
case 20:
|
|
435
|
-
_context9.next = 24;
|
|
436
|
-
break;
|
|
437
439
|
case 22:
|
|
438
|
-
_context9.
|
|
439
|
-
|
|
440
|
+
_context9.next = 26;
|
|
441
|
+
break;
|
|
440
442
|
case 24:
|
|
443
|
+
_context9.prev = 24;
|
|
444
|
+
_context9.t0 = _context9["catch"](19);
|
|
445
|
+
case 26:
|
|
441
446
|
case "end":
|
|
442
447
|
return _context9.stop();
|
|
443
448
|
}
|
|
444
|
-
}, _callee9, null, [[
|
|
449
|
+
}, _callee9, null, [[19, 24]]);
|
|
445
450
|
}));
|
|
446
451
|
return _initializeApp.apply(this, arguments);
|
|
452
|
+
}
|
|
453
|
+
function getIconCssPathsFromFontConfig() {
|
|
454
|
+
var source = projectConfig.fontConfig;
|
|
455
|
+
if (!source) {
|
|
456
|
+
return [];
|
|
457
|
+
}
|
|
458
|
+
return (0, _toConsumableArray2["default"])(source.matchAll(/"csspath":\s*"([^"]+)"/g)).map(function (match) {
|
|
459
|
+
return match[1];
|
|
460
|
+
});
|
|
461
|
+
}
|
|
462
|
+
function resolvePreviewIconStylesheetUrl(csspath) {
|
|
463
|
+
if (/^https?:\/\//i.test(csspath) || csspath.startsWith("//")) {
|
|
464
|
+
return csspath;
|
|
465
|
+
}
|
|
466
|
+
return (0, _previewResourceBase.resolvePreviewFetchUrl)(csspath);
|
|
467
|
+
}
|
|
468
|
+
function loadPreviewCustomIcons() {
|
|
469
|
+
getIconCssPathsFromFontConfig().forEach(function (csspath) {
|
|
470
|
+
(0, _utils2.appendStylesheetLink)(resolvePreviewIconStylesheetUrl(csspath));
|
|
471
|
+
});
|
|
447
472
|
}
|
|
@@ -7,7 +7,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
});
|
|
8
8
|
exports["default"] = void 0;
|
|
9
9
|
var _react = _interopRequireWildcard(require("react"));
|
|
10
|
-
var _Container = _interopRequireDefault(require("@mui/material/Container"));
|
|
11
10
|
var _spinner = require("../../components/basic/spinner");
|
|
12
11
|
var _isEqual = _interopRequireDefault(require("lodash-es/isEqual"));
|
|
13
12
|
var _store = require("@wavemaker-ai/react-runtime/runtime-dynamic/registry/store");
|
|
@@ -22,15 +21,13 @@ var WmPartialContent = /*#__PURE__*/(0, _react.memo)(function (props) {
|
|
|
22
21
|
return __jsx(_ErrorBoundary.ComponentErrorBoundary, {
|
|
23
22
|
scope: "partial",
|
|
24
23
|
componentName: props.content
|
|
25
|
-
}, __jsx(_Container["default"], {
|
|
26
|
-
className: "partial-container"
|
|
27
24
|
}, __jsx(_react.Suspense, {
|
|
28
25
|
fallback: __jsx(_spinner.WmSpinner, {
|
|
29
26
|
show: true,
|
|
30
27
|
listener: props.listener,
|
|
31
28
|
name: "partial-container-spinner"
|
|
32
29
|
})
|
|
33
|
-
}, Component && __jsx(Component, props)))
|
|
30
|
+
}, Component && __jsx(Component, props)));
|
|
34
31
|
}, function (prevProps, nextProps) {
|
|
35
32
|
var staticKeys = ["content", "prefab", "prefabName", "partialName", "styles", "params"];
|
|
36
33
|
var staticEqual = staticKeys.every(function (key) {
|
|
@@ -54,13 +54,12 @@ function createDynamicInnerComponent(_ref) {
|
|
|
54
54
|
transpiled = _ref.transpiled,
|
|
55
55
|
styles = _ref.styles;
|
|
56
56
|
var InnerComponent = function InnerComponent(props) {
|
|
57
|
-
var _useAppContext;
|
|
58
57
|
var appState = (0, _WidgetProvider.useAppState)();
|
|
59
58
|
var stateProxy = (0, _WidgetProvider.useProxy)();
|
|
60
59
|
usePageEvents(appState, componentType);
|
|
61
60
|
var appStateRef = (0, _react.useRef)(appState);
|
|
62
61
|
appStateRef.current = appState;
|
|
63
|
-
var notification = (
|
|
62
|
+
var notification = (0, _AppContext.useAppContext)().notification || {};
|
|
64
63
|
(0, _react.useEffect)(function () {
|
|
65
64
|
if (styles) {
|
|
66
65
|
(0, _cssScoping.scopeComponentStyles)(componentName, componentType, styles);
|
|
@@ -8,6 +8,9 @@ exports.scopeComponentStyles = scopeComponentStyles;
|
|
|
8
8
|
// Cache scoped CSS strings keyed by `${scopeSelector}::${rawStyles}` to avoid
|
|
9
9
|
// re-running the regex on every component mount for the same styles.
|
|
10
10
|
var scopedCssCache = new Map();
|
|
11
|
+
function isWmAppScopedInStyles(styles) {
|
|
12
|
+
return /\.wm-app(?![\w-])/.test(styles);
|
|
13
|
+
}
|
|
11
14
|
function prefixSelectors(css, scope) {
|
|
12
15
|
return css.replace(/([^{}@]+)\{/g, function (match, selectorsStr) {
|
|
13
16
|
if (selectorsStr.trim().startsWith("@")) return match;
|
|
@@ -26,12 +29,13 @@ function prefixSelectors(css, scope) {
|
|
|
26
29
|
function scopeComponentStyles(componentName, componentType, styles) {
|
|
27
30
|
var _styleElement$textCon;
|
|
28
31
|
if (!styles) return "";
|
|
29
|
-
var
|
|
32
|
+
var isWmAppScoped = isWmAppScopedInStyles(styles);
|
|
33
|
+
var scopeSelector = isWmAppScoped ? "" : ".wm-app";
|
|
30
34
|
var scopeAttribute = "".concat(componentType, "-").concat(componentName);
|
|
31
35
|
var cacheKey = "".concat(scopeSelector, "::").concat(styles);
|
|
32
36
|
var scopedCss = scopedCssCache.get(cacheKey);
|
|
33
37
|
if (!scopedCss) {
|
|
34
|
-
scopedCss = prefixSelectors(styles, scopeSelector);
|
|
38
|
+
scopedCss = isWmAppScoped ? styles : prefixSelectors(styles, scopeSelector);
|
|
35
39
|
scopedCssCache.set(cacheKey, scopedCss);
|
|
36
40
|
}
|
|
37
41
|
var styleElement = document.createElement("style");
|
|
@@ -10,6 +10,7 @@ exports.loadPrefabResourcesFromConfig = loadPrefabResourcesFromConfig;
|
|
|
10
10
|
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
11
11
|
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
12
12
|
var _endsWith = _interopRequireDefault(require("lodash-es/endsWith"));
|
|
13
|
+
var _utils = require("../utils");
|
|
13
14
|
var _previewResourceBase = require("../preview-resource-base");
|
|
14
15
|
var _fragmentUrl = require("./fragment-url");
|
|
15
16
|
function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; }
|
|
@@ -36,22 +37,11 @@ function getPrefabResourceUrl(resourcePath, resourceBasePath) {
|
|
|
36
37
|
}
|
|
37
38
|
return "".concat(resourceBasePath).concat(resourcePath);
|
|
38
39
|
}
|
|
39
|
-
function isStylesheetLoaded(href) {
|
|
40
|
-
var links = document.getElementsByTagName("link");
|
|
41
|
-
for (var i = 0; i < links.length; i++) {
|
|
42
|
-
var el = links[i];
|
|
43
|
-
if (el.rel === "stylesheet" && el.getAttribute("href") === href) return true;
|
|
44
|
-
}
|
|
45
|
-
return false;
|
|
46
|
-
}
|
|
47
40
|
function loadStyleSheetOnce(href) {
|
|
48
41
|
var resolved = (0, _previewResourceBase.resolvePreviewFetchUrl)(href);
|
|
49
|
-
if (
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
link.type = "text/css";
|
|
53
|
-
link.href = resolved;
|
|
54
|
-
document.head.appendChild(link);
|
|
42
|
+
if (resolved) {
|
|
43
|
+
(0, _utils.appendStylesheetLink)(resolved);
|
|
44
|
+
}
|
|
55
45
|
}
|
|
56
46
|
function isScriptLoaded(src) {
|
|
57
47
|
var scripts = document.getElementsByTagName("script");
|
|
@@ -7,3 +7,5 @@ export declare function getMetaContent(name: string): string;
|
|
|
7
7
|
* compilation phases. Prevents long-task jank (>50ms) that degrades INP.
|
|
8
8
|
*/
|
|
9
9
|
export declare const yieldToMain: () => Promise<void>;
|
|
10
|
+
/** Injects a stylesheet link if the href is not already present. */
|
|
11
|
+
export declare function appendStylesheetLink(href: string): void;
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
+
exports.appendStylesheetLink = appendStylesheetLink;
|
|
6
7
|
exports.decodeURIComponentSafe = decodeURIComponentSafe;
|
|
7
8
|
exports.getMetaContent = getMetaContent;
|
|
8
9
|
exports.parseJsonSafe = parseJsonSafe;
|
|
@@ -37,4 +38,16 @@ var yieldToMain = exports.yieldToMain = function yieldToMain() {
|
|
|
37
38
|
return new Promise(function (resolve) {
|
|
38
39
|
return setTimeout(resolve, 0);
|
|
39
40
|
});
|
|
40
|
-
};
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
/** Injects a stylesheet link if the href is not already present. */
|
|
44
|
+
function appendStylesheetLink(href) {
|
|
45
|
+
if (!href || document.querySelector("link[href=\"".concat(href, "\"]"))) {
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
var link = document.createElement("link");
|
|
49
|
+
link.rel = "stylesheet";
|
|
50
|
+
link.type = "text/css";
|
|
51
|
+
link.href = href;
|
|
52
|
+
document.head.appendChild(link);
|
|
53
|
+
}
|