保誠-保戶業務員媒合平台
HelenHuang
2022-06-09 9bdb95c9e34cef640534e5e5a1e2225a80442000
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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
const path = require('path');
 
const rootCompiler = compiler => {
  while (compiler.parentCompilation) {
    compiler = compiler.parentCompilation.compiler;
  }
  return compiler;
};
 
const compilerContext = (exports.compilerContext = function compilerContext(
  compiler,
) {
  return rootCompiler(compiler.compiler ? compiler.compiler : compiler).context;
});
 
const relateNormalPath = (exports.relateNormalPath = function relateNormalPath(
  compiler,
  key,
) {
  if (typeof key !== 'string') {
    return key;
  }
  if (compilerContext(compiler) === key) {
    return '.';
  }
  if (key === '') {
    return key;
  }
  const rel = path.relative(compilerContext(compiler), key.split('?')[0]);
  return [rel.replace(/\\/g, '/')].concat(key.split('?').slice(1)).join('?');
});
 
const relateNormalRequest = (exports.relateNormalRequest = function relateNormalRequest(
  compiler,
  key,
) {
  return key
    .split('!')
    .map(subkey => relateNormalPath(compiler, subkey))
    .join('!');
});
 
const relateNormalModuleId = (exports.relateNormalModuleId = function relateNormalModuleId(
  compiler,
  id,
) {
  return id.substring(0, 24) + relateNormalRequest(compiler, id.substring(24));
});
 
const relateNormalLoaders = (exports.relateNormalLoaders = function relateNormalLoaders(
  compiler,
  loaders,
) {
  return loaders.map(loader =>
    Object.assign({}, loader, {
      loader: relateNormalPath(compiler, loader.loader),
    }),
  );
});
 
const relateNormalPathArray = (exports.relateNormalPathArray = function relateNormalPathArray(
  compiler,
  paths,
) {
  return paths.map(subpath => relateNormalPath(compiler, subpath));
});
 
const relateNormalPathSet = (exports.relateNormalPathSet = function relateNormalPathSet(
  compiler,
  paths,
) {
  return relateNormalPathArray(compiler, Array.from(paths));
});
 
/**
 *
 */
 
// Cache whether we need to replace path.sep because contextNormalPath is called _very_ frequently
const resolveRelativeCompilerContext =
  '/' === path.sep
    ? function(context, key) {
        return path.resolve(context, key);
      }
    : function(context, key) {
        return path.resolve(context, key).replace(/\//g, path.sep);
      };
 
const contextNormalPath = (exports.contextNormalPath = function contextNormalPath(
  compiler,
  key,
) {
  if (typeof key !== 'string' || key === '') {
    return key;
  }
 
  const context = compilerContext(compiler);
  if (key === '.') {
    return context;
  }
 
  const markIndex = key.indexOf('?');
  if (markIndex === -1) {
    return resolveRelativeCompilerContext(context, key);
  }
 
  const abs = resolveRelativeCompilerContext(
    context,
    key.substring(0, markIndex),
  );
  return abs + '?' + key.substring(markIndex + 1);
});
 
const contextNormalRequest = (exports.contextNormalRequest = function contextNormalRequest(
  compiler,
  key,
) {
  // return key
  // .split('!')
  // .map(subkey => contextNormalPath(compiler, subkey))
  // .join('!');
 
  let i = -1;
  let j = -1;
  let _newkey = '';
  while ((i = key.indexOf('!', i + 1)) !== -1) {
    _newkey += contextNormalPath(compiler, key.substring(j + 1, i));
    _newkey += '!';
    j = i;
  }
  _newkey += contextNormalPath(compiler, key.substring(j + 1));
  return _newkey;
});
 
const contextNormalModuleId = (exports.contextNormalModuleId = function contextNormalModuleId(
  compiler,
  id,
) {
  return id.substring(0, 24) + contextNormalRequest(compiler, id.substring(24));
});
 
const contextNormalLoaders = (exports.contextNormalLoaders = function contextNormalLoaders(
  compiler,
  loaders,
) {
  return loaders.map(loader =>
    Object.assign({}, loader, {
      loader: contextNormalPath(compiler, loader.loader),
    }),
  );
});
 
const contextNormalPathArray = (exports.contextNormalPathArray = function contextNormalPathArray(
  compiler,
  paths,
) {
  return paths.map(subpath => contextNormalPath(compiler, subpath));
});
 
const contextNormalPathSet = (exports.contextNormalPathSet = function contextNormalPathSet(
  compiler,
  paths,
) {
  return new Set(contextNormalPathArray(compiler, paths));
});
 
/**
 *
 */
 
const maybeAbsolutePath = (exports.maybeAbsolutePath = function maybeAbsolutePath(
  path,
) {
  return /^([a-zA-Z]:\\\\|\/)/.test(path);
});
 
const relateAbsolutePath = (exports.relateAbsolutePath = function relateAbsolutePath(
  context,
  absPath,
) {
  if (maybeAbsolutePath(absPath)) {
    return path.relative(context, absPath);
  }
  return absPath;
});
 
const relateAbsoluteRequest = (exports.relateAbsoluteRequest = function relateAbsoluteRequest(
  context,
  absReq,
) {
  return absReq
    .split(/!/g)
    .map(path => relateAbsolutePath(context, path))
    .join('!');
});