@nocobase/app 2.1.8 → 2.1.9
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/client/src/__tests__/runtimePublicPath.test.ts +24 -0
- package/client/src/main.tsx +1 -0
- package/client/src/runtimePublicPath.ts +40 -0
- package/dist/client/assets/{index-74da7c73.js → index-e104b378.js} +368 -342
- package/dist/client/index.html +1 -1
- package/dist/client/index.html.tpl +1 -1
- package/dist/client/v/assets/{index-2f56959f.js → index-b02117dc.js} +139 -113
- package/dist/client/v/index.html +1 -1
- package/package.json +7 -7
- /package/dist/client/assets/{index-74da7c73.js.LICENSE.txt → index-e104b378.js.LICENSE.txt} +0 -0
- /package/dist/client/v/assets/{index-2f56959f.js.LICENSE.txt → index-b02117dc.js.LICENSE.txt} +0 -0
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import { resolveRuntimeAssetPublicPath } from '../runtimePublicPath';
|
|
11
|
+
|
|
12
|
+
describe('resolveRuntimeAssetPublicPath', () => {
|
|
13
|
+
it('should prefer the injected window public path over an auto-detected runtime path', () => {
|
|
14
|
+
expect(resolveRuntimeAssetPublicPath('/dist/2.1.8/', 'https://static.cloudflareinsights.com/assets/../')).toBe(
|
|
15
|
+
'/dist/2.1.8/',
|
|
16
|
+
);
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
it('should fall back to the runtime public path when the injected value is missing', () => {
|
|
20
|
+
expect(resolveRuntimeAssetPublicPath(undefined, 'https://cdn.nocobase.com/dist/2.1.8/')).toBe(
|
|
21
|
+
'https://cdn.nocobase.com/dist/2.1.8/',
|
|
22
|
+
);
|
|
23
|
+
});
|
|
24
|
+
});
|
package/client/src/main.tsx
CHANGED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
declare global {
|
|
11
|
+
interface Window {
|
|
12
|
+
__webpack_public_path__?: string;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function normalizePublicPath(value: string | undefined, fallback = '/') {
|
|
17
|
+
let normalized = value?.trim() || fallback;
|
|
18
|
+
if (!normalized.endsWith('/')) {
|
|
19
|
+
normalized = `${normalized}/`;
|
|
20
|
+
}
|
|
21
|
+
return normalized;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export function resolveRuntimeAssetPublicPath(
|
|
25
|
+
windowPublicPath: string | undefined,
|
|
26
|
+
runtimePublicPath: string | undefined,
|
|
27
|
+
) {
|
|
28
|
+
return normalizePublicPath(windowPublicPath, normalizePublicPath(runtimePublicPath, '/'));
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// `__webpack_public_path__` is a webpack magic global that must be assigned
|
|
32
|
+
// before any lazy-loaded chunk request happens.
|
|
33
|
+
declare let __webpack_public_path__: string;
|
|
34
|
+
|
|
35
|
+
const runtimePublicPath = typeof __webpack_public_path__ === 'string' ? __webpack_public_path__ : undefined;
|
|
36
|
+
|
|
37
|
+
if (typeof window !== 'undefined' && typeof __webpack_public_path__ !== 'undefined') {
|
|
38
|
+
// eslint-disable-next-line prefer-const
|
|
39
|
+
__webpack_public_path__ = resolveRuntimeAssetPublicPath(window.__webpack_public_path__, runtimePublicPath);
|
|
40
|
+
}
|