@axelor/aos-mobile-core 8.4.24 → 8.4.25
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/lib/apiProviders/Action/index.d.ts +1 -1
- package/lib/apiProviders/Action/index.js +1 -0
- package/lib/apiProviders/Action/index.js.map +1 -1
- package/lib/apiProviders/Action/utils.d.ts +5 -0
- package/lib/apiProviders/Action/utils.js +16 -1
- package/lib/apiProviders/Action/utils.js.map +1 -1
- package/lib/apiProviders/Standard/requests.helper.js +2 -2
- package/lib/apiProviders/Standard/requests.helper.js.map +1 -1
- package/lib/apiProviders/index.d.ts +6 -6
- package/lib/apiProviders/index.js.map +1 -1
- package/lib/apiProviders/middlewares/fieldParser.js +18 -6
- package/lib/apiProviders/middlewares/fieldParser.js.map +1 -1
- package/lib/app/ContextedApplication.js +2 -0
- package/lib/app/ContextedApplication.js.map +1 -1
- package/lib/components/external/WebView/WebView.d.ts +5 -1
- package/lib/components/external/WebView/WebView.js +13 -5
- package/lib/components/external/WebView/WebView.js.map +1 -1
- package/lib/components/organisms/DateInput/DateInput.js +6 -3
- package/lib/components/organisms/DateInput/DateInput.js.map +1 -1
- package/lib/components/pages/FormView/Components/Field.d.ts +3 -3
- package/lib/components/pages/FormView/Components/Field.js +11 -20
- package/lib/components/pages/FormView/Components/Field.js.map +1 -1
- package/lib/components/pages/FormView/Components/Panel.d.ts +4 -2
- package/lib/components/pages/FormView/Components/Panel.js +19 -14
- package/lib/components/pages/FormView/Components/Panel.js.map +1 -1
- package/lib/components/pages/FormView/FormView.js +12 -12
- package/lib/components/pages/FormView/FormView.js.map +1 -1
- package/lib/components/templates/SearchListView/SearchListView.d.ts +2 -1
- package/lib/components/templates/SearchListView/SearchListView.js +4 -1
- package/lib/components/templates/SearchListView/SearchListView.js.map +1 -1
- package/lib/forms/studio/display.helpers.js +6 -1
- package/lib/forms/studio/display.helpers.js.map +1 -1
- package/lib/forms/studio/formula.helpers.js +55 -0
- package/lib/forms/studio/formula.helpers.js.map +1 -1
- package/lib/forms/types.d.ts +3 -0
- package/lib/header/HeaderActionsProvider.js +6 -4
- package/lib/header/HeaderActionsProvider.js.map +1 -1
- package/lib/header/hooks.js +1 -1
- package/lib/header/hooks.js.map +1 -1
- package/lib/loader/ProcessStorage.d.ts +1 -0
- package/lib/loader/ProcessStorage.js +3 -0
- package/lib/loader/ProcessStorage.js.map +1 -1
- package/lib/loader/hooks.js +3 -0
- package/lib/loader/hooks.js.map +1 -1
- package/lib/permissions/format.helpers.js +9 -3
- package/lib/permissions/format.helpers.js.map +1 -1
- package/lib/selections/SelectionProvider.js +3 -2
- package/lib/selections/SelectionProvider.js.map +1 -1
- package/lib/tools/FileViewer.js +15 -16
- package/lib/tools/FileViewer.js.map +1 -1
- package/lib/utils/file.d.ts +1 -0
- package/lib/utils/file.js +1 -0
- package/lib/utils/file.js.map +1 -1
- package/lib/utils/index.d.ts +1 -1
- package/lib/utils/index.js +1 -1
- package/lib/utils/index.js.map +1 -1
- package/lib/webViews/WebViewPreloader.d.ts +3 -0
- package/lib/webViews/WebViewPreloader.js +111 -0
- package/lib/webViews/WebViewPreloader.js.map +1 -0
- package/lib/webViews/display.helpers.d.ts +5 -0
- package/lib/webViews/display.helpers.js +5 -0
- package/lib/webViews/display.helpers.js.map +1 -1
- package/lib/webViews/menu.helper.d.ts +2 -9
- package/lib/webViews/menu.helper.js +11 -4
- package/lib/webViews/menu.helper.js.map +1 -1
- package/lib/webViews/view/WebViewScreen.d.ts +3 -1
- package/lib/webViews/view/WebViewScreen.js +14 -10
- package/lib/webViews/view/WebViewScreen.js.map +1 -1
- package/lib/webViews/webView.provider.d.ts +28 -0
- package/lib/webViews/webView.provider.js +65 -0
- package/lib/webViews/webView.provider.js.map +1 -0
- package/package.json +8 -3
package/lib/tools/FileViewer.js
CHANGED
|
@@ -16,32 +16,31 @@
|
|
|
16
16
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
17
17
|
*/
|
|
18
18
|
import FileViewer from 'react-native-file-viewer';
|
|
19
|
+
import RNFetchBlob from 'react-native-blob-util';
|
|
19
20
|
import RNFS from 'react-native-fs';
|
|
20
|
-
import { showToastMessage } from '../utils
|
|
21
|
+
import { sanitizeLocalFileName, showToastMessage } from '../utils';
|
|
21
22
|
export const openFileInExternalApp = async (file, authentification, I18n) => {
|
|
22
23
|
if (file == null) {
|
|
23
24
|
return;
|
|
24
25
|
}
|
|
25
|
-
const localFile = `${RNFS.DocumentDirectoryPath}/${file.fileName}`;
|
|
26
|
+
const localFile = `${RNFS.DocumentDirectoryPath}/${sanitizeLocalFileName(file.fileName)}`;
|
|
26
27
|
const fromUrl = file.path != null
|
|
27
28
|
? `${authentification.baseUrl}${file.path}`
|
|
28
29
|
: file.isMetaFile
|
|
29
30
|
? `${authentification.baseUrl}ws/rest/com.axelor.meta.db.MetaFile/${file.id}/content/download`
|
|
30
31
|
: `${authentification.baseUrl}ws/dms/inline/${file.id}`;
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
toFile: localFile,
|
|
34
|
-
headers: {
|
|
32
|
+
try {
|
|
33
|
+
const res = await RNFetchBlob.config({ path: localFile }).fetch('GET', fromUrl, {
|
|
35
34
|
Cookie: `CSRF-TOKEN=${authentification.token}; ${authentification.jsessionId}`,
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
35
|
+
});
|
|
36
|
+
const { status } = res.info();
|
|
37
|
+
if (status < 200 || status >= 300) {
|
|
38
|
+
await RNFS.unlink(localFile).catch(() => { });
|
|
39
|
+
throw new Error(`Download failed with status ${status}`);
|
|
40
|
+
}
|
|
41
|
+
await FileViewer.open(localFile, { showOpenWithDialog: true });
|
|
42
|
+
}
|
|
43
|
+
catch (error) {
|
|
45
44
|
showToastMessage({
|
|
46
45
|
type: 'error',
|
|
47
46
|
position: 'bottom',
|
|
@@ -49,6 +48,6 @@ export const openFileInExternalApp = async (file, authentification, I18n) => {
|
|
|
49
48
|
text2: I18n.t('Auth_CannotOpenFile'),
|
|
50
49
|
});
|
|
51
50
|
console.log(error);
|
|
52
|
-
}
|
|
51
|
+
}
|
|
53
52
|
};
|
|
54
53
|
//# sourceMappingURL=FileViewer.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FileViewer.js","sourceRoot":"","sources":["../../src/tools/FileViewer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,UAAU,MAAM,0BAA0B,CAAC;AAClD,OAAO,IAAI,MAAM,iBAAiB,CAAC;AAEnC,OAAO,EAAC,gBAAgB,EAAC,MAAM,
|
|
1
|
+
{"version":3,"file":"FileViewer.js","sourceRoot":"","sources":["../../src/tools/FileViewer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,UAAU,MAAM,0BAA0B,CAAC;AAClD,OAAO,WAAW,MAAM,wBAAwB,CAAC;AACjD,OAAO,IAAI,MAAM,iBAAiB,CAAC;AAEnC,OAAO,EAAC,qBAAqB,EAAE,gBAAgB,EAAC,MAAM,UAAU,CAAC;AAmBjE,MAAM,CAAC,MAAM,qBAAqB,GAAG,KAAK,EACxC,IAAyB,EACzB,gBAA+B,EAC/B,IAAqB,EACrB,EAAE;IACF,IAAI,IAAI,IAAI,IAAI,EAAE;QAChB,OAAO;KACR;IAED,MAAM,SAAS,GAAG,GAAG,IAAI,CAAC,qBAAqB,IAAI,qBAAqB,CACtE,IAAI,CAAC,QAAQ,CACd,EAAE,CAAC;IAEJ,MAAM,OAAO,GACV,IAAiB,CAAC,IAAI,IAAI,IAAI;QAC7B,CAAC,CAAC,GAAG,gBAAgB,CAAC,OAAO,GAAI,IAAiB,CAAC,IAAI,EAAE;QACzD,CAAC,CAAE,IAAiB,CAAC,UAAU;YAC7B,CAAC,CAAC,GAAG,gBAAgB,CAAC,OAAO,uCACxB,IAAiB,CAAC,EACrB,mBAAmB;YACrB,CAAC,CAAC,GAAG,gBAAgB,CAAC,OAAO,iBAAkB,IAAiB,CAAC,EAAE,EAAE,CAAC;IAE5E,IAAI;QACF,MAAM,GAAG,GAAG,MAAM,WAAW,CAAC,MAAM,CAAC,EAAC,IAAI,EAAE,SAAS,EAAC,CAAC,CAAC,KAAK,CAC3D,KAAK,EACL,OAAO,EACP;YACE,MAAM,EAAE,cAAc,gBAAgB,CAAC,KAAK,KAAK,gBAAgB,CAAC,UAAU,EAAE;SAC/E,CACF,CAAC;QACF,MAAM,EAAC,MAAM,EAAC,GAAG,GAAG,CAAC,IAAI,EAAE,CAAC;QAE5B,IAAI,MAAM,GAAG,GAAG,IAAI,MAAM,IAAI,GAAG,EAAE;YACjC,MAAM,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;YAC7C,MAAM,IAAI,KAAK,CAAC,+BAA+B,MAAM,EAAE,CAAC,CAAC;SAC1D;QAED,MAAM,UAAU,CAAC,IAAI,CAAC,SAAS,EAAE,EAAC,kBAAkB,EAAE,IAAI,EAAC,CAAC,CAAC;KAC9D;IAAC,OAAO,KAAK,EAAE;QACd,gBAAgB,CAAC;YACf,IAAI,EAAE,OAAO;YACb,QAAQ,EAAE,QAAQ;YAClB,KAAK,EAAE,IAAI,CAAC,CAAC,CAAC,YAAY,CAAC;YAC3B,KAAK,EAAE,IAAI,CAAC,CAAC,CAAC,qBAAqB,CAAC;SACrC,CAAC,CAAC;QACH,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;KACpB;AACH,CAAC,CAAC"}
|
package/lib/utils/file.d.ts
CHANGED
package/lib/utils/file.js
CHANGED
|
@@ -19,4 +19,5 @@ export const sanitizeFileName = (name) => name
|
|
|
19
19
|
?.normalize('NFD')
|
|
20
20
|
.replace(/[\u0300-\u036f]/g, '')
|
|
21
21
|
.replace(/[ :*?"<>|\\]/g, '_');
|
|
22
|
+
export const sanitizeLocalFileName = (name) => sanitizeFileName(name)?.replace(/[^a-zA-Z0-9._\-()]/g, '_');
|
|
22
23
|
//# sourceMappingURL=file.js.map
|
package/lib/utils/file.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"file.js","sourceRoot":"","sources":["../../src/utils/file.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,IAAY,EAAE,EAAE,CAC/C,IAAI;IACF,EAAE,SAAS,CAAC,KAAK,CAAC;KACjB,OAAO,CAAC,kBAAkB,EAAE,EAAE,CAAC;KAC/B,OAAO,CAAC,eAAe,EAAE,GAAG,CAAC,CAAC"}
|
|
1
|
+
{"version":3,"file":"file.js","sourceRoot":"","sources":["../../src/utils/file.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,IAAY,EAAE,EAAE,CAC/C,IAAI;IACF,EAAE,SAAS,CAAC,KAAK,CAAC;KACjB,OAAO,CAAC,kBAAkB,EAAE,EAAE,CAAC;KAC/B,OAAO,CAAC,eAAe,EAAE,GAAG,CAAC,CAAC;AAEnC,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,IAAY,EAAE,EAAE,CACpD,gBAAgB,CAAC,IAAI,CAAC,EAAE,OAAO,CAAC,qBAAqB,EAAE,GAAG,CAAC,CAAC"}
|
package/lib/utils/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ export { updateAgendaItems } from './agenda';
|
|
|
2
2
|
export * from './api';
|
|
3
3
|
export { decreaseDate, diffDate, getDay, getEndOfDay, getFromNowDate, getFullDateItems, getMonth, getNextMonth, getPreviousMonth, getStartOfDay, incrementDate, isDate, isDateTime, ISODateTimeToDate, isMidnightDate, isToday, sameDate, } from './date';
|
|
4
4
|
export { displayItemName, displayItemFullname, displayItemTitle, } from './displayers';
|
|
5
|
-
export { sanitizeFileName } from './file';
|
|
5
|
+
export { sanitizeFileName, sanitizeLocalFileName } from './file';
|
|
6
6
|
export { formatDate, formatDateTime, formatTime, formatScan, formatURL, getNowDateZonesISOString, getDateZonesISOString, formatRequestBody, } from './formatters';
|
|
7
7
|
export { useBinaryImageUri, useBinaryPictureUri, useMetafileUri } from './image';
|
|
8
8
|
export { filterList, filterListContain, getLastItem, getNextItem } from './list';
|
package/lib/utils/index.js
CHANGED
|
@@ -19,7 +19,7 @@ export { updateAgendaItems } from './agenda';
|
|
|
19
19
|
export * from './api';
|
|
20
20
|
export { decreaseDate, diffDate, getDay, getEndOfDay, getFromNowDate, getFullDateItems, getMonth, getNextMonth, getPreviousMonth, getStartOfDay, incrementDate, isDate, isDateTime, ISODateTimeToDate, isMidnightDate, isToday, sameDate, } from './date';
|
|
21
21
|
export { displayItemName, displayItemFullname, displayItemTitle, } from './displayers';
|
|
22
|
-
export { sanitizeFileName } from './file';
|
|
22
|
+
export { sanitizeFileName, sanitizeLocalFileName } from './file';
|
|
23
23
|
export { formatDate, formatDateTime, formatTime, formatScan, formatURL, getNowDateZonesISOString, getDateZonesISOString, formatRequestBody, } from './formatters';
|
|
24
24
|
export { useBinaryImageUri, useBinaryPictureUri, useMetafileUri } from './image';
|
|
25
25
|
export { filterList, filterListContain, getLastItem, getNextItem } from './list';
|
package/lib/utils/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAC,iBAAiB,EAAC,MAAM,UAAU,CAAC;AAC3C,cAAc,OAAO,CAAC;AACtB,OAAO,EACL,YAAY,EACZ,QAAQ,EACR,MAAM,EACN,WAAW,EACX,cAAc,EACd,gBAAgB,EAChB,QAAQ,EACR,YAAY,EACZ,gBAAgB,EAChB,aAAa,EACb,aAAa,EACb,MAAM,EACN,UAAU,EACV,iBAAiB,EACjB,cAAc,EACd,OAAO,EACP,QAAQ,GACT,MAAM,QAAQ,CAAC;AAChB,OAAO,EACL,eAAe,EACf,mBAAmB,EACnB,gBAAgB,GACjB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAC,gBAAgB,EAAC,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAC,iBAAiB,EAAC,MAAM,UAAU,CAAC;AAC3C,cAAc,OAAO,CAAC;AACtB,OAAO,EACL,YAAY,EACZ,QAAQ,EACR,MAAM,EACN,WAAW,EACX,cAAc,EACd,gBAAgB,EAChB,QAAQ,EACR,YAAY,EACZ,gBAAgB,EAChB,aAAa,EACb,aAAa,EACb,MAAM,EACN,UAAU,EACV,iBAAiB,EACjB,cAAc,EACd,OAAO,EACP,QAAQ,GACT,MAAM,QAAQ,CAAC;AAChB,OAAO,EACL,eAAe,EACf,mBAAmB,EACnB,gBAAgB,GACjB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAC,gBAAgB,EAAE,qBAAqB,EAAC,MAAM,QAAQ,CAAC;AAC/D,OAAO,EACL,UAAU,EACV,cAAc,EACd,UAAU,EACV,UAAU,EACV,SAAS,EACT,wBAAwB,EACxB,qBAAqB,EACrB,iBAAiB,GAClB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAC,iBAAiB,EAAE,mBAAmB,EAAE,cAAc,EAAC,MAAM,SAAS,CAAC;AAC/E,OAAO,EAAC,UAAU,EAAE,iBAAiB,EAAE,WAAW,EAAE,WAAW,EAAC,MAAM,QAAQ,CAAC;AAC/E,OAAO,EACL,aAAa,EACb,cAAc,EACd,eAAe,EACf,cAAc,EACd,2BAA2B,EAC3B,mBAAmB,GACpB,MAAM,QAAQ,CAAC;AAChB,OAAO,EACL,gBAAgB,EAChB,OAAO,EACP,cAAc,EACd,mBAAmB,EACnB,kBAAkB,EAClB,aAAa,GACd,MAAM,UAAU,CAAC;AAClB,OAAO,EAAC,QAAQ,EAAC,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAC,gBAAgB,EAAC,MAAM,sBAAsB,CAAC;AACtD,OAAO,EACL,eAAe,EACf,mBAAmB,EACnB,MAAM,EACN,UAAU,EACV,cAAc,GACf,MAAM,UAAU,CAAC;AAClB,OAAO,EAAC,UAAU,EAAE,kBAAkB,EAAC,MAAM,UAAU,CAAC"}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Axelor Business Solutions
|
|
3
|
+
*
|
|
4
|
+
* Copyright (C) 2026 Axelor (<http://axelor.com>).
|
|
5
|
+
*
|
|
6
|
+
* This program is free software: you can redistribute it and/or modify
|
|
7
|
+
* it under the terms of the GNU Affero General Public License, version 3,
|
|
8
|
+
* as published by the Free Software Foundation.
|
|
9
|
+
*
|
|
10
|
+
* This program is distributed in the hope that it will be useful,
|
|
11
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13
|
+
* GNU Affero General Public License for more details.
|
|
14
|
+
*
|
|
15
|
+
* You should have received a copy of the GNU Affero General Public License
|
|
16
|
+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
17
|
+
*/
|
|
18
|
+
import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
19
|
+
import { StyleSheet, View } from 'react-native';
|
|
20
|
+
import { WebView } from '../components';
|
|
21
|
+
import { useOnline } from '../features/onlineSlice';
|
|
22
|
+
import { useSelector } from '../redux/hooks';
|
|
23
|
+
import { createWebViewPath } from './display.helpers';
|
|
24
|
+
import { useWebViewConfigs } from './webView.provider';
|
|
25
|
+
const PRELOAD_MESSAGE_TYPE = 'aos-webview-preload';
|
|
26
|
+
const SERVICE_WORKER_TIMEOUT = 20000;
|
|
27
|
+
const NATIVE_FALLBACK_TIMEOUT = SERVICE_WORKER_TIMEOUT + 5000;
|
|
28
|
+
const PRELOAD_SCRIPT = `
|
|
29
|
+
(function () {
|
|
30
|
+
var reported = false;
|
|
31
|
+
var report = function (hasServiceWorker) {
|
|
32
|
+
if (reported) { return; }
|
|
33
|
+
reported = true;
|
|
34
|
+
window.ReactNativeWebView.postMessage(JSON.stringify({
|
|
35
|
+
type: '${PRELOAD_MESSAGE_TYPE}',
|
|
36
|
+
hasServiceWorker: hasServiceWorker,
|
|
37
|
+
}));
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
if (!('serviceWorker' in navigator)) {
|
|
41
|
+
report(false);
|
|
42
|
+
} else {
|
|
43
|
+
navigator.serviceWorker.ready.then(function () { report(true); });
|
|
44
|
+
setTimeout(function () { report(false); }, ${SERVICE_WORKER_TIMEOUT});
|
|
45
|
+
}
|
|
46
|
+
})();
|
|
47
|
+
true;
|
|
48
|
+
`;
|
|
49
|
+
const WebViewPreloader = () => {
|
|
50
|
+
const configs = useWebViewConfigs();
|
|
51
|
+
const { isEnabled: isConnected } = useOnline();
|
|
52
|
+
const { logged } = useSelector(state => state.auth);
|
|
53
|
+
const [queue, setQueue] = useState([]);
|
|
54
|
+
const preloadedIds = useRef([]);
|
|
55
|
+
const fallbackTimeout = useRef(null);
|
|
56
|
+
useEffect(() => {
|
|
57
|
+
if (!logged) {
|
|
58
|
+
preloadedIds.current = [];
|
|
59
|
+
setQueue([]);
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
if (!isConnected)
|
|
63
|
+
return;
|
|
64
|
+
setQueue(configs.filter(({ id }) => !preloadedIds.current.includes(id)));
|
|
65
|
+
}, [configs, isConnected, logged]);
|
|
66
|
+
const current = useMemo(() => (logged && isConnected ? queue[0] : null), [isConnected, logged, queue]);
|
|
67
|
+
const completeCurrent = useCallback((isPreloaded) => {
|
|
68
|
+
clearTimeout(fallbackTimeout.current);
|
|
69
|
+
if (isPreloaded && current != null) {
|
|
70
|
+
preloadedIds.current = [...preloadedIds.current, current.id];
|
|
71
|
+
}
|
|
72
|
+
setQueue(_queue => _queue.slice(1));
|
|
73
|
+
}, [current]);
|
|
74
|
+
useEffect(() => {
|
|
75
|
+
if (current == null)
|
|
76
|
+
return;
|
|
77
|
+
fallbackTimeout.current = setTimeout(() => completeCurrent(false), NATIVE_FALLBACK_TIMEOUT);
|
|
78
|
+
return () => clearTimeout(fallbackTimeout.current);
|
|
79
|
+
}, [completeCurrent, current]);
|
|
80
|
+
const handleMessage = useCallback((event) => {
|
|
81
|
+
try {
|
|
82
|
+
const payload = JSON.parse(event?.nativeEvent?.data);
|
|
83
|
+
if (payload?.type === PRELOAD_MESSAGE_TYPE) {
|
|
84
|
+
completeCurrent(payload.hasServiceWorker === true);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
catch { }
|
|
88
|
+
}, [completeCurrent]);
|
|
89
|
+
const handleError = useCallback(() => completeCurrent(false), [completeCurrent]);
|
|
90
|
+
if (current == null)
|
|
91
|
+
return null;
|
|
92
|
+
return (<View style={styles.container} pointerEvents="none">
|
|
93
|
+
<WebView key={current.id} style={styles.webView} baseUrl={current.url} path={createWebViewPath(current)} injectedJavaScript={PRELOAD_SCRIPT} onMessage={handleMessage} onError={handleError}/>
|
|
94
|
+
</View>);
|
|
95
|
+
};
|
|
96
|
+
const styles = StyleSheet.create({
|
|
97
|
+
container: {
|
|
98
|
+
position: 'absolute',
|
|
99
|
+
top: -1000,
|
|
100
|
+
left: -1000,
|
|
101
|
+
width: 1,
|
|
102
|
+
height: 1,
|
|
103
|
+
opacity: 0,
|
|
104
|
+
},
|
|
105
|
+
webView: {
|
|
106
|
+
width: 1,
|
|
107
|
+
height: 1,
|
|
108
|
+
},
|
|
109
|
+
});
|
|
110
|
+
export default WebViewPreloader;
|
|
111
|
+
//# sourceMappingURL=WebViewPreloader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WebViewPreloader.js","sourceRoot":"","sources":["../../src/webVi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E,CAAC;QACR,MAAM,EAAE,CAAC;QACT,OAAO,EAAE,CAAC;KACX;IACD,OAAO,EAAE;QACP,KAAK,EAAE,CAAC;QACR,MAAM,EAAE,CAAC;KACV;CACF,CAAC,CAAC;AAEH,eAAe,gBAAgB,CAAC"}
|
|
@@ -18,4 +18,9 @@
|
|
|
18
18
|
export const createWebViewActionID = (id) => {
|
|
19
19
|
return `core_webView${id}_details`;
|
|
20
20
|
};
|
|
21
|
+
export const createWebViewPath = (config) => {
|
|
22
|
+
return config?.metaAction?.name != null
|
|
23
|
+
? `#/ds/${config.metaAction.name}`
|
|
24
|
+
: '';
|
|
25
|
+
};
|
|
21
26
|
//# sourceMappingURL=display.helpers.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"display.helpers.js","sourceRoot":"","sources":["../../src/webViews/display.helpers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,EAAU,EAAE,EAAE;IAClD,OAAO,eAAe,EAAE,UAAU,CAAC;AACrC,CAAC,CAAC"}
|
|
1
|
+
{"version":3,"file":"display.helpers.js","sourceRoot":"","sources":["../../src/webViews/display.helpers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,EAAU,EAAE,EAAE;IAClD,OAAO,eAAe,EAAE,UAAU,CAAC;AACrC,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,MAEjC,EAAU,EAAE;IACX,OAAO,MAAM,EAAE,UAAU,EAAE,IAAI,IAAI,IAAI;QACrC,CAAC,CAAC,QAAQ,MAAM,CAAC,UAAU,CAAC,IAAI,EAAE;QAClC,CAAC,CAAC,EAAE,CAAC;AACT,CAAC,CAAC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Menu, Screen } from '../app';
|
|
2
|
+
import { WebViewConfig } from './webView.provider';
|
|
2
3
|
type WebViewMenuConfig = {
|
|
3
4
|
[menuKey: string]: {
|
|
4
5
|
menu: Menu;
|
|
@@ -11,15 +12,7 @@ type Menus = {
|
|
|
11
12
|
type Screens = {
|
|
12
13
|
[screenKey: string]: Screen;
|
|
13
14
|
};
|
|
14
|
-
export declare const createWebViewScreens: (webViewConfigs: {
|
|
15
|
-
id: number;
|
|
16
|
-
appName: string;
|
|
17
|
-
isAosWebView: boolean;
|
|
18
|
-
menuTitle?: string;
|
|
19
|
-
iconName?: string;
|
|
20
|
-
menuOrder?: number;
|
|
21
|
-
authorizedRoleSet: any[];
|
|
22
|
-
}[]) => {
|
|
15
|
+
export declare const createWebViewScreens: (webViewConfigs: WebViewConfig[]) => {
|
|
23
16
|
menus: WebViewMenuConfig;
|
|
24
17
|
screens: Screens;
|
|
25
18
|
};
|
|
@@ -19,15 +19,21 @@ import { modulesProvider } from '../app';
|
|
|
19
19
|
import { fetchWebViewConfigs } from './api.helpers';
|
|
20
20
|
import { createWebViewActionID } from './display.helpers';
|
|
21
21
|
import { WebViewScreen } from './view';
|
|
22
|
+
import { webViewProvider } from './webView.provider';
|
|
22
23
|
import { getRoles } from '../utils';
|
|
23
|
-
const createScreenComponent =
|
|
24
|
-
return props => WebViewScreen({
|
|
24
|
+
const createScreenComponent = (webViewConfig) => {
|
|
25
|
+
return props => WebViewScreen({
|
|
26
|
+
...props,
|
|
27
|
+
webViewId: webViewConfig.id,
|
|
28
|
+
defaultConfig: webViewConfig,
|
|
29
|
+
});
|
|
25
30
|
};
|
|
26
31
|
export const createWebViewScreens = (webViewConfigs) => {
|
|
27
32
|
const screens = {};
|
|
28
33
|
const menus = {};
|
|
29
34
|
if (Array.isArray(webViewConfigs) && webViewConfigs.length > 0) {
|
|
30
|
-
webViewConfigs.forEach(
|
|
35
|
+
webViewConfigs.forEach(webViewConfig => {
|
|
36
|
+
const { id, appName, menuTitle, iconName, menuOrder, authorizedRoleSet = [], } = webViewConfig;
|
|
31
37
|
const config = {
|
|
32
38
|
title: menuTitle ?? 'Base_WebView',
|
|
33
39
|
icon: iconName ?? 'layers',
|
|
@@ -36,7 +42,7 @@ export const createWebViewScreens = (webViewConfigs) => {
|
|
|
36
42
|
const screenKey = `WebView_${appName}_${id}`;
|
|
37
43
|
screens[screenKey] = {
|
|
38
44
|
title: config.title,
|
|
39
|
-
component: createScreenComponent(
|
|
45
|
+
component: createScreenComponent(webViewConfig),
|
|
40
46
|
actionID: createWebViewActionID(id),
|
|
41
47
|
};
|
|
42
48
|
const _menu = {
|
|
@@ -81,6 +87,7 @@ export const registerWebViewModule = async (user) => {
|
|
|
81
87
|
const webViewConfigs = await fetchWebViewConfigs()
|
|
82
88
|
.then(res => res?.data?.data)
|
|
83
89
|
.catch(() => []);
|
|
90
|
+
webViewProvider.registerConfigs(webViewConfigs);
|
|
84
91
|
const { screens, menus } = createWebViewScreens(webViewConfigs);
|
|
85
92
|
const userRoles = getRoles(user);
|
|
86
93
|
modulesProvider.registerModule({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"menu.helper.js","sourceRoot":"","sources":["../../src/webViews/menu.helper.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAO,eAAe,EAAS,MAAM,QAAQ,CAAC;AACrD,OAAO,EAAC,mBAAmB,EAAC,MAAM,eAAe,CAAC;AAClD,OAAO,EAAC,qBAAqB,EAAC,MAAM,mBAAmB,CAAC;AACxD,OAAO,EAAC,aAAa,EAAC,MAAM,QAAQ,CAAC;AACrC,OAAO,EAAC,QAAQ,EAAC,MAAM,UAAU,CAAC;AAclC,MAAM,qBAAqB,GAAG,
|
|
1
|
+
{"version":3,"file":"menu.helper.js","sourceRoot":"","sources":["../../src/webViews/menu.helper.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAO,eAAe,EAAS,MAAM,QAAQ,CAAC;AACrD,OAAO,EAAC,mBAAmB,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GAAG,EAAE,EAAC,IAAI,EAAC,CAAC,EAAE,EAAE;QACzB,KAAK,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC;IACpB,CAAC,CAAC,CAAC;IAEL,OAAO,KAAK,CAAC;AACf,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,qBAAqB,GAAG,KAAK,EAAE,IAAS,EAAE,EAAE;IACvD,MAAM,cAAc,GAAG,MAAM,mBAAmB,EAAE;SAC/C,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,EAAE,IAAI,EAAE,IAAI,CAAC;SAC5B,KAAK,CAAC,GAAG,EAAE,CAAC,EAAE,CAAC,CAAC;IAEnB,eAAe,CAAC,eAAe,CAAC,cAAc,CAAC,CAAC;IAEhD,MAAM,EAAC,OAAO,EAAE,KAAK,EAAC,GAAG,oBAAoB,CAAC,cAAc,CAAC,CAAC;IAC9D,MAAM,SAAS,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC;IAEjC,eAAe,CAAC,cAAc,CAAC;QAC7B,IAAI,EAAE,aAAa;QACnB,KAAK,EAAE,4BAA4B,CAAC,KAAK,EAAE,SAAS,CAAC;QACrD,OAAO;KACR,CAAC,CAAC;AACL,CAAC,CAAC"}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { WebViewConfig } from '../webView.provider';
|
|
2
3
|
interface WebViewScreenProps {
|
|
3
4
|
webViewId: number;
|
|
5
|
+
defaultConfig?: WebViewConfig;
|
|
4
6
|
hideCardBackground?: boolean;
|
|
5
7
|
chartWidth?: number;
|
|
6
8
|
}
|
|
7
|
-
export declare const WebViewScreen: ({ webViewId }: WebViewScreenProps) => React.JSX.Element;
|
|
9
|
+
export declare const WebViewScreen: ({ webViewId, defaultConfig, }: WebViewScreenProps) => React.JSX.Element;
|
|
8
10
|
export {};
|
|
@@ -15,24 +15,29 @@
|
|
|
15
15
|
* You should have received a copy of the GNU Affero General Public License
|
|
16
16
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
17
17
|
*/
|
|
18
|
-
import React, { useCallback, useEffect, useState } from 'react';
|
|
18
|
+
import React, { useCallback, useEffect, useMemo, useState } from 'react';
|
|
19
19
|
import { ActivityIndicator } from 'react-native';
|
|
20
20
|
import { WebView } from '../../components';
|
|
21
21
|
import { headerActionsProvider } from '../../header';
|
|
22
22
|
import { useTranslator } from '../../i18n';
|
|
23
23
|
import { fetchWebViewById } from '../api.helpers';
|
|
24
|
-
import { createWebViewActionID } from '../display.helpers';
|
|
25
|
-
|
|
24
|
+
import { createWebViewActionID, createWebViewPath } from '../display.helpers';
|
|
25
|
+
import { webViewProvider } from '../webView.provider';
|
|
26
|
+
export const WebViewScreen = ({ webViewId, defaultConfig, }) => {
|
|
26
27
|
const I18n = useTranslator();
|
|
27
|
-
const [webViewData, setWebViewData] = useState({});
|
|
28
|
+
const [webViewData, setWebViewData] = useState(defaultConfig ?? webViewProvider.getConfig(webViewId) ?? {});
|
|
28
29
|
const [loading, setLoading] = useState(false);
|
|
29
30
|
const refresh = useCallback(() => {
|
|
30
31
|
setLoading(true);
|
|
31
32
|
fetchWebViewById({ mobileWebViewId: webViewId })
|
|
32
33
|
.then(response => {
|
|
33
|
-
|
|
34
|
+
const config = response?.data?.data?.[0];
|
|
35
|
+
if (config != null) {
|
|
36
|
+
setWebViewData(config);
|
|
37
|
+
webViewProvider.updateConfig(config);
|
|
38
|
+
}
|
|
34
39
|
})
|
|
35
|
-
.catch(() =>
|
|
40
|
+
.catch(() => { })
|
|
36
41
|
.finally(() => setLoading(false));
|
|
37
42
|
}, [webViewId]);
|
|
38
43
|
useEffect(() => {
|
|
@@ -44,6 +49,7 @@ export const WebViewScreen = ({ webViewId }) => {
|
|
|
44
49
|
isMounted = false;
|
|
45
50
|
};
|
|
46
51
|
}, [refresh]);
|
|
52
|
+
const hasConfig = useMemo(() => Object.keys(webViewData ?? {}).length > 0, [webViewData]);
|
|
47
53
|
useEffect(() => {
|
|
48
54
|
headerActionsProvider.registerModel(createWebViewActionID(webViewId), {
|
|
49
55
|
actions: [
|
|
@@ -58,11 +64,9 @@ export const WebViewScreen = ({ webViewId }) => {
|
|
|
58
64
|
],
|
|
59
65
|
});
|
|
60
66
|
}, [I18n, webViewId, refresh]);
|
|
61
|
-
if (loading) {
|
|
67
|
+
if (loading && !hasConfig) {
|
|
62
68
|
return <ActivityIndicator size="large"/>;
|
|
63
69
|
}
|
|
64
|
-
return (<WebView baseUrl={webViewData?.url} path={webViewData
|
|
65
|
-
? `#/ds/${webViewData?.metaAction?.name}`
|
|
66
|
-
: ''}/>);
|
|
70
|
+
return (<WebView baseUrl={webViewData?.url} path={createWebViewPath(webViewData)}/>);
|
|
67
71
|
};
|
|
68
72
|
//# sourceMappingURL=WebViewScreen.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WebViewScreen.js","sourceRoot":"","sources":["../../../src/webViews/view/WebViewScreen.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,KAAK,EAAE,EAAC,WAAW,EAAE,SAAS,EAAE,QAAQ,EAAC,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"WebViewScreen.js","sourceRoot":"","sources":["../../../src/webViews/view/WebViewScreen.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,KAAK,EAAE,EAAC,WAAW,EAAE,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAC,MAAM,OAAO,CAAC;AACvE,OAAO,EAAC,iBAAiB,EAAC,MAAM,cAAc,CAAC;AAC/C,OAAO,EAAC,OAAO,EAAC,MAAM,kBAAkB,CAAC;AACzC,OAAO,EAAC,qBAAqB,EAAC,MAAM,cAAc,CAAC;AACnD,OAAO,EAAC,aAAa,EAAC,MAAM,YAAY,CAAC;AACzC,OAAO,EAAC,gBAAgB,EAAC,MAAM,gBAAgB,CAAC;AAChD,OAAO,EAAC,qBAAqB,EAAE,iBAAi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AAC;IAEd,MAAM,SAAS,GAAG,OAAO,CACvB,GAAG,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,WAAW,IAAI,EAAE,CAAC,CAAC,MAAM,GAAG,CAAC,EAC/C,CAAC,WAAW,CAAC,CACd,CAAC;IAEF,SAAS,CAAC,GAAG,EAAE;QACb,qBAAqB,CAAC,aAAa,CAAC,qBAAqB,CAAC,SAAS,CAAC,EAAE;YACpE,OAAO,EAAE;gBACP;oBACE,GAAG,EAAE,eAAe;oBACpB,KAAK,EAAE,EAAE;oBACT,YAAY,EAAE,KAAK;oBACnB,QAAQ,EAAE,cAAc;oBACxB,KAAK,EAAE,IAAI,CAAC,CAAC,CAAC,4BAA4B,CAAC;oBAC3C,OAAO,EAAE,OAAO;iBACjB;aACF;SACF,CAAC,CAAC;IACL,CAAC,EAAE,CAAC,IAAI,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC,CAAC;IAE/B,IAAI,OAAO,IAAI,CAAC,SAAS,EAAE;QACzB,OAAO,CAAC,iBAAiB,CAAC,IAAI,CAAC,OAAO,EAAG,CAAC;KAC3C;IAED,OAAO,CACL,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,WAAW,EAAE,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,iBAAiB,CAAC,WAAW,CAAC,CAAC,EAAG,CAC7E,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export interface WebViewConfig {
|
|
2
|
+
id: number;
|
|
3
|
+
appName: string;
|
|
4
|
+
isAosWebView?: boolean;
|
|
5
|
+
url?: string;
|
|
6
|
+
metaAction?: {
|
|
7
|
+
name: string;
|
|
8
|
+
};
|
|
9
|
+
menuTitle?: string;
|
|
10
|
+
iconName?: string;
|
|
11
|
+
menuOrder?: number;
|
|
12
|
+
authorizedRoleSet?: any[];
|
|
13
|
+
}
|
|
14
|
+
declare class WebViewProvider {
|
|
15
|
+
private configs;
|
|
16
|
+
private refreshCallBack;
|
|
17
|
+
constructor();
|
|
18
|
+
registerCallback(callBack: Function): void;
|
|
19
|
+
unregisterCallback(callBack: Function): void;
|
|
20
|
+
registerConfigs(configs: WebViewConfig[]): void;
|
|
21
|
+
updateConfig(config: WebViewConfig): void;
|
|
22
|
+
getConfigs(): WebViewConfig[];
|
|
23
|
+
getConfig(id: number): WebViewConfig;
|
|
24
|
+
private updateState;
|
|
25
|
+
}
|
|
26
|
+
export declare const webViewProvider: WebViewProvider;
|
|
27
|
+
export declare const useWebViewConfigs: () => WebViewConfig[];
|
|
28
|
+
export {};
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Axelor Business Solutions
|
|
3
|
+
*
|
|
4
|
+
* Copyright (C) 2026 Axelor (<http://axelor.com>).
|
|
5
|
+
*
|
|
6
|
+
* This program is free software: you can redistribute it and/or modify
|
|
7
|
+
* it under the terms of the GNU Affero General Public License, version 3,
|
|
8
|
+
* as published by the Free Software Foundation.
|
|
9
|
+
*
|
|
10
|
+
* This program is distributed in the hope that it will be useful,
|
|
11
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13
|
+
* GNU Affero General Public License for more details.
|
|
14
|
+
*
|
|
15
|
+
* You should have received a copy of the GNU Affero General Public License
|
|
16
|
+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
17
|
+
*/
|
|
18
|
+
import { useCallback, useEffect, useState } from 'react';
|
|
19
|
+
class WebViewProvider {
|
|
20
|
+
configs;
|
|
21
|
+
refreshCallBack;
|
|
22
|
+
constructor() {
|
|
23
|
+
this.configs = [];
|
|
24
|
+
this.refreshCallBack = [];
|
|
25
|
+
}
|
|
26
|
+
registerCallback(callBack) {
|
|
27
|
+
this.refreshCallBack.push(callBack);
|
|
28
|
+
}
|
|
29
|
+
unregisterCallback(callBack) {
|
|
30
|
+
this.refreshCallBack = this.refreshCallBack.filter(_f => _f !== callBack);
|
|
31
|
+
}
|
|
32
|
+
registerConfigs(configs) {
|
|
33
|
+
this.configs = Array.isArray(configs) ? configs : [];
|
|
34
|
+
this.updateState();
|
|
35
|
+
}
|
|
36
|
+
updateConfig(config) {
|
|
37
|
+
if (config?.id == null) {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
this.configs = this.configs.map(_config => _config.id === config.id ? { ..._config, ...config } : _config);
|
|
41
|
+
this.updateState();
|
|
42
|
+
}
|
|
43
|
+
getConfigs() {
|
|
44
|
+
return this.configs;
|
|
45
|
+
}
|
|
46
|
+
getConfig(id) {
|
|
47
|
+
return this.configs.find(_config => _config.id === id);
|
|
48
|
+
}
|
|
49
|
+
updateState() {
|
|
50
|
+
this.refreshCallBack.forEach(_f => _f(this.configs));
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
export const webViewProvider = new WebViewProvider();
|
|
54
|
+
export const useWebViewConfigs = () => {
|
|
55
|
+
const [configs, setConfigs] = useState(webViewProvider.getConfigs());
|
|
56
|
+
const refreshData = useCallback((data) => setConfigs([...data]), []);
|
|
57
|
+
useEffect(() => {
|
|
58
|
+
webViewProvider.registerCallback(refreshData);
|
|
59
|
+
return () => {
|
|
60
|
+
webViewProvider.unregisterCallback(refreshData);
|
|
61
|
+
};
|
|
62
|
+
}, [refreshData]);
|
|
63
|
+
return configs;
|
|
64
|
+
};
|
|
65
|
+
//# sourceMappingURL=webView.provider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"webView.provider.js","sourceRoot":"","sources":["../../src/webViews/webView.provider.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAC,WAAW,EAAE,SAAS,EAAE,QAAQ,EAAC,MAAM,OAAO,CAAC;AAcvD,MAAM,eAAe;IACX,OAAO,CAAkB;IACzB,eAAe,CAAa;IAEpC;QACE,IAAI,CAAC,OAAO,GAAG,EAAE,CAAC;QAClB,IAAI,CAAC,eA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e,GAAG,IAAI,eAAe,EAAE,CAAC;AAErD,MAAM,CAAC,MAAM,iBAAiB,GAAG,GAAoB,EAAE;IACrD,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,QAAQ,CACpC,eAAe,CAAC,UAAU,EAAE,CAC7B,CAAC;IAEF,MAAM,WAAW,GAAG,WAAW,CAC7B,CAAC,IAAqB,EAAE,EAAE,CAAC,UAAU,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,EAChD,EAAE,CACH,CAAC;IAEF,SAAS,CAAC,GAAG,EAAE;QACb,eAAe,CAAC,gBAAgB,CAAC,WAAW,CAAC,CAAC;QAE9C,OAAO,GAAG,EAAE;YACV,eAAe,CAAC,kBAAkB,CAAC,WAAW,CAAC,CAAC;QAClD,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,WAAW,CAAC,CAAC,CAAC;IAElB,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@axelor/aos-mobile-core",
|
|
3
|
-
"version": "8.4.
|
|
3
|
+
"version": "8.4.25",
|
|
4
4
|
"author": "Axelor",
|
|
5
5
|
"license": "AGPL-3.0-only",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/axelor/axelor-mobile.git",
|
|
9
|
+
"directory": "packages/core"
|
|
10
|
+
},
|
|
6
11
|
"publishConfig": {
|
|
7
12
|
"access": "public"
|
|
8
13
|
},
|
|
@@ -24,8 +29,8 @@
|
|
|
24
29
|
"license:add": "npx add-copyright-header --generate --dir 'src'"
|
|
25
30
|
},
|
|
26
31
|
"dependencies": {
|
|
27
|
-
"@axelor/aos-mobile-error": "8.4.
|
|
28
|
-
"@axelor/aos-mobile-ui": "8.4.
|
|
32
|
+
"@axelor/aos-mobile-error": "8.4.25",
|
|
33
|
+
"@axelor/aos-mobile-ui": "8.4.25",
|
|
29
34
|
"@react-navigation/drawer": "7.3.9",
|
|
30
35
|
"@react-navigation/native": "7.1.6",
|
|
31
36
|
"@react-navigation/native-stack": "7.3.10",
|