路泰科技体检小程序UI设计新版本
qx
2025-08-06 fe97f78b9a343ee9fa45a3531d03d73dcd1df31b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
/**
 * @param {{ defer?: boolean, source?: boolean }} options
 * @param {typeof import("acorn").Parser} Parser
 * @param {typeof import("acorn").tokTypes} acorn
 */
exports.plugin = function acornImportPhase(options, Parser, tt) {
  return class extends Parser {
    parseImport(node) {
      this._phase = null;
      const result = super.parseImport(node);
      if (this._phase) {
        node.phase = this._phase;
      }
      return result;
    }
 
    parseImportSpecifiers() {
      let phase =
        options.defer !== false && this.isContextual("defer")
          ? "defer"
          : options.source !== false && this.isContextual("source")
          ? "source"
          : null;
      if (!phase) return super.parseImportSpecifiers();
 
      const phaseId = this.parseIdent();
      if (this.isContextual("from") || this.type === tt.comma) {
        const defaultSpecifier = this.startNodeAt(phaseId.start, phaseId.loc && phaseId.loc.start);
        defaultSpecifier.local = phaseId;
        this.checkLValSimple(phaseId, /* BIND_LEXICAL */ 2);
 
        const nodes = [this.finishNode(defaultSpecifier, "ImportDefaultSpecifier")];
        if (this.eat(tt.comma)) {
          if (this.type !== tt.star && this.type !== tt.braceL) {
            this.unexpected();
          }
          nodes.push(...super.parseImportSpecifiers());
        }
        return nodes;
      }
 
      this._phase = phase;
 
      if (phase === "defer") {
        if (this.type !== tt.star) {
          this.raiseRecoverable(
            phaseId.start,
            "'import defer' can only be used with namespace imports ('import defer * as identifierName from ...')."
          );
        }
      } else if (phase === "source") {
        if (this.type !== tt.name) {
          this.raiseRecoverable(
            phaseId.start,
            "'import source' can only be used with direct identifier specifier imports."
          );
        }
      }
 
      const specifiers =  super.parseImportSpecifiers();
 
      if (phase === "source" && specifiers.some(s => s.type !== "ImportDefaultSpecifier")) {
        this.raiseRecoverable(
          phaseId.start,
          `'import source' can only be used with direct identifier specifier imports ('import source identifierName from ...').`
        );
      }
 
      return specifiers;
    }
 
    parseExprImport(forNew) {
      const node = super.parseExprImport(forNew);
 
      if (node.type === "MetaProperty" && (node.property.name === "defer" || node.property.name === "source")) {
        if (this.type === tt.parenL) {
          const dynImport = this.parseDynamicImport(this.startNodeAt(node.start, node.loc && node.loc.start));
          dynImport.phase = node.property.name;
          return dynImport;
        } else {
          this.raiseRecoverable(
            node.start,
            `'import.${node.property.name}' can only be used in a dynamic import.`
          );
        }
      }
 
      return node;
    }
 
    parseImportMeta(node) {
      this.next();
 
      var containsEsc = this.containsEsc;
      node.property = this.parseIdent(true);
 
      const { name } = node.property;
 
      if (name !== "meta" && name !== "defer" && name !== "source") {
        this.raiseRecoverable(
          node.property.start,
          "The only valid meta property for import is 'import.meta'"
        );
      }
      if (containsEsc) {
        this.raiseRecoverable(
          node.start,
          `'import.${name}' must not contain escaped characters`
        );
      }
      if (
        name === "meta" &&
        this.options.sourceType !== "module" &&
        !this.options.allowImportExportEverywhere
      ) {
        this.raiseRecoverable(
          node.start,
          "Cannot use 'import.meta' outside a module"
        );
      }
 
      return this.finishNode(node, "MetaProperty");
    }
  };
};