@wavemaker-ai/react-runtime 1.0.0-rc.314 → 1.0.0-rc.317

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. package/actions/navigation-action.d.ts +1 -0
  2. package/actions/navigation-action.js +34 -9
  3. package/components/auth/RoleAuthGuard.d.ts +6 -0
  4. package/components/auth/RoleAuthGuard.js +65 -0
  5. package/components/basic/search/index.js +2 -1
  6. package/components/basic/search/providers.js +2 -2
  7. package/components/basic/tree/Components/TreeNodeComponent.d.ts +1 -1
  8. package/components/basic/tree/Components/TreeNodeComponent.js +14 -8
  9. package/components/basic/tree/hooks/useTreePersistedState.d.ts +3 -0
  10. package/components/basic/tree/hooks/useTreePersistedState.js +38 -0
  11. package/components/basic/tree/index.d.ts +1 -0
  12. package/components/basic/tree/index.js +105 -30
  13. package/components/basic/tree/props.d.ts +18 -1
  14. package/components/basic/tree/utils.d.ts +16 -1
  15. package/components/basic/tree/utils.js +111 -0
  16. package/components/chart/src/dataUtils.js +1 -1
  17. package/components/common/customTemplate/useCustomTemplate.js +1 -1
  18. package/components/container/layout-grid/grid-column/index.js +2 -1
  19. package/components/data/form/base-form/index.js +3 -1
  20. package/components/data/form/form-controller/withFormController.js +3 -7
  21. package/components/data/pagination/hooks/usePagination.js +0 -1
  22. package/components/data/table/index.js +5 -2
  23. package/components/data/table/utils/columnBuilder.d.ts +1 -1
  24. package/components/data/table/utils/columnBuilder.js +7 -4
  25. package/components/data/table/utils/crud-handlers.js +10 -10
  26. package/components/data/table/utils/index.d.ts +9 -8
  27. package/components/data/table/utils/index.js +73 -9
  28. package/components/layout/leftnav/index.js +21 -2
  29. package/components/layout/leftnav/props.d.ts +9 -0
  30. package/components/layout/leftnav/utils/page-class-util.d.ts +9 -0
  31. package/components/layout/leftnav/utils/page-class-util.js +28 -0
  32. package/components/navigation/popover/index.js +1 -0
  33. package/components/page/index.js +22 -6
  34. package/components/page/page-context.d.ts +4 -0
  35. package/components/page/page-context.js +5 -0
  36. package/components/page/partial-container/index.js +1 -4
  37. package/higherOrder/BaseApp.js +4 -3
  38. package/higherOrder/BaseAppProps.d.ts +1 -0
  39. package/higherOrder/BasePage.js +0 -10
  40. package/hooks/useDataSourceSubscription.js +1 -1
  41. package/hooks/useHttp.js +0 -4
  42. package/package-lock.json +103 -103
  43. package/package.json +3 -3
  44. package/runtime-dynamic/app-initializer.js +1 -1
  45. package/runtime-dynamic/components/use-dynamic-component.js +17 -31
  46. package/runtime-dynamic/factories/build-base-page-like-component.d.ts +1 -1
  47. package/runtime-dynamic/factories/dynamic-component.js +9 -1
  48. package/runtime-dynamic/factories/prefab-factory.d.ts +1 -1
  49. package/runtime-dynamic/factories/utils.d.ts +1 -1
  50. package/runtime-dynamic/services/component-ref-provider.d.ts +18 -3
  51. package/runtime-dynamic/services/component-ref-provider.js +15 -38
  52. package/runtime-dynamic/services/index.d.ts +2 -3
  53. package/runtime-dynamic/services/index.js +1 -18
  54. package/runtime-dynamic/services/resource-manager.d.ts +2 -3
  55. package/runtime-dynamic/services/resource-manager.js +5 -15
  56. package/runtime-dynamic/services/script-executor.js +1 -7
  57. package/runtime-dynamic/services/variable-registry.js +0 -4
  58. package/utils/attr.js +2 -9
  59. package/utils/custom-expression/index.js +4 -1
  60. package/utils/custom-expression/parser.js +4 -2
  61. package/utils/state-persistance.d.ts +1 -1
  62. package/runtime-dynamic/services/cache.d.ts +0 -29
  63. package/runtime-dynamic/services/cache.js +0 -51
@@ -2,7 +2,7 @@ import React from "react";
2
2
  import { ScriptScope } from "../services/script-executor";
3
3
  import { buildStartupInfo } from "./startup-info";
4
4
  import type { TranspileOptions } from "../services/markup-transpiler";
5
- import type { DecodedFragment } from "../services/cache";
5
+ import type { DecodedFragment } from "../services/component-ref-provider";
6
6
  export interface DynamicComponentConfig {
7
7
  componentName: string;
8
8
  componentType: "page" | "partial" | "prefab";
@@ -1,12 +1,27 @@
1
1
  import { ComponentType } from "./fragment-url";
2
- import type { DecodedFragment } from "./cache";
2
+ export interface PageMinJSON {
3
+ markup: string;
4
+ script: string;
5
+ styles: string;
6
+ variables: string;
7
+ config?: string;
8
+ error?: string;
9
+ }
10
+ export interface DecodedFragment {
11
+ markup: string;
12
+ script: string;
13
+ styles: string;
14
+ variables: Record<string, unknown>;
15
+ config?: Record<string, unknown>;
16
+ error?: string;
17
+ }
3
18
  export interface GetComponentOptions {
4
19
  prefabName?: string;
5
20
  }
6
21
  export declare function getComponentRef(componentName: string, componentType: ComponentType, options?: GetComponentOptions): Promise<DecodedFragment>;
7
22
  export declare function getPrefabConfig(prefabName: string): Promise<Record<string, unknown>>;
8
23
  /**
9
- * Clears fetched fragments, built components, resource HTTP cache, prefab injected assets,
10
- * transpiled markup cache, and compiled variable factories so the next load rebuilds from disk.
24
+ * Resets injected prefab assets and transpile/variable caches so the next
25
+ * load rebuilds from the server.
11
26
  */
12
27
  export declare function clearComponentRefCache(): void;
@@ -1,29 +1,22 @@
1
1
  import isString from "lodash-es/isString";
2
2
  import { transformEx } from "@wavemaker-ai/react-codegen/transpiler";
3
- import { fetchResource, clearResourceCache } from "./resource-manager";
3
+ import { fetchResource } from "./resource-manager";
4
4
  import { getFragmentUrl, getPrefabConfigUrl } from "./fragment-url";
5
- import {
6
- getFragmentFromCache,
7
- setFragmentInCache,
8
- deleteFragmentFromCache,
9
- clearAllCaches,
10
- getPrefabConfigFromCache,
11
- setPrefabConfigInCache,
12
- deletePrefabConfigFromCache
13
- } from "./cache";
14
5
  import { decodeURIComponentSafe, parseJsonSafe } from "../utils";
15
6
  import { clearPrefabResourcesLoaded, loadPrefabResourcesFromConfig } from "./prefab-resources";
16
7
  import { clearTranspileCache } from "./markup-transpiler";
17
8
  import { clearVariablesCache } from "./variable-transpiler";
18
- function getOrCreateCachedPromise(get, set, del, key, create) {
19
- const existing = get(key);
20
- if (existing) return existing;
21
- const pending = create();
22
- set(key, pending);
23
- pending.catch(() => del(key));
24
- return pending;
25
- }
26
9
  function decodeFragment(raw) {
10
+ if (!raw) {
11
+ return {
12
+ markup: "",
13
+ script: "",
14
+ styles: "",
15
+ variables: parseJsonSafe("{}"),
16
+ config: void 0,
17
+ error: "Access Denied"
18
+ };
19
+ }
27
20
  return {
28
21
  markup: decodeURIComponentSafe(raw.markup || ""),
29
22
  script: decodeURIComponentSafe(raw.script || ""),
@@ -34,13 +27,7 @@ function decodeFragment(raw) {
34
27
  }
35
28
  async function loadFragment(componentName, componentType, prefabName) {
36
29
  const url = getFragmentUrl(componentName, componentType, prefabName);
37
- return getOrCreateCachedPromise(
38
- getFragmentFromCache,
39
- setFragmentInCache,
40
- deleteFragmentFromCache,
41
- url,
42
- () => fetchResource(url, true).then(decodeFragment)
43
- );
30
+ return fetchResource(url).then(decodeFragment);
44
31
  }
45
32
  async function getComponentRef(componentName, componentType, options) {
46
33
  return loadFragment(componentName, componentType, options == null ? void 0 : options.prefabName);
@@ -69,21 +56,11 @@ function buildDynamicPrefabProps(result) {
69
56
  }
70
57
  async function getPrefabConfig(prefabName) {
71
58
  const url = getPrefabConfigUrl(prefabName);
72
- return getOrCreateCachedPromise(
73
- getPrefabConfigFromCache,
74
- setPrefabConfigInCache,
75
- deletePrefabConfigFromCache,
76
- url,
77
- async () => {
78
- const raw = await fetchResource(url, true);
79
- await loadPrefabResourcesFromConfig(prefabName, raw);
80
- return buildDynamicPrefabProps(raw);
81
- }
82
- );
59
+ const raw = await fetchResource(url);
60
+ await loadPrefabResourcesFromConfig(prefabName, raw);
61
+ return buildDynamicPrefabProps(raw);
83
62
  }
84
63
  function clearComponentRefCache() {
85
- clearResourceCache();
86
- clearAllCaches();
87
64
  clearPrefabResourcesLoaded();
88
65
  clearTranspileCache();
89
66
  clearVariablesCache();
@@ -1,4 +1,4 @@
1
- export { fetchResource, clearResourceCache } from "./resource-manager";
1
+ export { fetchResource } from "./resource-manager";
2
2
  export { ComponentType, getFragmentUrl, getPrefabBaseUrl, getPrefabConfigUrl, isPrefabSelfPreview, } from "./fragment-url";
3
3
  export { getComponentRef, clearComponentRefCache } from "./component-ref-provider";
4
4
  export { getPrefabResourceUrl } from "./prefab-resources";
@@ -6,5 +6,4 @@ export { buildAddPageScript } from "./script-executor";
6
6
  export { transpileAndBuildGetVariables, clearVariablesCache } from "./variable-transpiler";
7
7
  export { scopeComponentStyles, removeComponentStyles } from "./css-scoping";
8
8
  export { loadAppExtensions } from "./app-extension-provider";
9
- export type { PageMinJSON, DecodedFragment } from "./cache";
10
- export { getFragmentFromCache, setFragmentInCache, getComponentFromCache, setComponentInCache, getScriptFromCache, setScriptInCache, clearAllCaches, } from "./cache";
9
+ export type { PageMinJSON, DecodedFragment } from "./component-ref-provider";
@@ -1,4 +1,4 @@
1
- import { fetchResource, clearResourceCache } from "./resource-manager";
1
+ import { fetchResource } from "./resource-manager";
2
2
  import {
3
3
  ComponentType,
4
4
  getFragmentUrl,
@@ -12,37 +12,20 @@ import { buildAddPageScript } from "./script-executor";
12
12
  import { transpileAndBuildGetVariables, clearVariablesCache } from "./variable-transpiler";
13
13
  import { scopeComponentStyles, removeComponentStyles } from "./css-scoping";
14
14
  import { loadAppExtensions } from "./app-extension-provider";
15
- import {
16
- getFragmentFromCache,
17
- setFragmentInCache,
18
- getComponentFromCache,
19
- setComponentInCache,
20
- getScriptFromCache,
21
- setScriptInCache,
22
- clearAllCaches
23
- } from "./cache";
24
15
  export {
25
16
  ComponentType,
26
17
  buildAddPageScript,
27
- clearAllCaches,
28
18
  clearComponentRefCache,
29
- clearResourceCache,
30
19
  clearVariablesCache,
31
20
  fetchResource,
32
- getComponentFromCache,
33
21
  getComponentRef,
34
- getFragmentFromCache,
35
22
  getFragmentUrl,
36
23
  getPrefabBaseUrl,
37
24
  getPrefabConfigUrl,
38
25
  getPrefabResourceUrl,
39
- getScriptFromCache,
40
26
  isPrefabSelfPreview,
41
27
  loadAppExtensions,
42
28
  removeComponentStyles,
43
29
  scopeComponentStyles,
44
- setComponentInCache,
45
- setFragmentInCache,
46
- setScriptInCache,
47
30
  transpileAndBuildGetVariables
48
31
  };
@@ -1,3 +1,2 @@
1
- export declare function fetchResource<T = unknown>(url: string, useCache?: boolean, optional?: false): Promise<T>;
2
- export declare function fetchResource<T = unknown>(url: string, useCache: boolean, optional: true): Promise<T | null>;
3
- export declare function clearResourceCache(): void;
1
+ export declare function fetchResource<T = unknown>(url: string, optional?: false): Promise<T>;
2
+ export declare function fetchResource<T = unknown>(url: string, optional: true): Promise<T | null>;
@@ -1,35 +1,25 @@
1
1
  import axios from "axios";
2
2
  import { resolvePreviewFetchUrl } from "../preview-resource-base";
3
3
  import { handle401 } from "../../core/app.service";
4
- const cache = /* @__PURE__ */ new Map();
5
- async function fetchResource(url, useCache = true, optional = false) {
4
+ async function fetchResource(url, optional = false) {
6
5
  var _a;
7
6
  const resolvedUrl = resolvePreviewFetchUrl(url);
8
- if (useCache && cache.has(resolvedUrl)) {
9
- return cache.get(resolvedUrl);
10
- }
11
7
  try {
12
8
  const response = await axios.get(resolvedUrl);
13
- const { data } = response;
14
- if (useCache) {
15
- cache.set(resolvedUrl, data);
16
- }
17
- return data;
9
+ return response.data;
18
10
  } catch (error) {
19
11
  if (optional) {
20
12
  return null;
21
13
  }
22
14
  const status = (_a = error == null ? void 0 : error.response) == null ? void 0 : _a.status;
23
- if (status === 401 || status === 403) {
15
+ if (status === 401) {
24
16
  handle401();
17
+ } else if (status === 403) {
18
+ return null;
25
19
  }
26
20
  throw error;
27
21
  }
28
22
  }
29
- function clearResourceCache() {
30
- cache.clear();
31
- }
32
23
  export {
33
- clearResourceCache,
34
24
  fetchResource
35
25
  };
@@ -1,7 +1,6 @@
1
1
  import * as lodash from "lodash-es";
2
2
  import moment from "moment";
3
3
  import { Utils } from "../../core/util/utils";
4
- import { getScriptFromCache, setScriptInCache } from "./cache";
5
4
  var ScriptScope = /* @__PURE__ */ ((ScriptScope2) => {
6
5
  ScriptScope2["PAGE"] = "Page";
7
6
  ScriptScope2["PARTIAL"] = "Partial";
@@ -43,15 +42,12 @@ function prepareScript(raw) {
43
42
  function buildAddPageScript(script, scopeKind, componentName) {
44
43
  if (!script) return () => {
45
44
  };
46
- const cacheKey = `${scopeKind}:${componentName}`;
47
- const cached = getScriptFromCache(cacheKey);
48
- if (cached) return cached;
49
45
  try {
50
46
  const cleanScript = prepareScript(script);
51
47
  const allNames = [...Object.keys(SCRIPT_GLOBALS), ...DEFERRED_GLOBALS];
52
48
  const compiledFn = new Function("App", scopeKind, ...allNames, cleanScript);
53
49
  const staticValues = Object.keys(SCRIPT_GLOBALS).map((k) => SCRIPT_GLOBALS[k]);
54
- const boundFn = (app, page) => {
50
+ return (app, page) => {
55
51
  try {
56
52
  const deferredValues = DEFERRED_GLOBALS.map((k) => window[k]);
57
53
  compiledFn(app, page, ...staticValues, ...deferredValues);
@@ -62,8 +58,6 @@ function buildAddPageScript(script, scopeKind, componentName) {
62
58
  );
63
59
  }
64
60
  };
65
- setScriptInCache(cacheKey, boundFn);
66
- return boundFn;
67
61
  } catch (compileError) {
68
62
  console.error(
69
63
  `[script-executor] Compilation error in ${scopeKind} script "${componentName}":`,
@@ -51,15 +51,11 @@ const SCOPE_MAP = {
51
51
  const EMPTY_RESULT = { Variables: {}, Actions: {} };
52
52
  function createLazyPartial(partialName) {
53
53
  return lazy(async () => {
54
- const { getComponentFromCache, setComponentInCache } = await import("./cache");
55
54
  const { ComponentType: FType } = await import("./fragment-url");
56
55
  const { getComponentRef } = await import("./component-ref-provider");
57
56
  const { buildBasePageLikeComponent } = await import("../factories/build-base-page-like-component");
58
- const cached = getComponentFromCache(FType.PARTIAL, partialName);
59
- if (cached) return { default: cached };
60
57
  const fragment = await getComponentRef(partialName, FType.PARTIAL);
61
58
  const Built = await buildBasePageLikeComponent("partial", partialName, fragment);
62
- setComponentInCache(FType.PARTIAL, partialName, Built);
63
59
  return { default: Built };
64
60
  });
65
61
  }
package/utils/attr.js CHANGED
@@ -4,24 +4,17 @@ const INTERNAL_ATTRIBUTES = /* @__PURE__ */ new Set([
4
4
  "conditionalstyle",
5
5
  "dataset",
6
6
  "destroy",
7
- "eventCallback",
8
7
  "formfield",
9
- "forwardedRef",
10
8
  "inbound",
11
9
  "iswidget",
12
- "listener",
13
- "onHeaderclick",
14
- "onHeaderClick",
15
- "onLoad",
16
- "onDestroy",
17
- "onNavHeightChange",
18
10
  "onRender",
19
11
  "outbound",
20
12
  "prefab",
21
13
  "ref",
22
14
  "showindevice",
23
15
  "styles",
24
- "viewParent"
16
+ "viewParent",
17
+ "onLeftPanelAnimationChange"
25
18
  ]);
26
19
  const SAFE_ATTRIBUTES = /* @__PURE__ */ new Set([
27
20
  "accessKey",
@@ -43,7 +43,10 @@ async function buildCustomExpressionComponentsMap(options) {
43
43
  const results = await Promise.all(
44
44
  keys.map(async (key) => {
45
45
  const transformedMarkup = normalizeTransformedMarkupRowBinding(
46
- tm(columnSource[key].customExpression)
46
+ tm(columnSource[key].customExpression, {
47
+ appUrl: "",
48
+ insideTableColumn: true
49
+ })
47
50
  );
48
51
  const component = await parseFn(transformedMarkup, listener);
49
52
  return { key, component };
@@ -18,8 +18,8 @@ function extractMarkupComponents(markup) {
18
18
  }
19
19
  function resolveCustomExpressionScope(imports, fragment, markupForInference) {
20
20
  const fr = fragment;
21
- const names = ["React", "fragment", "row", "Widgets", "Variables"];
22
- const values = [React, fragment, void 0, fr == null ? void 0 : fr.Widgets, fr == null ? void 0 : fr.Variables];
21
+ const names = ["React", "fragment", "row", "rowData", "Widgets", "Variables"];
22
+ const values = [React, fragment, void 0, void 0, fr == null ? void 0 : fr.Widgets, fr == null ? void 0 : fr.Variables];
23
23
  const seen = new Set(names);
24
24
  for (const importDef of imports) {
25
25
  const binding = importDef.as || importDef.name;
@@ -87,6 +87,7 @@ return __render__();`;
87
87
  ${jsxInner}`
88
88
  );
89
89
  const rowIdx = names.indexOf("row");
90
+ const rowDataIdx = names.indexOf("rowData");
90
91
  const fragmentIdx = names.indexOf("fragment");
91
92
  const widgetsIdx = names.indexOf("Widgets");
92
93
  const variablesIdx = names.indexOf("Variables");
@@ -110,6 +111,7 @@ ${jsxInner}`
110
111
  try {
111
112
  const args = templateValues.slice();
112
113
  args[rowIdx] = rowData;
114
+ if (rowDataIdx >= 0) args[rowDataIdx] = rowData;
113
115
  const fr = fragment;
114
116
  if (fragmentIdx >= 0) args[fragmentIdx] = fragment;
115
117
  if (widgetsIdx >= 0) args[widgetsIdx] = fr == null ? void 0 : fr.Widgets;
@@ -1,5 +1,5 @@
1
1
  export type StorageType = "localStorage" | "sessionStorage" | "URL" | "none";
2
- type WidgetType = "accordion" | "tabs" | "list" | "table";
2
+ type WidgetType = "accordion" | "tabs" | "list" | "table" | "tree";
3
3
  interface StateConfig {
4
4
  name: string;
5
5
  type: WidgetType;
@@ -1,29 +0,0 @@
1
- import type React from "react";
2
- import { ComponentType } from "./fragment-url";
3
- export interface PageMinJSON {
4
- markup: string;
5
- script: string;
6
- styles: string;
7
- variables: string;
8
- config?: string;
9
- }
10
- export interface DecodedFragment {
11
- markup: string;
12
- script: string;
13
- styles: string;
14
- variables: Record<string, unknown>;
15
- config?: Record<string, unknown>;
16
- }
17
- type ScriptFn = (...args: unknown[]) => void;
18
- export declare const getPrefabConfigFromCache: (url: string) => Promise<Record<string, unknown>> | undefined;
19
- export declare function setPrefabConfigInCache(url: string, config: Promise<Record<string, unknown>>): void;
20
- export declare function deletePrefabConfigFromCache(url: string): void;
21
- export declare const getFragmentFromCache: (url: string) => Promise<DecodedFragment> | undefined;
22
- export declare function setFragmentInCache(url: string, fragment: Promise<DecodedFragment>): void;
23
- export declare function deleteFragmentFromCache(url: string): void;
24
- export declare const getComponentFromCache: (componentType: ComponentType, componentName: string) => React.ComponentType<any> | undefined;
25
- export declare function setComponentInCache(componentType: ComponentType, componentName: string, component: React.ComponentType<any>): void;
26
- export declare const getScriptFromCache: (identifier: string) => ScriptFn | undefined;
27
- export declare function setScriptInCache(identifier: string, scriptFn: ScriptFn): void;
28
- export declare function clearAllCaches(): void;
29
- export {};
@@ -1,51 +0,0 @@
1
- const fragmentCache = /* @__PURE__ */ new Map();
2
- const componentCache = /* @__PURE__ */ new Map();
3
- const scriptCache = /* @__PURE__ */ new Map();
4
- const prefabConfigCache = /* @__PURE__ */ new Map();
5
- const getPrefabConfigFromCache = (url) => prefabConfigCache.get(url);
6
- function setPrefabConfigInCache(url, config) {
7
- prefabConfigCache.set(url, config);
8
- }
9
- function deletePrefabConfigFromCache(url) {
10
- prefabConfigCache.delete(url);
11
- }
12
- const getFragmentFromCache = (url) => fragmentCache.get(url);
13
- function setFragmentInCache(url, fragment) {
14
- fragmentCache.set(url, fragment);
15
- }
16
- function deleteFragmentFromCache(url) {
17
- fragmentCache.delete(url);
18
- }
19
- const getComponentFromCache = (componentType, componentName) => {
20
- var _a;
21
- return (_a = componentCache.get(componentType)) == null ? void 0 : _a.get(componentName);
22
- };
23
- function setComponentInCache(componentType, componentName, component) {
24
- if (!componentCache.has(componentType)) {
25
- componentCache.set(componentType, /* @__PURE__ */ new Map());
26
- }
27
- componentCache.get(componentType).set(componentName, component);
28
- }
29
- const getScriptFromCache = (identifier) => scriptCache.get(identifier);
30
- function setScriptInCache(identifier, scriptFn) {
31
- scriptCache.set(identifier, scriptFn);
32
- }
33
- function clearAllCaches() {
34
- fragmentCache.clear();
35
- componentCache.clear();
36
- scriptCache.clear();
37
- prefabConfigCache.clear();
38
- }
39
- export {
40
- clearAllCaches,
41
- deleteFragmentFromCache,
42
- deletePrefabConfigFromCache,
43
- getComponentFromCache,
44
- getFragmentFromCache,
45
- getPrefabConfigFromCache,
46
- getScriptFromCache,
47
- setComponentInCache,
48
- setFragmentInCache,
49
- setPrefabConfigInCache,
50
- setScriptInCache
51
- };