@douyinfe/semi-foundation 2.74.0 → 2.74.1-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.
package/getBabelConfig.js CHANGED
@@ -19,6 +19,7 @@ module.exports = ({ isESM }) => {
19
19
  ],
20
20
  plugins: [
21
21
  'lodash',
22
+ ...(isESM ? [] : ['./scripts/babel-plugin-lottie.js'])
22
23
  ]
23
24
  };
24
25
  };
@@ -5,8 +5,12 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = void 0;
7
7
  var _foundation = _interopRequireDefault(require("../base/foundation"));
8
- var _lottieWeb = _interopRequireDefault(require("lottie-web"));
9
8
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
9
+ var _lottieWeb = undefined;
10
+ if (typeof document !== "undefined") {
11
+ _lottieWeb = require("lottie-web");
12
+ if (_lottieWeb && _lottieWeb.__esModule) _lottieWeb = _lottieWeb.default;
13
+ }
10
14
  class LottieFoundation extends _foundation.default {
11
15
  constructor(adapter) {
12
16
  super(Object.assign(Object.assign({}, LottieFoundation.defaultAdapter), adapter));
@@ -14,14 +18,14 @@ class LottieFoundation extends _foundation.default {
14
18
  this.handleParamsUpdate = () => {
15
19
  var _a;
16
20
  this.animation.destroy();
17
- this.animation = _lottieWeb.default.loadAnimation(this._adapter.getLoadParams());
21
+ this.animation = lottie.loadAnimation(this._adapter.getLoadParams());
18
22
  (_a = this.getProp("getAnimationInstance")) === null || _a === void 0 ? void 0 : _a(this.animation);
19
23
  };
20
24
  }
21
25
  init(lifecycle) {
22
26
  var _a, _b;
23
27
  super.init(lifecycle);
24
- this.animation = _lottieWeb.default.loadAnimation(this._adapter.getLoadParams());
28
+ this.animation = lottie.loadAnimation(this._adapter.getLoadParams());
25
29
  (_a = this.getProp("getAnimationInstance")) === null || _a === void 0 ? void 0 : _a(this.animation);
26
30
  (_b = this.getProp("getLottie")) === null || _b === void 0 ? void 0 : _b(LottieFoundation.getLottie());
27
31
  }
@@ -31,6 +35,6 @@ class LottieFoundation extends _foundation.default {
31
35
  }
32
36
  }
33
37
  LottieFoundation.getLottie = () => {
34
- return _lottieWeb.default;
38
+ return lottie;
35
39
  };
36
40
  var _default = exports.default = LottieFoundation;
@@ -83,6 +83,6 @@ export declare function getValueOrKey(data: any, keyMaps?: KeyMapProps): any;
83
83
  export declare function normalizeValue(value: any, withObject: boolean, keyMaps?: KeyMapProps): any;
84
84
  export declare function updateKeys(keySet: Set<string> | string[], keyEntities: KeyEntities): string[];
85
85
  export declare function calcDisabledKeys(keyEntities: KeyEntities, keyMaps?: KeyMapProps): Set<string>;
86
- export declare function calcDropRelativePosition(event: any, treeNode: any): 1 | -1 | 0;
86
+ export declare function calcDropRelativePosition(event: any, treeNode: any): 0 | 1 | -1;
87
87
  export declare function getDragNodesKeys(key: string, keyEntities: KeyEntities): string[];
88
88
  export declare function calcDropActualPosition(pos: string, relativeDropPos: any): any;
@@ -18,7 +18,7 @@ declare const strings: {
18
18
  DRAG_AREA_ILLEGAL: string;
19
19
  TRIGGER_AUTO: "auto";
20
20
  TRIGGER_CUSTOM: "custom";
21
- UPLOAD_TRIGGER: ("auto" | "custom")[];
21
+ UPLOAD_TRIGGER: ("custom" | "auto")[];
22
22
  VALIDATE_STATUS: readonly ["default", "error", "warning", "success"];
23
23
  PROMPT_POSITION: readonly ["left", "right", "bottom"];
24
24
  };
@@ -83,6 +83,6 @@ export declare function getValueOrKey(data: any, keyMaps?: KeyMapProps): any;
83
83
  export declare function normalizeValue(value: any, withObject: boolean, keyMaps?: KeyMapProps): any;
84
84
  export declare function updateKeys(keySet: Set<string> | string[], keyEntities: KeyEntities): string[];
85
85
  export declare function calcDisabledKeys(keyEntities: KeyEntities, keyMaps?: KeyMapProps): Set<string>;
86
- export declare function calcDropRelativePosition(event: any, treeNode: any): 1 | -1 | 0;
86
+ export declare function calcDropRelativePosition(event: any, treeNode: any): 0 | 1 | -1;
87
87
  export declare function getDragNodesKeys(key: string, keyEntities: KeyEntities): string[];
88
88
  export declare function calcDropActualPosition(pos: string, relativeDropPos: any): any;
@@ -18,7 +18,7 @@ declare const strings: {
18
18
  DRAG_AREA_ILLEGAL: string;
19
19
  TRIGGER_AUTO: "auto";
20
20
  TRIGGER_CUSTOM: "custom";
21
- UPLOAD_TRIGGER: ("auto" | "custom")[];
21
+ UPLOAD_TRIGGER: ("custom" | "auto")[];
22
22
  VALIDATE_STATUS: readonly ["default", "error", "warning", "success"];
23
23
  PROMPT_POSITION: readonly ["left", "right", "bottom"];
24
24
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@douyinfe/semi-foundation",
3
- "version": "2.74.0",
3
+ "version": "2.74.1-alpha.2",
4
4
  "description": "",
5
5
  "scripts": {
6
6
  "build:lib": "node ./scripts/compileLib.js",
@@ -29,7 +29,7 @@
29
29
  "*.scss",
30
30
  "*.css"
31
31
  ],
32
- "gitHead": "f88ca5423473b6b4a44751396ceda02b6e6bf7d5",
32
+ "gitHead": "f20b6d5af38f745a6df72e0daffdbd238fcbe8cf",
33
33
  "devDependencies": {
34
34
  "@babel/plugin-transform-runtime": "^7.15.8",
35
35
  "@babel/preset-env": "^7.15.8",
@@ -0,0 +1,58 @@
1
+ module.exports = function (babel) {
2
+ const { types: t } = babel;
3
+ return {
4
+ visitor: {
5
+ ImportDeclaration(path) {
6
+ // 只处理 lottie-web 的导入
7
+ if (path.node.source.value === 'lottie-web') {
8
+ // 创建变量声明
9
+ const varDeclaration = t.variableDeclaration('var', [
10
+ t.variableDeclarator(
11
+ t.identifier('_lottieWeb'),
12
+ t.identifier('undefined')
13
+ )
14
+ ]);
15
+
16
+ // 创建条件语句
17
+ const ifStatement = t.ifStatement(
18
+ t.binaryExpression(
19
+ '!==',
20
+ t.unaryExpression('typeof', t.identifier('document')),
21
+ t.stringLiteral('undefined')
22
+ ),
23
+ t.blockStatement([
24
+ // _lottieWeb = require("lottie-web")
25
+ t.expressionStatement(
26
+ t.assignmentExpression(
27
+ '=',
28
+ t.identifier('_lottieWeb'),
29
+ t.callExpression(t.identifier('require'), [
30
+ t.stringLiteral('lottie-web')
31
+ ])
32
+ )
33
+ ),
34
+ // if (_lottieWeb && _lottieWeb.__esModule) _lottieWeb = _lottieWeb.default
35
+ t.ifStatement(
36
+ t.logicalExpression(
37
+ '&&',
38
+ t.identifier('_lottieWeb'),
39
+ t.memberExpression(t.identifier('_lottieWeb'), t.identifier('__esModule'))
40
+ ),
41
+ t.expressionStatement(
42
+ t.assignmentExpression(
43
+ '=',
44
+ t.identifier('_lottieWeb'),
45
+ t.memberExpression(t.identifier('_lottieWeb'), t.identifier('default'))
46
+ )
47
+ )
48
+ )
49
+ ])
50
+ );
51
+
52
+ path.insertBefore(varDeclaration);
53
+ path.replaceWith(ifStatement);
54
+ }
55
+ }
56
+ }
57
+ };
58
+ };