@module-federation/nextjs-mf 5.5.0 → 5.6.0
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/README.md +1 -27
- package/{lib/client → client}/CombinedPages.d.ts +27 -28
- package/client/CombinedPages.js +38 -0
- package/client/CombinedPages.js.map +1 -0
- package/{lib/client → client}/MFClient.d.ts +72 -73
- package/client/MFClient.js +159 -0
- package/client/MFClient.js.map +1 -0
- package/{lib/client → client}/RemoteContainer.d.ts +46 -58
- package/client/RemoteContainer.js +121 -0
- package/client/RemoteContainer.js.map +1 -0
- package/{lib/client → client}/RemotePages.d.ts +49 -49
- package/client/RemotePages.js +138 -0
- package/client/RemotePages.js.map +1 -0
- package/{lib/client → client}/UrlNode.d.ts +17 -18
- package/{lib/client → client}/UrlNode.js +157 -161
- package/client/UrlNode.js.map +1 -0
- package/{lib/client → client}/helpers.d.ts +16 -17
- package/{lib/client → client}/helpers.js +90 -104
- package/client/helpers.js.map +1 -0
- package/client/index.d.ts +2 -0
- package/client/index.js +6 -0
- package/client/index.js.map +1 -0
- package/{lib/client → client}/useMFClient.d.ts +24 -25
- package/client/useMFClient.js +55 -0
- package/client/useMFClient.js.map +1 -0
- package/{lib/client → client}/useMFRemote.d.ts +16 -17
- package/client/useMFRemote.js +50 -0
- package/client/useMFRemote.js.map +1 -0
- package/jest.config.d.ts +13 -0
- package/jest.config.js +18 -0
- package/jest.config.js.map +1 -0
- package/package.json +19 -42
- package/src/include-defaults.d.ts +0 -0
- package/{lib → src}/include-defaults.js +4 -3
- package/src/include-defaults.js.map +1 -0
- package/src/index.d.ts +3 -0
- package/src/index.js +9 -0
- package/src/index.js.map +1 -0
- package/src/internal.d.ts +12 -0
- package/src/internal.js +260 -0
- package/src/internal.js.map +1 -0
- package/src/loaders/fixImageLoader.d.ts +16 -0
- package/src/loaders/fixImageLoader.js +53 -0
- package/src/loaders/fixImageLoader.js.map +1 -0
- package/src/loaders/fixUrlLoader.d.ts +13 -0
- package/src/loaders/fixUrlLoader.js +25 -0
- package/src/loaders/fixUrlLoader.js.map +1 -0
- package/src/loaders/helpers.d.ts +10 -0
- package/src/loaders/helpers.js +46 -0
- package/src/loaders/helpers.js.map +1 -0
- package/src/loaders/nextPageMapLoader.d.ts +15 -0
- package/src/loaders/nextPageMapLoader.js +151 -0
- package/src/loaders/nextPageMapLoader.js.map +1 -0
- package/src/loaders/patchNextClientPageLoader.d.ts +7 -0
- package/src/loaders/patchNextClientPageLoader.js +43 -0
- package/src/loaders/patchNextClientPageLoader.js.map +1 -0
- package/src/plugins/AddRuntimeRequirementToPromiseExternalPlugin.d.ts +5 -0
- package/src/plugins/AddRuntimeRequirementToPromiseExternalPlugin.js +19 -0
- package/src/plugins/AddRuntimeRequirementToPromiseExternalPlugin.js.map +1 -0
- package/src/plugins/ChildFederationPlugin.d.ts +9 -0
- package/src/plugins/ChildFederationPlugin.js +281 -0
- package/src/plugins/ChildFederationPlugin.js.map +1 -0
- package/src/plugins/DevHmrFixInvalidPongPlugin.d.ts +11 -0
- package/src/plugins/DevHmrFixInvalidPongPlugin.js +55 -0
- package/src/plugins/DevHmrFixInvalidPongPlugin.js.map +1 -0
- package/src/plugins/ModuleFederationPlugin.d.ts +7 -0
- package/src/plugins/ModuleFederationPlugin.js +50 -0
- package/src/plugins/ModuleFederationPlugin.js.map +1 -0
- package/src/plugins/NextFederationPlugin.d.ts +9 -0
- package/src/plugins/NextFederationPlugin.js +111 -0
- package/src/plugins/NextFederationPlugin.js.map +1 -0
- package/src/plugins/RemoveRRRuntimePlugin.d.ts +5 -0
- package/src/plugins/RemoveRRRuntimePlugin.js +39 -0
- package/src/plugins/RemoveRRRuntimePlugin.js.map +1 -0
- package/utils/Template.d.ts +148 -0
- package/utils/Template.js +381 -0
- package/utils/Template.js.map +1 -0
- package/utils/build-utils.d.ts +3 -0
- package/utils/build-utils.js +175 -0
- package/utils/build-utils.js.map +1 -0
- package/utils/index.d.ts +1 -0
- package/utils/index.js +7 -0
- package/utils/index.js.map +1 -0
- package/.prettierignore +0 -2
- package/.prettierrc +0 -7
- package/LICENSE +0 -21
- package/lib/ModuleFederationPlugin.js +0 -84
- package/lib/NextFederationPlugin.js +0 -513
- package/lib/_virtual/Template.js +0 -7
- package/lib/_virtual/UrlNode.js +0 -9
- package/lib/_virtual/_commonjsHelpers.js +0 -44
- package/lib/_virtual/_fast-glob.js +0 -16
- package/lib/_virtual/_fs.js +0 -16
- package/lib/_virtual/_path.js +0 -16
- package/lib/_virtual/_tslib.js +0 -277
- package/lib/_virtual/_webpack-sources.js +0 -16
- package/lib/_virtual/fs.js +0 -4
- package/lib/_virtual/fs2.js +0 -7
- package/lib/_virtual/helpers.js +0 -7
- package/lib/_virtual/nextPageMapLoader.js +0 -7
- package/lib/_virtual/options.js +0 -7
- package/lib/_virtual/utils.js +0 -7
- package/lib/build-utils.js +0 -176
- package/lib/client/CombinedPages.d.ts.map +0 -1
- package/lib/client/CombinedPages.js +0 -60
- package/lib/client/MFClient.d.ts.map +0 -1
- package/lib/client/MFClient.js +0 -213
- package/lib/client/RemoteContainer.d.ts.map +0 -1
- package/lib/client/RemoteContainer.js +0 -162
- package/lib/client/RemotePages.d.ts.map +0 -1
- package/lib/client/RemotePages.js +0 -194
- package/lib/client/UrlNode.d.ts.map +0 -1
- package/lib/client/helpers.d.ts.map +0 -1
- package/lib/client/useMFClient.d.ts.map +0 -1
- package/lib/client/useMFClient.js +0 -79
- package/lib/client/useMFRemote.d.ts.map +0 -1
- package/lib/client/useMFRemote.js +0 -72
- package/lib/dependencies/webpack/lib/Template.js +0 -437
- package/lib/dependencies/webpack/lib/container/options.js +0 -102
- package/lib/dependencies/webpack/lib/sharing/utils.js +0 -104
- package/lib/dependencies/webpack/lib/util/fs.js +0 -359
- package/lib/index.js +0 -3
- package/lib/internal.js +0 -271
- package/lib/loaders/UrlNode.js +0 -219
- package/lib/loaders/fixImageLoader.js +0 -65
- package/lib/loaders/fixUrlLoader.js +0 -25
- package/lib/loaders/helpers.js +0 -60
- package/lib/loaders/nextPageMapLoader.js +0 -200
- package/lib/loaders/patchNextClientPageLoader.js +0 -53
- package/lib/plugins/DevHmrFixInvalidPongPlugin.js +0 -82
- package/lib/utils.js +0 -125
- package/node-plugin/README.md +0 -27
- package/node-plugin/package.json +0 -4
- package/node-plugin/streaming/CommonJsChunkLoadingPlugin.js +0 -89
- package/node-plugin/streaming/LoadFileChunkLoadingRuntimeModule.js +0 -410
- package/node-plugin/streaming/NodeRuntime.js +0 -245
- package/node-plugin/streaming/index.js +0 -42
- package/node-plugin/streaming/loadScript.js +0 -51
- package/tsconfig.json +0 -33
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
require('../../../../_virtual/_commonjsHelpers.js');
|
|
6
|
-
var utils = require('../../../../_virtual/utils.js');
|
|
7
|
-
require('../../../../_virtual/fs.js');
|
|
8
|
-
var fs = require('../../../../_virtual/fs2.js');
|
|
9
|
-
|
|
10
|
-
/*
|
|
11
|
-
MIT License http://www.opensource.org/licenses/mit-license.php
|
|
12
|
-
Author Tobias Koppers @sokra
|
|
13
|
-
*/
|
|
14
|
-
|
|
15
|
-
"use strict";
|
|
16
|
-
|
|
17
|
-
const { join, dirname, readJson } = fs.__exports;
|
|
18
|
-
|
|
19
|
-
/** @typedef {import("../util/fs").InputFileSystem} InputFileSystem */
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* @param {string} str maybe required version
|
|
23
|
-
* @returns {boolean} true, if it looks like a version
|
|
24
|
-
*/
|
|
25
|
-
var isRequiredVersion = utils.__exports.isRequiredVersion = str => {
|
|
26
|
-
return /^([\d^=v<>~]|[*xX]$)/.test(str);
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
*
|
|
31
|
-
* @param {InputFileSystem} fs file system
|
|
32
|
-
* @param {string} directory directory to start looking into
|
|
33
|
-
* @param {string[]} descriptionFiles possible description filenames
|
|
34
|
-
* @param {function(Error=, {data: object, path: string}=): void} callback callback
|
|
35
|
-
*/
|
|
36
|
-
const getDescriptionFile = (fs, directory, descriptionFiles, callback) => {
|
|
37
|
-
let i = 0;
|
|
38
|
-
const tryLoadCurrent = () => {
|
|
39
|
-
if (i >= descriptionFiles.length) {
|
|
40
|
-
const parentDirectory = dirname(fs, directory);
|
|
41
|
-
if (!parentDirectory || parentDirectory === directory) return callback();
|
|
42
|
-
return getDescriptionFile(
|
|
43
|
-
fs,
|
|
44
|
-
parentDirectory,
|
|
45
|
-
descriptionFiles,
|
|
46
|
-
callback
|
|
47
|
-
);
|
|
48
|
-
}
|
|
49
|
-
const filePath = join(fs, directory, descriptionFiles[i]);
|
|
50
|
-
readJson(fs, filePath, (err, data) => {
|
|
51
|
-
if (err) {
|
|
52
|
-
if ("code" in err && err.code === "ENOENT") {
|
|
53
|
-
i++;
|
|
54
|
-
return tryLoadCurrent();
|
|
55
|
-
}
|
|
56
|
-
return callback(err);
|
|
57
|
-
}
|
|
58
|
-
if (!data || typeof data !== "object" || Array.isArray(data)) {
|
|
59
|
-
return callback(
|
|
60
|
-
new Error(`Description file ${filePath} is not an object`)
|
|
61
|
-
);
|
|
62
|
-
}
|
|
63
|
-
callback(null, { data, path: filePath });
|
|
64
|
-
});
|
|
65
|
-
};
|
|
66
|
-
tryLoadCurrent();
|
|
67
|
-
};
|
|
68
|
-
var getDescriptionFile_1 = utils.__exports.getDescriptionFile = getDescriptionFile;
|
|
69
|
-
|
|
70
|
-
var getRequiredVersionFromDescriptionFile = utils.__exports.getRequiredVersionFromDescriptionFile = (data, packageName) => {
|
|
71
|
-
if (
|
|
72
|
-
data.optionalDependencies &&
|
|
73
|
-
typeof data.optionalDependencies === "object" &&
|
|
74
|
-
packageName in data.optionalDependencies
|
|
75
|
-
) {
|
|
76
|
-
return data.optionalDependencies[packageName];
|
|
77
|
-
}
|
|
78
|
-
if (
|
|
79
|
-
data.dependencies &&
|
|
80
|
-
typeof data.dependencies === "object" &&
|
|
81
|
-
packageName in data.dependencies
|
|
82
|
-
) {
|
|
83
|
-
return data.dependencies[packageName];
|
|
84
|
-
}
|
|
85
|
-
if (
|
|
86
|
-
data.peerDependencies &&
|
|
87
|
-
typeof data.peerDependencies === "object" &&
|
|
88
|
-
packageName in data.peerDependencies
|
|
89
|
-
) {
|
|
90
|
-
return data.peerDependencies[packageName];
|
|
91
|
-
}
|
|
92
|
-
if (
|
|
93
|
-
data.devDependencies &&
|
|
94
|
-
typeof data.devDependencies === "object" &&
|
|
95
|
-
packageName in data.devDependencies
|
|
96
|
-
) {
|
|
97
|
-
return data.devDependencies[packageName];
|
|
98
|
-
}
|
|
99
|
-
};
|
|
100
|
-
|
|
101
|
-
exports["default"] = utils.__exports;
|
|
102
|
-
exports.getDescriptionFile = getDescriptionFile_1;
|
|
103
|
-
exports.getRequiredVersionFromDescriptionFile = getRequiredVersionFromDescriptionFile;
|
|
104
|
-
exports.isRequiredVersion = isRequiredVersion;
|
|
@@ -1,359 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
require('../../../../_virtual/_commonjsHelpers.js');
|
|
6
|
-
var fs = require('../../../../_virtual/fs2.js');
|
|
7
|
-
require('../../../../_virtual/_path.js');
|
|
8
|
-
var path$1 = require('path');
|
|
9
|
-
|
|
10
|
-
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
11
|
-
|
|
12
|
-
var path__default = /*#__PURE__*/_interopDefaultLegacy(path$1);
|
|
13
|
-
|
|
14
|
-
/*
|
|
15
|
-
MIT License http://www.opensource.org/licenses/mit-license.php
|
|
16
|
-
Author Tobias Koppers @sokra
|
|
17
|
-
*/
|
|
18
|
-
|
|
19
|
-
"use strict";
|
|
20
|
-
|
|
21
|
-
const path = path__default["default"];
|
|
22
|
-
|
|
23
|
-
/** @typedef {import("../../declarations/WebpackOptions").WatchOptions} WatchOptions */
|
|
24
|
-
/** @typedef {import("../FileSystemInfo").FileSystemInfoEntry} FileSystemInfoEntry */
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* @typedef {Object} IStats
|
|
28
|
-
* @property {() => boolean} isFile
|
|
29
|
-
* @property {() => boolean} isDirectory
|
|
30
|
-
* @property {() => boolean} isBlockDevice
|
|
31
|
-
* @property {() => boolean} isCharacterDevice
|
|
32
|
-
* @property {() => boolean} isSymbolicLink
|
|
33
|
-
* @property {() => boolean} isFIFO
|
|
34
|
-
* @property {() => boolean} isSocket
|
|
35
|
-
* @property {number | bigint} dev
|
|
36
|
-
* @property {number | bigint} ino
|
|
37
|
-
* @property {number | bigint} mode
|
|
38
|
-
* @property {number | bigint} nlink
|
|
39
|
-
* @property {number | bigint} uid
|
|
40
|
-
* @property {number | bigint} gid
|
|
41
|
-
* @property {number | bigint} rdev
|
|
42
|
-
* @property {number | bigint} size
|
|
43
|
-
* @property {number | bigint} blksize
|
|
44
|
-
* @property {number | bigint} blocks
|
|
45
|
-
* @property {number | bigint} atimeMs
|
|
46
|
-
* @property {number | bigint} mtimeMs
|
|
47
|
-
* @property {number | bigint} ctimeMs
|
|
48
|
-
* @property {number | bigint} birthtimeMs
|
|
49
|
-
* @property {Date} atime
|
|
50
|
-
* @property {Date} mtime
|
|
51
|
-
* @property {Date} ctime
|
|
52
|
-
* @property {Date} birthtime
|
|
53
|
-
*/
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* @typedef {Object} IDirent
|
|
57
|
-
* @property {() => boolean} isFile
|
|
58
|
-
* @property {() => boolean} isDirectory
|
|
59
|
-
* @property {() => boolean} isBlockDevice
|
|
60
|
-
* @property {() => boolean} isCharacterDevice
|
|
61
|
-
* @property {() => boolean} isSymbolicLink
|
|
62
|
-
* @property {() => boolean} isFIFO
|
|
63
|
-
* @property {() => boolean} isSocket
|
|
64
|
-
* @property {string | Buffer} name
|
|
65
|
-
*/
|
|
66
|
-
|
|
67
|
-
/** @typedef {function((NodeJS.ErrnoException | null)=): void} Callback */
|
|
68
|
-
/** @typedef {function((NodeJS.ErrnoException | null)=, Buffer=): void} BufferCallback */
|
|
69
|
-
/** @typedef {function((NodeJS.ErrnoException | null)=, Buffer|string=): void} BufferOrStringCallback */
|
|
70
|
-
/** @typedef {function((NodeJS.ErrnoException | null)=, (string | Buffer)[] | IDirent[]=): void} DirentArrayCallback */
|
|
71
|
-
/** @typedef {function((NodeJS.ErrnoException | null)=, string=): void} StringCallback */
|
|
72
|
-
/** @typedef {function((NodeJS.ErrnoException | null)=, number=): void} NumberCallback */
|
|
73
|
-
/** @typedef {function((NodeJS.ErrnoException | null)=, IStats=): void} StatsCallback */
|
|
74
|
-
/** @typedef {function((NodeJS.ErrnoException | Error | null)=, any=): void} ReadJsonCallback */
|
|
75
|
-
/** @typedef {function((NodeJS.ErrnoException | Error | null)=, IStats|string=): void} LstatReadlinkAbsoluteCallback */
|
|
76
|
-
|
|
77
|
-
/**
|
|
78
|
-
* @typedef {Object} WatcherInfo
|
|
79
|
-
* @property {Set<string>} changes get current aggregated changes that have not yet send to callback
|
|
80
|
-
* @property {Set<string>} removals get current aggregated removals that have not yet send to callback
|
|
81
|
-
* @property {Map<string, FileSystemInfoEntry | "ignore">} fileTimeInfoEntries get info about files
|
|
82
|
-
* @property {Map<string, FileSystemInfoEntry | "ignore">} contextTimeInfoEntries get info about directories
|
|
83
|
-
*/
|
|
84
|
-
|
|
85
|
-
// TODO webpack 6 deprecate missing getInfo
|
|
86
|
-
/**
|
|
87
|
-
* @typedef {Object} Watcher
|
|
88
|
-
* @property {function(): void} close closes the watcher and all underlying file watchers
|
|
89
|
-
* @property {function(): void} pause closes the watcher, but keeps underlying file watchers alive until the next watch call
|
|
90
|
-
* @property {function(): Set<string>=} getAggregatedChanges get current aggregated changes that have not yet send to callback
|
|
91
|
-
* @property {function(): Set<string>=} getAggregatedRemovals get current aggregated removals that have not yet send to callback
|
|
92
|
-
* @property {function(): Map<string, FileSystemInfoEntry | "ignore">} getFileTimeInfoEntries get info about files
|
|
93
|
-
* @property {function(): Map<string, FileSystemInfoEntry | "ignore">} getContextTimeInfoEntries get info about directories
|
|
94
|
-
* @property {function(): WatcherInfo=} getInfo get info about timestamps and changes
|
|
95
|
-
*/
|
|
96
|
-
|
|
97
|
-
/**
|
|
98
|
-
* @callback WatchMethod
|
|
99
|
-
* @param {Iterable<string>} files watched files
|
|
100
|
-
* @param {Iterable<string>} directories watched directories
|
|
101
|
-
* @param {Iterable<string>} missing watched exitance entries
|
|
102
|
-
* @param {number} startTime timestamp of start time
|
|
103
|
-
* @param {WatchOptions} options options object
|
|
104
|
-
* @param {function(Error=, Map<string, FileSystemInfoEntry | "ignore">, Map<string, FileSystemInfoEntry | "ignore">, Set<string>, Set<string>): void} callback aggregated callback
|
|
105
|
-
* @param {function(string, number): void} callbackUndelayed callback when the first change was detected
|
|
106
|
-
* @returns {Watcher} a watcher
|
|
107
|
-
*/
|
|
108
|
-
|
|
109
|
-
// TODO webpack 6 make optional methods required
|
|
110
|
-
|
|
111
|
-
/**
|
|
112
|
-
* @typedef {Object} OutputFileSystem
|
|
113
|
-
* @property {function(string, Buffer|string, Callback): void} writeFile
|
|
114
|
-
* @property {function(string, Callback): void} mkdir
|
|
115
|
-
* @property {function(string, DirentArrayCallback): void=} readdir
|
|
116
|
-
* @property {function(string, Callback): void=} rmdir
|
|
117
|
-
* @property {function(string, Callback): void=} unlink
|
|
118
|
-
* @property {function(string, StatsCallback): void} stat
|
|
119
|
-
* @property {function(string, StatsCallback): void=} lstat
|
|
120
|
-
* @property {function(string, BufferOrStringCallback): void} readFile
|
|
121
|
-
* @property {(function(string, string): string)=} join
|
|
122
|
-
* @property {(function(string, string): string)=} relative
|
|
123
|
-
* @property {(function(string): string)=} dirname
|
|
124
|
-
*/
|
|
125
|
-
|
|
126
|
-
/**
|
|
127
|
-
* @typedef {Object} InputFileSystem
|
|
128
|
-
* @property {function(string, BufferOrStringCallback): void} readFile
|
|
129
|
-
* @property {(function(string, ReadJsonCallback): void)=} readJson
|
|
130
|
-
* @property {function(string, BufferOrStringCallback): void} readlink
|
|
131
|
-
* @property {function(string, DirentArrayCallback): void} readdir
|
|
132
|
-
* @property {function(string, StatsCallback): void} stat
|
|
133
|
-
* @property {function(string, StatsCallback): void=} lstat
|
|
134
|
-
* @property {(function(string, BufferOrStringCallback): void)=} realpath
|
|
135
|
-
* @property {(function(string=): void)=} purge
|
|
136
|
-
* @property {(function(string, string): string)=} join
|
|
137
|
-
* @property {(function(string, string): string)=} relative
|
|
138
|
-
* @property {(function(string): string)=} dirname
|
|
139
|
-
*/
|
|
140
|
-
|
|
141
|
-
/**
|
|
142
|
-
* @typedef {Object} WatchFileSystem
|
|
143
|
-
* @property {WatchMethod} watch
|
|
144
|
-
*/
|
|
145
|
-
|
|
146
|
-
/**
|
|
147
|
-
* @typedef {Object} IntermediateFileSystemExtras
|
|
148
|
-
* @property {function(string): void} mkdirSync
|
|
149
|
-
* @property {function(string): NodeJS.WritableStream} createWriteStream
|
|
150
|
-
* @property {function(string, string, NumberCallback): void} open
|
|
151
|
-
* @property {function(number, Buffer, number, number, number, NumberCallback): void} read
|
|
152
|
-
* @property {function(number, Callback): void} close
|
|
153
|
-
* @property {function(string, string, Callback): void} rename
|
|
154
|
-
*/
|
|
155
|
-
|
|
156
|
-
/** @typedef {InputFileSystem & OutputFileSystem & IntermediateFileSystemExtras} IntermediateFileSystem */
|
|
157
|
-
|
|
158
|
-
/**
|
|
159
|
-
*
|
|
160
|
-
* @param {InputFileSystem|OutputFileSystem|undefined} fs a file system
|
|
161
|
-
* @param {string} rootPath the root path
|
|
162
|
-
* @param {string} targetPath the target path
|
|
163
|
-
* @returns {string} location of targetPath relative to rootPath
|
|
164
|
-
*/
|
|
165
|
-
const relative = (fs, rootPath, targetPath) => {
|
|
166
|
-
if (fs && fs.relative) {
|
|
167
|
-
return fs.relative(rootPath, targetPath);
|
|
168
|
-
} else if (path.posix.isAbsolute(rootPath)) {
|
|
169
|
-
return path.posix.relative(rootPath, targetPath);
|
|
170
|
-
} else if (path.win32.isAbsolute(rootPath)) {
|
|
171
|
-
return path.win32.relative(rootPath, targetPath);
|
|
172
|
-
} else {
|
|
173
|
-
throw new Error(
|
|
174
|
-
`${rootPath} is neither a posix nor a windows path, and there is no 'relative' method defined in the file system`
|
|
175
|
-
);
|
|
176
|
-
}
|
|
177
|
-
};
|
|
178
|
-
var relative_1 = fs.__exports.relative = relative;
|
|
179
|
-
|
|
180
|
-
/**
|
|
181
|
-
* @param {InputFileSystem|OutputFileSystem|undefined} fs a file system
|
|
182
|
-
* @param {string} rootPath a path
|
|
183
|
-
* @param {string} filename a filename
|
|
184
|
-
* @returns {string} the joined path
|
|
185
|
-
*/
|
|
186
|
-
const join = (fs, rootPath, filename) => {
|
|
187
|
-
if (fs && fs.join) {
|
|
188
|
-
return fs.join(rootPath, filename);
|
|
189
|
-
} else if (path.posix.isAbsolute(rootPath)) {
|
|
190
|
-
return path.posix.join(rootPath, filename);
|
|
191
|
-
} else if (path.win32.isAbsolute(rootPath)) {
|
|
192
|
-
return path.win32.join(rootPath, filename);
|
|
193
|
-
} else {
|
|
194
|
-
throw new Error(
|
|
195
|
-
`${rootPath} is neither a posix nor a windows path, and there is no 'join' method defined in the file system`
|
|
196
|
-
);
|
|
197
|
-
}
|
|
198
|
-
};
|
|
199
|
-
var join_1 = fs.__exports.join = join;
|
|
200
|
-
|
|
201
|
-
/**
|
|
202
|
-
* @param {InputFileSystem|OutputFileSystem|undefined} fs a file system
|
|
203
|
-
* @param {string} absPath an absolute path
|
|
204
|
-
* @returns {string} the parent directory of the absolute path
|
|
205
|
-
*/
|
|
206
|
-
const dirname = (fs, absPath) => {
|
|
207
|
-
if (fs && fs.dirname) {
|
|
208
|
-
return fs.dirname(absPath);
|
|
209
|
-
} else if (path.posix.isAbsolute(absPath)) {
|
|
210
|
-
return path.posix.dirname(absPath);
|
|
211
|
-
} else if (path.win32.isAbsolute(absPath)) {
|
|
212
|
-
return path.win32.dirname(absPath);
|
|
213
|
-
} else {
|
|
214
|
-
throw new Error(
|
|
215
|
-
`${absPath} is neither a posix nor a windows path, and there is no 'dirname' method defined in the file system`
|
|
216
|
-
);
|
|
217
|
-
}
|
|
218
|
-
};
|
|
219
|
-
var dirname_1 = fs.__exports.dirname = dirname;
|
|
220
|
-
|
|
221
|
-
/**
|
|
222
|
-
* @param {OutputFileSystem} fs a file system
|
|
223
|
-
* @param {string} p an absolute path
|
|
224
|
-
* @param {function(Error=): void} callback callback function for the error
|
|
225
|
-
* @returns {void}
|
|
226
|
-
*/
|
|
227
|
-
const mkdirp = (fs, p, callback) => {
|
|
228
|
-
fs.mkdir(p, err => {
|
|
229
|
-
if (err) {
|
|
230
|
-
if (err.code === "ENOENT") {
|
|
231
|
-
const dir = dirname(fs, p);
|
|
232
|
-
if (dir === p) {
|
|
233
|
-
callback(err);
|
|
234
|
-
return;
|
|
235
|
-
}
|
|
236
|
-
mkdirp(fs, dir, err => {
|
|
237
|
-
if (err) {
|
|
238
|
-
callback(err);
|
|
239
|
-
return;
|
|
240
|
-
}
|
|
241
|
-
fs.mkdir(p, err => {
|
|
242
|
-
if (err) {
|
|
243
|
-
if (err.code === "EEXIST") {
|
|
244
|
-
callback();
|
|
245
|
-
return;
|
|
246
|
-
}
|
|
247
|
-
callback(err);
|
|
248
|
-
return;
|
|
249
|
-
}
|
|
250
|
-
callback();
|
|
251
|
-
});
|
|
252
|
-
});
|
|
253
|
-
return;
|
|
254
|
-
} else if (err.code === "EEXIST") {
|
|
255
|
-
callback();
|
|
256
|
-
return;
|
|
257
|
-
}
|
|
258
|
-
callback(err);
|
|
259
|
-
return;
|
|
260
|
-
}
|
|
261
|
-
callback();
|
|
262
|
-
});
|
|
263
|
-
};
|
|
264
|
-
var mkdirp_1 = fs.__exports.mkdirp = mkdirp;
|
|
265
|
-
|
|
266
|
-
/**
|
|
267
|
-
* @param {IntermediateFileSystem} fs a file system
|
|
268
|
-
* @param {string} p an absolute path
|
|
269
|
-
* @returns {void}
|
|
270
|
-
*/
|
|
271
|
-
const mkdirpSync = (fs, p) => {
|
|
272
|
-
try {
|
|
273
|
-
fs.mkdirSync(p);
|
|
274
|
-
} catch (err) {
|
|
275
|
-
if (err) {
|
|
276
|
-
if (err.code === "ENOENT") {
|
|
277
|
-
const dir = dirname(fs, p);
|
|
278
|
-
if (dir === p) {
|
|
279
|
-
throw err;
|
|
280
|
-
}
|
|
281
|
-
mkdirpSync(fs, dir);
|
|
282
|
-
fs.mkdirSync(p);
|
|
283
|
-
return;
|
|
284
|
-
} else if (err.code === "EEXIST") {
|
|
285
|
-
return;
|
|
286
|
-
}
|
|
287
|
-
throw err;
|
|
288
|
-
}
|
|
289
|
-
}
|
|
290
|
-
};
|
|
291
|
-
var mkdirpSync_1 = fs.__exports.mkdirpSync = mkdirpSync;
|
|
292
|
-
|
|
293
|
-
/**
|
|
294
|
-
* @param {InputFileSystem} fs a file system
|
|
295
|
-
* @param {string} p an absolute path
|
|
296
|
-
* @param {ReadJsonCallback} callback callback
|
|
297
|
-
* @returns {void}
|
|
298
|
-
*/
|
|
299
|
-
const readJson = (fs, p, callback) => {
|
|
300
|
-
if ("readJson" in fs) return fs.readJson(p, callback);
|
|
301
|
-
fs.readFile(p, (err, buf) => {
|
|
302
|
-
if (err) return callback(err);
|
|
303
|
-
let data;
|
|
304
|
-
try {
|
|
305
|
-
data = JSON.parse(buf.toString("utf-8"));
|
|
306
|
-
} catch (e) {
|
|
307
|
-
return callback(e);
|
|
308
|
-
}
|
|
309
|
-
return callback(null, data);
|
|
310
|
-
});
|
|
311
|
-
};
|
|
312
|
-
var readJson_1 = fs.__exports.readJson = readJson;
|
|
313
|
-
|
|
314
|
-
/**
|
|
315
|
-
* @param {InputFileSystem} fs a file system
|
|
316
|
-
* @param {string} p an absolute path
|
|
317
|
-
* @param {ReadJsonCallback} callback callback
|
|
318
|
-
* @returns {void}
|
|
319
|
-
*/
|
|
320
|
-
const lstatReadlinkAbsolute = (fs, p, callback) => {
|
|
321
|
-
let i = 3;
|
|
322
|
-
const doReadLink = () => {
|
|
323
|
-
fs.readlink(p, (err, target) => {
|
|
324
|
-
if (err && --i > 0) {
|
|
325
|
-
// It might was just changed from symlink to file
|
|
326
|
-
// we retry 2 times to catch this case before throwing the error
|
|
327
|
-
return doStat();
|
|
328
|
-
}
|
|
329
|
-
if (err || !target) return doStat();
|
|
330
|
-
const value = target.toString();
|
|
331
|
-
callback(null, join(fs, dirname(fs, p), value));
|
|
332
|
-
});
|
|
333
|
-
};
|
|
334
|
-
const doStat = () => {
|
|
335
|
-
if ("lstat" in fs) {
|
|
336
|
-
return fs.lstat(p, (err, stats) => {
|
|
337
|
-
if (err) return callback(err);
|
|
338
|
-
if (stats.isSymbolicLink()) {
|
|
339
|
-
return doReadLink();
|
|
340
|
-
}
|
|
341
|
-
callback(null, stats);
|
|
342
|
-
});
|
|
343
|
-
} else {
|
|
344
|
-
return fs.stat(p, callback);
|
|
345
|
-
}
|
|
346
|
-
};
|
|
347
|
-
if ("lstat" in fs) return doStat();
|
|
348
|
-
doReadLink();
|
|
349
|
-
};
|
|
350
|
-
var lstatReadlinkAbsolute_1 = fs.__exports.lstatReadlinkAbsolute = lstatReadlinkAbsolute;
|
|
351
|
-
|
|
352
|
-
exports["default"] = fs.__exports;
|
|
353
|
-
exports.dirname = dirname_1;
|
|
354
|
-
exports.join = join_1;
|
|
355
|
-
exports.lstatReadlinkAbsolute = lstatReadlinkAbsolute_1;
|
|
356
|
-
exports.mkdirp = mkdirp_1;
|
|
357
|
-
exports.mkdirpSync = mkdirpSync_1;
|
|
358
|
-
exports.readJson = readJson_1;
|
|
359
|
-
exports.relative = relative_1;
|
package/lib/index.js
DELETED