@umijs/plugins 4.6.56 → 4.6.58

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
 
@@ -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.56",
3
+ "version": "4.6.58",
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.56",
48
+ "@umijs/bundler-utils": "4.6.58",
49
49
  "@umijs/valtio": "1.0.4"
50
50
  },
51
51
  "devDependencies": {
52
52
  "antd": "^4.24.1",
53
- "umi": "4.6.56"
53
+ "umi": "4.6.58"
54
54
  },
55
55
  "publishConfig": {
56
56
  "access": "public"