@umijs/plugins 4.6.57 → 4.6.59

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/dist/access.js CHANGED
@@ -53,7 +53,10 @@ var access_default = (api) => {
53
53
  content: `
54
54
  import React from 'react';${hasAccessFile ? `
55
55
  import accessFactory from '@/access';
56
- import { useModel } from '@@/plugin-model';
56
+ import { useModel } from '${(0, import_withTmpPath.getPluginModelImport)({
57
+ api,
58
+ from: "runtime.tsx"
59
+ })}';
57
60
  ` : ""}
58
61
  import { AccessContext } from './context';
59
62
 
package/dist/antd.js CHANGED
@@ -306,6 +306,7 @@ var antd_default = (api) => {
306
306
  // 是否启用了 theme algorithm
307
307
  enableModernThemeAlgorithm,
308
308
  antdConfigSetter,
309
+ isUtooWin: (0, import_withTmpPath.isUtooWin)(api),
309
310
  modelPluginCompat,
310
311
  lodashPath,
311
312
  /**
@@ -55,7 +55,10 @@ var initial_state_default = (api) => {
55
55
  path: "Provider.tsx",
56
56
  content: `
57
57
  import React from 'react';
58
- import { useModel } from '@@/plugin-model';
58
+ import { useModel } from '${(0, import_withTmpPath.getPluginModelImport)({
59
+ api,
60
+ from: "Provider.tsx"
61
+ })}';
59
62
  ${loading ? `import Loading from '${loading}'` : `function Loading() { return <div />; }`}
60
63
  export default function InitialStateProvider(props: any) {
61
64
  const appLoaded = React.useRef(false);
package/dist/layout.js CHANGED
@@ -146,7 +146,10 @@ import './${layoutFile}';
146
146
  import Logo from './Logo';
147
147
  import Exception from './Exception';
148
148
  import { getRightRenderContent } from './rightRender';
149
- ${hasInitialStatePlugin ? `import { useModel } from '@@/plugin-model';` : "const useModel = null;"}
149
+ ${hasInitialStatePlugin ? `import { useModel } from '${(0, import_withTmpPath.getPluginModelImport)({
150
+ api,
151
+ from: "Layout.tsx"
152
+ })}';` : "const useModel = null;"}
150
153
  ${api.config.access ? `
151
154
  import { useAccessMarkedRoutes } from '@@/plugin-access';
152
155
  `.trim() : "const useAccessMarkedRoutes = (r) => r;"}
@@ -203,7 +203,10 @@ export const setMasterOptions = (newOpts) => options = ({ ...options, ...newOpts
203
203
  path: file.replace(/\.tpl$/, ""),
204
204
  content: content.replace(
205
205
  "__USE_MODEL__",
206
- api.isPluginEnable("model") ? `import { useModel } from '@@/plugin-model'` : `console.warn(\`[plugins/qiankun]: Seems like you're not using @umijs/plugin-model, you need to install it or some features may not work!\`);
206
+ api.isPluginEnable("model") ? `import { useModel } from '${(0, import_withTmpPath.getPluginModelImport)({
207
+ api,
208
+ from: "masterRuntimePlugin.tsx"
209
+ })}'` : `console.warn(\`[plugins/qiankun]: Seems like you're not using @umijs/plugin-model, you need to install it or some features may not work!\`);
207
210
  const useModel = null`
208
211
  ).replace(
209
212
  /from 'lodash\//g,
@@ -250,7 +250,10 @@ if (!isServer && !window.__POWERED_BY_QIANKUN__) {
250
250
  path: file.replace(/\.tpl$/, ""),
251
251
  content: getFileContent(file).replace(
252
252
  "__USE_MODEL__",
253
- api.isPluginEnable("model") ? `import { useModel } from '@@/plugin-model'` : `console.warn(\`[plugins/qiankun]: Seems like you're not using @umijs/plugin-model, you need to install it or some features may not work!\`);
253
+ api.isPluginEnable("model") ? `import { useModel } from '${(0, import_withTmpPath.getPluginModelImport)({
254
+ api,
255
+ from: "slaveRuntimePlugin.ts"
256
+ })}'` : `console.warn(\`[plugins/qiankun]: Seems like you're not using @umijs/plugin-model, you need to install it or some features may not work!\`);
254
257
  const useModel = null`
255
258
  ).replace(
256
259
  /from 'qiankun'/g,
@@ -4,3 +4,8 @@ export declare function withTmpPath(opts: {
4
4
  path: string;
5
5
  noPluginDir?: boolean;
6
6
  }): string;
7
+ export declare function isUtooWin(api: IApi): boolean;
8
+ export declare function getPluginModelImport(opts: {
9
+ api: IApi;
10
+ from: string;
11
+ }): string;
@@ -19,6 +19,8 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
19
19
  // src/utils/withTmpPath.ts
20
20
  var withTmpPath_exports = {};
21
21
  __export(withTmpPath_exports, {
22
+ getPluginModelImport: () => getPluginModelImport,
23
+ isUtooWin: () => isUtooWin,
22
24
  withTmpPath: () => withTmpPath
23
25
  });
24
26
  module.exports = __toCommonJS(withTmpPath_exports);
@@ -33,7 +35,24 @@ function withTmpPath(opts) {
33
35
  )
34
36
  );
35
37
  }
38
+ function withTmpPluginPath(opts) {
39
+ return (0, import_plugin_utils.winPath)((0, import_path.join)(opts.api.paths.absTmpPath, `plugin-${opts.pluginKey}`));
40
+ }
41
+ function isUtooWin(api) {
42
+ return process.platform === "win32" && api.appData.bundler === "utoopack";
43
+ }
44
+ function getPluginModelImport(opts) {
45
+ if (!isUtooWin(opts.api)) {
46
+ return "@@/plugin-model";
47
+ }
48
+ const from = withTmpPath({ api: opts.api, path: opts.from });
49
+ const to = withTmpPluginPath({ api: opts.api, pluginKey: "model" });
50
+ const relPath = (0, import_plugin_utils.winPath)((0, import_path.relative)((0, import_path.dirname)(from), to));
51
+ return relPath.startsWith(".") ? relPath : `./${relPath}`;
52
+ }
36
53
  // Annotate the CommonJS export names for ESM import in node:
37
54
  0 && (module.exports = {
55
+ getPluginModelImport,
56
+ isUtooWin,
38
57
  withTmpPath
39
58
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@umijs/plugins",
3
- "version": "4.6.57",
3
+ "version": "4.6.59",
4
4
  "description": "@umijs/plugins",
5
5
  "homepage": "https://github.com/umijs/umi/tree/master/packages/plugins#readme",
6
6
  "bugs": "https://github.com/umijs/umi/issues",
@@ -45,12 +45,12 @@
45
45
  "styled-components": "6.1.1",
46
46
  "tslib": "^2",
47
47
  "warning": "^4.0.3",
48
- "@umijs/bundler-utils": "4.6.57",
48
+ "@umijs/bundler-utils": "4.6.59",
49
49
  "@umijs/valtio": "1.0.4"
50
50
  },
51
51
  "devDependencies": {
52
52
  "antd": "^4.24.1",
53
- "umi": "4.6.57"
53
+ "umi": "4.6.59"
54
54
  },
55
55
  "publishConfig": {
56
56
  "access": "public"
@@ -30,9 +30,9 @@ import merge from '{{{lodashPath.merge}}}'
30
30
 
31
31
  let cacheAntdConfig = null;
32
32
 
33
- const getAntdConfig = () => {
33
+ const getAntdConfig = ({{#isUtooWin}}runtimePluginManager?: any{{/isUtooWin}}) => {
34
34
  if(!cacheAntdConfig){
35
- cacheAntdConfig = getPluginManager().applyPlugins({
35
+ cacheAntdConfig = {{#isUtooWin}}(runtimePluginManager || getPluginManager()){{/isUtooWin}}{{^isUtooWin}}getPluginManager(){{/isUtooWin}}.applyPlugins({
36
36
  key: 'antd',
37
37
  type: ApplyPluginsType.modify,
38
38
  initialValue: {
@@ -53,14 +53,14 @@ const getAntdConfig = () => {
53
53
  return cacheAntdConfig;
54
54
  }
55
55
 
56
- function AntdProvider({ children }) {
56
+ function AntdProvider({ children{{#isUtooWin}}, pluginManager{{/isUtooWin}} }) {
57
57
  let container = children;
58
58
 
59
59
  const [antdConfig, _setAntdConfig] = React.useState(() => {
60
60
  const {
61
61
  appConfig: _,
62
62
  ...finalConfigProvider
63
- } = getAntdConfig();
63
+ } = getAntdConfig({{#isUtooWin}}pluginManager{{/isUtooWin}});
64
64
  {{#enableModernThemeAlgorithm}}
65
65
  finalConfigProvider.theme ??= {};
66
66
  finalConfigProvider.theme.algorithm ??= [];
@@ -155,9 +155,9 @@ function AntdProvider({ children }) {
155
155
  return container;
156
156
  }
157
157
 
158
- export function rootContainer(children) {
158
+ export function rootContainer(children{{#isUtooWin}}, opts{{/isUtooWin}}) {
159
159
  return (
160
- <AntdProvider>
160
+ <AntdProvider{{#isUtooWin}} pluginManager={opts?.plugin}{{/isUtooWin}}>
161
161
  {children}
162
162
  </AntdProvider>
163
163
  );
@@ -166,10 +166,10 @@ export function rootContainer(children) {
166
166
  {{#appConfig}}
167
167
  // The App component should be under ConfigProvider
168
168
  // plugin-locale has other ConfigProvider
169
- export function innerProvider(container: any) {
169
+ export function innerProvider(container: any{{#isUtooWin}}, opts: any{{/isUtooWin}}) {
170
170
  const {
171
171
  appConfig: finalAppConfig = {},
172
- } = getAntdConfig();
172
+ } = getAntdConfig({{#isUtooWin}}opts?.plugin{{/isUtooWin}});
173
173
  return <App {...finalAppConfig}>{container}</App>;
174
174
  }
175
175
  {{/appConfig}}