From 90e6cb94e9c9a4d055a0983c9c7386daa48f61f9 Mon Sep 17 00:00:00 2001
From: HelenHuang <LinHuang@pollex.com.tw>
Date: 星期四, 09 六月 2022 15:45:03 +0800
Subject: [PATCH] TODO#139893 [ FAQ 常見問題 -我進行預約後,顧問會用甚麼方式聯繫我? ] 文案調整

---
 PAMapp/node_modules/@babel/helper-create-class-features-plugin/lib/features.js |   81 +++++++++++++++++++++++++++-------------
 1 files changed, 55 insertions(+), 26 deletions(-)

diff --git a/PAMapp/node_modules/@babel/helper-create-class-features-plugin/lib/features.js b/PAMapp/node_modules/@babel/helper-create-class-features-plugin/lib/features.js
index 8e21265..09dba46 100644
--- a/PAMapp/node_modules/@babel/helper-create-class-features-plugin/lib/features.js
+++ b/PAMapp/node_modules/@babel/helper-create-class-features-plugin/lib/features.js
@@ -3,10 +3,10 @@
 Object.defineProperty(exports, "__esModule", {
   value: true
 });
+exports.FEATURES = void 0;
 exports.enableFeature = enableFeature;
 exports.isLoose = isLoose;
-exports.verifyUsedFeatures = verifyUsedFeatures;
-exports.FEATURES = void 0;
+exports.shouldTransform = shouldTransform;
 
 var _decorators = require("./decorators");
 
@@ -82,41 +82,70 @@
   return !!(file.get(looseLowPriorityKey) & feature);
 }
 
-function verifyUsedFeatures(path, file) {
+function shouldTransform(path, file) {
+  let decoratorPath = null;
+  let publicFieldPath = null;
+  let privateFieldPath = null;
+  let privateMethodPath = null;
+  let staticBlockPath = null;
+
   if ((0, _decorators.hasOwnDecorators)(path.node)) {
-    if (!hasFeature(file, FEATURES.decorators)) {
-      throw path.buildCodeFrameError("Decorators are not enabled." + "\nIf you are using " + '["@babel/plugin-proposal-decorators", { "legacy": true }], ' + 'make sure it comes *before* "@babel/plugin-proposal-class-properties" ' + "and enable loose mode, like so:\n" + '\t["@babel/plugin-proposal-decorators", { "legacy": true }]\n' + '\t["@babel/plugin-proposal-class-properties", { "loose": true }]');
+    decoratorPath = path.get("decorators.0");
+  }
+
+  for (const el of path.get("body.body")) {
+    if (!decoratorPath && (0, _decorators.hasOwnDecorators)(el.node)) {
+      decoratorPath = el.get("decorators.0");
     }
 
-    if (path.isPrivate()) {
-      throw path.buildCodeFrameError(`Private ${path.isClassMethod() ? "methods" : "fields"} in decorated classes are not supported yet.`);
+    if (!publicFieldPath && el.isClassProperty()) {
+      publicFieldPath = el;
+    }
+
+    if (!privateFieldPath && el.isClassPrivateProperty()) {
+      privateFieldPath = el;
+    }
+
+    if (!privateMethodPath && el.isClassPrivateMethod != null && el.isClassPrivateMethod()) {
+      privateMethodPath = el;
+    }
+
+    if (!staticBlockPath && el.isStaticBlock != null && el.isStaticBlock()) {
+      staticBlockPath = el;
     }
   }
 
-  if (path.isClassPrivateMethod != null && path.isClassPrivateMethod()) {
-    if (!hasFeature(file, FEATURES.privateMethods)) {
-      throw path.buildCodeFrameError("Class private methods are not enabled.");
-    }
+  if (decoratorPath && privateFieldPath) {
+    throw privateFieldPath.buildCodeFrameError("Private fields in decorated classes are not supported yet.");
   }
 
-  if (path.isPrivateName() && path.parentPath.isBinaryExpression({
-    operator: "in",
-    left: path.node
-  })) {
-    if (!hasFeature(file, FEATURES.privateIn)) {
-      throw path.buildCodeFrameError("Private property in checks are not enabled.");
-    }
+  if (decoratorPath && privateMethodPath) {
+    throw privateMethodPath.buildCodeFrameError("Private methods in decorated classes are not supported yet.");
   }
 
-  if (path.isProperty()) {
-    if (!hasFeature(file, FEATURES.fields)) {
-      throw path.buildCodeFrameError("Class fields are not enabled.");
-    }
+  if (decoratorPath && !hasFeature(file, FEATURES.decorators)) {
+    throw path.buildCodeFrameError("Decorators are not enabled." + "\nIf you are using " + '["@babel/plugin-proposal-decorators", { "legacy": true }], ' + 'make sure it comes *before* "@babel/plugin-proposal-class-properties" ' + "and enable loose mode, like so:\n" + '\t["@babel/plugin-proposal-decorators", { "legacy": true }]\n' + '\t["@babel/plugin-proposal-class-properties", { "loose": true }]');
   }
 
-  if (path.isStaticBlock != null && path.isStaticBlock()) {
-    if (!hasFeature(file, FEATURES.staticBlocks)) {
-      throw path.buildCodeFrameError("Static class blocks are not enabled. " + "Please add `@babel/plugin-proposal-class-static-block` to your configuration.");
-    }
+  if (privateMethodPath && !hasFeature(file, FEATURES.privateMethods)) {
+    throw privateMethodPath.buildCodeFrameError("Class private methods are not enabled. " + "Please add `@babel/plugin-proposal-private-method` to your configuration.");
   }
+
+  if ((publicFieldPath || privateFieldPath) && !hasFeature(file, FEATURES.fields) && !hasFeature(file, FEATURES.privateMethods)) {
+    throw path.buildCodeFrameError("Class fields are not enabled. " + "Please add `@babel/plugin-proposal-class-properties` to your configuration.");
+  }
+
+  if (staticBlockPath && !hasFeature(file, FEATURES.staticBlocks)) {
+    throw path.buildCodeFrameError("Static class blocks are not enabled. " + "Please add `@babel/plugin-proposal-class-static-block` to your configuration.");
+  }
+
+  if (decoratorPath || privateMethodPath || staticBlockPath) {
+    return true;
+  }
+
+  if ((publicFieldPath || privateFieldPath) && hasFeature(file, FEATURES.fields)) {
+    return true;
+  }
+
+  return false;
 }
\ No newline at end of file

--
Gitblit v1.8.0