@nocobase/app 2.2.0-alpha.1 → 2.2.0-alpha.2

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.
@@ -17,9 +17,31 @@ function normalizePublicPath(value) {
17
17
  return ensureTrailingSlash(normalized);
18
18
  }
19
19
 
20
+ function trimTrailingSlash(value) {
21
+ return value === '/' ? value : value.replace(/\/+$/g, '');
22
+ }
23
+
24
+ function normalizePathname(value) {
25
+ const normalized = ensureLeadingSlash(String(value || '/').trim() || '/').replace(/\/{2,}/g, '/');
26
+ if (normalized !== '/' && normalized.endsWith('/')) {
27
+ return normalized.replace(/\/+$/g, '');
28
+ }
29
+ return normalized;
30
+ }
31
+
32
+ function isClientDocumentEntryPath(pathname) {
33
+ const normalized = normalizePathname(pathname);
34
+ return normalized === '/' || normalized === '/index.html' || !/\.[^/]+$/.test(normalized);
35
+ }
36
+
20
37
  const basename = normalizePublicPath(window['__nocobase_public_path__'] || '/');
21
38
  const currentPath = ensureLeadingSlash(String(window.location.pathname || '/').trim() || '/').replace(/\/{2,}/g, '/');
22
39
  const basenameWithoutTrailingSlash = basename === '/' ? '/' : basename.replace(/\/+$/, '');
40
+ const modernClientPrefix =
41
+ String(window['__nocobase_modern_client_prefix__'] || 'v')
42
+ .trim()
43
+ .replace(/^\/+|\/+$/g, '') || 'v';
44
+ const appClientEntryMode = window['__nocobase_app_client_entry_mode__'];
23
45
 
24
46
  if (basename !== '/' && currentPath === basenameWithoutTrailingSlash) {
25
47
  const newUrl = `${window.location.origin}${basename}${window.location.search}${window.location.hash}`;
@@ -28,6 +50,42 @@ if (basename !== '/' && currentPath === basenameWithoutTrailingSlash) {
28
50
  const newPath = currentPath === '/' ? basename : `${basenameWithoutTrailingSlash}${currentPath}`;
29
51
  let newUrl = window.location.origin + newPath + window.location.search + window.location.hash;
30
52
  window.location.replace(newUrl);
53
+ } else {
54
+ // This client-side redirect is still needed because legacy `index.html` is
55
+ // not always served through the node gateway. In nginx/static delivery paths
56
+ // the browser may already be running the legacy shell by the time entry-mode
57
+ // logic is evaluated, so the last hop into the modern entry has to be
58
+ // recoverable in the browser as well.
59
+ const normalizedPath = normalizePathname(currentPath);
60
+ const relativePath =
61
+ basename === '/'
62
+ ? normalizedPath
63
+ : normalizedPath === basenameWithoutTrailingSlash
64
+ ? '/'
65
+ : normalizedPath.startsWith(basename)
66
+ ? normalizePathname(normalizedPath.slice(basename.length - 1))
67
+ : null;
68
+ const modernBase = `${trimTrailingSlash(basename)}/${modernClientPrefix}/`.replace(/\/{2,}/g, '/');
69
+ const isModernDefault = appClientEntryMode === 'modern-default';
70
+ const isModernOnly = appClientEntryMode === 'modern-only';
71
+ if (
72
+ relativePath &&
73
+ isClientDocumentEntryPath(relativePath) &&
74
+ (isModernDefault || isModernOnly) &&
75
+ !normalizedPath.startsWith(modernBase)
76
+ ) {
77
+ const targetPath = isModernDefault
78
+ ? relativePath === '/' || relativePath === '/index.html'
79
+ ? relativePath === '/index.html'
80
+ ? `${modernBase}index.html`
81
+ : modernBase
82
+ : null
83
+ : `${trimTrailingSlash(modernBase)}${relativePath}`;
84
+ if (targetPath && targetPath !== currentPath) {
85
+ const newUrl = window.location.origin + targetPath + window.location.search + window.location.hash;
86
+ window.location.replace(newUrl);
87
+ }
88
+ }
31
89
  }
32
90
  let showLog = true;
33
91
  function log(m) {
@@ -7,6 +7,8 @@
7
7
  <title>Loading...</title>
8
8
  <link rel="stylesheet" href="/global.css"><script>window['__webpack_public_path__'] = '';
9
9
  window['__nocobase_public_path__'] = '/';
10
+ window['__nocobase_modern_client_prefix__'] = 'v';
11
+ window['__nocobase_app_client_entry_mode__'] = 'legacy-default';
10
12
  window['__nocobase_api_base_url__'] = '/api/';
11
13
  window['__nocobase_api_client_storage_prefix__'] = 'NOCOBASE_';
12
14
  window['__nocobase_api_client_storage_type__'] = 'localStorage';
@@ -15,7 +17,7 @@ window['__nocobase_ws_url__'] = '';
15
17
  window['__nocobase_ws_path__'] = '/ws';
16
18
  window['__nocobase_app_dev__'] = false;
17
19
  window['__esm_cdn_base_url__'] = 'https://esm.sh';
18
- window['__esm_cdn_suffix__'] = '';</script><script src="/browser-checker.js?v=1"></script><script type="module" src="/assets/runtime-6964d231.js"></script><script type="module" src="/assets/vendor-core-a233b529.js"></script><script type="module" src="/assets/vendor-antd-ecosystem-b9174353.js"></script><script type="module" src="/assets/vendor-moment-8e0638ed.js"></script><script type="module" src="/assets/vendor-lodash-97b39f5f.js"></script><script type="module" src="/assets/vendor-ses-4e1acd6f.js"></script><script type="module" src="/assets/vendor-antd-icons-b345e75b.js"></script><script type="module" src="/assets/vendor-antd-a0dccf46.js"></script><script type="module" src="/assets/vendor-antv-b2b63ca6.js"></script><script type="module" src="/assets/vendor-markdown-6cd7c4ae.js"></script><script type="module" src="/assets/vendor-math-template-e14d2da2.js"></script><script type="module" src="/assets/vendor-editor-4a3d9571.js"></script><script type="module" src="/assets/vendor-mobile-ui-d13eb245.js"></script><script type="module" src="/assets/vendor-dayjs-b86f7bf1.js"></script><script type="module" src="/assets/vendor-diagram-686f3f07.js"></script><script type="module" src="/assets/vendor-misc-b5370062.js"></script><script type="module" src="/assets/index-055f2436.js"></script><link href="/assets/vendor-antd-debce1bd.css" rel="stylesheet"><link href="/assets/vendor-markdown-c8e9c5dd.css" rel="stylesheet"><link href="/assets/vendor-mobile-ui-4d3e1f9f.css" rel="stylesheet"><link href="/assets/9967-52c0cdfd.css" rel="stylesheet"><link href="/assets/index-560f1b6d.css" rel="stylesheet"></head>
20
+ window['__esm_cdn_suffix__'] = '';</script><script src="/browser-checker.js?v=1"></script><script type="module" src="/assets/runtime-6964d231.js"></script><script type="module" src="/assets/vendor-core-a233b529.js"></script><script type="module" src="/assets/vendor-antd-ecosystem-b9174353.js"></script><script type="module" src="/assets/vendor-moment-8e0638ed.js"></script><script type="module" src="/assets/vendor-lodash-97b39f5f.js"></script><script type="module" src="/assets/vendor-ses-4e1acd6f.js"></script><script type="module" src="/assets/vendor-antd-icons-b345e75b.js"></script><script type="module" src="/assets/vendor-antd-a0dccf46.js"></script><script type="module" src="/assets/vendor-antv-b2b63ca6.js"></script><script type="module" src="/assets/vendor-markdown-6cd7c4ae.js"></script><script type="module" src="/assets/vendor-math-template-e14d2da2.js"></script><script type="module" src="/assets/vendor-editor-4a3d9571.js"></script><script type="module" src="/assets/vendor-mobile-ui-d13eb245.js"></script><script type="module" src="/assets/vendor-dayjs-b86f7bf1.js"></script><script type="module" src="/assets/vendor-diagram-686f3f07.js"></script><script type="module" src="/assets/vendor-misc-0f74f11a.js"></script><script type="module" src="/assets/index-269423c2.js"></script><link href="/assets/vendor-antd-debce1bd.css" rel="stylesheet"><link href="/assets/vendor-markdown-c8e9c5dd.css" rel="stylesheet"><link href="/assets/vendor-mobile-ui-4d3e1f9f.css" rel="stylesheet"><link href="/assets/9967-52c0cdfd.css" rel="stylesheet"><link href="/assets/index-560f1b6d.css" rel="stylesheet"></head>
19
21
 
20
22
  <body>
21
23
  <div id="root"></div>
@@ -7,6 +7,8 @@
7
7
  <title>Loading...</title>
8
8
  <link rel="stylesheet" href="{{env.APP_PUBLIC_PATH}}global.css"><script>window['__webpack_public_path__'] = '{{env.CDN_BASE_URL}}';
9
9
  window['__nocobase_public_path__'] = '{{env.APP_PUBLIC_PATH}}';
10
+ window['__nocobase_modern_client_prefix__'] = '{{env.APP_MODERN_CLIENT_PREFIX}}';
11
+ window['__nocobase_app_client_entry_mode__'] = '{{env.APP_CLIENT_ENTRY_MODE}}';
10
12
  window['__nocobase_api_base_url__'] = '{{env.API_BASE_URL}}';
11
13
  window['__nocobase_api_client_storage_prefix__'] = '{{env.API_CLIENT_STORAGE_PREFIX}}';
12
14
  window['__nocobase_api_client_storage_type__'] = '{{env.API_CLIENT_STORAGE_TYPE}}';
@@ -15,7 +17,7 @@ window['__nocobase_ws_url__'] = '{{env.WS_URL}}';
15
17
  window['__nocobase_ws_path__'] = '{{env.WS_PATH}}';
16
18
  window['__nocobase_app_dev__'] = {{env.NOCOBASE_APP_DEV}};
17
19
  window['__esm_cdn_base_url__'] = '{{env.ESM_CDN_BASE_URL}}';
18
- window['__esm_cdn_suffix__'] = '{{env.ESM_CDN_SUFFIX}}';</script><script src="{{env.APP_PUBLIC_PATH}}browser-checker.js?v=1"></script><script type="module" src="assets/runtime-6964d231.js"></script><script type="module" src="assets/vendor-core-a233b529.js"></script><script type="module" src="assets/vendor-antd-ecosystem-b9174353.js"></script><script type="module" src="assets/vendor-moment-8e0638ed.js"></script><script type="module" src="assets/vendor-lodash-97b39f5f.js"></script><script type="module" src="assets/vendor-ses-4e1acd6f.js"></script><script type="module" src="assets/vendor-antd-icons-b345e75b.js"></script><script type="module" src="assets/vendor-antd-a0dccf46.js"></script><script type="module" src="assets/vendor-antv-b2b63ca6.js"></script><script type="module" src="assets/vendor-markdown-6cd7c4ae.js"></script><script type="module" src="assets/vendor-math-template-e14d2da2.js"></script><script type="module" src="assets/vendor-editor-4a3d9571.js"></script><script type="module" src="assets/vendor-mobile-ui-d13eb245.js"></script><script type="module" src="assets/vendor-dayjs-b86f7bf1.js"></script><script type="module" src="assets/vendor-diagram-686f3f07.js"></script><script type="module" src="assets/vendor-misc-b5370062.js"></script><script type="module" src="assets/index-055f2436.js"></script><link href="assets/vendor-antd-debce1bd.css" rel="stylesheet"><link href="assets/vendor-markdown-c8e9c5dd.css" rel="stylesheet"><link href="assets/vendor-mobile-ui-4d3e1f9f.css" rel="stylesheet"><link href="assets/9967-52c0cdfd.css" rel="stylesheet"><link href="assets/index-560f1b6d.css" rel="stylesheet"></head>
20
+ window['__esm_cdn_suffix__'] = '{{env.ESM_CDN_SUFFIX}}';</script><script src="{{env.APP_PUBLIC_PATH}}browser-checker.js?v=1"></script><script type="module" src="assets/runtime-6964d231.js"></script><script type="module" src="assets/vendor-core-a233b529.js"></script><script type="module" src="assets/vendor-antd-ecosystem-b9174353.js"></script><script type="module" src="assets/vendor-moment-8e0638ed.js"></script><script type="module" src="assets/vendor-lodash-97b39f5f.js"></script><script type="module" src="assets/vendor-ses-4e1acd6f.js"></script><script type="module" src="assets/vendor-antd-icons-b345e75b.js"></script><script type="module" src="assets/vendor-antd-a0dccf46.js"></script><script type="module" src="assets/vendor-antv-b2b63ca6.js"></script><script type="module" src="assets/vendor-markdown-6cd7c4ae.js"></script><script type="module" src="assets/vendor-math-template-e14d2da2.js"></script><script type="module" src="assets/vendor-editor-4a3d9571.js"></script><script type="module" src="assets/vendor-mobile-ui-d13eb245.js"></script><script type="module" src="assets/vendor-dayjs-b86f7bf1.js"></script><script type="module" src="assets/vendor-diagram-686f3f07.js"></script><script type="module" src="assets/vendor-misc-0f74f11a.js"></script><script type="module" src="assets/index-269423c2.js"></script><link href="assets/vendor-antd-debce1bd.css" rel="stylesheet"><link href="assets/vendor-markdown-c8e9c5dd.css" rel="stylesheet"><link href="assets/vendor-mobile-ui-4d3e1f9f.css" rel="stylesheet"><link href="assets/9967-52c0cdfd.css" rel="stylesheet"><link href="assets/index-560f1b6d.css" rel="stylesheet"></head>
19
21
 
20
22
  <body>
21
23
  <div id="root"></div>