@granite-js/mpack 0.1.34 → 1.0.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/CHANGELOG.md +6 -360
- package/dist/bundler/internal/presets.d.ts +4 -1
- package/dist/bundler/internal/presets.js +16 -11
- package/dist/bundler/plugins/transformPlugin/steps/createFlowStripStep.d.ts +2 -0
- package/dist/{vendors/@react-native-community/cli-server-api/createWebSocketEndpoints.js → bundler/plugins/transformPlugin/steps/createFlowStripStep.js} +28 -13
- package/dist/bundler/plugins/transformPlugin/steps/createFullyTransformStep.js +0 -1
- package/dist/bundler/plugins/transformPlugin/steps/createTransformCodegenStep.d.ts +2 -0
- package/dist/bundler/plugins/transformPlugin/steps/createTransformCodegenStep.js +70 -0
- package/dist/bundler/plugins/transformPlugin/steps/createTransformToHermesSyntaxStep.d.ts +1 -2
- package/dist/bundler/plugins/transformPlugin/steps/createTransformToHermesSyntaxStep.js +5 -19
- package/dist/bundler/plugins/transformPlugin/transformPlugin.js +11 -5
- package/dist/experimental/index.d.ts +2 -0
- package/dist/{server/debugger/parseDomain.js → experimental/index.js} +9 -8
- package/dist/{operations/experimental → experimental/operations}/serve.js +19 -67
- package/dist/{server → experimental/server}/DevServer.d.ts +3 -3
- package/dist/{server → experimental/server}/DevServer.js +58 -41
- package/dist/{server → experimental/server}/debugger/DebuggerEventHandler.d.ts +1 -0
- package/dist/{server → experimental/server}/debugger/DebuggerEventHandler.js +8 -4
- package/dist/{vendors/@react-native/dev-middleware → experimental/server/debugger}/types.d.ts +1 -1
- package/dist/{server → experimental/server}/helpers/createBundlerForDevServer.d.ts +1 -1
- package/dist/{server → experimental/server}/helpers/createBundlerForDevServer.js +2 -2
- package/dist/{server → experimental/server}/helpers/mergeBundles.js +3 -3
- package/dist/{server → experimental/server}/middlewares/createLiveReloadMiddleware.js +1 -1
- package/dist/{server → experimental/server}/plugins/index.d.ts +0 -1
- package/dist/{server → experimental/server}/plugins/index.js +0 -2
- package/dist/{server → experimental/server}/plugins/indexPagePlugin.js +1 -1
- package/dist/{server → experimental/server}/plugins/reply.js +1 -1
- package/dist/{server → experimental/server}/plugins/serveBundlePlugin.js +2 -2
- package/dist/{server → experimental/server}/plugins/symbolicatePlugin/symbolicatePlugin.js +2 -2
- package/dist/{server → experimental/server}/types.d.ts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +3 -3
- package/dist/logger/clientLogger.d.ts +3 -2
- package/dist/metro/getMetroConfig.js +5 -5
- package/dist/operations/OpenDebuggerKeyboardHandler.d.ts +17 -0
- package/dist/operations/OpenDebuggerKeyboardHandler.js +129 -0
- package/dist/operations/attachKeyHandlers.d.ts +15 -0
- package/dist/operations/attachKeyHandlers.js +132 -0
- package/dist/operations/index.d.ts +0 -1
- package/dist/operations/index.js +1 -3
- package/dist/operations/keyReporter.d.ts +6 -0
- package/dist/operations/keyReporter.js +57 -0
- package/dist/operations/serve.d.ts +1 -2
- package/dist/operations/serve.js +38 -36
- package/dist/transformer/AsyncTransformPipeline.js +24 -7
- package/dist/transformer/TransformPipeline.d.ts +17 -12
- package/dist/transformer/TransformPipeline.js +6 -2
- package/dist/utils/getDefaultReactNativePath.d.ts +1 -0
- package/dist/utils/getDefaultReactNativePath.js +45 -0
- package/dist/utils/getId.js +3 -1
- package/dist/vendors/metro/src/DeltaBundler/Serializers/helpers/getSourceMapInfo.js +2 -1
- package/dist/vendors/metro/src/DeltaBundler/Serializers/sourceMapGenerator.js +3 -1
- package/dist/vendors/metro/src/Server.js +119 -11
- package/package.json +19 -16
- package/src/lib.d.ts +90 -0
- package/dist/bundler/plugins/transformPlugin/steps/createStripFlowStep.d.ts +0 -6
- package/dist/bundler/plugins/transformPlugin/steps/createStripFlowStep.js +0 -91
- package/dist/operations/constants.d.ts +0 -3
- package/dist/operations/constants.js +0 -34
- package/dist/operations/createDebuggerMiddleware.d.ts +0 -10
- package/dist/operations/createDebuggerMiddleware.js +0 -128
- package/dist/operations/experimental/StartMenuHandler.d.ts +0 -13
- package/dist/operations/experimental/StartMenuHandler.js +0 -86
- package/dist/operations/openDebugger.d.ts +0 -1
- package/dist/operations/openDebugger.js +0 -74
- package/dist/server/debugger/parseDomain.d.ts +0 -1
- package/dist/server/plugins/debuggerPlugin.d.ts +0 -7
- package/dist/server/plugins/debuggerPlugin.js +0 -68
- package/dist/vendors/@react-native/dev-middleware/Device.d.ts +0 -5
- package/dist/vendors/@react-native/dev-middleware/Device.js +0 -33
- package/dist/vendors/@react-native/dev-middleware/InspectorProxy.d.ts +0 -31
- package/dist/vendors/@react-native/dev-middleware/InspectorProxy.js +0 -169
- package/dist/vendors/@react-native/dev-middleware/index.d.ts +0 -3
- package/dist/vendors/@react-native/dev-middleware/index.js +0 -26
- package/dist/vendors/@react-native-community/cli-server-api/createWebSocketEndpoints.d.ts +0 -23
- package/dist/vendors/@react-native-community/cli-server-api/index.d.ts +0 -1
- package/dist/vendors/@react-native-community/cli-server-api/index.js +0 -22
- /package/dist/{operations/experimental → experimental/operations}/serve.d.ts +0 -0
- /package/dist/{server → experimental/server}/constants.d.ts +0 -0
- /package/dist/{server → experimental/server}/constants.js +0 -0
- /package/dist/{server → experimental/server/debugger}/types.js +0 -0
- /package/dist/{server → experimental/server}/helpers/mergeBundles.d.ts +0 -0
- /package/dist/{server → experimental/server}/index.d.ts +0 -0
- /package/dist/{server → experimental/server}/index.js +0 -0
- /package/dist/{server → experimental/server}/middlewares/createLiveReloadMiddleware.d.ts +0 -0
- /package/dist/{server → experimental/server}/middlewares/index.d.ts +0 -0
- /package/dist/{server → experimental/server}/middlewares/index.js +0 -0
- /package/dist/{server → experimental/server}/plugins/indexPagePlugin.d.ts +0 -0
- /package/dist/{server → experimental/server}/plugins/reply.d.ts +0 -0
- /package/dist/{server → experimental/server}/plugins/serveBundlePlugin.d.ts +0 -0
- /package/dist/{server → experimental/server}/plugins/statusPlugin.d.ts +0 -0
- /package/dist/{server → experimental/server}/plugins/statusPlugin.js +0 -0
- /package/dist/{server → experimental/server}/plugins/symbolicatePlugin/index.d.ts +0 -0
- /package/dist/{server → experimental/server}/plugins/symbolicatePlugin/index.js +0 -0
- /package/dist/{server → experimental/server}/plugins/symbolicatePlugin/parseStackFrame.d.ts +0 -0
- /package/dist/{server → experimental/server}/plugins/symbolicatePlugin/parseStackFrame.js +0 -0
- /package/dist/{server → experimental/server}/plugins/symbolicatePlugin/symbolicate.d.ts +0 -0
- /package/dist/{server → experimental/server}/plugins/symbolicatePlugin/symbolicate.js +0 -0
- /package/dist/{server → experimental/server}/plugins/symbolicatePlugin/symbolicatePlugin.d.ts +0 -0
- /package/dist/{vendors/@react-native/dev-middleware → experimental/server}/types.js +0 -0
- /package/dist/{server → experimental/server}/wss/WebSocketServerDelegate.d.ts +0 -0
- /package/dist/{server → experimental/server}/wss/WebSocketServerDelegate.js +0 -0
- /package/dist/{server → experimental/server}/wss/WebSocketServerRouter.d.ts +0 -0
- /package/dist/{server → experimental/server}/wss/WebSocketServerRouter.js +0 -0
- /package/dist/{server → experimental/server}/wss/index.d.ts +0 -0
- /package/dist/{server → experimental/server}/wss/index.js +0 -0
|
@@ -11,7 +11,9 @@ function getSourceMapInfosImpl(isBlocking, onDone, modules, options) {
|
|
|
11
11
|
}
|
|
12
12
|
const mod = modulesToProcess.shift();
|
|
13
13
|
const info = getSourceMapInfo(mod, {
|
|
14
|
-
excludeSource: options.excludeSource
|
|
14
|
+
excludeSource: options.excludeSource,
|
|
15
|
+
// MARK: - 0.81
|
|
16
|
+
getSourceUrl: options.getSourceUrl
|
|
15
17
|
});
|
|
16
18
|
sourceMapInfos.push(info);
|
|
17
19
|
return false;
|
|
@@ -56,6 +56,22 @@ class Server {
|
|
|
56
56
|
this._reporter = config.reporter;
|
|
57
57
|
this._logger = Logger;
|
|
58
58
|
this._platforms = new Set(this._config.resolver.platforms);
|
|
59
|
+
this._allowedSuffixesForSourceRequests = [
|
|
60
|
+
...new Set(
|
|
61
|
+
[
|
|
62
|
+
...this._config.resolver.sourceExts,
|
|
63
|
+
...this._config.watcher.additionalExts,
|
|
64
|
+
...this._config.resolver.assetExts
|
|
65
|
+
].map((ext) => "." + ext)
|
|
66
|
+
)
|
|
67
|
+
];
|
|
68
|
+
this._sourceRequestRoutingMap = [
|
|
69
|
+
["/[metro-project]/", path.resolve(this._config.projectRoot)],
|
|
70
|
+
...this._config.watchFolders.map((watchFolder, index) => [
|
|
71
|
+
`/[metro-watchFolders]/${index}/`,
|
|
72
|
+
path.resolve(watchFolder)
|
|
73
|
+
])
|
|
74
|
+
];
|
|
59
75
|
this._isEnded = false;
|
|
60
76
|
this._createModuleId = config.serializer.createModuleIdFactory();
|
|
61
77
|
this._bundler = new IncrementalBundler(config, {
|
|
@@ -77,7 +93,11 @@ class Server {
|
|
|
77
93
|
return this._createModuleId;
|
|
78
94
|
}
|
|
79
95
|
async build(options) {
|
|
80
|
-
const
|
|
96
|
+
const splitOptions = splitBundleOptions(options);
|
|
97
|
+
if (options.sourcePaths) {
|
|
98
|
+
splitOptions.serializerOptions.sourcePaths = options.sourcePaths;
|
|
99
|
+
}
|
|
100
|
+
const { entryFile, graphOptions, onProgress, resolverOptions, serializerOptions, transformOptions } = splitOptions;
|
|
81
101
|
const { prepend, graph } = await this._bundler.buildGraph(entryFile, transformOptions, resolverOptions, {
|
|
82
102
|
onProgress,
|
|
83
103
|
shallow: graphOptions.shallow
|
|
@@ -102,7 +122,8 @@ class Server {
|
|
|
102
122
|
sourceMapUrl: serializerOptions.sourceMapUrl,
|
|
103
123
|
sourceUrl: serializerOptions.sourceUrl,
|
|
104
124
|
inlineSourceMap: serializerOptions.inlineSourceMap,
|
|
105
|
-
serverRoot: this._config.server.unstable_serverRoot ?? this._config.projectRoot
|
|
125
|
+
serverRoot: this._config.server.unstable_serverRoot ?? this._config.projectRoot,
|
|
126
|
+
getSourceUrl: (module2) => this._getModuleSourceUrl(module2, serializerOptions.sourcePaths)
|
|
106
127
|
};
|
|
107
128
|
let bundleCode = null;
|
|
108
129
|
let bundleMap = null;
|
|
@@ -120,7 +141,8 @@ class Server {
|
|
|
120
141
|
if (!bundleMap) {
|
|
121
142
|
bundleMap = sourceMapString([...prepend, ...this._getSortedModules(graph)], {
|
|
122
143
|
excludeSource: serializerOptions.excludeSource,
|
|
123
|
-
processModuleFilter: this._config.serializer.processModuleFilter
|
|
144
|
+
processModuleFilter: this._config.serializer.processModuleFilter,
|
|
145
|
+
getSourceUrl: (module2) => this._getModuleSourceUrl(module2, serializerOptions.sourcePaths)
|
|
124
146
|
});
|
|
125
147
|
}
|
|
126
148
|
return {
|
|
@@ -129,7 +151,11 @@ class Server {
|
|
|
129
151
|
};
|
|
130
152
|
}
|
|
131
153
|
async getRamBundleInfo(options) {
|
|
132
|
-
const
|
|
154
|
+
const splitOptions = splitBundleOptions(options);
|
|
155
|
+
if (options.sourcePaths) {
|
|
156
|
+
splitOptions.serializerOptions.sourcePaths = options.sourcePaths;
|
|
157
|
+
}
|
|
158
|
+
const { entryFile, graphOptions, onProgress, resolverOptions, serializerOptions, transformOptions } = splitOptions;
|
|
133
159
|
const { prepend, graph } = await this._bundler.buildGraph(entryFile, transformOptions, resolverOptions, {
|
|
134
160
|
onProgress,
|
|
135
161
|
shallow: graphOptions.shallow
|
|
@@ -157,7 +183,8 @@ class Server {
|
|
|
157
183
|
sourceMapUrl: serializerOptions.sourceMapUrl,
|
|
158
184
|
sourceUrl: serializerOptions.sourceUrl,
|
|
159
185
|
inlineSourceMap: serializerOptions.inlineSourceMap,
|
|
160
|
-
serverRoot: this._config.server.unstable_serverRoot ?? this._config.projectRoot
|
|
186
|
+
serverRoot: this._config.server.unstable_serverRoot ?? this._config.projectRoot,
|
|
187
|
+
getSourceUrl: (module2) => this._getModuleSourceUrl(module2, serializerOptions.sourcePaths)
|
|
161
188
|
});
|
|
162
189
|
}
|
|
163
190
|
async getAssets(options) {
|
|
@@ -258,7 +285,14 @@ class Server {
|
|
|
258
285
|
this._processRequest(req, res, next).catch(next);
|
|
259
286
|
};
|
|
260
287
|
_parseOptions(url2) {
|
|
261
|
-
|
|
288
|
+
const options = parseOptionsFromUrl(url2, new Set(this._config.resolver.platforms), getBytecodeVersion());
|
|
289
|
+
const urlObj = require("url").parse(url2, true);
|
|
290
|
+
if (urlObj.query && urlObj.query.sourcePaths) {
|
|
291
|
+
options.sourcePaths = urlObj.query.sourcePaths;
|
|
292
|
+
} else if (options.platform === "android" || urlObj.query && (urlObj.query.platform === "android" || urlObj.query.p === "android")) {
|
|
293
|
+
options.sourcePaths = "url-server";
|
|
294
|
+
}
|
|
295
|
+
return options;
|
|
262
296
|
}
|
|
263
297
|
async _processRequest(req, res, next) {
|
|
264
298
|
const originalUrl = req.url;
|
|
@@ -294,12 +328,59 @@ class Server {
|
|
|
294
328
|
} else if (pathname === "/symbolicate") {
|
|
295
329
|
await this._symbolicate(req, res);
|
|
296
330
|
} else {
|
|
297
|
-
|
|
331
|
+
const filePathname = pathname.split("/").map((segment) => decodeURIComponent(segment)).join("/");
|
|
332
|
+
let handled = false;
|
|
333
|
+
for (const [pathnamePrefix, normalizedRootDir] of this._sourceRequestRoutingMap) {
|
|
334
|
+
if (filePathname.startsWith(pathnamePrefix)) {
|
|
335
|
+
const relativeFilePathname = filePathname.substr(pathnamePrefix.length);
|
|
336
|
+
await this._processSourceRequest(relativeFilePathname, normalizedRootDir, res);
|
|
337
|
+
handled = true;
|
|
338
|
+
break;
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
if (!handled) {
|
|
342
|
+
next();
|
|
343
|
+
}
|
|
298
344
|
}
|
|
299
345
|
}
|
|
346
|
+
async _processSourceRequest(relativeFilePathname, rootDir, res) {
|
|
347
|
+
if (!this._allowedSuffixesForSourceRequests.some((suffix) => relativeFilePathname.endsWith(suffix))) {
|
|
348
|
+
res.writeHead(404);
|
|
349
|
+
res.end();
|
|
350
|
+
return;
|
|
351
|
+
}
|
|
352
|
+
const filePath = path.join(rootDir, relativeFilePathname);
|
|
353
|
+
try {
|
|
354
|
+
const stats = fs.statSync(filePath);
|
|
355
|
+
if (!stats.isFile()) {
|
|
356
|
+
throw new Error("Not a file");
|
|
357
|
+
}
|
|
358
|
+
} catch (e) {
|
|
359
|
+
res.writeHead(404);
|
|
360
|
+
res.end();
|
|
361
|
+
return;
|
|
362
|
+
}
|
|
363
|
+
const mimeType = mime.lookup(path.basename(relativeFilePathname));
|
|
364
|
+
res.setHeader("Content-Type", mimeType);
|
|
365
|
+
const stream = fs.createReadStream(filePath);
|
|
366
|
+
stream.pipe(res);
|
|
367
|
+
stream.on("error", (error) => {
|
|
368
|
+
if (error.code === "ENOENT") {
|
|
369
|
+
res.writeHead(404);
|
|
370
|
+
res.end();
|
|
371
|
+
} else {
|
|
372
|
+
res.writeHead(500);
|
|
373
|
+
res.end();
|
|
374
|
+
}
|
|
375
|
+
});
|
|
376
|
+
}
|
|
300
377
|
_createRequestProcessor({ createStartEntry, createEndEntry, build, delete: deleteFn, finish }) {
|
|
301
378
|
return async function requestProcessor(req, res, bundleOptions) {
|
|
302
|
-
const
|
|
379
|
+
const splitOptions = splitBundleOptions(bundleOptions);
|
|
380
|
+
if (bundleOptions.sourcePaths) {
|
|
381
|
+
splitOptions.serializerOptions.sourcePaths = bundleOptions.sourcePaths;
|
|
382
|
+
}
|
|
383
|
+
const { entryFile, graphOptions, resolverOptions, serializerOptions, transformOptions } = splitOptions;
|
|
303
384
|
const resolvedEntryFilePath = await this._resolveRelativePath(entryFile, {
|
|
304
385
|
relativeTo: "server",
|
|
305
386
|
resolverOptions,
|
|
@@ -483,7 +564,8 @@ class Server {
|
|
|
483
564
|
sourceMapUrl: serializerOptions.sourceMapUrl,
|
|
484
565
|
sourceUrl: serializerOptions.sourceUrl,
|
|
485
566
|
inlineSourceMap: serializerOptions.inlineSourceMap,
|
|
486
|
-
serverRoot: this._config.server.unstable_serverRoot ?? this._config.projectRoot
|
|
567
|
+
serverRoot: this._config.server.unstable_serverRoot ?? this._config.projectRoot,
|
|
568
|
+
getSourceUrl: (module2) => this._getModuleSourceUrl(module2, serializerOptions.sourcePaths)
|
|
487
569
|
});
|
|
488
570
|
const bundleCode = typeof bundle === "string" ? bundle : bundle.code;
|
|
489
571
|
return {
|
|
@@ -569,7 +651,8 @@ class Server {
|
|
|
569
651
|
sourceMapUrl: serializerOptions.sourceMapUrl,
|
|
570
652
|
sourceUrl: serializerOptions.sourceUrl,
|
|
571
653
|
inlineSourceMap: serializerOptions.inlineSourceMap,
|
|
572
|
-
serverRoot: this._config.server.unstable_serverRoot ?? this._config.projectRoot
|
|
654
|
+
serverRoot: this._config.server.unstable_serverRoot ?? this._config.projectRoot,
|
|
655
|
+
getSourceUrl: (module2) => this._getModuleSourceUrl(module2, serializerOptions.sourcePaths)
|
|
573
656
|
})
|
|
574
657
|
);
|
|
575
658
|
return {
|
|
@@ -608,6 +691,30 @@ class Server {
|
|
|
608
691
|
}
|
|
609
692
|
return modules.sort((a, b) => this._createModuleId(a.path) - this._createModuleId(b.path));
|
|
610
693
|
}
|
|
694
|
+
_getModuleSourceUrl(module2, mode) {
|
|
695
|
+
if (mode === "url-server") {
|
|
696
|
+
for (const [pathnamePrefix, normalizedRootDir] of this._sourceRequestRoutingMap) {
|
|
697
|
+
if (module2.path.startsWith(normalizedRootDir + path.sep)) {
|
|
698
|
+
const relativePath = module2.path.slice(normalizedRootDir.length + 1);
|
|
699
|
+
const relativePathPosix = relativePath.split(path.sep).map((segment) => encodeURIComponent(segment)).join("/");
|
|
700
|
+
return pathnamePrefix + relativePathPosix;
|
|
701
|
+
}
|
|
702
|
+
}
|
|
703
|
+
const projectRoot = this._config.projectRoot;
|
|
704
|
+
if (module2.path.startsWith(projectRoot + path.sep)) {
|
|
705
|
+
const relativePath = module2.path.slice(projectRoot.length + 1);
|
|
706
|
+
const relativePathPosix = relativePath.split(path.sep).map((segment) => encodeURIComponent(segment)).join("/");
|
|
707
|
+
return "/[metro-project]/" + relativePathPosix;
|
|
708
|
+
}
|
|
709
|
+
const relativeToRoot = path.relative(projectRoot, module2.path);
|
|
710
|
+
if (!relativeToRoot.startsWith("..") && !path.isAbsolute(relativeToRoot)) {
|
|
711
|
+
return "/[metro-project]/" + relativeToRoot.split(path.sep).map((segment) => encodeURIComponent(segment)).join("/");
|
|
712
|
+
}
|
|
713
|
+
const modulePathPosix = module2.path.split(path.sep).map((segment) => encodeURIComponent(segment)).join("/");
|
|
714
|
+
return modulePathPosix.startsWith("/") ? modulePathPosix : "/" + modulePathPosix;
|
|
715
|
+
}
|
|
716
|
+
return module2.path;
|
|
717
|
+
}
|
|
611
718
|
_processSourceMapRequest = this._createRequestProcessor({
|
|
612
719
|
createStartEntry(context) {
|
|
613
720
|
return {
|
|
@@ -647,7 +754,8 @@ class Server {
|
|
|
647
754
|
}
|
|
648
755
|
return sourceMapString([...prepend, ...this._getSortedModules(graph)], {
|
|
649
756
|
excludeSource: serializerOptions.excludeSource,
|
|
650
|
-
processModuleFilter: this._config.serializer.processModuleFilter
|
|
757
|
+
processModuleFilter: this._config.serializer.processModuleFilter,
|
|
758
|
+
getSourceUrl: (module2) => this._getModuleSourceUrl(module2, serializerOptions.sourcePaths)
|
|
651
759
|
});
|
|
652
760
|
},
|
|
653
761
|
finish({ mres, result }) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@granite-js/mpack",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.0",
|
|
4
4
|
"description": "A bundler for Granite apps",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -14,6 +14,10 @@
|
|
|
14
14
|
"types": "./dist/index.d.ts",
|
|
15
15
|
"default": "./dist/index.js"
|
|
16
16
|
},
|
|
17
|
+
"./experimental": {
|
|
18
|
+
"types": "./dist/experimental/index.d.ts",
|
|
19
|
+
"default": "./dist/experimental/index.js"
|
|
20
|
+
},
|
|
17
21
|
"./plugins": {
|
|
18
22
|
"types": "./dist/plugins/index.d.ts",
|
|
19
23
|
"default": "./dist/plugins/index.js"
|
|
@@ -55,21 +59,19 @@
|
|
|
55
59
|
"@types/invariant": "^2",
|
|
56
60
|
"@types/lodash.throttle": "^4",
|
|
57
61
|
"@types/mime-types": "^2",
|
|
58
|
-
"@types/node": "
|
|
62
|
+
"@types/node": "24.10.12",
|
|
59
63
|
"@types/path-browserify": "^1",
|
|
60
64
|
"@types/pnpapi": "^0",
|
|
61
65
|
"@types/prompts": "^2",
|
|
62
|
-
"@types/serve-static": "^1",
|
|
63
66
|
"@types/temp": "^0",
|
|
64
67
|
"@types/ws": "^8",
|
|
65
68
|
"@vitest/coverage-v8": "^4.0.12",
|
|
66
69
|
"eslint": "9.7.0",
|
|
67
70
|
"execa": "^5.0.0",
|
|
68
71
|
"fast-glob": "^3.3.2",
|
|
69
|
-
"flow-remove-types": "^2.251.1",
|
|
70
72
|
"prettier-2": "npm:prettier@^2",
|
|
71
73
|
"ts-prune": "^0.10.3",
|
|
72
|
-
"typescript": "5.
|
|
74
|
+
"typescript": "5.9.3",
|
|
73
75
|
"vitest": "^4.0.12"
|
|
74
76
|
},
|
|
75
77
|
"dependencies": {
|
|
@@ -80,6 +82,7 @@
|
|
|
80
82
|
"@babel/plugin-proposal-class-properties": "7.18.6",
|
|
81
83
|
"@babel/plugin-proposal-private-methods": "7.18.6",
|
|
82
84
|
"@babel/plugin-proposal-private-property-in-object": "7.21.11",
|
|
85
|
+
"@babel/plugin-syntax-typescript": "^7.27.1",
|
|
83
86
|
"@babel/plugin-transform-flow-strip-types": "7.27.1",
|
|
84
87
|
"@babel/preset-env": "7.28.5",
|
|
85
88
|
"@babel/preset-react": "7.28.5",
|
|
@@ -88,27 +91,27 @@
|
|
|
88
91
|
"@babel/template": "7.27.2",
|
|
89
92
|
"@babel/traverse": "7.28.5",
|
|
90
93
|
"@babel/types": "7.28.5",
|
|
91
|
-
"@fastify/
|
|
92
|
-
"@granite-js/
|
|
93
|
-
"@granite-js/
|
|
94
|
-
"@granite-js/utils": "0.1.34",
|
|
95
|
-
"@inquirer/prompts": "^7.2.3",
|
|
94
|
+
"@fastify/middie": "8.3.0",
|
|
95
|
+
"@granite-js/plugin-core": "1.0.0",
|
|
96
|
+
"@granite-js/utils": "1.0.0",
|
|
96
97
|
"@react-native-community/cli-plugin-metro": "11.3.7",
|
|
97
98
|
"@react-native-community/cli-server-api": "11.3.7",
|
|
98
99
|
"@react-native-community/cli-tools": "11.3.7",
|
|
99
|
-
"@react-native/
|
|
100
|
+
"@react-native/babel-plugin-codegen": "0.84.0-rc.5",
|
|
101
|
+
"@react-native/babel-preset": "0.84.0-rc.5",
|
|
102
|
+
"@react-native/dev-middleware": "0.84.0-rc.5",
|
|
100
103
|
"@shopify/semaphore": "^3.1.0",
|
|
101
|
-
"@swc/core": "
|
|
104
|
+
"@swc/core": "1.15.8",
|
|
102
105
|
"@swc/helpers": "0.5.17",
|
|
103
106
|
"absolute-path": "^0.0.0",
|
|
104
107
|
"accepts": "^1.3.7",
|
|
105
108
|
"assert": "2.1.0",
|
|
106
109
|
"async": "^3.2.2",
|
|
110
|
+
"babel-plugin-syntax-hermes-parser": "^0.31.0",
|
|
107
111
|
"babel-preset-fbjs": "^3.4.0",
|
|
108
112
|
"browserify-zlib": "0.2.0",
|
|
109
113
|
"buffer": "6.0.3",
|
|
110
114
|
"chalk": "^4",
|
|
111
|
-
"chrome-launcher": "^0.15.0",
|
|
112
115
|
"ci-info": "^2.0.0",
|
|
113
116
|
"connect": "^3.7.0",
|
|
114
117
|
"cosmiconfig": "^7.0.0",
|
|
@@ -121,10 +124,11 @@
|
|
|
121
124
|
"events": "3.3.0",
|
|
122
125
|
"fastify": "4.14.0",
|
|
123
126
|
"fastify-plugin": "4.5.1",
|
|
127
|
+
"flow-remove-types": "^2.279.0",
|
|
124
128
|
"frogress-bar": "^0.1.0",
|
|
125
129
|
"fs-extra": "^1.0.0",
|
|
126
130
|
"graceful-fs": "^4.2.4",
|
|
127
|
-
"hermes-parser": "0.
|
|
131
|
+
"hermes-parser": "0.31.2",
|
|
128
132
|
"https-browserify": "1.0.0",
|
|
129
133
|
"image-size": "^0.6.0",
|
|
130
134
|
"invariant": "^2.2.4",
|
|
@@ -148,11 +152,10 @@
|
|
|
148
152
|
"mime-types": "^2.1.27",
|
|
149
153
|
"node-fetch": "^2.2.0",
|
|
150
154
|
"nullthrows": "^1.1.1",
|
|
155
|
+
"oxc-transform": "^0.82.1",
|
|
151
156
|
"path-browserify": "1.0.1",
|
|
152
|
-
"react-native-devtools-standalone": "^0.4.1",
|
|
153
157
|
"rimraf": "^2.5.4",
|
|
154
158
|
"serialize-error": "^2.1.0",
|
|
155
|
-
"serve-static": "^1.15.0",
|
|
156
159
|
"source-map": "^0.7.4",
|
|
157
160
|
"stream-browserify": "3.0.0",
|
|
158
161
|
"stream-http": "3.2.0",
|
package/src/lib.d.ts
CHANGED
|
@@ -59,3 +59,93 @@ declare module 'metro-react-native-babel-transformer' {
|
|
|
59
59
|
|
|
60
60
|
export default babelTransformer;
|
|
61
61
|
}
|
|
62
|
+
|
|
63
|
+
declare module 'flow-remove-types' {
|
|
64
|
+
declare const removeTypes: (
|
|
65
|
+
code: string,
|
|
66
|
+
options: {
|
|
67
|
+
all?: boolean;
|
|
68
|
+
ignoreUninitializedFields?: boolean;
|
|
69
|
+
pretty?: boolean;
|
|
70
|
+
removeEmptyImports?: boolean;
|
|
71
|
+
}
|
|
72
|
+
) => {
|
|
73
|
+
toString(): string;
|
|
74
|
+
generateMap(): {
|
|
75
|
+
version: number;
|
|
76
|
+
sources: string[];
|
|
77
|
+
names: string[];
|
|
78
|
+
mappings: string;
|
|
79
|
+
};
|
|
80
|
+
};
|
|
81
|
+
export = removeTypes;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
declare module 'hermes-parser' {
|
|
85
|
+
export type ParserOptions = {
|
|
86
|
+
allowReturnOutsideFunction?: boolean;
|
|
87
|
+
babel?: boolean;
|
|
88
|
+
flow?: 'all' | 'detect';
|
|
89
|
+
enableExperimentalComponentSyntax?: boolean;
|
|
90
|
+
enableExperimentalFlowMatchSyntax?: boolean;
|
|
91
|
+
reactRuntimeTarget?: '18' | '19';
|
|
92
|
+
sourceFilename?: string;
|
|
93
|
+
sourceType?: 'module' | 'script' | 'unambiguous';
|
|
94
|
+
tokens?: boolean;
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
export const ParserOptionsKeys: ReadonlySet<keyof ParserOptions>;
|
|
98
|
+
|
|
99
|
+
export type HermesPosition = {
|
|
100
|
+
/** >= 1 */
|
|
101
|
+
line: number;
|
|
102
|
+
/** >= 0 */
|
|
103
|
+
column: number;
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
export type HermesSourceLocation = {
|
|
107
|
+
start?: HermesPosition;
|
|
108
|
+
end?: HermesPosition;
|
|
109
|
+
rangeStart?: number;
|
|
110
|
+
rangeEnd?: number;
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
export type HermesNode = {
|
|
114
|
+
type: string;
|
|
115
|
+
[key: string]: any;
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
export type HermesToken = {
|
|
119
|
+
type:
|
|
120
|
+
| 'Boolean'
|
|
121
|
+
| 'Identifier'
|
|
122
|
+
| 'Keyword'
|
|
123
|
+
| 'Null'
|
|
124
|
+
| 'Numeric'
|
|
125
|
+
| 'BigInt'
|
|
126
|
+
| 'Punctuator'
|
|
127
|
+
| 'String'
|
|
128
|
+
| 'RegularExpression'
|
|
129
|
+
| 'Template'
|
|
130
|
+
| 'JSXText';
|
|
131
|
+
loc: HermesSourceLocation;
|
|
132
|
+
value?: string | null;
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
export type HermesComment = {
|
|
136
|
+
type: 'CommentLine' | 'CommentBlock' | 'InterpreterDirective';
|
|
137
|
+
loc: HermesSourceLocation;
|
|
138
|
+
value?: string | null;
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
export type HermesProgram = {
|
|
142
|
+
type: 'Program';
|
|
143
|
+
loc: HermesSourceLocation;
|
|
144
|
+
body: Array<HermesNode | null>;
|
|
145
|
+
comments: Array<HermesComment>;
|
|
146
|
+
tokens?: Array<HermesToken>;
|
|
147
|
+
interpreter?: HermesComment | null;
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
export function parse(code: string, options?: ParserOptions): HermesProgram;
|
|
151
|
+
}
|
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
|
-
var __copyProps = (to, from, except, desc) => {
|
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(from))
|
|
15
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return to;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
var createStripFlowStep_exports = {};
|
|
30
|
-
__export(createStripFlowStep_exports, {
|
|
31
|
-
createStripFlowStep: () => createStripFlowStep
|
|
32
|
-
});
|
|
33
|
-
module.exports = __toCommonJS(createStripFlowStep_exports);
|
|
34
|
-
var import_path = __toESM(require("path"));
|
|
35
|
-
var babel = __toESM(require("@babel/core"));
|
|
36
|
-
var sucrase = __toESM(require("sucrase"));
|
|
37
|
-
var import_defineStepName = require("../../../../utils/defineStepName");
|
|
38
|
-
function createStripFlowStep(config) {
|
|
39
|
-
const stripImportTypeofStatements = (code) => {
|
|
40
|
-
return code.split("\n").filter((line) => !line.startsWith("import typeof ")).join("\n");
|
|
41
|
-
};
|
|
42
|
-
const stripFlowStep = async function stripFlow(code, args) {
|
|
43
|
-
const shouldTransform = args.path.endsWith(".js");
|
|
44
|
-
if (!shouldTransform) {
|
|
45
|
-
return { code };
|
|
46
|
-
}
|
|
47
|
-
try {
|
|
48
|
-
const result = sucrase.transform(code, {
|
|
49
|
-
transforms: ["flow", "jsx"],
|
|
50
|
-
jsxRuntime: "preserve",
|
|
51
|
-
disableESTransforms: true
|
|
52
|
-
});
|
|
53
|
-
return { code: stripImportTypeofStatements(result.code) };
|
|
54
|
-
} catch {
|
|
55
|
-
const result = await babel.transformAsync(code, {
|
|
56
|
-
configFile: false,
|
|
57
|
-
minified: false,
|
|
58
|
-
compact: false,
|
|
59
|
-
babelrc: false,
|
|
60
|
-
envName: config.dev ? "development" : "production",
|
|
61
|
-
caller: {
|
|
62
|
-
name: "mpack-strip-flow-plugin",
|
|
63
|
-
supportsStaticESM: true
|
|
64
|
-
},
|
|
65
|
-
presets: [
|
|
66
|
-
/**
|
|
67
|
-
* flow 구문과 jsx 구문이 함께 존재하는 경우가 있기에 preset-react 사용
|
|
68
|
-
*/
|
|
69
|
-
[require.resolve("@babel/preset-react"), { runtime: "automatic" }]
|
|
70
|
-
],
|
|
71
|
-
plugins: [
|
|
72
|
-
/**
|
|
73
|
-
* flow 구문 변환을 위해 flow-strip-types 사용
|
|
74
|
-
*/
|
|
75
|
-
require.resolve("@babel/plugin-transform-flow-strip-types")
|
|
76
|
-
],
|
|
77
|
-
filename: import_path.default.basename(args.path)
|
|
78
|
-
});
|
|
79
|
-
if (result?.code != null) {
|
|
80
|
-
return { code: result.code };
|
|
81
|
-
}
|
|
82
|
-
throw new Error("babel transform result is null");
|
|
83
|
-
}
|
|
84
|
-
};
|
|
85
|
-
(0, import_defineStepName.defineStepName)(stripFlowStep, "strip-flow");
|
|
86
|
-
return stripFlowStep;
|
|
87
|
-
}
|
|
88
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
89
|
-
0 && (module.exports = {
|
|
90
|
-
createStripFlowStep
|
|
91
|
-
});
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var constants_exports = {};
|
|
20
|
-
__export(constants_exports, {
|
|
21
|
-
DEBUGGER_FRONTEND_PATH: () => DEBUGGER_FRONTEND_PATH,
|
|
22
|
-
DEBUGGER_TEMP_DIR: () => DEBUGGER_TEMP_DIR,
|
|
23
|
-
REACT_NATIVE_INSPECTOR_PAGE: () => REACT_NATIVE_INSPECTOR_PAGE
|
|
24
|
-
});
|
|
25
|
-
module.exports = __toCommonJS(constants_exports);
|
|
26
|
-
const DEBUGGER_FRONTEND_PATH = "debugger-frontend";
|
|
27
|
-
const DEBUGGER_TEMP_DIR = "granite-debugger";
|
|
28
|
-
const REACT_NATIVE_INSPECTOR_PAGE = "rn_inspector.html";
|
|
29
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
30
|
-
0 && (module.exports = {
|
|
31
|
-
DEBUGGER_FRONTEND_PATH,
|
|
32
|
-
DEBUGGER_TEMP_DIR,
|
|
33
|
-
REACT_NATIVE_INSPECTOR_PAGE
|
|
34
|
-
});
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import connect from 'connect';
|
|
2
|
-
interface DebuggerMiddlewareConfig {
|
|
3
|
-
port: number;
|
|
4
|
-
broadcastMessage: (method: string, params?: Record<string, unknown>) => void;
|
|
5
|
-
}
|
|
6
|
-
export declare function createDebuggerMiddleware({ port, broadcastMessage }: DebuggerMiddlewareConfig): {
|
|
7
|
-
middleware: connect.Server;
|
|
8
|
-
enableStdinWatchMode: () => void;
|
|
9
|
-
};
|
|
10
|
-
export {};
|