rollipop 0.1.0-alpha.11 → 0.1.0-alpha.13
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 +14 -0
- package/dist/{chunk-Dj-qOoLf.js → chunk-D0rfrjR5.js} +4 -5
- package/dist/commands.cjs +796 -2193
- package/dist/commands.js +787 -2185
- package/dist/hmr-client.js +137 -133
- package/dist/hmr-runtime.d.ts +1 -1
- package/dist/hmr-runtime.js +195 -187
- package/dist/index.d.ts +30 -48
- package/dist/index.js +973 -2369
- package/dist/pluginutils.d.ts +18 -21
- package/dist/pluginutils.js +7 -7
- package/dist/runtime.cjs +1 -0
- package/package.json +27 -33
- package/dist/pluginutils.cjs +0 -210
- package/dist/pluginutils.d.cts +0 -646
package/dist/commands.cjs
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
//#region
|
|
1
|
+
//#region \0rolldown/runtime.js
|
|
2
2
|
var __create = Object.create;
|
|
3
3
|
var __defProp = Object.defineProperty;
|
|
4
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
6
|
var __getProtoOf = Object.getPrototypeOf;
|
|
7
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __commonJSMin = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
|
|
9
8
|
var __copyProps = (to, from, except, desc) => {
|
|
10
9
|
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
10
|
for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
@@ -47,6 +46,8 @@ let flow_remove_types = require("flow-remove-types");
|
|
|
47
46
|
flow_remove_types = __toESM(flow_remove_types);
|
|
48
47
|
let hermes_parser = require("hermes-parser");
|
|
49
48
|
hermes_parser = __toESM(hermes_parser);
|
|
49
|
+
let wrap_ansi = require("wrap-ansi");
|
|
50
|
+
wrap_ansi = __toESM(wrap_ansi);
|
|
50
51
|
let c12 = require("c12");
|
|
51
52
|
c12 = __toESM(c12);
|
|
52
53
|
let p_limit = require("p-limit");
|
|
@@ -60,8 +61,6 @@ node_crypto = __toESM(node_crypto);
|
|
|
60
61
|
let _node_rs_xxhash = require("@node-rs/xxhash");
|
|
61
62
|
let dedent = require("dedent");
|
|
62
63
|
dedent = __toESM(dedent);
|
|
63
|
-
let wrap_ansi = require("wrap-ansi");
|
|
64
|
-
wrap_ansi = __toESM(wrap_ansi);
|
|
65
64
|
let dotenv = require("dotenv");
|
|
66
65
|
dotenv = __toESM(dotenv);
|
|
67
66
|
let dotenv_expand = require("dotenv-expand");
|
|
@@ -74,6 +73,8 @@ let _react_native_community_cli_server_api = require("@react-native-community/cl
|
|
|
74
73
|
let _react_native_dev_middleware = require("@react-native/dev-middleware");
|
|
75
74
|
let fastify = require("fastify");
|
|
76
75
|
fastify = __toESM(fastify);
|
|
76
|
+
let mitt = require("mitt");
|
|
77
|
+
mitt = __toESM(mitt);
|
|
77
78
|
let node_http = require("node:http");
|
|
78
79
|
node_http = __toESM(node_http);
|
|
79
80
|
let node_events = require("node:events");
|
|
@@ -88,6 +89,7 @@ let mime = require("mime");
|
|
|
88
89
|
mime = __toESM(mime);
|
|
89
90
|
let ajv = require("ajv");
|
|
90
91
|
ajv = __toESM(ajv);
|
|
92
|
+
let _babel_code_frame = require("@babel/code-frame");
|
|
91
93
|
let ws = require("ws");
|
|
92
94
|
ws = __toESM(ws);
|
|
93
95
|
let _svgr_core = require("@svgr/core");
|
|
@@ -131,9 +133,9 @@ function printLogo() {
|
|
|
131
133
|
DESCRIPTIONS.forEach((description, index) => {
|
|
132
134
|
const descriptionHalfLength = description.length / 2;
|
|
133
135
|
const logoHalfWidth = maxLogoWidth / 2;
|
|
134
|
-
const padding
|
|
135
|
-
if (index === 0) console.log(padding
|
|
136
|
-
else console.log(padding
|
|
136
|
+
const padding = " ".repeat(PADDING - descriptionHalfLength + logoHalfWidth);
|
|
137
|
+
if (index === 0) console.log(padding + chalk.default.bold.hex(PRIMARY_COLOR)(description));
|
|
138
|
+
else console.log(padding + description);
|
|
137
139
|
});
|
|
138
140
|
console.log("");
|
|
139
141
|
}
|
|
@@ -168,7 +170,7 @@ const FALSY_VALUES = [
|
|
|
168
170
|
];
|
|
169
171
|
function parseDebugKeys() {
|
|
170
172
|
return Object.keys(process.env).filter((key) => /^debug_/i.test(key)).reduce((acc, key) => {
|
|
171
|
-
const prop = key.slice(6).toLowerCase().replace(/_([a-z])/g, (_, key
|
|
173
|
+
const prop = key.slice(6).toLowerCase().replace(/_([a-z])/g, (_, key) => key.toUpperCase());
|
|
172
174
|
let value = process.env[key];
|
|
173
175
|
const lowerCase = typeof value === "string" ? value.toLowerCase() : value.toString();
|
|
174
176
|
if (TRUTHY_VALUES.includes(lowerCase)) value = true;
|
|
@@ -400,18 +402,18 @@ function setupInteractiveMode(options) {
|
|
|
400
402
|
process.emit("SIGINT");
|
|
401
403
|
process.exit(0);
|
|
402
404
|
}
|
|
403
|
-
const targetCommand = allCommands.find((command
|
|
405
|
+
const targetCommand = allCommands.find((command) => command.key === sequence && (command.shift ?? false) === shift);
|
|
404
406
|
if (targetCommand) targetCommand.handler.call({
|
|
405
407
|
server: devServer,
|
|
406
408
|
logger: logger$2
|
|
407
409
|
});
|
|
408
410
|
});
|
|
409
411
|
console.log();
|
|
410
|
-
allCommands.forEach((command
|
|
412
|
+
allCommands.forEach((command, index) => {
|
|
411
413
|
if (defaultCommands.length === index) console.log();
|
|
412
|
-
const leadingLabel = command
|
|
413
|
-
const shortcut = chalk.default.bold(shortcutLabel(command
|
|
414
|
-
console.log(`${leadingLabel} ${shortcut} │ ${typeof command
|
|
414
|
+
const leadingLabel = command.shift ? "»" : "» Press";
|
|
415
|
+
const shortcut = chalk.default.bold(shortcutLabel(command.key, command.shift));
|
|
416
|
+
console.log(`${leadingLabel} ${shortcut} │ ${typeof command.description === "function" ? command.description() : command.description}`);
|
|
415
417
|
});
|
|
416
418
|
}
|
|
417
419
|
function getDefaultCommands(devServer, debuggerOpener) {
|
|
@@ -460,10 +462,10 @@ function shortcutLabel(key, shift) {
|
|
|
460
462
|
if (shift) return `shift+${key}`;
|
|
461
463
|
return key;
|
|
462
464
|
}
|
|
463
|
-
function assertHasNoDuplicateCommands(defaultCommands, commands
|
|
465
|
+
function assertHasNoDuplicateCommands(defaultCommands, commands) {
|
|
464
466
|
const defaultCommandKeys = defaultCommands.map(({ key, shift }) => shortcutLabel(key, shift));
|
|
465
|
-
const duplicateKeys = commands
|
|
466
|
-
const invalidCommandKeys = commands
|
|
467
|
+
const duplicateKeys = commands.map(({ key, shift }) => shortcutLabel(key, shift)).filter((key) => defaultCommandKeys.includes(key));
|
|
468
|
+
const invalidCommandKeys = commands.filter(({ key }) => key.length > 1).map(({ key, shift }) => shortcutLabel(key, shift));
|
|
467
469
|
if (invalidCommandKeys.length > 0) throw new Error(`Invalid commands: ${invalidCommandKeys.join(", ")}`);
|
|
468
470
|
if (duplicateKeys.length > 0) throw new Error(`Duplicate commands: ${duplicateKeys.join(", ")}`);
|
|
469
471
|
}
|
|
@@ -508,10 +510,10 @@ function parseFlowSyntax(code) {
|
|
|
508
510
|
babel: true
|
|
509
511
|
});
|
|
510
512
|
}
|
|
511
|
-
function generateSourceFromAst(ast, id
|
|
513
|
+
function generateSourceFromAst(ast, id) {
|
|
512
514
|
const generated = (0, _babel_generator.generate)(ast, {
|
|
513
515
|
sourceMaps: true,
|
|
514
|
-
sourceFileName: node_path.default.basename(id
|
|
516
|
+
sourceFileName: node_path.default.basename(id)
|
|
515
517
|
});
|
|
516
518
|
return {
|
|
517
519
|
code: generated.code,
|
|
@@ -648,13 +650,13 @@ function getPolyfillScriptPaths(reactNativePath) {
|
|
|
648
650
|
const scriptPath = node_path.default.join(reactNativePath, "rn-get-polyfills");
|
|
649
651
|
return require(scriptPath)();
|
|
650
652
|
}
|
|
651
|
-
function getGlobalVariables(dev
|
|
652
|
-
const isDevServerMode = dev
|
|
653
|
+
function getGlobalVariables(dev, buildType) {
|
|
654
|
+
const isDevServerMode = dev && buildType === "serve";
|
|
653
655
|
return [
|
|
654
656
|
`var __BUNDLE_START_TIME__=globalThis.nativePerformanceNow?nativePerformanceNow():Date.now();`,
|
|
655
|
-
`var __DEV__=${dev
|
|
657
|
+
`var __DEV__=${dev};`,
|
|
656
658
|
`var ${GLOBAL_IDENTIFIER}=typeof globalThis!=='undefined'?globalThis:typeof global !== 'undefined'?global:typeof window!=='undefined'?window:this;`,
|
|
657
|
-
`var process=globalThis.process||{};process.env=process.env||{};process.env.NODE_ENV=process.env.NODE_ENV||"${dev
|
|
659
|
+
`var process=globalThis.process||{};process.env=process.env||{};process.env.NODE_ENV=process.env.NODE_ENV||"${dev ? "development" : "production"}";`,
|
|
658
660
|
isDevServerMode ? `var $RefreshReg$ = () => {};` : null,
|
|
659
661
|
isDevServerMode ? `var $RefreshSig$ = () => (v) => v;` : null
|
|
660
662
|
].filter(es_toolkit.isNotNil);
|
|
@@ -686,419 +688,68 @@ function resolvePackagePathWithNodeRequire(basePath, packageName, subpath) {
|
|
|
686
688
|
}
|
|
687
689
|
|
|
688
690
|
//#endregion
|
|
689
|
-
//#region src/
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
mode: mode ?? "development",
|
|
700
|
-
entry: "index.js",
|
|
701
|
-
resolver: {
|
|
702
|
-
sourceExtensions: DEFAULT_SOURCE_EXTENSIONS,
|
|
703
|
-
assetExtensions: DEFAULT_ASSET_EXTENSIONS,
|
|
704
|
-
mainFields: DEFAULT_RESOLVER_MAIN_FIELDS,
|
|
705
|
-
conditionNames: DEFAULT_RESOLVER_CONDITION_NAMES,
|
|
706
|
-
preferNativePlatform: true,
|
|
707
|
-
symlinks: true
|
|
708
|
-
},
|
|
709
|
-
transformer: {
|
|
710
|
-
svg: true,
|
|
711
|
-
flow: { filter: {
|
|
712
|
-
id: /\.jsx?$/,
|
|
713
|
-
code: /@flow/
|
|
714
|
-
} }
|
|
715
|
-
},
|
|
716
|
-
serializer: {
|
|
717
|
-
prelude: [getInitializeCorePath(projectRoot)],
|
|
718
|
-
polyfills: getPolyfillScriptPaths(reactNativePath).map((path$14) => ({
|
|
719
|
-
type: "iife",
|
|
720
|
-
code: generateSourceFromAst(stripFlowSyntax(node_fs.default.readFileSync(path$14, "utf-8")), path$14).code
|
|
721
|
-
}))
|
|
722
|
-
},
|
|
723
|
-
watcher: {
|
|
724
|
-
skipWrite: true,
|
|
725
|
-
useDebounce: true,
|
|
726
|
-
debounceDuration: 50
|
|
727
|
-
},
|
|
728
|
-
optimization: { treeshake: true },
|
|
729
|
-
reactNative: {
|
|
730
|
-
reactNativePath,
|
|
731
|
-
codegen: { filter: { code: /\bcodegenNativeComponent</ } },
|
|
732
|
-
assetRegistryPath: DEFAULT_ASSET_REGISTRY_PATH,
|
|
733
|
-
globalIdentifiers: DEFAULT_REACT_NATIVE_GLOBAL_IDENTIFIERS
|
|
734
|
-
},
|
|
735
|
-
devMode: { hmr: true },
|
|
736
|
-
terminal: { status: (() => {
|
|
737
|
-
if (isDebugEnabled()) return "compat";
|
|
738
|
-
if (process.stderr.isTTY) return "progress";
|
|
739
|
-
return "compat";
|
|
740
|
-
})() },
|
|
741
|
-
reporter: new TerminalReporter(),
|
|
742
|
-
envDir: projectRoot,
|
|
743
|
-
envPrefix: DEFAULT_ENV_PREFIX
|
|
744
|
-
};
|
|
745
|
-
}
|
|
746
|
-
var TerminalReporter = class {
|
|
747
|
-
logger = new Logger("app");
|
|
748
|
-
update(event) {
|
|
749
|
-
if (event.type === "client_log") {
|
|
750
|
-
if (event.level === "group" || event.level === "groupCollapsed") {
|
|
751
|
-
this.logger.info(...event.data);
|
|
752
|
-
return;
|
|
753
|
-
} else if (event.level === "groupEnd") return;
|
|
754
|
-
this.logger[event.level](...event.data);
|
|
755
|
-
}
|
|
756
|
-
}
|
|
757
|
-
};
|
|
758
|
-
|
|
759
|
-
//#endregion
|
|
760
|
-
//#region src/core/plugins/context.ts
|
|
761
|
-
const pluginLogger = new Logger();
|
|
762
|
-
function createPluginContext(name) {
|
|
763
|
-
return {
|
|
764
|
-
debug: (log) => {
|
|
765
|
-
printPluginLog("debug", log, name);
|
|
766
|
-
},
|
|
767
|
-
info: (log) => {
|
|
768
|
-
printPluginLog("info", log, name);
|
|
769
|
-
},
|
|
770
|
-
warn: (log) => {
|
|
771
|
-
printPluginLog("warn", log, name);
|
|
772
|
-
}
|
|
773
|
-
};
|
|
774
|
-
}
|
|
775
|
-
function printPluginLog(level, log, pluginName = "unknown") {
|
|
776
|
-
const pluginLabel = chalk.default.magenta(`plugin:${pluginName}`);
|
|
777
|
-
if (typeof log === "string") pluginLogger[level](pluginLabel, log);
|
|
778
|
-
else pluginLogger[level](pluginLabel, log.stack ?? log.message);
|
|
779
|
-
}
|
|
780
|
-
|
|
781
|
-
//#endregion
|
|
782
|
-
//#region src/config/merge-config.ts
|
|
783
|
-
function mergeConfig(baseConfig, ...overrideConfigs) {
|
|
784
|
-
let mergedConfig = baseConfig;
|
|
785
|
-
for (const overrideConfig of overrideConfigs) mergedConfig = (0, es_toolkit.mergeWith)(mergedConfig, overrideConfig, (target, source, key) => {
|
|
786
|
-
if ([
|
|
787
|
-
"sourceExtensions",
|
|
788
|
-
"assetExtensions",
|
|
789
|
-
"polyfills",
|
|
790
|
-
"prelude",
|
|
791
|
-
"plugins"
|
|
792
|
-
].includes(key)) return Array.from(new Set([...target ?? [], ...source ?? []]));
|
|
793
|
-
if (key === "reporter") return source ?? target;
|
|
794
|
-
});
|
|
795
|
-
return mergedConfig;
|
|
796
|
-
}
|
|
797
|
-
|
|
798
|
-
//#endregion
|
|
799
|
-
//#region src/config/load-config.ts
|
|
800
|
-
const CONFIG_FILE_NAME = "rollipop";
|
|
801
|
-
async function loadConfig(options = {}) {
|
|
802
|
-
const { cwd = process.cwd(), configFile, mode, context = {} } = options;
|
|
803
|
-
const defaultConfig = getDefaultConfig(cwd, mode);
|
|
804
|
-
const commonOptions = {
|
|
805
|
-
context: {
|
|
806
|
-
...context,
|
|
807
|
-
defaultConfig
|
|
808
|
-
},
|
|
809
|
-
rcFile: false
|
|
810
|
-
};
|
|
811
|
-
const { config: userConfig } = await c12.loadConfig(configFile ? {
|
|
812
|
-
configFile: node_path.default.resolve(cwd, configFile),
|
|
813
|
-
configFileRequired: true
|
|
814
|
-
} : {
|
|
815
|
-
cwd,
|
|
816
|
-
defaultConfig,
|
|
817
|
-
name: CONFIG_FILE_NAME,
|
|
818
|
-
...commonOptions
|
|
819
|
-
});
|
|
820
|
-
const plugins = await flattenPluginOption(userConfig.plugins);
|
|
821
|
-
const pluginConfig = await resolvePluginConfig(userConfig, plugins);
|
|
822
|
-
const resolvedConfig = mergeConfig(defaultConfig, ...[{
|
|
823
|
-
...userConfig,
|
|
824
|
-
plugins
|
|
825
|
-
}, pluginConfig]);
|
|
826
|
-
await invokeConfigResolved(resolvedConfig, plugins);
|
|
827
|
-
return resolvedConfig;
|
|
828
|
-
}
|
|
829
|
-
async function flattenPluginOption(pluginOption) {
|
|
830
|
-
const awaitedPluginOption = await pluginOption;
|
|
831
|
-
if (Array.isArray(awaitedPluginOption)) return (await Promise.all(awaitedPluginOption.map(flattenPluginOption))).flat();
|
|
832
|
-
if (awaitedPluginOption == null || awaitedPluginOption === false) return [];
|
|
833
|
-
return [awaitedPluginOption];
|
|
834
|
-
}
|
|
835
|
-
async function resolvePluginConfig(baseConfig, plugins) {
|
|
836
|
-
let mergedConfig = (0, es_toolkit.omit)(baseConfig, ["plugins", "dangerously_overrideRolldownOptions"]);
|
|
837
|
-
for (const plugin$3 of plugins) {
|
|
838
|
-
const context = createPluginContext(plugin$3.name);
|
|
839
|
-
if (typeof plugin$3.config === "function") {
|
|
840
|
-
const config = await plugin$3.config.call(context, mergedConfig);
|
|
841
|
-
if (config != null) mergedConfig = mergeConfig(mergedConfig, config);
|
|
842
|
-
} else if (typeof plugin$3.config === "object") mergedConfig = mergeConfig(mergedConfig, plugin$3.config);
|
|
843
|
-
}
|
|
844
|
-
return mergedConfig;
|
|
691
|
+
//#region src/utils/terminal.ts
|
|
692
|
+
/**
|
|
693
|
+
* Based on https://github.com/sindresorhus/log-update/blob/master/index.js
|
|
694
|
+
* Based on https://github.com/unjs/webpackbar
|
|
695
|
+
*/
|
|
696
|
+
function eraseLines(count) {
|
|
697
|
+
let clear = "";
|
|
698
|
+
for (let i = 0; i < count; i++) clear += `\u001B[2K` + (i < count - 1 ? `\u001B[1A` : "");
|
|
699
|
+
if (count) clear += `\u001B[G`;
|
|
700
|
+
return clear;
|
|
845
701
|
}
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
return plugin$3.configResolved?.call(context, config);
|
|
850
|
-
}));
|
|
702
|
+
function ellipsisLeft(value, maxLength) {
|
|
703
|
+
if (value.length <= maxLength - 3) return value;
|
|
704
|
+
return `...${value.slice(value.length - maxLength - 1)}`;
|
|
851
705
|
}
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
706
|
+
const originalWrite = Symbol("original-write");
|
|
707
|
+
var StreamManager = class {
|
|
708
|
+
prevLineCount;
|
|
709
|
+
listening;
|
|
710
|
+
extraLines;
|
|
711
|
+
_streams;
|
|
712
|
+
constructor() {
|
|
713
|
+
this.prevLineCount = 0;
|
|
714
|
+
this.listening = false;
|
|
715
|
+
this.extraLines = "";
|
|
716
|
+
this._onData = this._onData.bind(this);
|
|
717
|
+
this._streams = [process.stdout, process.stderr];
|
|
864
718
|
}
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
719
|
+
render(lines) {
|
|
720
|
+
this.listen();
|
|
721
|
+
const wrappedLines = (0, wrap_ansi.default)(lines, this.columns, {
|
|
722
|
+
trim: false,
|
|
723
|
+
hard: true,
|
|
724
|
+
wordWrap: false
|
|
869
725
|
});
|
|
726
|
+
const data = eraseLines(this.prevLineCount) + wrappedLines + "\n" + this.extraLines;
|
|
727
|
+
this.write(data);
|
|
728
|
+
this.prevLineCount = data.split("\n").length;
|
|
870
729
|
}
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
this.ensureCacheDirectory(this.cacheDirectory);
|
|
874
|
-
logger$1.debug("cache directory:", this.cacheDirectory);
|
|
875
|
-
}
|
|
876
|
-
ensureCacheDirectory(cacheDirectory) {
|
|
877
|
-
if (!node_fs.default.existsSync(cacheDirectory)) node_fs.default.mkdirSync(cacheDirectory, { recursive: true });
|
|
730
|
+
get columns() {
|
|
731
|
+
return (process.stderr.columns || 80) - 2;
|
|
878
732
|
}
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
return;
|
|
884
|
-
}
|
|
733
|
+
write(data) {
|
|
734
|
+
const stream = process.stderr;
|
|
735
|
+
if (stream.write[originalWrite]) stream.write[originalWrite].call(stream, data, "utf8");
|
|
736
|
+
else stream.write(data, "utf8");
|
|
885
737
|
}
|
|
886
|
-
|
|
887
|
-
this.
|
|
738
|
+
clear() {
|
|
739
|
+
this.done();
|
|
740
|
+
this.write(eraseLines(this.prevLineCount));
|
|
888
741
|
}
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
try {
|
|
894
|
-
await node_fs.default.promises.writeFile(node_path.default.join(this.cacheDirectory, key), value);
|
|
895
|
-
} catch (error) {
|
|
896
|
-
logger$1.error("Failed to write cache file", key);
|
|
897
|
-
logger$1.debug(error);
|
|
898
|
-
}
|
|
899
|
-
}))).catch((error) => {
|
|
900
|
-
logger$1.error("Failed to flush cache", error);
|
|
901
|
-
});
|
|
902
|
-
this.pendingData.clear();
|
|
742
|
+
done() {
|
|
743
|
+
this.stopListen();
|
|
744
|
+
this.prevLineCount = 0;
|
|
745
|
+
this.extraLines = "";
|
|
903
746
|
}
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
}
|
|
911
|
-
};
|
|
912
|
-
|
|
913
|
-
//#endregion
|
|
914
|
-
//#region src/utils/reset-cache.ts
|
|
915
|
-
function resetCache(projectRoot) {
|
|
916
|
-
FileSystemCache.clearAll(projectRoot);
|
|
917
|
-
}
|
|
918
|
-
|
|
919
|
-
//#endregion
|
|
920
|
-
//#region src/utils/build-options.ts
|
|
921
|
-
const DEFAULT_BUILD_OPTIONS = {
|
|
922
|
-
cache: true,
|
|
923
|
-
minify: false
|
|
924
|
-
};
|
|
925
|
-
function resolveBuildOptions(config, buildOptions) {
|
|
926
|
-
if (buildOptions.outfile) buildOptions.outfile = node_path.default.resolve(config.root, buildOptions.outfile);
|
|
927
|
-
if ((buildOptions.sourcemap === true || buildOptions.sourcemap === "hidden") && buildOptions.sourcemapOutfile) buildOptions.sourcemapOutfile = node_path.default.resolve(config.root, buildOptions.sourcemapOutfile);
|
|
928
|
-
return (0, es_toolkit.merge)(DEFAULT_BUILD_OPTIONS, {
|
|
929
|
-
...buildOptions,
|
|
930
|
-
dev: buildOptions.dev ?? config.mode === "development"
|
|
931
|
-
});
|
|
932
|
-
}
|
|
933
|
-
|
|
934
|
-
//#endregion
|
|
935
|
-
//#region src/utils/hash.ts
|
|
936
|
-
function xxhash(data) {
|
|
937
|
-
return (0, _node_rs_xxhash.xxh32)(data).toString(16);
|
|
938
|
-
}
|
|
939
|
-
function md5(data) {
|
|
940
|
-
return node_crypto.default.createHash("md5").update(data).digest("hex");
|
|
941
|
-
}
|
|
942
|
-
|
|
943
|
-
//#endregion
|
|
944
|
-
//#region src/utils/serialize.ts
|
|
945
|
-
function serialize(value) {
|
|
946
|
-
return JSON.stringify(value, (_, value$1) => {
|
|
947
|
-
if (typeof value$1 === "function") return value$1.toString();
|
|
948
|
-
if (value$1 instanceof RegExp) return value$1.toString();
|
|
949
|
-
return value$1;
|
|
950
|
-
});
|
|
951
|
-
}
|
|
952
|
-
|
|
953
|
-
//#endregion
|
|
954
|
-
//#region src/utils/id.ts
|
|
955
|
-
function createId(config, buildOptions) {
|
|
956
|
-
return md5(serialize([
|
|
957
|
-
ROLLIPOP_VERSION,
|
|
958
|
-
filterTransformAffectedOptions(buildOptions),
|
|
959
|
-
filterTransformAffectedConfig(config)
|
|
960
|
-
]));
|
|
961
|
-
}
|
|
962
|
-
function filterTransformAffectedOptions(buildOptions) {
|
|
963
|
-
return (0, es_toolkit.pick)(buildOptions, ["platform", "dev"]);
|
|
964
|
-
}
|
|
965
|
-
function filterTransformAffectedConfig(config) {
|
|
966
|
-
const { transformer, serializer, reactNative, devMode, plugins = [] } = config;
|
|
967
|
-
return [
|
|
968
|
-
transformer,
|
|
969
|
-
serializer.polyfills,
|
|
970
|
-
serializer.prelude,
|
|
971
|
-
reactNative.assetRegistryPath,
|
|
972
|
-
devMode,
|
|
973
|
-
plugins.map((plugin$3, index) => `${plugin$3.name}#${index}`)
|
|
974
|
-
];
|
|
975
|
-
}
|
|
976
|
-
|
|
977
|
-
//#endregion
|
|
978
|
-
//#region src/core/fs/storage.ts
|
|
979
|
-
const DEFAULT_DATA = { build: {} };
|
|
980
|
-
var FileStorage = class FileStorage {
|
|
981
|
-
static instance = null;
|
|
982
|
-
dataFilePath;
|
|
983
|
-
data;
|
|
984
|
-
static getInstance(basePath) {
|
|
985
|
-
if (FileStorage.instance == null) FileStorage.instance = new FileStorage(basePath);
|
|
986
|
-
return new FileStorage(basePath);
|
|
987
|
-
}
|
|
988
|
-
constructor(basePath) {
|
|
989
|
-
this.basePath = basePath;
|
|
990
|
-
this.dataFilePath = node_path.default.join(getSharedDataPath(basePath), "rollipop.json");
|
|
991
|
-
if (node_fs.default.existsSync(this.dataFilePath)) this.data = JSON.parse(node_fs.default.readFileSync(this.dataFilePath, "utf-8"));
|
|
992
|
-
else this.data = DEFAULT_DATA;
|
|
993
|
-
}
|
|
994
|
-
get() {
|
|
995
|
-
return this.data;
|
|
996
|
-
}
|
|
997
|
-
set(data) {
|
|
998
|
-
this.data = (0, es_toolkit.merge)(this.data, data);
|
|
999
|
-
node_fs.default.writeFileSync(this.dataFilePath, JSON.stringify(this.data, null, 2));
|
|
1000
|
-
}
|
|
1001
|
-
};
|
|
1002
|
-
|
|
1003
|
-
//#endregion
|
|
1004
|
-
//#region src/utils/string.ts
|
|
1005
|
-
function indent(text, indent$1, space = " ") {
|
|
1006
|
-
return text.replace(/^/gm, space.repeat(indent$1));
|
|
1007
|
-
}
|
|
1008
|
-
|
|
1009
|
-
//#endregion
|
|
1010
|
-
//#region src/common/code.ts
|
|
1011
|
-
function asLiteral(value) {
|
|
1012
|
-
return JSON.stringify(value);
|
|
1013
|
-
}
|
|
1014
|
-
function asIdentifier(name) {
|
|
1015
|
-
return name;
|
|
1016
|
-
}
|
|
1017
|
-
function nodeEnvironment(dev$1) {
|
|
1018
|
-
return dev$1 ? "development" : "production";
|
|
1019
|
-
}
|
|
1020
|
-
function iife(body, path$14 = "<unknown>") {
|
|
1021
|
-
const bodyPlaceholder = "__BODY__";
|
|
1022
|
-
return dedent.default`
|
|
1023
|
-
// ${path$14}
|
|
1024
|
-
(function (global) {
|
|
1025
|
-
${bodyPlaceholder}
|
|
1026
|
-
})(${GLOBAL_IDENTIFIER});
|
|
1027
|
-
`.replace(bodyPlaceholder, indent(body, 1));
|
|
1028
|
-
}
|
|
1029
|
-
|
|
1030
|
-
//#endregion
|
|
1031
|
-
//#region src/utils/storage.ts
|
|
1032
|
-
function getBuildTotalModules(storage, id$3) {
|
|
1033
|
-
return storage.get().build[id$3]?.totalModules ?? 0;
|
|
1034
|
-
}
|
|
1035
|
-
function setBuildTotalModules(storage, id$3, totalModules) {
|
|
1036
|
-
storage.set({ build: { [id$3]: { totalModules } } });
|
|
1037
|
-
}
|
|
1038
|
-
|
|
1039
|
-
//#endregion
|
|
1040
|
-
//#region src/utils/terminal.ts
|
|
1041
|
-
/**
|
|
1042
|
-
* Based on https://github.com/sindresorhus/log-update/blob/master/index.js
|
|
1043
|
-
* Based on https://github.com/unjs/webpackbar
|
|
1044
|
-
*/
|
|
1045
|
-
function eraseLines(count) {
|
|
1046
|
-
let clear = "";
|
|
1047
|
-
for (let i = 0; i < count; i++) clear += `\u001B[2K` + (i < count - 1 ? `\u001B[1A` : "");
|
|
1048
|
-
if (count) clear += `\u001B[G`;
|
|
1049
|
-
return clear;
|
|
1050
|
-
}
|
|
1051
|
-
function ellipsisLeft(value, maxLength) {
|
|
1052
|
-
if (value.length <= maxLength - 3) return value;
|
|
1053
|
-
return `...${value.slice(value.length - maxLength - 1)}`;
|
|
1054
|
-
}
|
|
1055
|
-
const originalWrite = Symbol("original-write");
|
|
1056
|
-
var StreamManager = class {
|
|
1057
|
-
prevLineCount;
|
|
1058
|
-
listening;
|
|
1059
|
-
extraLines;
|
|
1060
|
-
_streams;
|
|
1061
|
-
constructor() {
|
|
1062
|
-
this.prevLineCount = 0;
|
|
1063
|
-
this.listening = false;
|
|
1064
|
-
this.extraLines = "";
|
|
1065
|
-
this._onData = this._onData.bind(this);
|
|
1066
|
-
this._streams = [process.stdout, process.stderr];
|
|
1067
|
-
}
|
|
1068
|
-
render(lines) {
|
|
1069
|
-
this.listen();
|
|
1070
|
-
const wrappedLines = (0, wrap_ansi.default)(lines, this.columns, {
|
|
1071
|
-
trim: false,
|
|
1072
|
-
hard: true,
|
|
1073
|
-
wordWrap: false
|
|
1074
|
-
});
|
|
1075
|
-
const data = eraseLines(this.prevLineCount) + wrappedLines + "\n" + this.extraLines;
|
|
1076
|
-
this.write(data);
|
|
1077
|
-
this.prevLineCount = data.split("\n").length;
|
|
1078
|
-
}
|
|
1079
|
-
get columns() {
|
|
1080
|
-
return (process.stderr.columns || 80) - 2;
|
|
1081
|
-
}
|
|
1082
|
-
write(data) {
|
|
1083
|
-
const stream = process.stderr;
|
|
1084
|
-
if (stream.write[originalWrite]) stream.write[originalWrite].call(stream, data, "utf8");
|
|
1085
|
-
else stream.write(data, "utf8");
|
|
1086
|
-
}
|
|
1087
|
-
clear() {
|
|
1088
|
-
this.done();
|
|
1089
|
-
this.write(eraseLines(this.prevLineCount));
|
|
1090
|
-
}
|
|
1091
|
-
done() {
|
|
1092
|
-
this.stopListen();
|
|
1093
|
-
this.prevLineCount = 0;
|
|
1094
|
-
this.extraLines = "";
|
|
1095
|
-
}
|
|
1096
|
-
_onData(data) {
|
|
1097
|
-
const lines = String(data).split("\n").length - 1;
|
|
1098
|
-
if (lines > 0) {
|
|
1099
|
-
this.prevLineCount += lines;
|
|
1100
|
-
this.extraLines += data;
|
|
1101
|
-
}
|
|
747
|
+
_onData(data) {
|
|
748
|
+
const lines = String(data).split("\n").length - 1;
|
|
749
|
+
if (lines > 0) {
|
|
750
|
+
this.prevLineCount += lines;
|
|
751
|
+
this.extraLines += data;
|
|
752
|
+
}
|
|
1102
753
|
}
|
|
1103
754
|
listen() {
|
|
1104
755
|
if (this.listening) return;
|
|
@@ -1146,9 +797,12 @@ const runningRenderer = { render(state, context) {
|
|
|
1146
797
|
].join(" ")}\n${state.moduleId ? " " + chalk.default.grey(ellipsisLeft(state.moduleId, columns - 10)) : ""}`;
|
|
1147
798
|
} };
|
|
1148
799
|
const completedRenderer = { render(state, context) {
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
800
|
+
if (state.hasErrors) return `${chalk.default.red("✘")} Build failed ${chalk.default.gray(context.label)}`;
|
|
801
|
+
else {
|
|
802
|
+
const icon = chalk.default.green("✔");
|
|
803
|
+
const durationInSeconds = (state.duration / 1e3).toFixed(2);
|
|
804
|
+
return `${`${icon} Build completed ${chalk.default.gray(context.label)}`}\n${chalk.default.grey(` Built in ${durationInSeconds}s (${context.current}/${context.total} modules)`)}`;
|
|
805
|
+
}
|
|
1152
806
|
} };
|
|
1153
807
|
var ProgressBarRenderer = class {
|
|
1154
808
|
renderers = {
|
|
@@ -1222,147 +876,468 @@ var ProgressBar = class {
|
|
|
1222
876
|
};
|
|
1223
877
|
var ProgressBarRenderManager = class ProgressBarRenderManager {
|
|
1224
878
|
static instance = null;
|
|
1225
|
-
streamManager = new StreamManager();
|
|
1226
|
-
progressBars = /* @__PURE__ */ new Map();
|
|
1227
|
-
throttledRender;
|
|
1228
|
-
static getInstance() {
|
|
1229
|
-
if (!ProgressBarRenderManager.instance) ProgressBarRenderManager.instance = new ProgressBarRenderManager();
|
|
1230
|
-
return ProgressBarRenderManager.instance;
|
|
1231
|
-
}
|
|
1232
|
-
constructor() {
|
|
1233
|
-
this.throttledRender = (0, es_toolkit.throttle)(this._render.bind(this), 50);
|
|
1234
|
-
}
|
|
1235
|
-
_render() {
|
|
1236
|
-
const renderedLines = Array.from(this.progressBars.values().filter((progressBar
|
|
1237
|
-
if (renderedLines.length > 0) this.streamManager.render(renderedLines.join("\n\n"));
|
|
1238
|
-
}
|
|
1239
|
-
register(key, options) {
|
|
1240
|
-
const progressBar
|
|
1241
|
-
if (progressBar
|
|
1242
|
-
const newProgressBar = new ProgressBar(options);
|
|
1243
|
-
this.progressBars.set(key, newProgressBar);
|
|
1244
|
-
return newProgressBar;
|
|
1245
|
-
}
|
|
1246
|
-
return progressBar
|
|
1247
|
-
}
|
|
1248
|
-
start() {
|
|
1249
|
-
console.log();
|
|
1250
|
-
this.streamManager.listen();
|
|
1251
|
-
this._render();
|
|
879
|
+
streamManager = new StreamManager();
|
|
880
|
+
progressBars = /* @__PURE__ */ new Map();
|
|
881
|
+
throttledRender;
|
|
882
|
+
static getInstance() {
|
|
883
|
+
if (!ProgressBarRenderManager.instance) ProgressBarRenderManager.instance = new ProgressBarRenderManager();
|
|
884
|
+
return ProgressBarRenderManager.instance;
|
|
885
|
+
}
|
|
886
|
+
constructor() {
|
|
887
|
+
this.throttledRender = (0, es_toolkit.throttle)(this._render.bind(this), 50);
|
|
888
|
+
}
|
|
889
|
+
_render() {
|
|
890
|
+
const renderedLines = Array.from(this.progressBars.values().filter((progressBar) => progressBar.stale).map((progressBar) => progressBar.render()));
|
|
891
|
+
if (renderedLines.length > 0) this.streamManager.render(renderedLines.join("\n\n"));
|
|
892
|
+
}
|
|
893
|
+
register(key, options) {
|
|
894
|
+
const progressBar = this.progressBars.get(key);
|
|
895
|
+
if (progressBar == null) {
|
|
896
|
+
const newProgressBar = new ProgressBar(options);
|
|
897
|
+
this.progressBars.set(key, newProgressBar);
|
|
898
|
+
return newProgressBar;
|
|
899
|
+
}
|
|
900
|
+
return progressBar;
|
|
901
|
+
}
|
|
902
|
+
start() {
|
|
903
|
+
console.log();
|
|
904
|
+
this.streamManager.listen();
|
|
905
|
+
this._render();
|
|
906
|
+
}
|
|
907
|
+
render() {
|
|
908
|
+
this.throttledRender();
|
|
909
|
+
}
|
|
910
|
+
release() {
|
|
911
|
+
if (this.progressBars.values().every((progressBar) => progressBar.done)) {
|
|
912
|
+
this._render();
|
|
913
|
+
this.streamManager.done();
|
|
914
|
+
console.log();
|
|
915
|
+
}
|
|
916
|
+
}
|
|
917
|
+
clear() {
|
|
918
|
+
this.streamManager.clear();
|
|
919
|
+
}
|
|
920
|
+
};
|
|
921
|
+
|
|
922
|
+
//#endregion
|
|
923
|
+
//#region src/logger.ts
|
|
924
|
+
const logger$1 = new Logger("bundler");
|
|
925
|
+
|
|
926
|
+
//#endregion
|
|
927
|
+
//#region src/utils/reporters.ts
|
|
928
|
+
function mergeReporters(reporters) {
|
|
929
|
+
return { update(event) {
|
|
930
|
+
reporters.forEach((reporter) => reporter.update(event));
|
|
931
|
+
} };
|
|
932
|
+
}
|
|
933
|
+
var ClientLogReporter = class {
|
|
934
|
+
logger = new Logger("app");
|
|
935
|
+
update(event) {
|
|
936
|
+
if (event.type === "client_log") {
|
|
937
|
+
if (event.level === "group" || event.level === "groupCollapsed") {
|
|
938
|
+
this.logger.info(...event.data);
|
|
939
|
+
return;
|
|
940
|
+
} else if (event.level === "groupEnd") return;
|
|
941
|
+
this.logger[event.level](...event.data);
|
|
942
|
+
}
|
|
943
|
+
}
|
|
944
|
+
};
|
|
945
|
+
var ProgressFlags = /* @__PURE__ */ function(ProgressFlags) {
|
|
946
|
+
ProgressFlags[ProgressFlags["NONE"] = 0] = "NONE";
|
|
947
|
+
ProgressFlags[ProgressFlags["BUILD_IN_PROGRESS"] = 1] = "BUILD_IN_PROGRESS";
|
|
948
|
+
ProgressFlags[ProgressFlags["FILE_CHANGED"] = 2] = "FILE_CHANGED";
|
|
949
|
+
return ProgressFlags;
|
|
950
|
+
}(ProgressFlags || {});
|
|
951
|
+
var ProgressBarStatusReporter = class {
|
|
952
|
+
renderManager = ProgressBarRenderManager.getInstance();
|
|
953
|
+
progressBar;
|
|
954
|
+
flags = ProgressFlags.NONE;
|
|
955
|
+
constructor(id, label, initialTotalModules) {
|
|
956
|
+
this.progressBar = this.renderManager.register(id, {
|
|
957
|
+
label,
|
|
958
|
+
total: initialTotalModules
|
|
959
|
+
});
|
|
960
|
+
}
|
|
961
|
+
renderProgress(id, totalModules, transformedModules) {
|
|
962
|
+
if (totalModules != null) this.progressBar.setTotal(totalModules);
|
|
963
|
+
this.progressBar.setCurrent(transformedModules).setModuleId(id);
|
|
964
|
+
this.renderManager.render();
|
|
965
|
+
}
|
|
966
|
+
update(event) {
|
|
967
|
+
switch (event.type) {
|
|
968
|
+
case "bundle_build_started":
|
|
969
|
+
this.flags |= ProgressFlags.BUILD_IN_PROGRESS;
|
|
970
|
+
this.progressBar.start();
|
|
971
|
+
this.renderManager.start();
|
|
972
|
+
break;
|
|
973
|
+
case "bundle_build_failed":
|
|
974
|
+
this.flags = ProgressFlags.NONE;
|
|
975
|
+
this.progressBar.complete(0, true);
|
|
976
|
+
this.renderManager.release();
|
|
977
|
+
break;
|
|
978
|
+
case "bundle_build_done":
|
|
979
|
+
this.flags = ProgressFlags.NONE;
|
|
980
|
+
this.progressBar.setTotal(event.totalModules).complete(event.duration, false);
|
|
981
|
+
this.renderManager.release();
|
|
982
|
+
break;
|
|
983
|
+
case "transform":
|
|
984
|
+
const { id, totalModules, transformedModules } = event;
|
|
985
|
+
if (this.flags & ProgressFlags.FILE_CHANGED) {
|
|
986
|
+
logger$1.debug("Transformed changed file", { id });
|
|
987
|
+
return;
|
|
988
|
+
}
|
|
989
|
+
this.renderProgress(id, totalModules, transformedModules);
|
|
990
|
+
break;
|
|
991
|
+
case "watch_change":
|
|
992
|
+
this.flags |= ProgressFlags.FILE_CHANGED;
|
|
993
|
+
break;
|
|
994
|
+
}
|
|
995
|
+
}
|
|
996
|
+
};
|
|
997
|
+
var CompatStatusReporter = class {
|
|
998
|
+
update(event) {
|
|
999
|
+
switch (event.type) {
|
|
1000
|
+
case "bundle_build_started":
|
|
1001
|
+
logger$1.info("Build started...");
|
|
1002
|
+
break;
|
|
1003
|
+
case "bundle_build_failed":
|
|
1004
|
+
logger$1.error(`Build failed`);
|
|
1005
|
+
break;
|
|
1006
|
+
case "bundle_build_done":
|
|
1007
|
+
const { duration, totalModules } = event;
|
|
1008
|
+
const time = chalk.default.blue(`${duration.toFixed(2)}ms`);
|
|
1009
|
+
const modules = chalk.default.blue(`(${totalModules} modules)`);
|
|
1010
|
+
logger$1.info(`Build completed in ${time} ${modules}`);
|
|
1011
|
+
break;
|
|
1012
|
+
}
|
|
1013
|
+
}
|
|
1014
|
+
};
|
|
1015
|
+
|
|
1016
|
+
//#endregion
|
|
1017
|
+
//#region src/config/defaults.ts
|
|
1018
|
+
function getDefaultConfig(projectRoot, mode) {
|
|
1019
|
+
let reactNativePath;
|
|
1020
|
+
try {
|
|
1021
|
+
reactNativePath = process.env.ROLLIPOP_REACT_NATIVE_PATH ?? resolvePackagePath(projectRoot, "react-native");
|
|
1022
|
+
} catch {
|
|
1023
|
+
throw new Error(`Could not resolve 'react-native' package path. Please check your project path.`);
|
|
1024
|
+
}
|
|
1025
|
+
return {
|
|
1026
|
+
root: projectRoot,
|
|
1027
|
+
mode: mode ?? "development",
|
|
1028
|
+
entry: "index.js",
|
|
1029
|
+
resolver: {
|
|
1030
|
+
sourceExtensions: DEFAULT_SOURCE_EXTENSIONS,
|
|
1031
|
+
assetExtensions: DEFAULT_ASSET_EXTENSIONS,
|
|
1032
|
+
mainFields: DEFAULT_RESOLVER_MAIN_FIELDS,
|
|
1033
|
+
conditionNames: DEFAULT_RESOLVER_CONDITION_NAMES,
|
|
1034
|
+
preferNativePlatform: true,
|
|
1035
|
+
symlinks: true
|
|
1036
|
+
},
|
|
1037
|
+
transformer: {
|
|
1038
|
+
svg: true,
|
|
1039
|
+
flow: { filter: {
|
|
1040
|
+
id: /\.jsx?$/,
|
|
1041
|
+
code: /@flow/
|
|
1042
|
+
} }
|
|
1043
|
+
},
|
|
1044
|
+
serializer: {
|
|
1045
|
+
prelude: [getInitializeCorePath(projectRoot)],
|
|
1046
|
+
polyfills: getPolyfillScriptPaths(reactNativePath).map((path) => ({
|
|
1047
|
+
type: "iife",
|
|
1048
|
+
code: generateSourceFromAst(stripFlowSyntax(node_fs.default.readFileSync(path, "utf-8")), path).code
|
|
1049
|
+
}))
|
|
1050
|
+
},
|
|
1051
|
+
watcher: {
|
|
1052
|
+
skipWrite: true,
|
|
1053
|
+
useDebounce: true,
|
|
1054
|
+
debounceDuration: 50
|
|
1055
|
+
},
|
|
1056
|
+
optimization: { treeshake: true },
|
|
1057
|
+
reactNative: {
|
|
1058
|
+
reactNativePath,
|
|
1059
|
+
codegen: { filter: { code: /\bcodegenNativeComponent</ } },
|
|
1060
|
+
assetRegistryPath: DEFAULT_ASSET_REGISTRY_PATH,
|
|
1061
|
+
globalIdentifiers: DEFAULT_REACT_NATIVE_GLOBAL_IDENTIFIERS
|
|
1062
|
+
},
|
|
1063
|
+
devMode: { hmr: true },
|
|
1064
|
+
reporter: new ClientLogReporter(),
|
|
1065
|
+
terminal: { status: (() => {
|
|
1066
|
+
if (isDebugEnabled()) return "compat";
|
|
1067
|
+
if (process.stderr.isTTY) return "progress";
|
|
1068
|
+
return "compat";
|
|
1069
|
+
})() },
|
|
1070
|
+
envDir: projectRoot,
|
|
1071
|
+
envPrefix: DEFAULT_ENV_PREFIX
|
|
1072
|
+
};
|
|
1073
|
+
}
|
|
1074
|
+
|
|
1075
|
+
//#endregion
|
|
1076
|
+
//#region src/core/plugins/context.ts
|
|
1077
|
+
const pluginLogger = new Logger();
|
|
1078
|
+
function createPluginContext(name) {
|
|
1079
|
+
return {
|
|
1080
|
+
debug: (log) => {
|
|
1081
|
+
printPluginLog("debug", log, name);
|
|
1082
|
+
},
|
|
1083
|
+
info: (log) => {
|
|
1084
|
+
printPluginLog("info", log, name);
|
|
1085
|
+
},
|
|
1086
|
+
warn: (log) => {
|
|
1087
|
+
printPluginLog("warn", log, name);
|
|
1088
|
+
}
|
|
1089
|
+
};
|
|
1090
|
+
}
|
|
1091
|
+
function printPluginLog(level, log, pluginName = "unknown") {
|
|
1092
|
+
const pluginLabel = chalk.default.magenta(`plugin:${pluginName}`);
|
|
1093
|
+
if (typeof log === "string") pluginLogger[level](pluginLabel, log);
|
|
1094
|
+
else pluginLogger[level](pluginLabel, log.stack ?? log.message);
|
|
1095
|
+
}
|
|
1096
|
+
|
|
1097
|
+
//#endregion
|
|
1098
|
+
//#region src/config/merge-config.ts
|
|
1099
|
+
function mergeConfig(baseConfig, ...overrideConfigs) {
|
|
1100
|
+
let mergedConfig = baseConfig;
|
|
1101
|
+
for (const overrideConfig of overrideConfigs) mergedConfig = (0, es_toolkit.mergeWith)(mergedConfig, overrideConfig, (target, source, key) => {
|
|
1102
|
+
if ([
|
|
1103
|
+
"sourceExtensions",
|
|
1104
|
+
"assetExtensions",
|
|
1105
|
+
"polyfills",
|
|
1106
|
+
"prelude",
|
|
1107
|
+
"plugins"
|
|
1108
|
+
].includes(key)) return Array.from(new Set([...target ?? [], ...source ?? []]));
|
|
1109
|
+
if (key === "reporter") return source ?? target;
|
|
1110
|
+
});
|
|
1111
|
+
return mergedConfig;
|
|
1112
|
+
}
|
|
1113
|
+
|
|
1114
|
+
//#endregion
|
|
1115
|
+
//#region src/config/load-config.ts
|
|
1116
|
+
const CONFIG_FILE_NAME = "rollipop";
|
|
1117
|
+
async function loadConfig(options = {}) {
|
|
1118
|
+
const { cwd = process.cwd(), configFile, mode, context = {} } = options;
|
|
1119
|
+
const defaultConfig = getDefaultConfig(cwd, mode);
|
|
1120
|
+
const commonOptions = {
|
|
1121
|
+
context: {
|
|
1122
|
+
...context,
|
|
1123
|
+
defaultConfig
|
|
1124
|
+
},
|
|
1125
|
+
rcFile: false
|
|
1126
|
+
};
|
|
1127
|
+
const { config: userConfig } = await c12.loadConfig(configFile ? {
|
|
1128
|
+
configFile: node_path.default.resolve(cwd, configFile),
|
|
1129
|
+
configFileRequired: true
|
|
1130
|
+
} : {
|
|
1131
|
+
cwd,
|
|
1132
|
+
defaultConfig,
|
|
1133
|
+
name: CONFIG_FILE_NAME,
|
|
1134
|
+
...commonOptions
|
|
1135
|
+
});
|
|
1136
|
+
const plugins = await flattenPluginOption(userConfig.plugins);
|
|
1137
|
+
const pluginConfig = await resolvePluginConfig(userConfig, plugins);
|
|
1138
|
+
const resolvedConfig = mergeConfig(defaultConfig, ...[{
|
|
1139
|
+
...userConfig,
|
|
1140
|
+
plugins
|
|
1141
|
+
}, pluginConfig]);
|
|
1142
|
+
await invokeConfigResolved(resolvedConfig, plugins);
|
|
1143
|
+
return resolvedConfig;
|
|
1144
|
+
}
|
|
1145
|
+
async function flattenPluginOption(pluginOption) {
|
|
1146
|
+
const awaitedPluginOption = await pluginOption;
|
|
1147
|
+
if (Array.isArray(awaitedPluginOption)) return (await Promise.all(awaitedPluginOption.map(flattenPluginOption))).flat();
|
|
1148
|
+
if (awaitedPluginOption == null || awaitedPluginOption === false) return [];
|
|
1149
|
+
return [awaitedPluginOption];
|
|
1150
|
+
}
|
|
1151
|
+
async function resolvePluginConfig(baseConfig, plugins) {
|
|
1152
|
+
let mergedConfig = (0, es_toolkit.omit)(baseConfig, ["plugins", "dangerously_overrideRolldownOptions"]);
|
|
1153
|
+
for (const plugin of plugins) {
|
|
1154
|
+
const context = createPluginContext(plugin.name);
|
|
1155
|
+
if (typeof plugin.config === "function") {
|
|
1156
|
+
const config = await plugin.config.call(context, mergedConfig);
|
|
1157
|
+
if (config != null) mergedConfig = mergeConfig(mergedConfig, config);
|
|
1158
|
+
} else if (typeof plugin.config === "object") mergedConfig = mergeConfig(mergedConfig, plugin.config);
|
|
1159
|
+
}
|
|
1160
|
+
return mergedConfig;
|
|
1161
|
+
}
|
|
1162
|
+
async function invokeConfigResolved(config, plugins) {
|
|
1163
|
+
await Promise.all(plugins.map((plugin) => {
|
|
1164
|
+
const context = createPluginContext(plugin.name);
|
|
1165
|
+
return plugin.configResolved?.call(context, config);
|
|
1166
|
+
}));
|
|
1167
|
+
}
|
|
1168
|
+
|
|
1169
|
+
//#endregion
|
|
1170
|
+
//#region src/core/cache/file-system-cache.ts
|
|
1171
|
+
var FileSystemCache = class FileSystemCache {
|
|
1172
|
+
pendingData = /* @__PURE__ */ new Map();
|
|
1173
|
+
cacheDirectory;
|
|
1174
|
+
static getCacheDirectory(projectRoot) {
|
|
1175
|
+
return node_path.default.join(getSharedDataPath(projectRoot), "cache");
|
|
1176
|
+
}
|
|
1177
|
+
static clearAll(projectRoot) {
|
|
1178
|
+
node_fs.default.rmSync(FileSystemCache.getCacheDirectory(projectRoot), {
|
|
1179
|
+
recursive: true,
|
|
1180
|
+
force: true
|
|
1181
|
+
});
|
|
1182
|
+
}
|
|
1183
|
+
constructor(projectRoot, id) {
|
|
1184
|
+
this.cacheDirectory = node_path.default.join(FileSystemCache.getCacheDirectory(projectRoot), id);
|
|
1185
|
+
this.ensureCacheDirectory(this.cacheDirectory);
|
|
1186
|
+
logger$1.debug("cache directory:", this.cacheDirectory);
|
|
1187
|
+
}
|
|
1188
|
+
ensureCacheDirectory(cacheDirectory) {
|
|
1189
|
+
if (!node_fs.default.existsSync(cacheDirectory)) node_fs.default.mkdirSync(cacheDirectory, { recursive: true });
|
|
1190
|
+
}
|
|
1191
|
+
get(key) {
|
|
1192
|
+
try {
|
|
1193
|
+
return node_fs.default.readFileSync(node_path.default.join(this.cacheDirectory, key), "utf-8");
|
|
1194
|
+
} catch {
|
|
1195
|
+
return;
|
|
1196
|
+
}
|
|
1197
|
+
}
|
|
1198
|
+
set(key, value) {
|
|
1199
|
+
this.pendingData.set(key, value);
|
|
1200
|
+
}
|
|
1201
|
+
async flush() {
|
|
1202
|
+
const limit = (0, p_limit.default)(process.env.ROLLIPOP_CACHE_FLUSH_LIMIT ? parseInt(process.env.ROLLIPOP_CACHE_FLUSH_LIMIT) : 20);
|
|
1203
|
+
const entries = Array.from(this.pendingData.entries());
|
|
1204
|
+
await Promise.all(entries.map(([key, value]) => limit(async () => {
|
|
1205
|
+
try {
|
|
1206
|
+
await node_fs.default.promises.writeFile(node_path.default.join(this.cacheDirectory, key), value);
|
|
1207
|
+
} catch (error) {
|
|
1208
|
+
logger$1.error("Failed to write cache file", key);
|
|
1209
|
+
logger$1.debug(error);
|
|
1210
|
+
}
|
|
1211
|
+
}))).catch((error) => {
|
|
1212
|
+
logger$1.error("Failed to flush cache", error);
|
|
1213
|
+
});
|
|
1214
|
+
this.pendingData.clear();
|
|
1215
|
+
}
|
|
1216
|
+
clear() {
|
|
1217
|
+
node_fs.default.rmSync(this.cacheDirectory, {
|
|
1218
|
+
recursive: true,
|
|
1219
|
+
force: true
|
|
1220
|
+
});
|
|
1221
|
+
this.ensureCacheDirectory(this.cacheDirectory);
|
|
1222
|
+
}
|
|
1223
|
+
};
|
|
1224
|
+
|
|
1225
|
+
//#endregion
|
|
1226
|
+
//#region src/utils/reset-cache.ts
|
|
1227
|
+
function resetCache(projectRoot) {
|
|
1228
|
+
FileSystemCache.clearAll(projectRoot);
|
|
1229
|
+
}
|
|
1230
|
+
|
|
1231
|
+
//#endregion
|
|
1232
|
+
//#region src/utils/build-options.ts
|
|
1233
|
+
const DEFAULT_BUILD_OPTIONS = {
|
|
1234
|
+
cache: true,
|
|
1235
|
+
minify: false
|
|
1236
|
+
};
|
|
1237
|
+
function resolveBuildOptions(config, buildOptions) {
|
|
1238
|
+
if (buildOptions.outfile) buildOptions.outfile = node_path.default.resolve(config.root, buildOptions.outfile);
|
|
1239
|
+
if ((buildOptions.sourcemap === true || buildOptions.sourcemap === "hidden") && buildOptions.sourcemapOutfile) buildOptions.sourcemapOutfile = node_path.default.resolve(config.root, buildOptions.sourcemapOutfile);
|
|
1240
|
+
return (0, es_toolkit.merge)(DEFAULT_BUILD_OPTIONS, {
|
|
1241
|
+
...buildOptions,
|
|
1242
|
+
dev: buildOptions.dev ?? config.mode === "development"
|
|
1243
|
+
});
|
|
1244
|
+
}
|
|
1245
|
+
|
|
1246
|
+
//#endregion
|
|
1247
|
+
//#region src/utils/hash.ts
|
|
1248
|
+
function xxhash(data) {
|
|
1249
|
+
return (0, _node_rs_xxhash.xxh32)(data).toString(16);
|
|
1250
|
+
}
|
|
1251
|
+
function md5(data) {
|
|
1252
|
+
return node_crypto.default.createHash("md5").update(data).digest("hex");
|
|
1253
|
+
}
|
|
1254
|
+
|
|
1255
|
+
//#endregion
|
|
1256
|
+
//#region src/utils/serialize.ts
|
|
1257
|
+
function serialize(value) {
|
|
1258
|
+
return JSON.stringify(value, (_, value) => {
|
|
1259
|
+
if (typeof value === "function") return value.toString();
|
|
1260
|
+
if (value instanceof RegExp) return value.toString();
|
|
1261
|
+
return value;
|
|
1262
|
+
});
|
|
1263
|
+
}
|
|
1264
|
+
|
|
1265
|
+
//#endregion
|
|
1266
|
+
//#region src/utils/id.ts
|
|
1267
|
+
function createId(config, buildOptions) {
|
|
1268
|
+
return md5(serialize([
|
|
1269
|
+
ROLLIPOP_VERSION,
|
|
1270
|
+
filterTransformAffectedOptions(buildOptions),
|
|
1271
|
+
filterTransformAffectedConfig(config)
|
|
1272
|
+
]));
|
|
1273
|
+
}
|
|
1274
|
+
function filterTransformAffectedOptions(buildOptions) {
|
|
1275
|
+
return (0, es_toolkit.pick)(buildOptions, ["platform", "dev"]);
|
|
1276
|
+
}
|
|
1277
|
+
function filterTransformAffectedConfig(config) {
|
|
1278
|
+
const { transformer, serializer, reactNative, devMode, plugins = [] } = config;
|
|
1279
|
+
return [
|
|
1280
|
+
transformer,
|
|
1281
|
+
serializer.polyfills,
|
|
1282
|
+
serializer.prelude,
|
|
1283
|
+
reactNative.assetRegistryPath,
|
|
1284
|
+
devMode,
|
|
1285
|
+
plugins.map((plugin, index) => `${plugin.name}#${index}`)
|
|
1286
|
+
];
|
|
1287
|
+
}
|
|
1288
|
+
|
|
1289
|
+
//#endregion
|
|
1290
|
+
//#region src/core/fs/storage.ts
|
|
1291
|
+
const DEFAULT_DATA = { build: {} };
|
|
1292
|
+
var FileStorage = class FileStorage {
|
|
1293
|
+
static instance = null;
|
|
1294
|
+
dataFilePath;
|
|
1295
|
+
data;
|
|
1296
|
+
static getInstance(basePath) {
|
|
1297
|
+
if (FileStorage.instance == null) FileStorage.instance = new FileStorage(basePath);
|
|
1298
|
+
return new FileStorage(basePath);
|
|
1252
1299
|
}
|
|
1253
|
-
|
|
1254
|
-
this.
|
|
1300
|
+
constructor(basePath) {
|
|
1301
|
+
this.basePath = basePath;
|
|
1302
|
+
this.dataFilePath = node_path.default.join(getSharedDataPath(basePath), "rollipop.json");
|
|
1303
|
+
if (node_fs.default.existsSync(this.dataFilePath)) this.data = JSON.parse(node_fs.default.readFileSync(this.dataFilePath, "utf-8"));
|
|
1304
|
+
else this.data = DEFAULT_DATA;
|
|
1255
1305
|
}
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
this._render();
|
|
1259
|
-
this.streamManager.done();
|
|
1260
|
-
console.log();
|
|
1261
|
-
}
|
|
1306
|
+
get() {
|
|
1307
|
+
return this.data;
|
|
1262
1308
|
}
|
|
1263
|
-
|
|
1264
|
-
this.
|
|
1309
|
+
set(data) {
|
|
1310
|
+
this.data = (0, es_toolkit.merge)(this.data, data);
|
|
1311
|
+
node_fs.default.writeFileSync(this.dataFilePath, JSON.stringify(this.data, null, 2));
|
|
1265
1312
|
}
|
|
1266
1313
|
};
|
|
1267
1314
|
|
|
1268
1315
|
//#endregion
|
|
1269
|
-
//#region src/
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
ProgressFlags$1[ProgressFlags$1["BUILD_IN_PROGRESS"] = 1] = "BUILD_IN_PROGRESS";
|
|
1273
|
-
ProgressFlags$1[ProgressFlags$1["FILE_CHANGED"] = 2] = "FILE_CHANGED";
|
|
1274
|
-
return ProgressFlags$1;
|
|
1275
|
-
}(ProgressFlags || {});
|
|
1276
|
-
function none(reporter) {
|
|
1277
|
-
return withReporter(reporter);
|
|
1316
|
+
//#region src/utils/string.ts
|
|
1317
|
+
function indent(text, indent, space = " ") {
|
|
1318
|
+
return text.replace(/^/gm, space.repeat(indent));
|
|
1278
1319
|
}
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
onEnd({ totalModules, duration, error }) {
|
|
1285
|
-
const time = chalk.default.blue(`${duration.toFixed(2)}ms`);
|
|
1286
|
-
const modules = chalk.default.blue(`(${totalModules} modules)`);
|
|
1287
|
-
if (error) logger$1.error(`Build failed in ${time} ${modules}`);
|
|
1288
|
-
else logger$1.info(`Build completed in ${time} ${modules}`);
|
|
1289
|
-
}
|
|
1290
|
-
});
|
|
1320
|
+
|
|
1321
|
+
//#endregion
|
|
1322
|
+
//#region src/common/code.ts
|
|
1323
|
+
function asLiteral(value) {
|
|
1324
|
+
return JSON.stringify(value);
|
|
1291
1325
|
}
|
|
1292
|
-
function
|
|
1293
|
-
|
|
1294
|
-
const initialTotalModules = getBuildTotalModules(context.storage, context.id);
|
|
1295
|
-
const renderManager = ProgressBarRenderManager.getInstance();
|
|
1296
|
-
const progressBar$1 = renderManager.register(context.id, {
|
|
1297
|
-
label,
|
|
1298
|
-
total: initialTotalModules
|
|
1299
|
-
});
|
|
1300
|
-
const renderProgress = (id$3, totalModules, transformedModules) => {
|
|
1301
|
-
if (totalModules != null) progressBar$1.setTotal(totalModules);
|
|
1302
|
-
progressBar$1.setCurrent(transformedModules).setModuleId(id$3);
|
|
1303
|
-
renderManager.render();
|
|
1304
|
-
};
|
|
1305
|
-
return withReporter(reporter, {
|
|
1306
|
-
initialTotalModules,
|
|
1307
|
-
onStart() {
|
|
1308
|
-
flags |= ProgressFlags.BUILD_IN_PROGRESS;
|
|
1309
|
-
progressBar$1.start();
|
|
1310
|
-
renderManager.start();
|
|
1311
|
-
},
|
|
1312
|
-
onEnd({ error, duration, totalModules }) {
|
|
1313
|
-
flags = ProgressFlags.NONE;
|
|
1314
|
-
progressBar$1.setTotal(totalModules).complete(duration, Boolean(error));
|
|
1315
|
-
renderManager.release();
|
|
1316
|
-
setBuildTotalModules(context.storage, context.id, totalModules);
|
|
1317
|
-
},
|
|
1318
|
-
onTransform({ id: id$3, totalModules, transformedModules }) {
|
|
1319
|
-
if (flags & ProgressFlags.FILE_CHANGED) {
|
|
1320
|
-
logger$1.debug("Transformed changed file", { id: id$3 });
|
|
1321
|
-
return;
|
|
1322
|
-
}
|
|
1323
|
-
renderProgress(id$3, totalModules, transformedModules);
|
|
1324
|
-
},
|
|
1325
|
-
onWatchChange() {
|
|
1326
|
-
flags |= ProgressFlags.FILE_CHANGED;
|
|
1327
|
-
}
|
|
1328
|
-
});
|
|
1326
|
+
function asIdentifier(name) {
|
|
1327
|
+
return name;
|
|
1329
1328
|
}
|
|
1330
|
-
function
|
|
1331
|
-
return
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
});
|
|
1342
|
-
else reporter.update({ type: "bundle_build_done" });
|
|
1343
|
-
statusPluginOptions?.onEnd?.(result);
|
|
1344
|
-
},
|
|
1345
|
-
onTransform(result) {
|
|
1346
|
-
reporter.update({
|
|
1347
|
-
type: "transform",
|
|
1348
|
-
...result
|
|
1349
|
-
});
|
|
1350
|
-
statusPluginOptions?.onTransform?.(result);
|
|
1351
|
-
},
|
|
1352
|
-
onWatchChange(id$3) {
|
|
1353
|
-
reporter.update({
|
|
1354
|
-
type: "watch_change",
|
|
1355
|
-
id: id$3
|
|
1356
|
-
});
|
|
1357
|
-
statusPluginOptions?.onWatchChange?.(id$3);
|
|
1358
|
-
}
|
|
1359
|
-
};
|
|
1329
|
+
function nodeEnvironment(dev) {
|
|
1330
|
+
return dev ? "development" : "production";
|
|
1331
|
+
}
|
|
1332
|
+
function iife(body, path = "<unknown>") {
|
|
1333
|
+
const bodyPlaceholder = "__BODY__";
|
|
1334
|
+
return dedent.default`
|
|
1335
|
+
// ${path}
|
|
1336
|
+
(function (global) {
|
|
1337
|
+
${bodyPlaceholder}
|
|
1338
|
+
})(${GLOBAL_IDENTIFIER});
|
|
1339
|
+
`.replace(bodyPlaceholder, indent(body, 1));
|
|
1360
1340
|
}
|
|
1361
|
-
const statusPresets = {
|
|
1362
|
-
none,
|
|
1363
|
-
compat,
|
|
1364
|
-
progressBar
|
|
1365
|
-
};
|
|
1366
1341
|
|
|
1367
1342
|
//#endregion
|
|
1368
1343
|
//#region src/utils/config.ts
|
|
@@ -1386,7 +1361,7 @@ function bindReporter(config, eventSource) {
|
|
|
1386
1361
|
eventSource.emit("watchChange", event.id);
|
|
1387
1362
|
break;
|
|
1388
1363
|
}
|
|
1389
|
-
originalReporter
|
|
1364
|
+
originalReporter?.update(event);
|
|
1390
1365
|
} };
|
|
1391
1366
|
return config;
|
|
1392
1367
|
}
|
|
@@ -1421,6 +1396,12 @@ function getBaseUrl(host, port, https) {
|
|
|
1421
1396
|
return `${https ? "https" : "http"}://${host}:${port}`;
|
|
1422
1397
|
}
|
|
1423
1398
|
|
|
1399
|
+
//#endregion
|
|
1400
|
+
//#region src/utils/storage.ts
|
|
1401
|
+
function getBuildTotalModules(storage, id) {
|
|
1402
|
+
return storage.get().build[id]?.totalModules ?? 0;
|
|
1403
|
+
}
|
|
1404
|
+
|
|
1424
1405
|
//#endregion
|
|
1425
1406
|
//#region src/core/env.ts
|
|
1426
1407
|
function loadEnv(options) {
|
|
@@ -1450,30 +1431,6 @@ function loadEnv(options) {
|
|
|
1450
1431
|
return env;
|
|
1451
1432
|
}
|
|
1452
1433
|
|
|
1453
|
-
//#endregion
|
|
1454
|
-
//#region node_modules/mitt/dist/mitt.mjs
|
|
1455
|
-
function mitt_default(n) {
|
|
1456
|
-
return {
|
|
1457
|
-
all: n = n || /* @__PURE__ */ new Map(),
|
|
1458
|
-
on: function(t, e) {
|
|
1459
|
-
var i = n.get(t);
|
|
1460
|
-
i ? i.push(e) : n.set(t, [e]);
|
|
1461
|
-
},
|
|
1462
|
-
off: function(t, e) {
|
|
1463
|
-
var i = n.get(t);
|
|
1464
|
-
i && (e ? i.splice(i.indexOf(e) >>> 0, 1) : n.set(t, []));
|
|
1465
|
-
},
|
|
1466
|
-
emit: function(t, e) {
|
|
1467
|
-
var i = n.get(t);
|
|
1468
|
-
i && i.slice().map(function(n$1) {
|
|
1469
|
-
n$1(e);
|
|
1470
|
-
}), (i = n.get("*")) && i.slice().map(function(n$1) {
|
|
1471
|
-
n$1(t, e);
|
|
1472
|
-
});
|
|
1473
|
-
}
|
|
1474
|
-
};
|
|
1475
|
-
}
|
|
1476
|
-
|
|
1477
1434
|
//#endregion
|
|
1478
1435
|
//#region src/server/logger.ts
|
|
1479
1436
|
const logger = new Logger("dev-server");
|
|
@@ -1523,12 +1480,12 @@ async function assertDevServerStatus(options) {
|
|
|
1523
1480
|
}
|
|
1524
1481
|
if (shouldExit) process.exit(1);
|
|
1525
1482
|
}
|
|
1526
|
-
var DevServerStatus = /* @__PURE__ */ function(DevServerStatus
|
|
1527
|
-
DevServerStatus
|
|
1528
|
-
DevServerStatus
|
|
1529
|
-
DevServerStatus
|
|
1530
|
-
DevServerStatus
|
|
1531
|
-
return DevServerStatus
|
|
1483
|
+
var DevServerStatus = /* @__PURE__ */ function(DevServerStatus) {
|
|
1484
|
+
DevServerStatus[DevServerStatus["NOT_RUNNING"] = 0] = "NOT_RUNNING";
|
|
1485
|
+
DevServerStatus[DevServerStatus["MATCHED_SERVER_RUNNING"] = 1] = "MATCHED_SERVER_RUNNING";
|
|
1486
|
+
DevServerStatus[DevServerStatus["PORT_TAKEN"] = 2] = "PORT_TAKEN";
|
|
1487
|
+
DevServerStatus[DevServerStatus["UNKNOWN"] = 3] = "UNKNOWN";
|
|
1488
|
+
return DevServerStatus;
|
|
1532
1489
|
}(DevServerStatus || {});
|
|
1533
1490
|
async function getDevServerStatus(devServerUrl, projectRoot) {
|
|
1534
1491
|
const { hostname, port } = new URL(devServerUrl);
|
|
@@ -1659,9 +1616,9 @@ var BundlerDevEngine = class extends node_events.default {
|
|
|
1659
1616
|
}
|
|
1660
1617
|
get sourceMappingURL() {
|
|
1661
1618
|
const { host, port } = this.options.server;
|
|
1662
|
-
const { platform, dev
|
|
1619
|
+
const { platform, dev } = this.buildOptions;
|
|
1663
1620
|
const [name] = this.config.entry.split(".");
|
|
1664
|
-
return `http://${host}:${port}/${name}.bundle.map?platform=${platform}&dev=${dev
|
|
1621
|
+
return `http://${host}:${port}/${name}.bundle.map?platform=${platform}&dev=${dev}`;
|
|
1665
1622
|
}
|
|
1666
1623
|
async initialize() {
|
|
1667
1624
|
if (this._state !== "idle" || this._devEngine != null) return this;
|
|
@@ -1742,10 +1699,10 @@ var BundlerPool = class BundlerPool {
|
|
|
1742
1699
|
bundleName,
|
|
1743
1700
|
key
|
|
1744
1701
|
});
|
|
1745
|
-
const instance
|
|
1702
|
+
const instance = new BundlerDevEngine({ server: this.resolvedServerOptions }, this.config, buildOptions);
|
|
1746
1703
|
logger.debug("Setting new bundler instance", { key });
|
|
1747
|
-
BundlerPool.instances.set(key, instance
|
|
1748
|
-
return instance
|
|
1704
|
+
BundlerPool.instances.set(key, instance);
|
|
1705
|
+
return instance;
|
|
1749
1706
|
}
|
|
1750
1707
|
}
|
|
1751
1708
|
};
|
|
@@ -1786,18 +1743,18 @@ const queryParamSchema = (0, json_schema_to_ts.asConst)({
|
|
|
1786
1743
|
},
|
|
1787
1744
|
required: ["platform"]
|
|
1788
1745
|
});
|
|
1789
|
-
const plugin$2 = (0, fastify_plugin.default)((fastify
|
|
1746
|
+
const plugin$2 = (0, fastify_plugin.default)((fastify, options) => {
|
|
1790
1747
|
const { projectRoot, host, port, https, preferNativePlatform } = options;
|
|
1791
1748
|
const baseUrl = https ? `https://${host}:${port}` : `http://${host}:${port}`;
|
|
1792
1749
|
function resolveAsset(asset) {
|
|
1793
1750
|
return node_path.default.resolve(projectRoot, asset);
|
|
1794
1751
|
}
|
|
1795
|
-
fastify
|
|
1752
|
+
fastify.get(`/${DEV_SERVER_ASSET_PATH}/*`, {
|
|
1796
1753
|
schema: { querystring: queryParamSchema },
|
|
1797
1754
|
async handler(request, reply) {
|
|
1798
|
-
const { url
|
|
1799
|
-
const { pathname } = new URL(url
|
|
1800
|
-
const assetPath = resolveAsset(pathname.replace(
|
|
1755
|
+
const { url, query } = request;
|
|
1756
|
+
const { pathname } = new URL(url, baseUrl);
|
|
1757
|
+
const assetPath = resolveAsset(pathname.replace(new RegExp(`^/${DEV_SERVER_ASSET_PATH}/?`), ""));
|
|
1801
1758
|
let handle = null;
|
|
1802
1759
|
try {
|
|
1803
1760
|
handle = await node_fs.default.promises.open(resolveAssetPath(assetPath, {
|
|
@@ -1808,7 +1765,7 @@ const plugin$2 = (0, fastify_plugin.default)((fastify$1, options) => {
|
|
|
1808
1765
|
const { size } = await handle.stat();
|
|
1809
1766
|
await reply.header("Content-Type", mime.default.getType(assetPath) ?? "").header("Content-Length", size).send(assetData);
|
|
1810
1767
|
} catch (error) {
|
|
1811
|
-
fastify
|
|
1768
|
+
fastify.log.error(error, "Failed to serve asset (scale assets resolving is not implemented yet)");
|
|
1812
1769
|
await reply.status(500).send();
|
|
1813
1770
|
} finally {
|
|
1814
1771
|
await handle?.close();
|
|
@@ -1935,7 +1892,7 @@ function withGetBundleErrorHandler(reply, task) {
|
|
|
1935
1892
|
return reply.status(500).send(error instanceof Error ? error.message : "Internal Server Error");
|
|
1936
1893
|
});
|
|
1937
1894
|
}
|
|
1938
|
-
const plugin$1 = (0, fastify_plugin.default)((fastify
|
|
1895
|
+
const plugin$1 = (0, fastify_plugin.default)((fastify, options) => {
|
|
1939
1896
|
const { getBundler } = options;
|
|
1940
1897
|
const getBundleOptions = (buildOptions) => {
|
|
1941
1898
|
return {
|
|
@@ -1945,7 +1902,7 @@ const plugin$1 = (0, fastify_plugin.default)((fastify$1, options) => {
|
|
|
1945
1902
|
sourcemap: buildOptions.inlineSourceMap ? "inline" : true
|
|
1946
1903
|
};
|
|
1947
1904
|
};
|
|
1948
|
-
fastify
|
|
1905
|
+
fastify.get("/:name.bundle", {
|
|
1949
1906
|
schema: {
|
|
1950
1907
|
params: routeParamSchema,
|
|
1951
1908
|
querystring: bundleRequestSchema
|
|
@@ -1972,7 +1929,7 @@ const plugin$1 = (0, fastify_plugin.default)((fastify$1, options) => {
|
|
|
1972
1929
|
}
|
|
1973
1930
|
}
|
|
1974
1931
|
});
|
|
1975
|
-
fastify
|
|
1932
|
+
fastify.get("/:name.map", {
|
|
1976
1933
|
schema: {
|
|
1977
1934
|
params: routeParamSchema,
|
|
1978
1935
|
querystring: bundleRequestSchema
|
|
@@ -1992,1394 +1949,30 @@ const plugin$1 = (0, fastify_plugin.default)((fastify$1, options) => {
|
|
|
1992
1949
|
}, { name: "serve-bundle" });
|
|
1993
1950
|
|
|
1994
1951
|
//#endregion
|
|
1995
|
-
//#region
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
let formatter = (open, close, replace = open) => (input) => {
|
|
2000
|
-
let string = "" + input, index = string.indexOf(close, open.length);
|
|
2001
|
-
return ~index ? open + replaceClose(string, close, replace, index) + close : open + string + close;
|
|
2002
|
-
};
|
|
2003
|
-
let replaceClose = (string, close, replace, index) => {
|
|
2004
|
-
let result = "", cursor = 0;
|
|
2005
|
-
do {
|
|
2006
|
-
result += string.substring(cursor, index) + replace;
|
|
2007
|
-
cursor = index + close.length;
|
|
2008
|
-
index = string.indexOf(close, cursor);
|
|
2009
|
-
} while (~index);
|
|
2010
|
-
return result + string.substring(cursor);
|
|
2011
|
-
};
|
|
2012
|
-
let createColors = (enabled = isColorSupported) => {
|
|
2013
|
-
let f = enabled ? formatter : () => String;
|
|
1952
|
+
//#region src/utils/url.ts
|
|
1953
|
+
function parseUrl(value) {
|
|
1954
|
+
if (value.startsWith("/")) {
|
|
1955
|
+
const [pathname, query] = value.split("?");
|
|
2014
1956
|
return {
|
|
2015
|
-
|
|
2016
|
-
|
|
2017
|
-
bold: f("\x1B[1m", "\x1B[22m", "\x1B[22m\x1B[1m"),
|
|
2018
|
-
dim: f("\x1B[2m", "\x1B[22m", "\x1B[22m\x1B[2m"),
|
|
2019
|
-
italic: f("\x1B[3m", "\x1B[23m"),
|
|
2020
|
-
underline: f("\x1B[4m", "\x1B[24m"),
|
|
2021
|
-
inverse: f("\x1B[7m", "\x1B[27m"),
|
|
2022
|
-
hidden: f("\x1B[8m", "\x1B[28m"),
|
|
2023
|
-
strikethrough: f("\x1B[9m", "\x1B[29m"),
|
|
2024
|
-
black: f("\x1B[30m", "\x1B[39m"),
|
|
2025
|
-
red: f("\x1B[31m", "\x1B[39m"),
|
|
2026
|
-
green: f("\x1B[32m", "\x1B[39m"),
|
|
2027
|
-
yellow: f("\x1B[33m", "\x1B[39m"),
|
|
2028
|
-
blue: f("\x1B[34m", "\x1B[39m"),
|
|
2029
|
-
magenta: f("\x1B[35m", "\x1B[39m"),
|
|
2030
|
-
cyan: f("\x1B[36m", "\x1B[39m"),
|
|
2031
|
-
white: f("\x1B[37m", "\x1B[39m"),
|
|
2032
|
-
gray: f("\x1B[90m", "\x1B[39m"),
|
|
2033
|
-
bgBlack: f("\x1B[40m", "\x1B[49m"),
|
|
2034
|
-
bgRed: f("\x1B[41m", "\x1B[49m"),
|
|
2035
|
-
bgGreen: f("\x1B[42m", "\x1B[49m"),
|
|
2036
|
-
bgYellow: f("\x1B[43m", "\x1B[49m"),
|
|
2037
|
-
bgBlue: f("\x1B[44m", "\x1B[49m"),
|
|
2038
|
-
bgMagenta: f("\x1B[45m", "\x1B[49m"),
|
|
2039
|
-
bgCyan: f("\x1B[46m", "\x1B[49m"),
|
|
2040
|
-
bgWhite: f("\x1B[47m", "\x1B[49m"),
|
|
2041
|
-
blackBright: f("\x1B[90m", "\x1B[39m"),
|
|
2042
|
-
redBright: f("\x1B[91m", "\x1B[39m"),
|
|
2043
|
-
greenBright: f("\x1B[92m", "\x1B[39m"),
|
|
2044
|
-
yellowBright: f("\x1B[93m", "\x1B[39m"),
|
|
2045
|
-
blueBright: f("\x1B[94m", "\x1B[39m"),
|
|
2046
|
-
magentaBright: f("\x1B[95m", "\x1B[39m"),
|
|
2047
|
-
cyanBright: f("\x1B[96m", "\x1B[39m"),
|
|
2048
|
-
whiteBright: f("\x1B[97m", "\x1B[39m"),
|
|
2049
|
-
bgBlackBright: f("\x1B[100m", "\x1B[49m"),
|
|
2050
|
-
bgRedBright: f("\x1B[101m", "\x1B[49m"),
|
|
2051
|
-
bgGreenBright: f("\x1B[102m", "\x1B[49m"),
|
|
2052
|
-
bgYellowBright: f("\x1B[103m", "\x1B[49m"),
|
|
2053
|
-
bgBlueBright: f("\x1B[104m", "\x1B[49m"),
|
|
2054
|
-
bgMagentaBright: f("\x1B[105m", "\x1B[49m"),
|
|
2055
|
-
bgCyanBright: f("\x1B[106m", "\x1B[49m"),
|
|
2056
|
-
bgWhiteBright: f("\x1B[107m", "\x1B[49m")
|
|
2057
|
-
};
|
|
2058
|
-
};
|
|
2059
|
-
module.exports = createColors();
|
|
2060
|
-
module.exports.createColors = createColors;
|
|
2061
|
-
}));
|
|
2062
|
-
|
|
2063
|
-
//#endregion
|
|
2064
|
-
//#region node_modules/js-tokens/index.js
|
|
2065
|
-
var require_js_tokens = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
2066
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2067
|
-
exports.default = /((['"])(?:(?!\2|\\).|\\(?:\r\n|[\s\S]))*(\2)?|`(?:[^`\\$]|\\[\s\S]|\$(?!\{)|\$\{(?:[^{}]|\{[^}]*\}?)*\}?)*(`)?)|(\/\/.*)|(\/\*(?:[^*]|\*(?!\/))*(\*\/)?)|(\/(?!\*)(?:\[(?:(?![\]\\]).|\\.)*\]|(?![\/\]\\]).|\\.)+\/(?:(?!\s*(?:\b|[\u0080-\uFFFF$\\'"~({]|[+\-!](?!=)|\.?\d))|[gmiyus]{1,6}\b(?![\u0080-\uFFFF$\\]|\s*(?:[+\-*%&|^<>!=?({]|\/(?![\/*])))))|(0[xX][\da-fA-F]+|0[oO][0-7]+|0[bB][01]+|(?:\d*\.\d+|\d+\.?)(?:[eE][+-]?\d+)?)|((?!\d)(?:(?!\s)[$\w\u0080-\uFFFF]|\\u[\da-fA-F]{4}|\\u\{[\da-fA-F]+\})+)|(--|\+\+|&&|\|\||=>|\.{3}|(?:[+\-\/%&|^]|\*{1,2}|<{1,2}|>{1,3}|!=?|={1,2})=?|[?~.,:;[\](){}])|(\s+)|(^$|[\s\S])/g;
|
|
2068
|
-
exports.matchToToken = function(match) {
|
|
2069
|
-
var token = {
|
|
2070
|
-
type: "invalid",
|
|
2071
|
-
value: match[0],
|
|
2072
|
-
closed: void 0
|
|
1957
|
+
pathname,
|
|
1958
|
+
query: query ? toQueryObject(new URLSearchParams(query)) : {}
|
|
2073
1959
|
};
|
|
2074
|
-
if (match[1]) token.type = "string", token.closed = !!(match[3] || match[4]);
|
|
2075
|
-
else if (match[5]) token.type = "comment";
|
|
2076
|
-
else if (match[6]) token.type = "comment", token.closed = !!match[7];
|
|
2077
|
-
else if (match[8]) token.type = "regex";
|
|
2078
|
-
else if (match[9]) token.type = "number";
|
|
2079
|
-
else if (match[10]) token.type = "name";
|
|
2080
|
-
else if (match[11]) token.type = "punctuator";
|
|
2081
|
-
else if (match[12]) token.type = "whitespace";
|
|
2082
|
-
return token;
|
|
2083
|
-
};
|
|
2084
|
-
}));
|
|
2085
|
-
|
|
2086
|
-
//#endregion
|
|
2087
|
-
//#region node_modules/@babel/helper-validator-identifier/lib/identifier.js
|
|
2088
|
-
var require_identifier = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
2089
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2090
|
-
exports.isIdentifierChar = isIdentifierChar;
|
|
2091
|
-
exports.isIdentifierName = isIdentifierName;
|
|
2092
|
-
exports.isIdentifierStart = isIdentifierStart;
|
|
2093
|
-
let nonASCIIidentifierStartChars = "ªµºÀ-ÖØ-öø-ˁˆ-ˑˠ-ˤˬˮͰ-ʹͶͷͺ-ͽͿΆΈ-ΊΌΎ-ΡΣ-ϵϷ-ҁҊ-ԯԱ-Ֆՙՠ-ֈא-תׯ-ײؠ-يٮٯٱ-ۓەۥۦۮۯۺ-ۼۿܐܒ-ܯݍ-ޥޱߊ-ߪߴߵߺࠀ-ࠕࠚࠤࠨࡀ-ࡘࡠ-ࡪࡰ-ࢇࢉ-ࢠ-ࣉऄ-हऽॐक़-ॡॱ-ঀঅ-ঌএঐও-নপ-রলশ-হঽৎড়ঢ়য়-ৡৰৱৼਅ-ਊਏਐਓ-ਨਪ-ਰਲਲ਼ਵਸ਼ਸਹਖ਼-ੜਫ਼ੲ-ੴઅ-ઍએ-ઑઓ-નપ-રલળવ-હઽૐૠૡૹଅ-ଌଏଐଓ-ନପ-ରଲଳଵ-ହଽଡ଼ଢ଼ୟ-ୡୱஃஅ-ஊஎ-ஐஒ-கஙசஜஞடணதந-பம-ஹௐఅ-ఌఎ-ఐఒ-నప-హఽౘ-ౚౝౠౡಀಅ-ಌಎ-ಐಒ-ನಪ-ಳವ-ಹಽ-ೞೠೡೱೲഄ-ഌഎ-ഐഒ-ഺഽൎൔ-ൖൟ-ൡൺ-ൿඅ-ඖක-නඳ-රලව-ෆก-ะาำเ-ๆກຂຄຆ-ຊຌ-ຣລວ-ະາຳຽເ-ໄໆໜ-ໟༀཀ-ཇཉ-ཬྈ-ྌက-ဪဿၐ-ၕၚ-ၝၡၥၦၮ-ၰၵ-ႁႎႠ-ჅჇჍა-ჺჼ-ቈቊ-ቍቐ-ቖቘቚ-ቝበ-ኈኊ-ኍነ-ኰኲ-ኵኸ-ኾዀዂ-ዅወ-ዖዘ-ጐጒ-ጕጘ-ፚᎀ-ᎏᎠ-Ᏽᏸ-ᏽᐁ-ᙬᙯ-ᙿᚁ-ᚚᚠ-ᛪᛮ-ᛸᜀ-ᜑᜟ-ᜱᝀ-ᝑᝠ-ᝬᝮ-ᝰក-ឳៗៜᠠ-ᡸᢀ-ᢨᢪᢰ-ᣵᤀ-ᤞᥐ-ᥭᥰ-ᥴᦀ-ᦫᦰ-ᧉᨀ-ᨖᨠ-ᩔᪧᬅ-ᬳᭅ-ᭌᮃ-ᮠᮮᮯᮺ-ᯥᰀ-ᰣᱍ-ᱏᱚ-ᱽᲀ-Ა-ᲺᲽ-Ჿᳩ-ᳬᳮ-ᳳᳵᳶᳺᴀ-ᶿḀ-ἕἘ-Ἕἠ-ὅὈ-Ὅὐ-ὗὙὛὝὟ-ώᾀ-ᾴᾶ-ᾼιῂ-ῄῆ-ῌῐ-ΐῖ-Ίῠ-Ῥῲ-ῴῶ-ῼⁱⁿₐ-ₜℂℇℊ-ℓℕ℘-ℝℤΩℨK-ℹℼ-ℿⅅ-ⅉⅎⅠ-ↈⰀ-ⳤⳫ-ⳮⳲⳳⴀ-ⴥⴧⴭⴰ-ⵧⵯⶀ-ⶖⶠ-ⶦⶨ-ⶮⶰ-ⶶⶸ-ⶾⷀ-ⷆⷈ-ⷎⷐ-ⷖⷘ-ⷞ々-〇〡-〩〱-〵〸-〼ぁ-ゖ゛-ゟァ-ヺー-ヿㄅ-ㄯㄱ-ㆎㆠ-ㆿㇰ-ㇿ㐀-䶿一-ꒌꓐ-ꓽꔀ-ꘌꘐ-ꘟꘪꘫꙀ-ꙮꙿ-ꚝꚠ-ꛯꜗ-ꜟꜢ-ꞈꞋ--ꠁꠃ-ꠅꠇ-ꠊꠌ-ꠢꡀ-ꡳꢂ-ꢳꣲ-ꣷꣻꣽꣾꤊ-ꤥꤰ-ꥆꥠ-ꥼꦄ-ꦲꧏꧠ-ꧤꧦ-ꧯꧺ-ꧾꨀ-ꨨꩀ-ꩂꩄ-ꩋꩠ-ꩶꩺꩾ-ꪯꪱꪵꪶꪹ-ꪽꫀꫂꫛ-ꫝꫠ-ꫪꫲ-ꫴꬁ-ꬆꬉ-ꬎꬑ-ꬖꬠ-ꬦꬨ-ꬮꬰ-ꭚꭜ-ꭩꭰ-ꯢ가-힣ힰ-ퟆퟋ-ퟻ豈-舘並-龎ff-stﬓ-ﬗיִײַ-ﬨשׁ-זּטּ-לּמּנּסּףּפּצּ-ﮱﯓ-ﴽﵐ-ﶏﶒ-ﷇﷰ-ﷻﹰ-ﹴﹶ-ﻼA-Za-zヲ-하-ᅦᅧ-ᅬᅭ-ᅲᅳ-ᅵ";
|
|
2094
|
-
let nonASCIIidentifierChars = "·̀-ͯ·҃-֑҇-ׇֽֿׁׂׅׄؐ-ًؚ-٩ٰۖ-ۜ۟-۪ۤۧۨ-ۭ۰-۹ܑܰ-݊ަ-ް߀-߉߫-߽߳ࠖ-࠙ࠛ-ࠣࠥ-ࠧࠩ-࡙࠭-࡛-࢟࣊-ࣣ࣡-ःऺ-़ा-ॏ॑-ॗॢॣ०-९ঁ-ঃ়া-ৄেৈো-্ৗৢৣ০-৯৾ਁ-ਃ਼ਾ-ੂੇੈੋ-੍ੑ੦-ੱੵઁ-ઃ઼ા-ૅે-ૉો-્ૢૣ૦-૯ૺ-૿ଁ-ଃ଼ା-ୄେୈୋ-୍୕-ୗୢୣ୦-୯ஂா-ூெ-ைொ-்ௗ௦-௯ఀ-ఄ఼ా-ౄె-ైొ-్ౕౖౢౣ౦-౯ಁ-ಃ಼ಾ-ೄೆ-ೈೊ-್ೕೖೢೣ೦-೯ೳഀ-ഃ഻഼ാ-ൄെ-ൈൊ-്ൗൢൣ൦-൯ඁ-ඃ්ා-ුූෘ-ෟ෦-෯ෲෳัิ-ฺ็-๎๐-๙ັິ-ຼ່-໎໐-໙༘༙༠-༩༹༵༷༾༿ཱ-྄྆྇ྍ-ྗྙ-ྼ࿆ါ-ှ၀-၉ၖ-ၙၞ-ၠၢ-ၤၧ-ၭၱ-ၴႂ-ႍႏ-ႝ፝-፟፩-፱ᜒ-᜕ᜲ-᜴ᝒᝓᝲᝳ឴-៓៝០-៩᠋-᠍᠏-᠙ᢩᤠ-ᤫᤰ-᤻᥆-᥏᧐-᧚ᨗ-ᨛᩕ-ᩞ᩠-᩿᩼-᪉᪐-᪙᪰-᪽ᪿ--ᬀ-ᬄ᬴-᭄᭐-᭙᭫-᭳ᮀ-ᮂᮡ-ᮭ᮰-᮹᯦-᯳ᰤ-᰷᱀-᱉᱐-᱙᳐-᳔᳒-᳨᳭᳴᳷-᳹᷀-᷿‿⁀⁔⃐-⃥⃜⃡-⃰⳯-⵿⳱ⷠ-〪ⷿ-゙゚〯・꘠-꘩꙯ꙴ-꙽ꚞꚟ꛰꛱ꠂ꠆ꠋꠣ-ꠧ꠬ꢀꢁꢴ-ꣅ꣐-꣙꣠-꣱ꣿ-꤉ꤦ-꤭ꥇ-꥓ꦀ-ꦃ꦳-꧀꧐-꧙ꧥ꧰-꧹ꨩ-ꨶꩃꩌꩍ꩐-꩙ꩻ-ꩽꪰꪲ-ꪴꪷꪸꪾ꪿꫁ꫫ-ꫯꫵ꫶ꯣ-ꯪ꯬꯭꯰-꯹ﬞ︀-️︠-︯︳︴﹍-﹏0-9_・";
|
|
2095
|
-
const nonASCIIidentifierStart = /* @__PURE__ */ new RegExp("[" + nonASCIIidentifierStartChars + "]");
|
|
2096
|
-
const nonASCIIidentifier = /* @__PURE__ */ new RegExp("[" + nonASCIIidentifierStartChars + nonASCIIidentifierChars + "]");
|
|
2097
|
-
nonASCIIidentifierStartChars = nonASCIIidentifierChars = null;
|
|
2098
|
-
const astralIdentifierStartCodes = [
|
|
2099
|
-
0,
|
|
2100
|
-
11,
|
|
2101
|
-
2,
|
|
2102
|
-
25,
|
|
2103
|
-
2,
|
|
2104
|
-
18,
|
|
2105
|
-
2,
|
|
2106
|
-
1,
|
|
2107
|
-
2,
|
|
2108
|
-
14,
|
|
2109
|
-
3,
|
|
2110
|
-
13,
|
|
2111
|
-
35,
|
|
2112
|
-
122,
|
|
2113
|
-
70,
|
|
2114
|
-
52,
|
|
2115
|
-
268,
|
|
2116
|
-
28,
|
|
2117
|
-
4,
|
|
2118
|
-
48,
|
|
2119
|
-
48,
|
|
2120
|
-
31,
|
|
2121
|
-
14,
|
|
2122
|
-
29,
|
|
2123
|
-
6,
|
|
2124
|
-
37,
|
|
2125
|
-
11,
|
|
2126
|
-
29,
|
|
2127
|
-
3,
|
|
2128
|
-
35,
|
|
2129
|
-
5,
|
|
2130
|
-
7,
|
|
2131
|
-
2,
|
|
2132
|
-
4,
|
|
2133
|
-
43,
|
|
2134
|
-
157,
|
|
2135
|
-
19,
|
|
2136
|
-
35,
|
|
2137
|
-
5,
|
|
2138
|
-
35,
|
|
2139
|
-
5,
|
|
2140
|
-
39,
|
|
2141
|
-
9,
|
|
2142
|
-
51,
|
|
2143
|
-
13,
|
|
2144
|
-
10,
|
|
2145
|
-
2,
|
|
2146
|
-
14,
|
|
2147
|
-
2,
|
|
2148
|
-
6,
|
|
2149
|
-
2,
|
|
2150
|
-
1,
|
|
2151
|
-
2,
|
|
2152
|
-
10,
|
|
2153
|
-
2,
|
|
2154
|
-
14,
|
|
2155
|
-
2,
|
|
2156
|
-
6,
|
|
2157
|
-
2,
|
|
2158
|
-
1,
|
|
2159
|
-
4,
|
|
2160
|
-
51,
|
|
2161
|
-
13,
|
|
2162
|
-
310,
|
|
2163
|
-
10,
|
|
2164
|
-
21,
|
|
2165
|
-
11,
|
|
2166
|
-
7,
|
|
2167
|
-
25,
|
|
2168
|
-
5,
|
|
2169
|
-
2,
|
|
2170
|
-
41,
|
|
2171
|
-
2,
|
|
2172
|
-
8,
|
|
2173
|
-
70,
|
|
2174
|
-
5,
|
|
2175
|
-
3,
|
|
2176
|
-
0,
|
|
2177
|
-
2,
|
|
2178
|
-
43,
|
|
2179
|
-
2,
|
|
2180
|
-
1,
|
|
2181
|
-
4,
|
|
2182
|
-
0,
|
|
2183
|
-
3,
|
|
2184
|
-
22,
|
|
2185
|
-
11,
|
|
2186
|
-
22,
|
|
2187
|
-
10,
|
|
2188
|
-
30,
|
|
2189
|
-
66,
|
|
2190
|
-
18,
|
|
2191
|
-
2,
|
|
2192
|
-
1,
|
|
2193
|
-
11,
|
|
2194
|
-
21,
|
|
2195
|
-
11,
|
|
2196
|
-
25,
|
|
2197
|
-
7,
|
|
2198
|
-
25,
|
|
2199
|
-
39,
|
|
2200
|
-
55,
|
|
2201
|
-
7,
|
|
2202
|
-
1,
|
|
2203
|
-
65,
|
|
2204
|
-
0,
|
|
2205
|
-
16,
|
|
2206
|
-
3,
|
|
2207
|
-
2,
|
|
2208
|
-
2,
|
|
2209
|
-
2,
|
|
2210
|
-
28,
|
|
2211
|
-
43,
|
|
2212
|
-
28,
|
|
2213
|
-
4,
|
|
2214
|
-
28,
|
|
2215
|
-
36,
|
|
2216
|
-
7,
|
|
2217
|
-
2,
|
|
2218
|
-
27,
|
|
2219
|
-
28,
|
|
2220
|
-
53,
|
|
2221
|
-
11,
|
|
2222
|
-
21,
|
|
2223
|
-
11,
|
|
2224
|
-
18,
|
|
2225
|
-
14,
|
|
2226
|
-
17,
|
|
2227
|
-
111,
|
|
2228
|
-
72,
|
|
2229
|
-
56,
|
|
2230
|
-
50,
|
|
2231
|
-
14,
|
|
2232
|
-
50,
|
|
2233
|
-
14,
|
|
2234
|
-
35,
|
|
2235
|
-
39,
|
|
2236
|
-
27,
|
|
2237
|
-
10,
|
|
2238
|
-
22,
|
|
2239
|
-
251,
|
|
2240
|
-
41,
|
|
2241
|
-
7,
|
|
2242
|
-
1,
|
|
2243
|
-
17,
|
|
2244
|
-
5,
|
|
2245
|
-
57,
|
|
2246
|
-
28,
|
|
2247
|
-
11,
|
|
2248
|
-
0,
|
|
2249
|
-
9,
|
|
2250
|
-
21,
|
|
2251
|
-
43,
|
|
2252
|
-
17,
|
|
2253
|
-
47,
|
|
2254
|
-
20,
|
|
2255
|
-
28,
|
|
2256
|
-
22,
|
|
2257
|
-
13,
|
|
2258
|
-
52,
|
|
2259
|
-
58,
|
|
2260
|
-
1,
|
|
2261
|
-
3,
|
|
2262
|
-
0,
|
|
2263
|
-
14,
|
|
2264
|
-
44,
|
|
2265
|
-
33,
|
|
2266
|
-
24,
|
|
2267
|
-
27,
|
|
2268
|
-
35,
|
|
2269
|
-
30,
|
|
2270
|
-
0,
|
|
2271
|
-
3,
|
|
2272
|
-
0,
|
|
2273
|
-
9,
|
|
2274
|
-
34,
|
|
2275
|
-
4,
|
|
2276
|
-
0,
|
|
2277
|
-
13,
|
|
2278
|
-
47,
|
|
2279
|
-
15,
|
|
2280
|
-
3,
|
|
2281
|
-
22,
|
|
2282
|
-
0,
|
|
2283
|
-
2,
|
|
2284
|
-
0,
|
|
2285
|
-
36,
|
|
2286
|
-
17,
|
|
2287
|
-
2,
|
|
2288
|
-
24,
|
|
2289
|
-
20,
|
|
2290
|
-
1,
|
|
2291
|
-
64,
|
|
2292
|
-
6,
|
|
2293
|
-
2,
|
|
2294
|
-
0,
|
|
2295
|
-
2,
|
|
2296
|
-
3,
|
|
2297
|
-
2,
|
|
2298
|
-
14,
|
|
2299
|
-
2,
|
|
2300
|
-
9,
|
|
2301
|
-
8,
|
|
2302
|
-
46,
|
|
2303
|
-
39,
|
|
2304
|
-
7,
|
|
2305
|
-
3,
|
|
2306
|
-
1,
|
|
2307
|
-
3,
|
|
2308
|
-
21,
|
|
2309
|
-
2,
|
|
2310
|
-
6,
|
|
2311
|
-
2,
|
|
2312
|
-
1,
|
|
2313
|
-
2,
|
|
2314
|
-
4,
|
|
2315
|
-
4,
|
|
2316
|
-
0,
|
|
2317
|
-
19,
|
|
2318
|
-
0,
|
|
2319
|
-
13,
|
|
2320
|
-
4,
|
|
2321
|
-
31,
|
|
2322
|
-
9,
|
|
2323
|
-
2,
|
|
2324
|
-
0,
|
|
2325
|
-
3,
|
|
2326
|
-
0,
|
|
2327
|
-
2,
|
|
2328
|
-
37,
|
|
2329
|
-
2,
|
|
2330
|
-
0,
|
|
2331
|
-
26,
|
|
2332
|
-
0,
|
|
2333
|
-
2,
|
|
2334
|
-
0,
|
|
2335
|
-
45,
|
|
2336
|
-
52,
|
|
2337
|
-
19,
|
|
2338
|
-
3,
|
|
2339
|
-
21,
|
|
2340
|
-
2,
|
|
2341
|
-
31,
|
|
2342
|
-
47,
|
|
2343
|
-
21,
|
|
2344
|
-
1,
|
|
2345
|
-
2,
|
|
2346
|
-
0,
|
|
2347
|
-
185,
|
|
2348
|
-
46,
|
|
2349
|
-
42,
|
|
2350
|
-
3,
|
|
2351
|
-
37,
|
|
2352
|
-
47,
|
|
2353
|
-
21,
|
|
2354
|
-
0,
|
|
2355
|
-
60,
|
|
2356
|
-
42,
|
|
2357
|
-
14,
|
|
2358
|
-
0,
|
|
2359
|
-
72,
|
|
2360
|
-
26,
|
|
2361
|
-
38,
|
|
2362
|
-
6,
|
|
2363
|
-
186,
|
|
2364
|
-
43,
|
|
2365
|
-
117,
|
|
2366
|
-
63,
|
|
2367
|
-
32,
|
|
2368
|
-
7,
|
|
2369
|
-
3,
|
|
2370
|
-
0,
|
|
2371
|
-
3,
|
|
2372
|
-
7,
|
|
2373
|
-
2,
|
|
2374
|
-
1,
|
|
2375
|
-
2,
|
|
2376
|
-
23,
|
|
2377
|
-
16,
|
|
2378
|
-
0,
|
|
2379
|
-
2,
|
|
2380
|
-
0,
|
|
2381
|
-
95,
|
|
2382
|
-
7,
|
|
2383
|
-
3,
|
|
2384
|
-
38,
|
|
2385
|
-
17,
|
|
2386
|
-
0,
|
|
2387
|
-
2,
|
|
2388
|
-
0,
|
|
2389
|
-
29,
|
|
2390
|
-
0,
|
|
2391
|
-
11,
|
|
2392
|
-
39,
|
|
2393
|
-
8,
|
|
2394
|
-
0,
|
|
2395
|
-
22,
|
|
2396
|
-
0,
|
|
2397
|
-
12,
|
|
2398
|
-
45,
|
|
2399
|
-
20,
|
|
2400
|
-
0,
|
|
2401
|
-
19,
|
|
2402
|
-
72,
|
|
2403
|
-
200,
|
|
2404
|
-
32,
|
|
2405
|
-
32,
|
|
2406
|
-
8,
|
|
2407
|
-
2,
|
|
2408
|
-
36,
|
|
2409
|
-
18,
|
|
2410
|
-
0,
|
|
2411
|
-
50,
|
|
2412
|
-
29,
|
|
2413
|
-
113,
|
|
2414
|
-
6,
|
|
2415
|
-
2,
|
|
2416
|
-
1,
|
|
2417
|
-
2,
|
|
2418
|
-
37,
|
|
2419
|
-
22,
|
|
2420
|
-
0,
|
|
2421
|
-
26,
|
|
2422
|
-
5,
|
|
2423
|
-
2,
|
|
2424
|
-
1,
|
|
2425
|
-
2,
|
|
2426
|
-
31,
|
|
2427
|
-
15,
|
|
2428
|
-
0,
|
|
2429
|
-
24,
|
|
2430
|
-
43,
|
|
2431
|
-
261,
|
|
2432
|
-
18,
|
|
2433
|
-
16,
|
|
2434
|
-
0,
|
|
2435
|
-
2,
|
|
2436
|
-
12,
|
|
2437
|
-
2,
|
|
2438
|
-
33,
|
|
2439
|
-
125,
|
|
2440
|
-
0,
|
|
2441
|
-
80,
|
|
2442
|
-
921,
|
|
2443
|
-
103,
|
|
2444
|
-
110,
|
|
2445
|
-
18,
|
|
2446
|
-
195,
|
|
2447
|
-
2637,
|
|
2448
|
-
96,
|
|
2449
|
-
16,
|
|
2450
|
-
1071,
|
|
2451
|
-
18,
|
|
2452
|
-
5,
|
|
2453
|
-
26,
|
|
2454
|
-
3994,
|
|
2455
|
-
6,
|
|
2456
|
-
582,
|
|
2457
|
-
6842,
|
|
2458
|
-
29,
|
|
2459
|
-
1763,
|
|
2460
|
-
568,
|
|
2461
|
-
8,
|
|
2462
|
-
30,
|
|
2463
|
-
18,
|
|
2464
|
-
78,
|
|
2465
|
-
18,
|
|
2466
|
-
29,
|
|
2467
|
-
19,
|
|
2468
|
-
47,
|
|
2469
|
-
17,
|
|
2470
|
-
3,
|
|
2471
|
-
32,
|
|
2472
|
-
20,
|
|
2473
|
-
6,
|
|
2474
|
-
18,
|
|
2475
|
-
433,
|
|
2476
|
-
44,
|
|
2477
|
-
212,
|
|
2478
|
-
63,
|
|
2479
|
-
33,
|
|
2480
|
-
24,
|
|
2481
|
-
3,
|
|
2482
|
-
24,
|
|
2483
|
-
45,
|
|
2484
|
-
74,
|
|
2485
|
-
6,
|
|
2486
|
-
0,
|
|
2487
|
-
67,
|
|
2488
|
-
12,
|
|
2489
|
-
65,
|
|
2490
|
-
1,
|
|
2491
|
-
2,
|
|
2492
|
-
0,
|
|
2493
|
-
15,
|
|
2494
|
-
4,
|
|
2495
|
-
10,
|
|
2496
|
-
7381,
|
|
2497
|
-
42,
|
|
2498
|
-
31,
|
|
2499
|
-
98,
|
|
2500
|
-
114,
|
|
2501
|
-
8702,
|
|
2502
|
-
3,
|
|
2503
|
-
2,
|
|
2504
|
-
6,
|
|
2505
|
-
2,
|
|
2506
|
-
1,
|
|
2507
|
-
2,
|
|
2508
|
-
290,
|
|
2509
|
-
16,
|
|
2510
|
-
0,
|
|
2511
|
-
30,
|
|
2512
|
-
2,
|
|
2513
|
-
3,
|
|
2514
|
-
0,
|
|
2515
|
-
15,
|
|
2516
|
-
3,
|
|
2517
|
-
9,
|
|
2518
|
-
395,
|
|
2519
|
-
2309,
|
|
2520
|
-
106,
|
|
2521
|
-
6,
|
|
2522
|
-
12,
|
|
2523
|
-
4,
|
|
2524
|
-
8,
|
|
2525
|
-
8,
|
|
2526
|
-
9,
|
|
2527
|
-
5991,
|
|
2528
|
-
84,
|
|
2529
|
-
2,
|
|
2530
|
-
70,
|
|
2531
|
-
2,
|
|
2532
|
-
1,
|
|
2533
|
-
3,
|
|
2534
|
-
0,
|
|
2535
|
-
3,
|
|
2536
|
-
1,
|
|
2537
|
-
3,
|
|
2538
|
-
3,
|
|
2539
|
-
2,
|
|
2540
|
-
11,
|
|
2541
|
-
2,
|
|
2542
|
-
0,
|
|
2543
|
-
2,
|
|
2544
|
-
6,
|
|
2545
|
-
2,
|
|
2546
|
-
64,
|
|
2547
|
-
2,
|
|
2548
|
-
3,
|
|
2549
|
-
3,
|
|
2550
|
-
7,
|
|
2551
|
-
2,
|
|
2552
|
-
6,
|
|
2553
|
-
2,
|
|
2554
|
-
27,
|
|
2555
|
-
2,
|
|
2556
|
-
3,
|
|
2557
|
-
2,
|
|
2558
|
-
4,
|
|
2559
|
-
2,
|
|
2560
|
-
0,
|
|
2561
|
-
4,
|
|
2562
|
-
6,
|
|
2563
|
-
2,
|
|
2564
|
-
339,
|
|
2565
|
-
3,
|
|
2566
|
-
24,
|
|
2567
|
-
2,
|
|
2568
|
-
24,
|
|
2569
|
-
2,
|
|
2570
|
-
30,
|
|
2571
|
-
2,
|
|
2572
|
-
24,
|
|
2573
|
-
2,
|
|
2574
|
-
30,
|
|
2575
|
-
2,
|
|
2576
|
-
24,
|
|
2577
|
-
2,
|
|
2578
|
-
30,
|
|
2579
|
-
2,
|
|
2580
|
-
24,
|
|
2581
|
-
2,
|
|
2582
|
-
30,
|
|
2583
|
-
2,
|
|
2584
|
-
24,
|
|
2585
|
-
2,
|
|
2586
|
-
7,
|
|
2587
|
-
1845,
|
|
2588
|
-
30,
|
|
2589
|
-
7,
|
|
2590
|
-
5,
|
|
2591
|
-
262,
|
|
2592
|
-
61,
|
|
2593
|
-
147,
|
|
2594
|
-
44,
|
|
2595
|
-
11,
|
|
2596
|
-
6,
|
|
2597
|
-
17,
|
|
2598
|
-
0,
|
|
2599
|
-
322,
|
|
2600
|
-
29,
|
|
2601
|
-
19,
|
|
2602
|
-
43,
|
|
2603
|
-
485,
|
|
2604
|
-
27,
|
|
2605
|
-
229,
|
|
2606
|
-
29,
|
|
2607
|
-
3,
|
|
2608
|
-
0,
|
|
2609
|
-
208,
|
|
2610
|
-
30,
|
|
2611
|
-
2,
|
|
2612
|
-
2,
|
|
2613
|
-
2,
|
|
2614
|
-
1,
|
|
2615
|
-
2,
|
|
2616
|
-
6,
|
|
2617
|
-
3,
|
|
2618
|
-
4,
|
|
2619
|
-
10,
|
|
2620
|
-
1,
|
|
2621
|
-
225,
|
|
2622
|
-
6,
|
|
2623
|
-
2,
|
|
2624
|
-
3,
|
|
2625
|
-
2,
|
|
2626
|
-
1,
|
|
2627
|
-
2,
|
|
2628
|
-
14,
|
|
2629
|
-
2,
|
|
2630
|
-
196,
|
|
2631
|
-
60,
|
|
2632
|
-
67,
|
|
2633
|
-
8,
|
|
2634
|
-
0,
|
|
2635
|
-
1205,
|
|
2636
|
-
3,
|
|
2637
|
-
2,
|
|
2638
|
-
26,
|
|
2639
|
-
2,
|
|
2640
|
-
1,
|
|
2641
|
-
2,
|
|
2642
|
-
0,
|
|
2643
|
-
3,
|
|
2644
|
-
0,
|
|
2645
|
-
2,
|
|
2646
|
-
9,
|
|
2647
|
-
2,
|
|
2648
|
-
3,
|
|
2649
|
-
2,
|
|
2650
|
-
0,
|
|
2651
|
-
2,
|
|
2652
|
-
0,
|
|
2653
|
-
7,
|
|
2654
|
-
0,
|
|
2655
|
-
5,
|
|
2656
|
-
0,
|
|
2657
|
-
2,
|
|
2658
|
-
0,
|
|
2659
|
-
2,
|
|
2660
|
-
0,
|
|
2661
|
-
2,
|
|
2662
|
-
2,
|
|
2663
|
-
2,
|
|
2664
|
-
1,
|
|
2665
|
-
2,
|
|
2666
|
-
0,
|
|
2667
|
-
3,
|
|
2668
|
-
0,
|
|
2669
|
-
2,
|
|
2670
|
-
0,
|
|
2671
|
-
2,
|
|
2672
|
-
0,
|
|
2673
|
-
2,
|
|
2674
|
-
0,
|
|
2675
|
-
2,
|
|
2676
|
-
0,
|
|
2677
|
-
2,
|
|
2678
|
-
1,
|
|
2679
|
-
2,
|
|
2680
|
-
0,
|
|
2681
|
-
3,
|
|
2682
|
-
3,
|
|
2683
|
-
2,
|
|
2684
|
-
6,
|
|
2685
|
-
2,
|
|
2686
|
-
3,
|
|
2687
|
-
2,
|
|
2688
|
-
3,
|
|
2689
|
-
2,
|
|
2690
|
-
0,
|
|
2691
|
-
2,
|
|
2692
|
-
9,
|
|
2693
|
-
2,
|
|
2694
|
-
16,
|
|
2695
|
-
6,
|
|
2696
|
-
2,
|
|
2697
|
-
2,
|
|
2698
|
-
4,
|
|
2699
|
-
2,
|
|
2700
|
-
16,
|
|
2701
|
-
4421,
|
|
2702
|
-
42719,
|
|
2703
|
-
33,
|
|
2704
|
-
4381,
|
|
2705
|
-
3,
|
|
2706
|
-
5773,
|
|
2707
|
-
3,
|
|
2708
|
-
7472,
|
|
2709
|
-
16,
|
|
2710
|
-
621,
|
|
2711
|
-
2467,
|
|
2712
|
-
541,
|
|
2713
|
-
1507,
|
|
2714
|
-
4938,
|
|
2715
|
-
6,
|
|
2716
|
-
8489
|
|
2717
|
-
];
|
|
2718
|
-
const astralIdentifierCodes = [
|
|
2719
|
-
509,
|
|
2720
|
-
0,
|
|
2721
|
-
227,
|
|
2722
|
-
0,
|
|
2723
|
-
150,
|
|
2724
|
-
4,
|
|
2725
|
-
294,
|
|
2726
|
-
9,
|
|
2727
|
-
1368,
|
|
2728
|
-
2,
|
|
2729
|
-
2,
|
|
2730
|
-
1,
|
|
2731
|
-
6,
|
|
2732
|
-
3,
|
|
2733
|
-
41,
|
|
2734
|
-
2,
|
|
2735
|
-
5,
|
|
2736
|
-
0,
|
|
2737
|
-
166,
|
|
2738
|
-
1,
|
|
2739
|
-
574,
|
|
2740
|
-
3,
|
|
2741
|
-
9,
|
|
2742
|
-
9,
|
|
2743
|
-
7,
|
|
2744
|
-
9,
|
|
2745
|
-
32,
|
|
2746
|
-
4,
|
|
2747
|
-
318,
|
|
2748
|
-
1,
|
|
2749
|
-
78,
|
|
2750
|
-
5,
|
|
2751
|
-
71,
|
|
2752
|
-
10,
|
|
2753
|
-
50,
|
|
2754
|
-
3,
|
|
2755
|
-
123,
|
|
2756
|
-
2,
|
|
2757
|
-
54,
|
|
2758
|
-
14,
|
|
2759
|
-
32,
|
|
2760
|
-
10,
|
|
2761
|
-
3,
|
|
2762
|
-
1,
|
|
2763
|
-
11,
|
|
2764
|
-
3,
|
|
2765
|
-
46,
|
|
2766
|
-
10,
|
|
2767
|
-
8,
|
|
2768
|
-
0,
|
|
2769
|
-
46,
|
|
2770
|
-
9,
|
|
2771
|
-
7,
|
|
2772
|
-
2,
|
|
2773
|
-
37,
|
|
2774
|
-
13,
|
|
2775
|
-
2,
|
|
2776
|
-
9,
|
|
2777
|
-
6,
|
|
2778
|
-
1,
|
|
2779
|
-
45,
|
|
2780
|
-
0,
|
|
2781
|
-
13,
|
|
2782
|
-
2,
|
|
2783
|
-
49,
|
|
2784
|
-
13,
|
|
2785
|
-
9,
|
|
2786
|
-
3,
|
|
2787
|
-
2,
|
|
2788
|
-
11,
|
|
2789
|
-
83,
|
|
2790
|
-
11,
|
|
2791
|
-
7,
|
|
2792
|
-
0,
|
|
2793
|
-
3,
|
|
2794
|
-
0,
|
|
2795
|
-
158,
|
|
2796
|
-
11,
|
|
2797
|
-
6,
|
|
2798
|
-
9,
|
|
2799
|
-
7,
|
|
2800
|
-
3,
|
|
2801
|
-
56,
|
|
2802
|
-
1,
|
|
2803
|
-
2,
|
|
2804
|
-
6,
|
|
2805
|
-
3,
|
|
2806
|
-
1,
|
|
2807
|
-
3,
|
|
2808
|
-
2,
|
|
2809
|
-
10,
|
|
2810
|
-
0,
|
|
2811
|
-
11,
|
|
2812
|
-
1,
|
|
2813
|
-
3,
|
|
2814
|
-
6,
|
|
2815
|
-
4,
|
|
2816
|
-
4,
|
|
2817
|
-
68,
|
|
2818
|
-
8,
|
|
2819
|
-
2,
|
|
2820
|
-
0,
|
|
2821
|
-
3,
|
|
2822
|
-
0,
|
|
2823
|
-
2,
|
|
2824
|
-
3,
|
|
2825
|
-
2,
|
|
2826
|
-
4,
|
|
2827
|
-
2,
|
|
2828
|
-
0,
|
|
2829
|
-
15,
|
|
2830
|
-
1,
|
|
2831
|
-
83,
|
|
2832
|
-
17,
|
|
2833
|
-
10,
|
|
2834
|
-
9,
|
|
2835
|
-
5,
|
|
2836
|
-
0,
|
|
2837
|
-
82,
|
|
2838
|
-
19,
|
|
2839
|
-
13,
|
|
2840
|
-
9,
|
|
2841
|
-
214,
|
|
2842
|
-
6,
|
|
2843
|
-
3,
|
|
2844
|
-
8,
|
|
2845
|
-
28,
|
|
2846
|
-
1,
|
|
2847
|
-
83,
|
|
2848
|
-
16,
|
|
2849
|
-
16,
|
|
2850
|
-
9,
|
|
2851
|
-
82,
|
|
2852
|
-
12,
|
|
2853
|
-
9,
|
|
2854
|
-
9,
|
|
2855
|
-
7,
|
|
2856
|
-
19,
|
|
2857
|
-
58,
|
|
2858
|
-
14,
|
|
2859
|
-
5,
|
|
2860
|
-
9,
|
|
2861
|
-
243,
|
|
2862
|
-
14,
|
|
2863
|
-
166,
|
|
2864
|
-
9,
|
|
2865
|
-
71,
|
|
2866
|
-
5,
|
|
2867
|
-
2,
|
|
2868
|
-
1,
|
|
2869
|
-
3,
|
|
2870
|
-
3,
|
|
2871
|
-
2,
|
|
2872
|
-
0,
|
|
2873
|
-
2,
|
|
2874
|
-
1,
|
|
2875
|
-
13,
|
|
2876
|
-
9,
|
|
2877
|
-
120,
|
|
2878
|
-
6,
|
|
2879
|
-
3,
|
|
2880
|
-
6,
|
|
2881
|
-
4,
|
|
2882
|
-
0,
|
|
2883
|
-
29,
|
|
2884
|
-
9,
|
|
2885
|
-
41,
|
|
2886
|
-
6,
|
|
2887
|
-
2,
|
|
2888
|
-
3,
|
|
2889
|
-
9,
|
|
2890
|
-
0,
|
|
2891
|
-
10,
|
|
2892
|
-
10,
|
|
2893
|
-
47,
|
|
2894
|
-
15,
|
|
2895
|
-
199,
|
|
2896
|
-
7,
|
|
2897
|
-
137,
|
|
2898
|
-
9,
|
|
2899
|
-
54,
|
|
2900
|
-
7,
|
|
2901
|
-
2,
|
|
2902
|
-
7,
|
|
2903
|
-
17,
|
|
2904
|
-
9,
|
|
2905
|
-
57,
|
|
2906
|
-
21,
|
|
2907
|
-
2,
|
|
2908
|
-
13,
|
|
2909
|
-
123,
|
|
2910
|
-
5,
|
|
2911
|
-
4,
|
|
2912
|
-
0,
|
|
2913
|
-
2,
|
|
2914
|
-
1,
|
|
2915
|
-
2,
|
|
2916
|
-
6,
|
|
2917
|
-
2,
|
|
2918
|
-
0,
|
|
2919
|
-
9,
|
|
2920
|
-
9,
|
|
2921
|
-
49,
|
|
2922
|
-
4,
|
|
2923
|
-
2,
|
|
2924
|
-
1,
|
|
2925
|
-
2,
|
|
2926
|
-
4,
|
|
2927
|
-
9,
|
|
2928
|
-
9,
|
|
2929
|
-
55,
|
|
2930
|
-
9,
|
|
2931
|
-
266,
|
|
2932
|
-
3,
|
|
2933
|
-
10,
|
|
2934
|
-
1,
|
|
2935
|
-
2,
|
|
2936
|
-
0,
|
|
2937
|
-
49,
|
|
2938
|
-
6,
|
|
2939
|
-
4,
|
|
2940
|
-
4,
|
|
2941
|
-
14,
|
|
2942
|
-
10,
|
|
2943
|
-
5350,
|
|
2944
|
-
0,
|
|
2945
|
-
7,
|
|
2946
|
-
14,
|
|
2947
|
-
11465,
|
|
2948
|
-
27,
|
|
2949
|
-
2343,
|
|
2950
|
-
9,
|
|
2951
|
-
87,
|
|
2952
|
-
9,
|
|
2953
|
-
39,
|
|
2954
|
-
4,
|
|
2955
|
-
60,
|
|
2956
|
-
6,
|
|
2957
|
-
26,
|
|
2958
|
-
9,
|
|
2959
|
-
535,
|
|
2960
|
-
9,
|
|
2961
|
-
470,
|
|
2962
|
-
0,
|
|
2963
|
-
2,
|
|
2964
|
-
54,
|
|
2965
|
-
8,
|
|
2966
|
-
3,
|
|
2967
|
-
82,
|
|
2968
|
-
0,
|
|
2969
|
-
12,
|
|
2970
|
-
1,
|
|
2971
|
-
19628,
|
|
2972
|
-
1,
|
|
2973
|
-
4178,
|
|
2974
|
-
9,
|
|
2975
|
-
519,
|
|
2976
|
-
45,
|
|
2977
|
-
3,
|
|
2978
|
-
22,
|
|
2979
|
-
543,
|
|
2980
|
-
4,
|
|
2981
|
-
4,
|
|
2982
|
-
5,
|
|
2983
|
-
9,
|
|
2984
|
-
7,
|
|
2985
|
-
3,
|
|
2986
|
-
6,
|
|
2987
|
-
31,
|
|
2988
|
-
3,
|
|
2989
|
-
149,
|
|
2990
|
-
2,
|
|
2991
|
-
1418,
|
|
2992
|
-
49,
|
|
2993
|
-
513,
|
|
2994
|
-
54,
|
|
2995
|
-
5,
|
|
2996
|
-
49,
|
|
2997
|
-
9,
|
|
2998
|
-
0,
|
|
2999
|
-
15,
|
|
3000
|
-
0,
|
|
3001
|
-
23,
|
|
3002
|
-
4,
|
|
3003
|
-
2,
|
|
3004
|
-
14,
|
|
3005
|
-
1361,
|
|
3006
|
-
6,
|
|
3007
|
-
2,
|
|
3008
|
-
16,
|
|
3009
|
-
3,
|
|
3010
|
-
6,
|
|
3011
|
-
2,
|
|
3012
|
-
1,
|
|
3013
|
-
2,
|
|
3014
|
-
4,
|
|
3015
|
-
101,
|
|
3016
|
-
0,
|
|
3017
|
-
161,
|
|
3018
|
-
6,
|
|
3019
|
-
10,
|
|
3020
|
-
9,
|
|
3021
|
-
357,
|
|
3022
|
-
0,
|
|
3023
|
-
62,
|
|
3024
|
-
13,
|
|
3025
|
-
499,
|
|
3026
|
-
13,
|
|
3027
|
-
245,
|
|
3028
|
-
1,
|
|
3029
|
-
2,
|
|
3030
|
-
9,
|
|
3031
|
-
233,
|
|
3032
|
-
0,
|
|
3033
|
-
3,
|
|
3034
|
-
0,
|
|
3035
|
-
8,
|
|
3036
|
-
1,
|
|
3037
|
-
6,
|
|
3038
|
-
0,
|
|
3039
|
-
475,
|
|
3040
|
-
6,
|
|
3041
|
-
110,
|
|
3042
|
-
6,
|
|
3043
|
-
6,
|
|
3044
|
-
9,
|
|
3045
|
-
4759,
|
|
3046
|
-
9,
|
|
3047
|
-
787719,
|
|
3048
|
-
239
|
|
3049
|
-
];
|
|
3050
|
-
function isInAstralSet(code, set) {
|
|
3051
|
-
let pos = 65536;
|
|
3052
|
-
for (let i = 0, length = set.length; i < length; i += 2) {
|
|
3053
|
-
pos += set[i];
|
|
3054
|
-
if (pos > code) return false;
|
|
3055
|
-
pos += set[i + 1];
|
|
3056
|
-
if (pos >= code) return true;
|
|
3057
|
-
}
|
|
3058
|
-
return false;
|
|
3059
|
-
}
|
|
3060
|
-
function isIdentifierStart(code) {
|
|
3061
|
-
if (code < 65) return code === 36;
|
|
3062
|
-
if (code <= 90) return true;
|
|
3063
|
-
if (code < 97) return code === 95;
|
|
3064
|
-
if (code <= 122) return true;
|
|
3065
|
-
if (code <= 65535) return code >= 170 && nonASCIIidentifierStart.test(String.fromCharCode(code));
|
|
3066
|
-
return isInAstralSet(code, astralIdentifierStartCodes);
|
|
3067
|
-
}
|
|
3068
|
-
function isIdentifierChar(code) {
|
|
3069
|
-
if (code < 48) return code === 36;
|
|
3070
|
-
if (code < 58) return true;
|
|
3071
|
-
if (code < 65) return false;
|
|
3072
|
-
if (code <= 90) return true;
|
|
3073
|
-
if (code < 97) return code === 95;
|
|
3074
|
-
if (code <= 122) return true;
|
|
3075
|
-
if (code <= 65535) return code >= 170 && nonASCIIidentifier.test(String.fromCharCode(code));
|
|
3076
|
-
return isInAstralSet(code, astralIdentifierStartCodes) || isInAstralSet(code, astralIdentifierCodes);
|
|
3077
|
-
}
|
|
3078
|
-
function isIdentifierName(name) {
|
|
3079
|
-
let isFirst = true;
|
|
3080
|
-
for (let i = 0; i < name.length; i++) {
|
|
3081
|
-
let cp = name.charCodeAt(i);
|
|
3082
|
-
if ((cp & 64512) === 55296 && i + 1 < name.length) {
|
|
3083
|
-
const trail = name.charCodeAt(++i);
|
|
3084
|
-
if ((trail & 64512) === 56320) cp = 65536 + ((cp & 1023) << 10) + (trail & 1023);
|
|
3085
|
-
}
|
|
3086
|
-
if (isFirst) {
|
|
3087
|
-
isFirst = false;
|
|
3088
|
-
if (!isIdentifierStart(cp)) return false;
|
|
3089
|
-
} else if (!isIdentifierChar(cp)) return false;
|
|
3090
|
-
}
|
|
3091
|
-
return !isFirst;
|
|
3092
1960
|
}
|
|
3093
|
-
|
|
3094
|
-
|
|
3095
|
-
|
|
3096
|
-
|
|
3097
|
-
var require_keyword = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
3098
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3099
|
-
exports.isKeyword = isKeyword;
|
|
3100
|
-
exports.isReservedWord = isReservedWord;
|
|
3101
|
-
exports.isStrictBindOnlyReservedWord = isStrictBindOnlyReservedWord;
|
|
3102
|
-
exports.isStrictBindReservedWord = isStrictBindReservedWord;
|
|
3103
|
-
exports.isStrictReservedWord = isStrictReservedWord;
|
|
3104
|
-
const reservedWords = {
|
|
3105
|
-
keyword: [
|
|
3106
|
-
"break",
|
|
3107
|
-
"case",
|
|
3108
|
-
"catch",
|
|
3109
|
-
"continue",
|
|
3110
|
-
"debugger",
|
|
3111
|
-
"default",
|
|
3112
|
-
"do",
|
|
3113
|
-
"else",
|
|
3114
|
-
"finally",
|
|
3115
|
-
"for",
|
|
3116
|
-
"function",
|
|
3117
|
-
"if",
|
|
3118
|
-
"return",
|
|
3119
|
-
"switch",
|
|
3120
|
-
"throw",
|
|
3121
|
-
"try",
|
|
3122
|
-
"var",
|
|
3123
|
-
"const",
|
|
3124
|
-
"while",
|
|
3125
|
-
"with",
|
|
3126
|
-
"new",
|
|
3127
|
-
"this",
|
|
3128
|
-
"super",
|
|
3129
|
-
"class",
|
|
3130
|
-
"extends",
|
|
3131
|
-
"export",
|
|
3132
|
-
"import",
|
|
3133
|
-
"null",
|
|
3134
|
-
"true",
|
|
3135
|
-
"false",
|
|
3136
|
-
"in",
|
|
3137
|
-
"instanceof",
|
|
3138
|
-
"typeof",
|
|
3139
|
-
"void",
|
|
3140
|
-
"delete"
|
|
3141
|
-
],
|
|
3142
|
-
strict: [
|
|
3143
|
-
"implements",
|
|
3144
|
-
"interface",
|
|
3145
|
-
"let",
|
|
3146
|
-
"package",
|
|
3147
|
-
"private",
|
|
3148
|
-
"protected",
|
|
3149
|
-
"public",
|
|
3150
|
-
"static",
|
|
3151
|
-
"yield"
|
|
3152
|
-
],
|
|
3153
|
-
strictBind: ["eval", "arguments"]
|
|
1961
|
+
const url = new URL(value);
|
|
1962
|
+
return {
|
|
1963
|
+
pathname: url.pathname,
|
|
1964
|
+
query: toQueryObject(url.searchParams)
|
|
3154
1965
|
};
|
|
3155
|
-
|
|
3156
|
-
|
|
3157
|
-
|
|
3158
|
-
|
|
3159
|
-
|
|
3160
|
-
}
|
|
3161
|
-
|
|
3162
|
-
return isReservedWord(word, inModule) || reservedWordsStrictSet.has(word);
|
|
3163
|
-
}
|
|
3164
|
-
function isStrictBindOnlyReservedWord(word) {
|
|
3165
|
-
return reservedWordsStrictBindSet.has(word);
|
|
3166
|
-
}
|
|
3167
|
-
function isStrictBindReservedWord(word, inModule) {
|
|
3168
|
-
return isStrictReservedWord(word, inModule) || isStrictBindOnlyReservedWord(word);
|
|
3169
|
-
}
|
|
3170
|
-
function isKeyword(word) {
|
|
3171
|
-
return keywords.has(word);
|
|
3172
|
-
}
|
|
3173
|
-
}));
|
|
3174
|
-
|
|
3175
|
-
//#endregion
|
|
3176
|
-
//#region node_modules/@babel/helper-validator-identifier/lib/index.js
|
|
3177
|
-
var require_lib$1 = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
3178
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3179
|
-
Object.defineProperty(exports, "isIdentifierChar", {
|
|
3180
|
-
enumerable: true,
|
|
3181
|
-
get: function() {
|
|
3182
|
-
return _identifier.isIdentifierChar;
|
|
3183
|
-
}
|
|
3184
|
-
});
|
|
3185
|
-
Object.defineProperty(exports, "isIdentifierName", {
|
|
3186
|
-
enumerable: true,
|
|
3187
|
-
get: function() {
|
|
3188
|
-
return _identifier.isIdentifierName;
|
|
3189
|
-
}
|
|
3190
|
-
});
|
|
3191
|
-
Object.defineProperty(exports, "isIdentifierStart", {
|
|
3192
|
-
enumerable: true,
|
|
3193
|
-
get: function() {
|
|
3194
|
-
return _identifier.isIdentifierStart;
|
|
3195
|
-
}
|
|
3196
|
-
});
|
|
3197
|
-
Object.defineProperty(exports, "isKeyword", {
|
|
3198
|
-
enumerable: true,
|
|
3199
|
-
get: function() {
|
|
3200
|
-
return _keyword.isKeyword;
|
|
3201
|
-
}
|
|
3202
|
-
});
|
|
3203
|
-
Object.defineProperty(exports, "isReservedWord", {
|
|
3204
|
-
enumerable: true,
|
|
3205
|
-
get: function() {
|
|
3206
|
-
return _keyword.isReservedWord;
|
|
3207
|
-
}
|
|
3208
|
-
});
|
|
3209
|
-
Object.defineProperty(exports, "isStrictBindOnlyReservedWord", {
|
|
3210
|
-
enumerable: true,
|
|
3211
|
-
get: function() {
|
|
3212
|
-
return _keyword.isStrictBindOnlyReservedWord;
|
|
3213
|
-
}
|
|
3214
|
-
});
|
|
3215
|
-
Object.defineProperty(exports, "isStrictBindReservedWord", {
|
|
3216
|
-
enumerable: true,
|
|
3217
|
-
get: function() {
|
|
3218
|
-
return _keyword.isStrictBindReservedWord;
|
|
3219
|
-
}
|
|
3220
|
-
});
|
|
3221
|
-
Object.defineProperty(exports, "isStrictReservedWord", {
|
|
3222
|
-
enumerable: true,
|
|
3223
|
-
get: function() {
|
|
3224
|
-
return _keyword.isStrictReservedWord;
|
|
3225
|
-
}
|
|
3226
|
-
});
|
|
3227
|
-
var _identifier = require_identifier();
|
|
3228
|
-
var _keyword = require_keyword();
|
|
3229
|
-
}));
|
|
3230
|
-
|
|
3231
|
-
//#endregion
|
|
3232
|
-
//#region node_modules/@babel/code-frame/lib/index.js
|
|
3233
|
-
var require_lib = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
3234
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3235
|
-
var picocolors = require_picocolors();
|
|
3236
|
-
var jsTokens = require_js_tokens();
|
|
3237
|
-
var helperValidatorIdentifier = require_lib$1();
|
|
3238
|
-
function isColorSupported() {
|
|
3239
|
-
return typeof process === "object" && (process.env.FORCE_COLOR === "0" || process.env.FORCE_COLOR === "false") ? false : picocolors.isColorSupported;
|
|
3240
|
-
}
|
|
3241
|
-
const compose = (f, g) => (v) => f(g(v));
|
|
3242
|
-
function buildDefs(colors) {
|
|
3243
|
-
return {
|
|
3244
|
-
keyword: colors.cyan,
|
|
3245
|
-
capitalized: colors.yellow,
|
|
3246
|
-
jsxIdentifier: colors.yellow,
|
|
3247
|
-
punctuator: colors.yellow,
|
|
3248
|
-
number: colors.magenta,
|
|
3249
|
-
string: colors.green,
|
|
3250
|
-
regex: colors.magenta,
|
|
3251
|
-
comment: colors.gray,
|
|
3252
|
-
invalid: compose(compose(colors.white, colors.bgRed), colors.bold),
|
|
3253
|
-
gutter: colors.gray,
|
|
3254
|
-
marker: compose(colors.red, colors.bold),
|
|
3255
|
-
message: compose(colors.red, colors.bold),
|
|
3256
|
-
reset: colors.reset
|
|
3257
|
-
};
|
|
3258
|
-
}
|
|
3259
|
-
const defsOn = buildDefs(picocolors.createColors(true));
|
|
3260
|
-
const defsOff = buildDefs(picocolors.createColors(false));
|
|
3261
|
-
function getDefs(enabled) {
|
|
3262
|
-
return enabled ? defsOn : defsOff;
|
|
3263
|
-
}
|
|
3264
|
-
const sometimesKeywords = new Set([
|
|
3265
|
-
"as",
|
|
3266
|
-
"async",
|
|
3267
|
-
"from",
|
|
3268
|
-
"get",
|
|
3269
|
-
"of",
|
|
3270
|
-
"set"
|
|
3271
|
-
]);
|
|
3272
|
-
const NEWLINE$1 = /\r\n|[\n\r\u2028\u2029]/;
|
|
3273
|
-
const BRACKET = /^[()[\]{}]$/;
|
|
3274
|
-
let tokenize;
|
|
3275
|
-
{
|
|
3276
|
-
const JSX_TAG = /^[a-z][\w-]*$/i;
|
|
3277
|
-
const getTokenType = function(token, offset, text) {
|
|
3278
|
-
if (token.type === "name") {
|
|
3279
|
-
if (helperValidatorIdentifier.isKeyword(token.value) || helperValidatorIdentifier.isStrictReservedWord(token.value, true) || sometimesKeywords.has(token.value)) return "keyword";
|
|
3280
|
-
if (JSX_TAG.test(token.value) && (text[offset - 1] === "<" || text.slice(offset - 2, offset) === "</")) return "jsxIdentifier";
|
|
3281
|
-
if (token.value[0] !== token.value[0].toLowerCase()) return "capitalized";
|
|
3282
|
-
}
|
|
3283
|
-
if (token.type === "punctuator" && BRACKET.test(token.value)) return "bracket";
|
|
3284
|
-
if (token.type === "invalid" && (token.value === "@" || token.value === "#")) return "punctuator";
|
|
3285
|
-
return token.type;
|
|
3286
|
-
};
|
|
3287
|
-
tokenize = function* (text) {
|
|
3288
|
-
let match;
|
|
3289
|
-
while (match = jsTokens.default.exec(text)) {
|
|
3290
|
-
const token = jsTokens.matchToToken(match);
|
|
3291
|
-
yield {
|
|
3292
|
-
type: getTokenType(token, match.index, text),
|
|
3293
|
-
value: token.value
|
|
3294
|
-
};
|
|
3295
|
-
}
|
|
3296
|
-
};
|
|
3297
|
-
}
|
|
3298
|
-
function highlight(text) {
|
|
3299
|
-
if (text === "") return "";
|
|
3300
|
-
const defs = getDefs(true);
|
|
3301
|
-
let highlighted = "";
|
|
3302
|
-
for (const { type, value } of tokenize(text)) if (type in defs) highlighted += value.split(NEWLINE$1).map((str) => defs[type](str)).join("\n");
|
|
3303
|
-
else highlighted += value;
|
|
3304
|
-
return highlighted;
|
|
3305
|
-
}
|
|
3306
|
-
const NEWLINE = /\r\n|[\n\r\u2028\u2029]/;
|
|
3307
|
-
function getMarkerLines(loc, source, opts) {
|
|
3308
|
-
const startLoc = Object.assign({
|
|
3309
|
-
column: 0,
|
|
3310
|
-
line: -1
|
|
3311
|
-
}, loc.start);
|
|
3312
|
-
const endLoc = Object.assign({}, startLoc, loc.end);
|
|
3313
|
-
const { linesAbove = 2, linesBelow = 3 } = opts || {};
|
|
3314
|
-
const startLine = startLoc.line;
|
|
3315
|
-
const startColumn = startLoc.column;
|
|
3316
|
-
const endLine = endLoc.line;
|
|
3317
|
-
const endColumn = endLoc.column;
|
|
3318
|
-
let start = Math.max(startLine - (linesAbove + 1), 0);
|
|
3319
|
-
let end = Math.min(source.length, endLine + linesBelow);
|
|
3320
|
-
if (startLine === -1) start = 0;
|
|
3321
|
-
if (endLine === -1) end = source.length;
|
|
3322
|
-
const lineDiff = endLine - startLine;
|
|
3323
|
-
const markerLines = {};
|
|
3324
|
-
if (lineDiff) for (let i = 0; i <= lineDiff; i++) {
|
|
3325
|
-
const lineNumber = i + startLine;
|
|
3326
|
-
if (!startColumn) markerLines[lineNumber] = true;
|
|
3327
|
-
else if (i === 0) markerLines[lineNumber] = [startColumn, source[lineNumber - 1].length - startColumn + 1];
|
|
3328
|
-
else if (i === lineDiff) markerLines[lineNumber] = [0, endColumn];
|
|
3329
|
-
else markerLines[lineNumber] = [0, source[lineNumber - i].length];
|
|
3330
|
-
}
|
|
3331
|
-
else if (startColumn === endColumn) if (startColumn) markerLines[startLine] = [startColumn, 0];
|
|
3332
|
-
else markerLines[startLine] = true;
|
|
3333
|
-
else markerLines[startLine] = [startColumn, endColumn - startColumn];
|
|
3334
|
-
return {
|
|
3335
|
-
start,
|
|
3336
|
-
end,
|
|
3337
|
-
markerLines
|
|
3338
|
-
};
|
|
3339
|
-
}
|
|
3340
|
-
function codeFrameColumns(rawLines, loc, opts = {}) {
|
|
3341
|
-
const shouldHighlight = opts.forceColor || isColorSupported() && opts.highlightCode;
|
|
3342
|
-
const defs = getDefs(shouldHighlight);
|
|
3343
|
-
const { start, end, markerLines } = getMarkerLines(loc, rawLines.split(NEWLINE), opts);
|
|
3344
|
-
const hasColumns = loc.start && typeof loc.start.column === "number";
|
|
3345
|
-
const numberMaxWidth = String(end).length;
|
|
3346
|
-
let frame = (shouldHighlight ? highlight(rawLines) : rawLines).split(NEWLINE, end).slice(start, end).map((line, index) => {
|
|
3347
|
-
const number = start + 1 + index;
|
|
3348
|
-
const gutter = ` ${` ${number}`.slice(-numberMaxWidth)} |`;
|
|
3349
|
-
const hasMarker = markerLines[number];
|
|
3350
|
-
const lastMarkerLine = !markerLines[number + 1];
|
|
3351
|
-
if (hasMarker) {
|
|
3352
|
-
let markerLine = "";
|
|
3353
|
-
if (Array.isArray(hasMarker)) {
|
|
3354
|
-
const markerSpacing = line.slice(0, Math.max(hasMarker[0] - 1, 0)).replace(/[^\t]/g, " ");
|
|
3355
|
-
const numberOfMarkers = hasMarker[1] || 1;
|
|
3356
|
-
markerLine = [
|
|
3357
|
-
"\n ",
|
|
3358
|
-
defs.gutter(gutter.replace(/\d/g, " ")),
|
|
3359
|
-
" ",
|
|
3360
|
-
markerSpacing,
|
|
3361
|
-
defs.marker("^").repeat(numberOfMarkers)
|
|
3362
|
-
].join("");
|
|
3363
|
-
if (lastMarkerLine && opts.message) markerLine += " " + defs.message(opts.message);
|
|
3364
|
-
}
|
|
3365
|
-
return [
|
|
3366
|
-
defs.marker(">"),
|
|
3367
|
-
defs.gutter(gutter),
|
|
3368
|
-
line.length > 0 ? ` ${line}` : "",
|
|
3369
|
-
markerLine
|
|
3370
|
-
].join("");
|
|
3371
|
-
} else return ` ${defs.gutter(gutter)}${line.length > 0 ? ` ${line}` : ""}`;
|
|
3372
|
-
}).join("\n");
|
|
3373
|
-
if (opts.message && !hasColumns) frame = `${" ".repeat(numberMaxWidth + 1)}${opts.message}\n${frame}`;
|
|
3374
|
-
if (shouldHighlight) return defs.reset(frame);
|
|
3375
|
-
else return frame;
|
|
3376
|
-
}
|
|
3377
|
-
exports.codeFrameColumns = codeFrameColumns;
|
|
3378
|
-
}));
|
|
1966
|
+
}
|
|
1967
|
+
function toQueryObject(searchParams) {
|
|
1968
|
+
return searchParams.entries().reduce((acc, [key, value]) => ({
|
|
1969
|
+
...acc,
|
|
1970
|
+
[key]: value
|
|
1971
|
+
}), {});
|
|
1972
|
+
}
|
|
3379
1973
|
|
|
3380
1974
|
//#endregion
|
|
3381
1975
|
//#region src/server/symbolicate.ts
|
|
3382
|
-
var import_lib = require_lib();
|
|
3383
1976
|
/**
|
|
3384
1977
|
* @see https://github.com/facebook/react-native/blob/0.83-stable/packages/metro-config/src/index.flow.js#L17
|
|
3385
1978
|
*/
|
|
@@ -3418,10 +2011,10 @@ function originalPositionFor(sourceMapConsumer, frame) {
|
|
|
3418
2011
|
column: frame.column,
|
|
3419
2012
|
line: frame.lineNumber
|
|
3420
2013
|
});
|
|
3421
|
-
return Object.entries(originalPosition).reduce((frame
|
|
2014
|
+
return Object.entries(originalPosition).reduce((frame, [key, value]) => {
|
|
3422
2015
|
const targetKey = convertFrameKey(key);
|
|
3423
2016
|
return {
|
|
3424
|
-
...frame
|
|
2017
|
+
...frame,
|
|
3425
2018
|
...value ? { [targetKey]: value } : null
|
|
3426
2019
|
};
|
|
3427
2020
|
}, frame);
|
|
@@ -3442,17 +2035,17 @@ function convertFrameKey(key) {
|
|
|
3442
2035
|
return key;
|
|
3443
2036
|
}
|
|
3444
2037
|
function getCodeFrame(sourceMapConsumer, frames, bundle) {
|
|
3445
|
-
const frame = frames.find((frame
|
|
3446
|
-
return frame
|
|
2038
|
+
const frame = frames.find((frame) => {
|
|
2039
|
+
return frame.lineNumber != null && frame.column != null && !isCollapsed(frame);
|
|
3447
2040
|
});
|
|
3448
2041
|
if (frame?.file == null || frame.column == null || frame.lineNumber == null) return null;
|
|
3449
2042
|
try {
|
|
3450
2043
|
const { lineNumber, column, file } = frame;
|
|
3451
2044
|
const unresolved = file.startsWith("http");
|
|
3452
2045
|
const source = unresolved ? bundle.code : sourceMapConsumer.sourceContentFor(frame.file);
|
|
3453
|
-
const fileName = unresolved ?
|
|
2046
|
+
const fileName = unresolved ? parseUrl(file).pathname ?? "unknown" : file;
|
|
3454
2047
|
let content = "";
|
|
3455
|
-
if (source) content = (0,
|
|
2048
|
+
if (source) content = (0, _babel_code_frame.codeFrameColumns)(source, { start: {
|
|
3456
2049
|
column,
|
|
3457
2050
|
line: lineNumber
|
|
3458
2051
|
} }, { highlightCode: true });
|
|
@@ -3482,15 +2075,15 @@ const bodySchema = (0, json_schema_to_ts.asConst)({
|
|
|
3482
2075
|
},
|
|
3483
2076
|
required: ["stack"]
|
|
3484
2077
|
});
|
|
3485
|
-
const plugin = (0, fastify_plugin.default)((fastify
|
|
2078
|
+
const plugin = (0, fastify_plugin.default)((fastify, options) => {
|
|
3486
2079
|
const { getBundler } = options;
|
|
3487
|
-
fastify
|
|
2080
|
+
fastify.post("/symbolicate", {
|
|
3488
2081
|
schema: { body: bodySchema },
|
|
3489
2082
|
async handler(request, reply) {
|
|
3490
2083
|
const { stack } = request.body;
|
|
3491
2084
|
const bundleUrl = stack.find((frame) => frame.file?.startsWith("http"));
|
|
3492
2085
|
(0, es_toolkit.invariant)(bundleUrl?.file, "No bundle URL found in stack frames");
|
|
3493
|
-
const { pathname, query } =
|
|
2086
|
+
const { pathname, query } = parseUrl(bundleUrl.file);
|
|
3494
2087
|
(0, es_toolkit.invariant)(pathname, "No pathname found in bundle URL");
|
|
3495
2088
|
(0, es_toolkit.invariant)(query.platform, "No platform found in query");
|
|
3496
2089
|
(0, es_toolkit.invariant)(query.dev, "No dev found in query");
|
|
@@ -3559,11 +2152,11 @@ function getWebSocketUpgradeHandler(websocketEndpoints) {
|
|
|
3559
2152
|
socket.destroy();
|
|
3560
2153
|
return;
|
|
3561
2154
|
}
|
|
3562
|
-
const { pathname } =
|
|
2155
|
+
const { pathname } = parseUrl(request.url);
|
|
3563
2156
|
if (pathname != null && websocketEndpoints[pathname]) {
|
|
3564
2157
|
const wss = websocketEndpoints[pathname];
|
|
3565
|
-
wss.handleUpgrade(request, socket, head, (socket
|
|
3566
|
-
wss.emit("connection", socket
|
|
2158
|
+
wss.handleUpgrade(request, socket, head, (socket) => {
|
|
2159
|
+
wss.emit("connection", socket, request);
|
|
3567
2160
|
});
|
|
3568
2161
|
} else socket.destroy();
|
|
3569
2162
|
};
|
|
@@ -3692,8 +2285,8 @@ var HMRServer = class extends WebSocketServer {
|
|
|
3692
2285
|
sendError(client, error) {
|
|
3693
2286
|
try {
|
|
3694
2287
|
this.send(client, JSON.stringify(error));
|
|
3695
|
-
} catch (error
|
|
3696
|
-
this.logger.error(`Failed to send HMR error message to client (clientId: ${client.id})`, error
|
|
2288
|
+
} catch (error) {
|
|
2289
|
+
this.logger.error(`Failed to send HMR error message to client (clientId: ${client.id})`, error);
|
|
3697
2290
|
}
|
|
3698
2291
|
}
|
|
3699
2292
|
cleanup(client) {
|
|
@@ -3724,12 +2317,12 @@ var HMRServer = class extends WebSocketServer {
|
|
|
3724
2317
|
};
|
|
3725
2318
|
this.logger.trace("HMR client message received", traceMessage);
|
|
3726
2319
|
} catch (error) {
|
|
3727
|
-
const message
|
|
3728
|
-
this.logger.error(message
|
|
2320
|
+
const message = "Failed to parse HMR client message";
|
|
2321
|
+
this.logger.error(message, error);
|
|
3729
2322
|
this.sendError(client, {
|
|
3730
2323
|
type: "InternalError",
|
|
3731
2324
|
errors: [{ description: error instanceof Error ? error.message : String(error) }],
|
|
3732
|
-
message
|
|
2325
|
+
message
|
|
3733
2326
|
});
|
|
3734
2327
|
return;
|
|
3735
2328
|
}
|
|
@@ -3790,7 +2383,7 @@ async function createDevServer(config, options) {
|
|
|
3790
2383
|
projectRoot,
|
|
3791
2384
|
port
|
|
3792
2385
|
});
|
|
3793
|
-
const emitter =
|
|
2386
|
+
const emitter = (0, mitt.default)();
|
|
3794
2387
|
const fastify$1 = (0, fastify.default)({
|
|
3795
2388
|
loggerInstance: new DevServerLogger(),
|
|
3796
2389
|
disableRequestLogging: true
|
|
@@ -3826,7 +2419,7 @@ async function createDevServer(config, options) {
|
|
|
3826
2419
|
bundlerPool,
|
|
3827
2420
|
reportEvent: (event) => {
|
|
3828
2421
|
reportEvent?.(event);
|
|
3829
|
-
config.reporter
|
|
2422
|
+
config.reporter?.update(event);
|
|
3830
2423
|
}
|
|
3831
2424
|
}).on("connection", (client) => emitter.emit("device.connected", { client })).on("message", (client, data) => emitter.emit("device.message", {
|
|
3832
2425
|
client,
|
|
@@ -3876,9 +2469,9 @@ async function createDevServer(config, options) {
|
|
|
3876
2469
|
}
|
|
3877
2470
|
async function invokeConfigureServer(server, plugins) {
|
|
3878
2471
|
const postConfigureServerHandlers = [];
|
|
3879
|
-
for (const plugin
|
|
3880
|
-
const context = createPluginContext(plugin
|
|
3881
|
-
const result = await plugin
|
|
2472
|
+
for (const plugin of plugins) {
|
|
2473
|
+
const context = createPluginContext(plugin.name);
|
|
2474
|
+
const result = await plugin.configureServer?.call(context, server);
|
|
3882
2475
|
if (typeof result === "function") postConfigureServerHandlers.push(result);
|
|
3883
2476
|
}
|
|
3884
2477
|
return { invokePostConfigureServer: async () => {
|
|
@@ -3928,7 +2521,7 @@ async function resolveScaledAssets(options) {
|
|
|
3928
2521
|
const files = node_fs.default.readdirSync(dirname);
|
|
3929
2522
|
const stripedBasename = stripSuffix(assetPath, context);
|
|
3930
2523
|
const suffixPattern = platformSuffixPattern(context);
|
|
3931
|
-
const assetRegExp =
|
|
2524
|
+
const assetRegExp = new RegExp(`${stripedBasename}(${SCALE_PATTERN})?(?:${suffixPattern})?${extension}$`);
|
|
3932
2525
|
const scaledAssets = {};
|
|
3933
2526
|
for (const file of files.sort((a, b) => getAssetPriority(b, context) - getAssetPriority(a, context))) {
|
|
3934
2527
|
const match = assetRegExp.exec(file);
|
|
@@ -3973,13 +2566,13 @@ function stripSuffix(assetPath, context) {
|
|
|
3973
2566
|
const basename = node_path.default.basename(assetPath);
|
|
3974
2567
|
const extension = node_path.default.extname(assetPath);
|
|
3975
2568
|
const suffixPattern = platformSuffixPattern(context);
|
|
3976
|
-
return basename.replace(
|
|
2569
|
+
return basename.replace(new RegExp(`(${SCALE_PATTERN})?(?:${suffixPattern})?${extension}$`), "");
|
|
3977
2570
|
}
|
|
3978
2571
|
function getAssetPriority(assetPath, context) {
|
|
3979
2572
|
const suffixPattern = platformSuffixPattern(context);
|
|
3980
|
-
if (
|
|
3981
|
-
else if (
|
|
3982
|
-
else if (
|
|
2573
|
+
if (new RegExp(`${SCALE_PATTERN}(?:${suffixPattern})`).test(assetPath)) return 3;
|
|
2574
|
+
else if (new RegExp(`(?:${suffixPattern})`).test(assetPath)) return 2;
|
|
2575
|
+
else if (new RegExp(`${SCALE_PATTERN}`).test(assetPath)) return 1;
|
|
3983
2576
|
return 0;
|
|
3984
2577
|
}
|
|
3985
2578
|
function addSuffix(assetPath, context, options) {
|
|
@@ -4062,10 +2655,10 @@ async function copyAssetsToDestination(options) {
|
|
|
4062
2655
|
return Promise.all(assets.map((asset) => {
|
|
4063
2656
|
return Promise.all(asset.scales.map(async (scale) => {
|
|
4064
2657
|
if (platform !== "android") {
|
|
4065
|
-
const from
|
|
4066
|
-
const to
|
|
4067
|
-
mkdirWithAssertPath(to
|
|
4068
|
-
return node_fs.default.copyFileSync(from
|
|
2658
|
+
const from = resolveAssetPath(asset.id, context, scale);
|
|
2659
|
+
const to = node_path.default.join(assetsDir, getIosAssetDestinationPath(asset, scale));
|
|
2660
|
+
mkdirWithAssertPath(to);
|
|
2661
|
+
return node_fs.default.copyFileSync(from, to);
|
|
4069
2662
|
}
|
|
4070
2663
|
const from = resolveAssetPath(asset.id, context, scale);
|
|
4071
2664
|
const to = node_path.default.join(assetsDir, getAndroidAssetDestinationPath(asset, scale));
|
|
@@ -4112,15 +2705,15 @@ function generateAssetRegistryCode(assetRegistryPath, asset) {
|
|
|
4112
2705
|
//#endregion
|
|
4113
2706
|
//#region src/core/plugins/utils/transform-utils.ts
|
|
4114
2707
|
const TRANSFORM_FLAGS_KEY = Symbol("transform-flags");
|
|
4115
|
-
let TransformFlag = /* @__PURE__ */ function(TransformFlag
|
|
4116
|
-
TransformFlag
|
|
4117
|
-
TransformFlag
|
|
4118
|
-
TransformFlag
|
|
4119
|
-
TransformFlag
|
|
4120
|
-
return TransformFlag
|
|
2708
|
+
let TransformFlag = /* @__PURE__ */ function(TransformFlag) {
|
|
2709
|
+
TransformFlag[TransformFlag["NONE"] = 0] = "NONE";
|
|
2710
|
+
TransformFlag[TransformFlag["CODEGEN_REQUIRED"] = 1] = "CODEGEN_REQUIRED";
|
|
2711
|
+
TransformFlag[TransformFlag["STRIP_FLOW_REQUIRED"] = 2] = "STRIP_FLOW_REQUIRED";
|
|
2712
|
+
TransformFlag[TransformFlag["SKIP_ALL"] = 128] = "SKIP_ALL";
|
|
2713
|
+
return TransformFlag;
|
|
4121
2714
|
}({});
|
|
4122
|
-
function setFlag(context, id
|
|
4123
|
-
const moduleInfo = context.getModuleInfo(id
|
|
2715
|
+
function setFlag(context, id, flag, options) {
|
|
2716
|
+
const moduleInfo = context.getModuleInfo(id);
|
|
4124
2717
|
if (moduleInfo && hasFlag(moduleInfo.meta)) {
|
|
4125
2718
|
if (options?.override) moduleInfo.meta[TRANSFORM_FLAGS_KEY] = flag;
|
|
4126
2719
|
else moduleInfo.meta[TRANSFORM_FLAGS_KEY] |= flag;
|
|
@@ -4130,8 +2723,8 @@ function setFlag(context, id$3, flag, options) {
|
|
|
4130
2723
|
function hasFlag(meta) {
|
|
4131
2724
|
return TRANSFORM_FLAGS_KEY in meta;
|
|
4132
2725
|
}
|
|
4133
|
-
function getFlag(context, id
|
|
4134
|
-
return getFlagFromModuleInfo(context.getModuleInfo(id
|
|
2726
|
+
function getFlag(context, id) {
|
|
2727
|
+
return getFlagFromModuleInfo(context.getModuleInfo(id));
|
|
4135
2728
|
}
|
|
4136
2729
|
function getFlagFromModuleInfo(moduleInfo) {
|
|
4137
2730
|
if (moduleInfo && hasFlag(moduleInfo.meta)) return moduleInfo.meta[TRANSFORM_FLAGS_KEY];
|
|
@@ -4144,18 +2737,18 @@ function withTransformBoundary(plugins, options) {
|
|
|
4144
2737
|
name: "rollipop:transform-initializer",
|
|
4145
2738
|
transform: {
|
|
4146
2739
|
order: "pre",
|
|
4147
|
-
handler(_code, id
|
|
4148
|
-
if (context.state.hmrUpdates.has(id
|
|
4149
|
-
context.state.hmrUpdates.delete(id
|
|
4150
|
-
return { meta: setFlag(this, id
|
|
2740
|
+
handler(_code, id) {
|
|
2741
|
+
if (context.state.hmrUpdates.has(id)) {
|
|
2742
|
+
context.state.hmrUpdates.delete(id);
|
|
2743
|
+
return { meta: setFlag(this, id, TransformFlag.NONE, { override: true }) };
|
|
4151
2744
|
}
|
|
4152
2745
|
}
|
|
4153
2746
|
}
|
|
4154
2747
|
},
|
|
4155
2748
|
{
|
|
4156
2749
|
name: "rollipop:transform-change-watcher",
|
|
4157
|
-
watchChange(id
|
|
4158
|
-
context.state.hmrUpdates.add(id
|
|
2750
|
+
watchChange(id) {
|
|
2751
|
+
context.state.hmrUpdates.add(id);
|
|
4159
2752
|
}
|
|
4160
2753
|
},
|
|
4161
2754
|
options?.beforeTransform,
|
|
@@ -4172,8 +2765,8 @@ function getPersistCachePlugins(options) {
|
|
|
4172
2765
|
afterTransform: null
|
|
4173
2766
|
};
|
|
4174
2767
|
const { sourceExtensions, context } = options;
|
|
4175
|
-
const includePattern =
|
|
4176
|
-
const filter = [(0, _rollipop_rolldown_pluginutils.exclude)((0, _rollipop_rolldown_pluginutils.id)(/@oxc-project\+runtime/)), (0, _rollipop_rolldown_pluginutils.include)((0, _rollipop_rolldown_pluginutils.id)(includePattern))];
|
|
2768
|
+
const includePattern = new RegExp(`\\.(?:${sourceExtensions.join("|")})$`);
|
|
2769
|
+
const filter = [(0, _rollipop_rolldown_pluginutils.exclude)((0, _rollipop_rolldown_pluginutils.or)((0, _rollipop_rolldown_pluginutils.id)(/rolldown\/runtime/), (0, _rollipop_rolldown_pluginutils.id)(/@oxc-project\+runtime/))), (0, _rollipop_rolldown_pluginutils.include)((0, _rollipop_rolldown_pluginutils.id)(includePattern))];
|
|
4177
2770
|
let cacheHits = 0;
|
|
4178
2771
|
return {
|
|
4179
2772
|
beforeTransform: {
|
|
@@ -4187,15 +2780,15 @@ function getPersistCachePlugins(options) {
|
|
|
4187
2780
|
transform: {
|
|
4188
2781
|
order: "pre",
|
|
4189
2782
|
filter,
|
|
4190
|
-
handler(_code, id
|
|
4191
|
-
const key = getCacheKey(id
|
|
2783
|
+
handler(_code, id) {
|
|
2784
|
+
const key = getCacheKey(id, context.id);
|
|
4192
2785
|
const cache = context.cache.get(key);
|
|
4193
2786
|
if (cache != null) {
|
|
4194
2787
|
cacheHits++;
|
|
4195
2788
|
return {
|
|
4196
2789
|
code: cache,
|
|
4197
2790
|
moduleType: "tsx",
|
|
4198
|
-
meta: setFlag(this, id
|
|
2791
|
+
meta: setFlag(this, id, TransformFlag.SKIP_ALL)
|
|
4199
2792
|
};
|
|
4200
2793
|
}
|
|
4201
2794
|
}
|
|
@@ -4206,9 +2799,9 @@ function getPersistCachePlugins(options) {
|
|
|
4206
2799
|
transform: {
|
|
4207
2800
|
order: "post",
|
|
4208
2801
|
filter,
|
|
4209
|
-
handler(code, id
|
|
4210
|
-
if (getFlag(this, id
|
|
4211
|
-
context.cache.set(getCacheKey(id
|
|
2802
|
+
handler(code, id) {
|
|
2803
|
+
if (getFlag(this, id) & TransformFlag.SKIP_ALL) return;
|
|
2804
|
+
context.cache.set(getCacheKey(id, context.id), code);
|
|
4212
2805
|
}
|
|
4213
2806
|
},
|
|
4214
2807
|
buildEnd() {
|
|
@@ -4217,60 +2810,60 @@ function getPersistCachePlugins(options) {
|
|
|
4217
2810
|
}
|
|
4218
2811
|
};
|
|
4219
2812
|
}
|
|
4220
|
-
function getCacheKey(id
|
|
4221
|
-
const { mtimeMs } = node_fs.default.statSync(id
|
|
4222
|
-
return xxhash(`${id
|
|
2813
|
+
function getCacheKey(id, buildHash) {
|
|
2814
|
+
const { mtimeMs } = node_fs.default.statSync(id);
|
|
2815
|
+
return xxhash(`${id}${buildHash}${mtimeMs}`);
|
|
4223
2816
|
}
|
|
4224
2817
|
/**
|
|
4225
2818
|
* Enhance a plugin to cache the result. (transform hook only)
|
|
4226
2819
|
*/
|
|
4227
|
-
function cacheable(plugin
|
|
2820
|
+
function cacheable(plugin) {
|
|
4228
2821
|
let configured = false;
|
|
4229
|
-
const originalTransform = plugin
|
|
2822
|
+
const originalTransform = plugin.transform;
|
|
4230
2823
|
if (typeof originalTransform === "function") {
|
|
4231
|
-
plugin
|
|
4232
|
-
if (getFlag(this, id
|
|
4233
|
-
return originalTransform.call(this, code, id
|
|
2824
|
+
plugin.transform = function(code, id, meta) {
|
|
2825
|
+
if (getFlag(this, id) & TransformFlag.SKIP_ALL) return;
|
|
2826
|
+
return originalTransform.call(this, code, id, meta);
|
|
4234
2827
|
};
|
|
4235
2828
|
configured = true;
|
|
4236
2829
|
}
|
|
4237
2830
|
if (typeof originalTransform === "object") {
|
|
4238
|
-
plugin
|
|
2831
|
+
plugin.transform = {
|
|
4239
2832
|
...originalTransform,
|
|
4240
|
-
handler(code, id
|
|
4241
|
-
if (getFlag(this, id
|
|
4242
|
-
return originalTransform.handler.call(this, code, id
|
|
2833
|
+
handler(code, id, meta) {
|
|
2834
|
+
if (getFlag(this, id) & TransformFlag.SKIP_ALL) return;
|
|
2835
|
+
return originalTransform.handler.call(this, code, id, meta);
|
|
4243
2836
|
}
|
|
4244
2837
|
};
|
|
4245
2838
|
configured = true;
|
|
4246
2839
|
}
|
|
4247
|
-
if (configured) plugin
|
|
4248
|
-
else logger$1.warn(`Plugin '${plugin
|
|
4249
|
-
return plugin
|
|
2840
|
+
if (configured) plugin.name = `${plugin.name}:cacheable`;
|
|
2841
|
+
else logger$1.warn(`Plugin '${plugin.name}' is could not be cached`);
|
|
2842
|
+
return plugin;
|
|
4250
2843
|
}
|
|
4251
2844
|
|
|
4252
2845
|
//#endregion
|
|
4253
2846
|
//#region src/core/plugins/utils/source.ts
|
|
4254
2847
|
const TS_EXTENSION_REGEXP = /\.tsx?$/;
|
|
4255
|
-
function isTS(id
|
|
4256
|
-
return TS_EXTENSION_REGEXP.test(id
|
|
2848
|
+
function isTS(id) {
|
|
2849
|
+
return TS_EXTENSION_REGEXP.test(id);
|
|
4257
2850
|
}
|
|
4258
|
-
function isJSX(id
|
|
4259
|
-
return id
|
|
2851
|
+
function isJSX(id) {
|
|
2852
|
+
return id.endsWith("x");
|
|
4260
2853
|
}
|
|
4261
2854
|
|
|
4262
2855
|
//#endregion
|
|
4263
2856
|
//#region src/core/plugins/react-native-plugin.ts
|
|
4264
2857
|
function reactNativePlugin(config, options) {
|
|
4265
2858
|
const { buildType, flowFilter, codegenFilter, assetsDir, assetExtensions, assetRegistryPath } = options;
|
|
4266
|
-
const assetExtensionRegex =
|
|
2859
|
+
const assetExtensionRegex = new RegExp(`\\.(?:${assetExtensions.join("|")})$`);
|
|
4267
2860
|
const codegenPlugin = {
|
|
4268
2861
|
name: "rollipop:react-native-codegen-marker",
|
|
4269
2862
|
transform: {
|
|
4270
2863
|
order: "pre",
|
|
4271
2864
|
filter: codegenFilter,
|
|
4272
|
-
handler(_code, id
|
|
4273
|
-
return { meta: setFlag(this, id
|
|
2865
|
+
handler(_code, id) {
|
|
2866
|
+
return { meta: setFlag(this, id, TransformFlag.CODEGEN_REQUIRED) };
|
|
4274
2867
|
}
|
|
4275
2868
|
}
|
|
4276
2869
|
};
|
|
@@ -4279,11 +2872,11 @@ function reactNativePlugin(config, options) {
|
|
|
4279
2872
|
transform: {
|
|
4280
2873
|
order: "pre",
|
|
4281
2874
|
filter: flowFilter,
|
|
4282
|
-
handler(code, id
|
|
4283
|
-
const flags = getFlag(this, id
|
|
2875
|
+
handler(code, id) {
|
|
2876
|
+
const flags = getFlag(this, id);
|
|
4284
2877
|
if (flags & TransformFlag.SKIP_ALL) return;
|
|
4285
|
-
if (flags & TransformFlag.CODEGEN_REQUIRED) return { meta: setFlag(this, id
|
|
4286
|
-
const result = generateSourceFromAst(stripFlowSyntax(code), id
|
|
2878
|
+
if (flags & TransformFlag.CODEGEN_REQUIRED) return { meta: setFlag(this, id, TransformFlag.STRIP_FLOW_REQUIRED) };
|
|
2879
|
+
const result = generateSourceFromAst(stripFlowSyntax(code), id);
|
|
4287
2880
|
return {
|
|
4288
2881
|
code: result.code,
|
|
4289
2882
|
map: result.map,
|
|
@@ -4297,18 +2890,18 @@ function reactNativePlugin(config, options) {
|
|
|
4297
2890
|
name: "rollipop:react-native-asset",
|
|
4298
2891
|
load: {
|
|
4299
2892
|
filter: [(0, _rollipop_rolldown_pluginutils.include)((0, _rollipop_rolldown_pluginutils.id)(assetExtensionRegex))],
|
|
4300
|
-
async handler(id
|
|
4301
|
-
this.debug(`Asset ${id
|
|
2893
|
+
async handler(id) {
|
|
2894
|
+
this.debug(`Asset ${id} found`);
|
|
4302
2895
|
const assetData = await resolveScaledAssets({
|
|
4303
2896
|
projectRoot: config.root,
|
|
4304
|
-
assetPath: id
|
|
2897
|
+
assetPath: id,
|
|
4305
2898
|
platform: options.platform,
|
|
4306
2899
|
preferNativePlatform: config.resolver.preferNativePlatform
|
|
4307
2900
|
});
|
|
4308
2901
|
assets.push(assetData);
|
|
4309
2902
|
return {
|
|
4310
2903
|
code: generateAssetRegistryCode(assetRegistryPath, assetData),
|
|
4311
|
-
meta: setFlag(this, id
|
|
2904
|
+
meta: setFlag(this, id, TransformFlag.SKIP_ALL),
|
|
4312
2905
|
moduleType: "js"
|
|
4313
2906
|
};
|
|
4314
2907
|
}
|
|
@@ -4336,15 +2929,15 @@ function reactNativePlugin(config, options) {
|
|
|
4336
2929
|
name: "rollipop:react-native-replace-hmr-client",
|
|
4337
2930
|
resolveId: {
|
|
4338
2931
|
filter: [(0, _rollipop_rolldown_pluginutils.include)((0, _rollipop_rolldown_pluginutils.id)(/\/HMRClient\.js$/))],
|
|
4339
|
-
async handler(id
|
|
4340
|
-
const resolvedId = await this.resolve(id
|
|
2932
|
+
async handler(id, importer) {
|
|
2933
|
+
const resolvedId = await this.resolve(id, importer, { skipSelf: true });
|
|
4341
2934
|
if (resolvedId?.id === hmrClientPath) await this.load({ id: resolvedId.id });
|
|
4342
2935
|
}
|
|
4343
2936
|
},
|
|
4344
2937
|
load: {
|
|
4345
2938
|
filter: [(0, _rollipop_rolldown_pluginutils.include)((0, _rollipop_rolldown_pluginutils.id)((0, _rollipop_rolldown_pluginutils.exactRegex)(hmrClientPath)))],
|
|
4346
|
-
handler(id
|
|
4347
|
-
this.debug(`Replacing HMR client: ${id
|
|
2939
|
+
handler(id) {
|
|
2940
|
+
this.debug(`Replacing HMR client: ${id}`);
|
|
4348
2941
|
return hmrConfig?.clientImplement ?? defaultRuntimeImplements.clientImplement;
|
|
4349
2942
|
}
|
|
4350
2943
|
}
|
|
@@ -4365,17 +2958,17 @@ const DEFAULT_EXCLUDE_REGEX = /\/node_modules\//;
|
|
|
4365
2958
|
const HAS_REFRESH_REGEX = /\$RefreshReg\$\(/;
|
|
4366
2959
|
const ONLY_REACT_COMPONENT_REGEX = /extends\s+(?:React\.)?(?:Pure)?Component/;
|
|
4367
2960
|
function reactRefreshPlugin(options) {
|
|
4368
|
-
const { include
|
|
2961
|
+
const { include = DEFAULT_INCLUDE_REGEX, exclude = DEFAULT_EXCLUDE_REGEX } = options ?? {};
|
|
4369
2962
|
return [{
|
|
4370
2963
|
name: "rollipop:transform-react-refresh",
|
|
4371
2964
|
transform: {
|
|
4372
2965
|
filter: { id: {
|
|
4373
|
-
include
|
|
4374
|
-
exclude
|
|
2966
|
+
include,
|
|
2967
|
+
exclude
|
|
4375
2968
|
} },
|
|
4376
|
-
handler(code, id
|
|
4377
|
-
if (getFlag(this, id
|
|
4378
|
-
const result = (0, _rollipop_rolldown_experimental.transformSync)(id
|
|
2969
|
+
handler(code, id) {
|
|
2970
|
+
if (getFlag(this, id) & TransformFlag.SKIP_ALL) return;
|
|
2971
|
+
const result = (0, _rollipop_rolldown_experimental.transformSync)(id, code, {
|
|
4379
2972
|
sourcemap: true,
|
|
4380
2973
|
jsx: {
|
|
4381
2974
|
runtime: "automatic",
|
|
@@ -4396,15 +2989,15 @@ function reactRefreshPlugin(options) {
|
|
|
4396
2989
|
name: "rollipop:react-refresh-boundary",
|
|
4397
2990
|
transform: {
|
|
4398
2991
|
filter: { id: {
|
|
4399
|
-
include
|
|
4400
|
-
exclude
|
|
2992
|
+
include,
|
|
2993
|
+
exclude
|
|
4401
2994
|
} },
|
|
4402
|
-
handler(code, id
|
|
4403
|
-
if (getFlag(this, id
|
|
2995
|
+
handler(code, id, meta) {
|
|
2996
|
+
if (getFlag(this, id) & TransformFlag.SKIP_ALL) return;
|
|
4404
2997
|
const { magicString } = meta;
|
|
4405
2998
|
(0, es_toolkit.invariant)(magicString != null, "magicString is not available");
|
|
4406
2999
|
applyRefreshWrapper(magicString, {
|
|
4407
|
-
id
|
|
3000
|
+
id,
|
|
4408
3001
|
hasRefresh: HAS_REFRESH_REGEX.test(code),
|
|
4409
3002
|
onlyReactComponent: ONLY_REACT_COMPONENT_REGEX.test(code)
|
|
4410
3003
|
});
|
|
@@ -4414,12 +3007,12 @@ function reactRefreshPlugin(options) {
|
|
|
4414
3007
|
}];
|
|
4415
3008
|
}
|
|
4416
3009
|
function applyRefreshWrapper(s, options) {
|
|
4417
|
-
const { id
|
|
3010
|
+
const { id, hasRefresh, onlyReactComponent } = options;
|
|
4418
3011
|
if (!(hasRefresh || onlyReactComponent)) return;
|
|
4419
3012
|
if (hasRefresh) s.prepend(`
|
|
4420
3013
|
var __prev$RefreshReg$ = global.$RefreshReg$;
|
|
4421
3014
|
var __prev$RefreshSig$ = global.$RefreshSig$;
|
|
4422
|
-
global.$RefreshReg$ = function(type, id) { return __ReactRefresh.register(type, ${JSON.stringify(id
|
|
3015
|
+
global.$RefreshReg$ = function(type, id) { return __ReactRefresh.register(type, ${JSON.stringify(id)} + ' ' + id) }
|
|
4423
3016
|
global.$RefreshSig$ = function() { return __ReactRefresh.createSignatureFunctionForTransform(); }
|
|
4424
3017
|
`);
|
|
4425
3018
|
s.append(`
|
|
@@ -4456,12 +3049,12 @@ function preludePlugin(options) {
|
|
|
4456
3049
|
meta: { [IS_ENTRY]: true }
|
|
4457
3050
|
};
|
|
4458
3051
|
} },
|
|
4459
|
-
load: { handler(id
|
|
3052
|
+
load: { handler(id) {
|
|
4460
3053
|
if (processed) return;
|
|
4461
|
-
const moduleInfo = this.getModuleInfo(id
|
|
3054
|
+
const moduleInfo = this.getModuleInfo(id);
|
|
4462
3055
|
if (moduleInfo && isEntry(moduleInfo.meta)) {
|
|
4463
|
-
this.debug(`Prelude plugin found entry ${id
|
|
4464
|
-
const modifiedSource = [preludeImportStatements, node_fs.default.readFileSync(id
|
|
3056
|
+
this.debug(`Prelude plugin found entry ${id}`);
|
|
3057
|
+
const modifiedSource = [preludeImportStatements, node_fs.default.readFileSync(id, "utf-8")].join("\n");
|
|
4465
3058
|
processed = true;
|
|
4466
3059
|
return modifiedSource;
|
|
4467
3060
|
}
|
|
@@ -4472,47 +3065,6 @@ function isEntry(meta) {
|
|
|
4472
3065
|
return IS_ENTRY in meta;
|
|
4473
3066
|
}
|
|
4474
3067
|
|
|
4475
|
-
//#endregion
|
|
4476
|
-
//#region src/core/plugins/status-plugin.ts
|
|
4477
|
-
function statusPlugin(options) {
|
|
4478
|
-
let totalModules = options?.initialTotalModules ?? 0;
|
|
4479
|
-
let startedAt = 0;
|
|
4480
|
-
let transformedModules = 0;
|
|
4481
|
-
let unknownTotalModules = totalModules === 0;
|
|
4482
|
-
return {
|
|
4483
|
-
name: "rollipop:status",
|
|
4484
|
-
buildStart() {
|
|
4485
|
-
startedAt = performance.now();
|
|
4486
|
-
transformedModules = 0;
|
|
4487
|
-
options?.onStart?.();
|
|
4488
|
-
},
|
|
4489
|
-
buildEnd(error) {
|
|
4490
|
-
if (transformedModules !== 0) totalModules = transformedModules;
|
|
4491
|
-
unknownTotalModules = false;
|
|
4492
|
-
options?.onEnd?.({
|
|
4493
|
-
error,
|
|
4494
|
-
totalModules,
|
|
4495
|
-
duration: performance.now() - startedAt
|
|
4496
|
-
});
|
|
4497
|
-
},
|
|
4498
|
-
transform: {
|
|
4499
|
-
order: "post",
|
|
4500
|
-
handler(_code, id$3) {
|
|
4501
|
-
++transformedModules;
|
|
4502
|
-
if (!unknownTotalModules && totalModules < transformedModules) totalModules = transformedModules;
|
|
4503
|
-
options?.onTransform?.({
|
|
4504
|
-
id: id$3,
|
|
4505
|
-
totalModules: unknownTotalModules ? void 0 : totalModules,
|
|
4506
|
-
transformedModules
|
|
4507
|
-
});
|
|
4508
|
-
}
|
|
4509
|
-
},
|
|
4510
|
-
watchChange(id$3) {
|
|
4511
|
-
options?.onWatchChange?.(id$3);
|
|
4512
|
-
}
|
|
4513
|
-
};
|
|
4514
|
-
}
|
|
4515
|
-
|
|
4516
3068
|
//#endregion
|
|
4517
3069
|
//#region src/core/plugins/json-plugin.ts
|
|
4518
3070
|
function jsonPlugin() {
|
|
@@ -4520,10 +3072,10 @@ function jsonPlugin() {
|
|
|
4520
3072
|
name: "rollipop:json",
|
|
4521
3073
|
load: {
|
|
4522
3074
|
filter: [(0, _rollipop_rolldown_pluginutils.include)((0, _rollipop_rolldown_pluginutils.id)(/\.json$/))],
|
|
4523
|
-
handler(id
|
|
3075
|
+
handler(id) {
|
|
4524
3076
|
return {
|
|
4525
|
-
code: `export = ${node_fs.default.readFileSync(id
|
|
4526
|
-
meta: setFlag(this, id
|
|
3077
|
+
code: `export = ${node_fs.default.readFileSync(id, "utf-8")};`,
|
|
3078
|
+
meta: setFlag(this, id, TransformFlag.SKIP_ALL),
|
|
4527
3079
|
moduleType: "ts"
|
|
4528
3080
|
};
|
|
4529
3081
|
}
|
|
@@ -4539,13 +3091,13 @@ function svgPlugin(options) {
|
|
|
4539
3091
|
name: "rollipop:svg",
|
|
4540
3092
|
load: {
|
|
4541
3093
|
filter: { id: /\.svg$/ },
|
|
4542
|
-
async handler(id
|
|
3094
|
+
async handler(id) {
|
|
4543
3095
|
return {
|
|
4544
|
-
code: await (0, _svgr_core.transform)(node_fs.default.readFileSync(id
|
|
3096
|
+
code: await (0, _svgr_core.transform)(node_fs.default.readFileSync(id, "utf-8"), {
|
|
4545
3097
|
template: defaultTemplate,
|
|
4546
3098
|
plugins: [require.resolve("@svgr/plugin-jsx")],
|
|
4547
3099
|
native: true
|
|
4548
|
-
}, { filePath: id
|
|
3100
|
+
}, { filePath: id }),
|
|
4549
3101
|
moduleType: "jsx"
|
|
4550
3102
|
};
|
|
4551
3103
|
}
|
|
@@ -4568,7 +3120,7 @@ export default ${SVG_COMPONENT_NAME};`;
|
|
|
4568
3120
|
//#endregion
|
|
4569
3121
|
//#region src/utils/babel.ts
|
|
4570
3122
|
function mergeBabelOptions(baseOptions, ...options) {
|
|
4571
|
-
return options.reduce((acc, options
|
|
3123
|
+
return options.reduce((acc, options) => (0, es_toolkit.mergeWith)(acc, options, merge$3), baseOptions);
|
|
4572
3124
|
}
|
|
4573
3125
|
function merge$3(target, source, key) {
|
|
4574
3126
|
if (key === "plugins") return [...target ?? [], ...source ?? []];
|
|
@@ -4580,47 +3132,47 @@ function merge$3(target, source, key) {
|
|
|
4580
3132
|
function babelPlugin(options) {
|
|
4581
3133
|
const { rules = [] } = options ?? {};
|
|
4582
3134
|
const babelOptionsById = /* @__PURE__ */ new Map();
|
|
4583
|
-
const babelRules = rules.map(({ filter, options
|
|
3135
|
+
const babelRules = rules.map(({ filter, options }, index) => {
|
|
4584
3136
|
return {
|
|
4585
3137
|
name: `rollipop:babel-rule-${index}`,
|
|
4586
3138
|
transform: {
|
|
4587
3139
|
filter,
|
|
4588
|
-
handler(code, id
|
|
4589
|
-
const existingBabelOptions = babelOptionsById.get(id
|
|
4590
|
-
const resolvedOptions = typeof options
|
|
4591
|
-
existingBabelOptions ? existingBabelOptions.push(resolvedOptions) : babelOptionsById.set(id
|
|
3140
|
+
handler(code, id) {
|
|
3141
|
+
const existingBabelOptions = babelOptionsById.get(id);
|
|
3142
|
+
const resolvedOptions = typeof options === "function" ? options(code, id) : options;
|
|
3143
|
+
existingBabelOptions ? existingBabelOptions.push(resolvedOptions) : babelOptionsById.set(id, [resolvedOptions]);
|
|
4592
3144
|
}
|
|
4593
3145
|
}
|
|
4594
3146
|
};
|
|
4595
3147
|
});
|
|
4596
|
-
const babelPlugin
|
|
3148
|
+
const babelPlugin = {
|
|
4597
3149
|
name: "rollipop:babel",
|
|
4598
3150
|
buildStart() {
|
|
4599
3151
|
babelOptionsById.clear();
|
|
4600
3152
|
},
|
|
4601
|
-
transform: { handler(code, id
|
|
4602
|
-
const flags = getFlag(this, id
|
|
3153
|
+
transform: { handler(code, id) {
|
|
3154
|
+
const flags = getFlag(this, id);
|
|
4603
3155
|
if (flags & TransformFlag.SKIP_ALL) return;
|
|
4604
|
-
const babelOptions = babelOptionsById.get(id
|
|
3156
|
+
const babelOptions = babelOptionsById.get(id) ?? [];
|
|
4605
3157
|
if (!(flags & TransformFlag.CODEGEN_REQUIRED || babelOptions.length > 0)) return;
|
|
4606
|
-
const baseOptions = getPreset$1(flags, id
|
|
3158
|
+
const baseOptions = getPreset$1(flags, id);
|
|
4607
3159
|
const result = _babel_core.transformSync(code, {
|
|
4608
|
-
filename: id
|
|
3160
|
+
filename: id,
|
|
4609
3161
|
babelrc: false,
|
|
4610
3162
|
configFile: false,
|
|
4611
3163
|
sourceMaps: true,
|
|
4612
3164
|
...mergeBabelOptions(baseOptions, ...babelOptions)
|
|
4613
3165
|
});
|
|
4614
|
-
(0, es_toolkit.invariant)(result?.code, `Failed to transform with babel: ${id
|
|
3166
|
+
(0, es_toolkit.invariant)(result?.code, `Failed to transform with babel: ${id}`);
|
|
4615
3167
|
return {
|
|
4616
3168
|
code: result.code,
|
|
4617
3169
|
map: result.map
|
|
4618
3170
|
};
|
|
4619
3171
|
} }
|
|
4620
3172
|
};
|
|
4621
|
-
return [...babelRules, babelPlugin
|
|
3173
|
+
return [...babelRules, babelPlugin].map(cacheable);
|
|
4622
3174
|
}
|
|
4623
|
-
function getPreset$1(flags, id
|
|
3175
|
+
function getPreset$1(flags, id) {
|
|
4624
3176
|
const presets = [];
|
|
4625
3177
|
const plugins = [];
|
|
4626
3178
|
let parserOpts = null;
|
|
@@ -4630,8 +3182,8 @@ function getPreset$1(flags, id$3) {
|
|
|
4630
3182
|
parseLangTypes: "flow",
|
|
4631
3183
|
reactRuntimeTarget: "19"
|
|
4632
3184
|
}], require.resolve("@babel/plugin-transform-flow-strip-types"));
|
|
4633
|
-
} else if (isTS(id
|
|
4634
|
-
isTSX: isJSX(id
|
|
3185
|
+
} else if (isTS(id)) plugins.push([require.resolve("@babel/plugin-transform-typescript"), {
|
|
3186
|
+
isTSX: isJSX(id),
|
|
4635
3187
|
allowNamespaces: true
|
|
4636
3188
|
}]);
|
|
4637
3189
|
if (flags & TransformFlag.CODEGEN_REQUIRED) plugins.push([require.resolve("@react-native/babel-plugin-codegen")]);
|
|
@@ -4646,7 +3198,7 @@ function getPreset$1(flags, id$3) {
|
|
|
4646
3198
|
//#endregion
|
|
4647
3199
|
//#region src/utils/swc.ts
|
|
4648
3200
|
function mergeSwcOptions(baseOptions, ...options) {
|
|
4649
|
-
return options.reduce((acc, options
|
|
3201
|
+
return options.reduce((acc, options) => (0, es_toolkit.mergeWith)(acc, options, merge$2), baseOptions);
|
|
4650
3202
|
}
|
|
4651
3203
|
function merge$2(target, source, key) {
|
|
4652
3204
|
if (key === "plugins") return [...target ?? [], ...source ?? []];
|
|
@@ -4657,30 +3209,30 @@ function merge$2(target, source, key) {
|
|
|
4657
3209
|
function swcPlugin(options) {
|
|
4658
3210
|
const { rules = [] } = options ?? {};
|
|
4659
3211
|
const swcOptionsById = /* @__PURE__ */ new Map();
|
|
4660
|
-
const swcRules = rules.map(({ filter, options
|
|
3212
|
+
const swcRules = rules.map(({ filter, options }, index) => {
|
|
4661
3213
|
return {
|
|
4662
3214
|
name: `rollipop:swc-rule-${index}`,
|
|
4663
3215
|
transform: {
|
|
4664
3216
|
filter,
|
|
4665
|
-
handler(code, id
|
|
4666
|
-
const existingBabelOptions = swcOptionsById.get(id
|
|
4667
|
-
const resolvedOptions = typeof options
|
|
4668
|
-
existingBabelOptions ? existingBabelOptions.push(resolvedOptions) : swcOptionsById.set(id
|
|
3217
|
+
handler(code, id) {
|
|
3218
|
+
const existingBabelOptions = swcOptionsById.get(id);
|
|
3219
|
+
const resolvedOptions = typeof options === "function" ? options(code, id) : options;
|
|
3220
|
+
existingBabelOptions ? existingBabelOptions.push(resolvedOptions) : swcOptionsById.set(id, [resolvedOptions]);
|
|
4669
3221
|
}
|
|
4670
3222
|
}
|
|
4671
3223
|
};
|
|
4672
3224
|
});
|
|
4673
|
-
const swcPlugin
|
|
3225
|
+
const swcPlugin = {
|
|
4674
3226
|
name: "rollipop:swc",
|
|
4675
3227
|
buildStart() {
|
|
4676
3228
|
swcOptionsById.clear();
|
|
4677
3229
|
},
|
|
4678
|
-
transform: { handler(code, id
|
|
4679
|
-
if (getFlag(this, id
|
|
4680
|
-
const swcOptions = swcOptionsById.get(id
|
|
3230
|
+
transform: { handler(code, id) {
|
|
3231
|
+
if (getFlag(this, id) & TransformFlag.SKIP_ALL) return;
|
|
3232
|
+
const swcOptions = swcOptionsById.get(id) ?? [];
|
|
4681
3233
|
const baseOptions = getPreset();
|
|
4682
3234
|
const result = _swc_core.transformSync(code, {
|
|
4683
|
-
filename: id
|
|
3235
|
+
filename: id,
|
|
4684
3236
|
configFile: false,
|
|
4685
3237
|
swcrc: false,
|
|
4686
3238
|
sourceMaps: true,
|
|
@@ -4693,7 +3245,7 @@ function swcPlugin(options) {
|
|
|
4693
3245
|
};
|
|
4694
3246
|
} }
|
|
4695
3247
|
};
|
|
4696
|
-
return [...swcRules, swcPlugin
|
|
3248
|
+
return [...swcRules, swcPlugin].map(cacheable);
|
|
4697
3249
|
}
|
|
4698
3250
|
function getPreset() {
|
|
4699
3251
|
return {
|
|
@@ -4715,14 +3267,64 @@ function getPreset() {
|
|
|
4715
3267
|
};
|
|
4716
3268
|
}
|
|
4717
3269
|
|
|
3270
|
+
//#endregion
|
|
3271
|
+
//#region src/core/plugins/reporter-plugin.ts
|
|
3272
|
+
function reporterPlugin(options) {
|
|
3273
|
+
const { reporter, initialTotalModules = 0 } = options ?? {};
|
|
3274
|
+
let totalModules = initialTotalModules;
|
|
3275
|
+
let startedAt = 0;
|
|
3276
|
+
let transformedModules = 0;
|
|
3277
|
+
let unknownTotalModules = totalModules === 0;
|
|
3278
|
+
return {
|
|
3279
|
+
name: "rollipop:status",
|
|
3280
|
+
buildStart() {
|
|
3281
|
+
startedAt = performance.now();
|
|
3282
|
+
transformedModules = 0;
|
|
3283
|
+
reporter?.update({ type: "bundle_build_started" });
|
|
3284
|
+
},
|
|
3285
|
+
buildEnd(error) {
|
|
3286
|
+
const endedAt = performance.now();
|
|
3287
|
+
if (transformedModules !== 0) totalModules = transformedModules;
|
|
3288
|
+
unknownTotalModules = false;
|
|
3289
|
+
reporter?.update(error == null ? {
|
|
3290
|
+
type: "bundle_build_done",
|
|
3291
|
+
totalModules,
|
|
3292
|
+
duration: endedAt - startedAt
|
|
3293
|
+
} : {
|
|
3294
|
+
type: "bundle_build_failed",
|
|
3295
|
+
error
|
|
3296
|
+
});
|
|
3297
|
+
},
|
|
3298
|
+
transform: {
|
|
3299
|
+
order: "post",
|
|
3300
|
+
handler(_code, id) {
|
|
3301
|
+
++transformedModules;
|
|
3302
|
+
if (!unknownTotalModules && totalModules < transformedModules) totalModules = transformedModules;
|
|
3303
|
+
reporter?.update({
|
|
3304
|
+
type: "transform",
|
|
3305
|
+
id,
|
|
3306
|
+
totalModules: unknownTotalModules ? void 0 : totalModules,
|
|
3307
|
+
transformedModules
|
|
3308
|
+
});
|
|
3309
|
+
}
|
|
3310
|
+
},
|
|
3311
|
+
watchChange(id) {
|
|
3312
|
+
reporter?.update({
|
|
3313
|
+
type: "watch_change",
|
|
3314
|
+
id
|
|
3315
|
+
});
|
|
3316
|
+
}
|
|
3317
|
+
};
|
|
3318
|
+
}
|
|
3319
|
+
|
|
4718
3320
|
//#endregion
|
|
4719
3321
|
//#region src/core/rolldown.ts
|
|
4720
3322
|
resolveRolldownOptions.cache = /* @__PURE__ */ new Map();
|
|
4721
3323
|
async function resolveRolldownOptions(context, config, buildOptions, devEngineOptions) {
|
|
4722
3324
|
const cachedOptions = resolveRolldownOptions.cache.get(context.id);
|
|
4723
3325
|
if (cachedOptions != null) return cachedOptions;
|
|
4724
|
-
const { platform, dev
|
|
4725
|
-
const isDevServerMode = dev
|
|
3326
|
+
const { platform, dev, cache } = buildOptions;
|
|
3327
|
+
const isDevServerMode = dev && context.buildType === "serve";
|
|
4726
3328
|
(0, es_toolkit.invariant)(isDevServerMode ? devEngineOptions != null : true, "devEngineOptions is required in dev server mode");
|
|
4727
3329
|
const env = loadEnv(config);
|
|
4728
3330
|
const builtInEnv = {
|
|
@@ -4732,7 +3334,7 @@ async function resolveRolldownOptions(context, config, buildOptions, devEngineOp
|
|
|
4732
3334
|
const { sourceExtensions, assetExtensions, preferNativePlatform, external: rolldownExternal, ...rolldownResolve } = config.resolver;
|
|
4733
3335
|
const { prelude: preludePaths, polyfills, banner: rolldownBanner, footer: rolldownFooter, postBanner: rolldownPostBanner, postFooter: rolldownPostFooter, intro: rolldownIntro, outro: rolldownOutro, shimMissingExports: rolldownShimMissingExports } = config.serializer;
|
|
4734
3336
|
const { flow, babel: babelConfig, swc: swcConfig, ...rolldownTransform } = config.transformer;
|
|
4735
|
-
const { treeshake: rolldownTreeshake, minify: rolldownMinify, ...rolldownOptimization } = config.optimization;
|
|
3337
|
+
const { treeshake: rolldownTreeshake, minify: rolldownMinify, lazyBarrel: rolldownLazyBarrel, ...rolldownOptimization } = config.optimization;
|
|
4736
3338
|
const { codegen, assetRegistryPath, globalIdentifiers: rolldownGlobalIdentifiers } = config.reactNative;
|
|
4737
3339
|
const { sourcemap: rolldownSourcemap, sourcemapBaseUrl: rolldownSourcemapBaseUrl, sourcemapDebugIds: rolldownSourcemapDebugIds, sourcemapIgnoreList: rolldownSourcemapIgnoreList, sourcemapPathTransform: rolldownSourcemapPathTransform } = config;
|
|
4738
3340
|
const transformSvg = config.transformer.svg;
|
|
@@ -4749,12 +3351,12 @@ async function resolveRolldownOptions(context, config, buildOptions, devEngineOp
|
|
|
4749
3351
|
target: "es2015",
|
|
4750
3352
|
jsx: {
|
|
4751
3353
|
runtime: "automatic",
|
|
4752
|
-
development: dev
|
|
3354
|
+
development: dev
|
|
4753
3355
|
},
|
|
4754
3356
|
define: {
|
|
4755
|
-
__DEV__: asLiteral(dev
|
|
3357
|
+
__DEV__: asLiteral(dev),
|
|
4756
3358
|
global: asIdentifier(GLOBAL_IDENTIFIER),
|
|
4757
|
-
"process.env.NODE_ENV": asLiteral(nodeEnvironment(dev
|
|
3359
|
+
"process.env.NODE_ENV": asLiteral(nodeEnvironment(dev)),
|
|
4758
3360
|
"process.env.DEBUG_ROLLIPOP": asLiteral(isDebugEnabled()),
|
|
4759
3361
|
...defineEnvFromObject(env),
|
|
4760
3362
|
...defineEnvFromObject(builtInEnv)
|
|
@@ -4769,14 +3371,16 @@ async function resolveRolldownOptions(context, config, buildOptions, devEngineOp
|
|
|
4769
3371
|
sourceExtensions,
|
|
4770
3372
|
context
|
|
4771
3373
|
});
|
|
4772
|
-
const
|
|
3374
|
+
const defaultReporters = [(() => {
|
|
4773
3375
|
switch (config.terminal.status) {
|
|
4774
|
-
case "compat": return
|
|
4775
|
-
case "progress": return
|
|
4776
|
-
case "none":
|
|
4777
|
-
default: return statusPresets.none(config.reporter);
|
|
3376
|
+
case "compat": return new CompatStatusReporter();
|
|
3377
|
+
case "progress": return new ProgressBarStatusReporter(context.id, `[${platform}, ${buildOptions.dev ? "dev" : "prod"}]`, getBuildTotalModules(context.storage, context.id));
|
|
4778
3378
|
}
|
|
4779
|
-
})();
|
|
3379
|
+
})()];
|
|
3380
|
+
const reporterOptions = {
|
|
3381
|
+
initialTotalModules: getBuildTotalModules(context.storage, context.id),
|
|
3382
|
+
reporter: mergeReporters([...defaultReporters, config.reporter].filter(es_toolkit.isNotNil))
|
|
3383
|
+
};
|
|
4780
3384
|
const finalOptions = await applyDangerouslyOverrideOptionsFinalizer(config, {
|
|
4781
3385
|
platform: "neutral",
|
|
4782
3386
|
cwd: config.root,
|
|
@@ -4788,10 +3392,11 @@ async function resolveRolldownOptions(context, config, buildOptions, devEngineOp
|
|
|
4788
3392
|
treeshake: rolldownTreeshake,
|
|
4789
3393
|
external: rolldownExternal,
|
|
4790
3394
|
shimMissingExports: rolldownShimMissingExports,
|
|
3395
|
+
experimental: { lazyBarrel: rolldownLazyBarrel },
|
|
4791
3396
|
plugins: withTransformBoundary([
|
|
4792
3397
|
preludePlugin({ modulePaths: preludePaths }),
|
|
4793
3398
|
reactNativePlugin(config, {
|
|
4794
|
-
dev
|
|
3399
|
+
dev,
|
|
4795
3400
|
platform,
|
|
4796
3401
|
buildType: context.buildType,
|
|
4797
3402
|
codegenFilter: codegen.filter,
|
|
@@ -4804,7 +3409,7 @@ async function resolveRolldownOptions(context, config, buildOptions, devEngineOp
|
|
|
4804
3409
|
svgPlugin({ enabled: transformSvg }),
|
|
4805
3410
|
babelPlugin(babelConfig),
|
|
4806
3411
|
swcPlugin(swcConfig),
|
|
4807
|
-
|
|
3412
|
+
reporterPlugin(reporterOptions),
|
|
4808
3413
|
devServerPlugins,
|
|
4809
3414
|
config.plugins
|
|
4810
3415
|
], {
|
|
@@ -4831,19 +3436,18 @@ async function resolveRolldownOptions(context, config, buildOptions, devEngineOp
|
|
|
4831
3436
|
outro: rolldownOutro,
|
|
4832
3437
|
intro: async (chunk) => {
|
|
4833
3438
|
return [
|
|
4834
|
-
...getGlobalVariables(dev
|
|
3439
|
+
...getGlobalVariables(dev, context.buildType),
|
|
4835
3440
|
...loadPolyfills(polyfills),
|
|
4836
3441
|
typeof rolldownIntro === "function" ? await rolldownIntro(chunk) : rolldownIntro
|
|
4837
3442
|
].filter(es_toolkit.isNotNil).join("\n");
|
|
4838
3443
|
},
|
|
4839
|
-
keepNames: dev$1,
|
|
4840
3444
|
minify: buildOptions.minify ?? rolldownMinify,
|
|
4841
3445
|
sourcemap: buildOptions.sourcemap ?? rolldownSourcemap,
|
|
4842
3446
|
sourcemapBaseUrl: rolldownSourcemapBaseUrl,
|
|
4843
3447
|
sourcemapDebugIds: rolldownSourcemapDebugIds,
|
|
4844
3448
|
sourcemapIgnoreList: rolldownSourcemapIgnoreList,
|
|
4845
3449
|
sourcemapPathTransform: rolldownSourcemapPathTransform,
|
|
4846
|
-
|
|
3450
|
+
codeSplitting: false,
|
|
4847
3451
|
strictExecutionOrder: true,
|
|
4848
3452
|
globalIdentifiers: rolldownGlobalIdentifiers
|
|
4849
3453
|
});
|
|
@@ -4852,16 +3456,16 @@ async function resolveRolldownOptions(context, config, buildOptions, devEngineOp
|
|
|
4852
3456
|
}
|
|
4853
3457
|
function getResolveExtensions({ platform, sourceExtensions, assetExtensions, preferNativePlatform }) {
|
|
4854
3458
|
const supportedExtensions = [...sourceExtensions, ...assetExtensions];
|
|
4855
|
-
return [...[platform, preferNativePlatform ? "native" : null].filter(es_toolkit.isNotNil).map((platform
|
|
4856
|
-
return supportedExtensions.map((extension) => `.${platform
|
|
3459
|
+
return [...[platform, preferNativePlatform ? "native" : null].filter(es_toolkit.isNotNil).map((platform) => {
|
|
3460
|
+
return supportedExtensions.map((extension) => `.${platform}.${extension}`);
|
|
4857
3461
|
}), ...supportedExtensions.map((extension) => `.${extension}`)].flat();
|
|
4858
3462
|
}
|
|
4859
3463
|
function loadPolyfills(polyfills) {
|
|
4860
3464
|
return polyfills.map((polyfill) => {
|
|
4861
3465
|
if (typeof polyfill === "string") return node_fs.default.readFileSync(polyfill, "utf-8");
|
|
4862
|
-
const path
|
|
3466
|
+
const path = "path" in polyfill ? polyfill.path : void 0;
|
|
4863
3467
|
const content = "code" in polyfill ? polyfill.code : node_fs.default.readFileSync(polyfill.path, "utf-8");
|
|
4864
|
-
return polyfill.type === "iife" ? iife(content, path
|
|
3468
|
+
return polyfill.type === "iife" ? iife(content, path) : content;
|
|
4865
3469
|
});
|
|
4866
3470
|
}
|
|
4867
3471
|
async function applyDangerouslyOverrideOptionsFinalizer(config, inputOptions, outputOptions) {
|
|
@@ -4921,11 +3525,11 @@ var Bundler = class Bundler {
|
|
|
4921
3525
|
return createId(config, buildOptions);
|
|
4922
3526
|
}
|
|
4923
3527
|
static createContext(buildType, config, buildOptions) {
|
|
4924
|
-
const id
|
|
3528
|
+
const id = Bundler.createId(config, buildOptions);
|
|
4925
3529
|
return {
|
|
4926
|
-
id
|
|
3530
|
+
id,
|
|
4927
3531
|
root: config.root,
|
|
4928
|
-
cache: new FileSystemCache(config.root, id
|
|
3532
|
+
cache: new FileSystemCache(config.root, id),
|
|
4929
3533
|
storage: FileStorage.getInstance(config.root),
|
|
4930
3534
|
buildType,
|
|
4931
3535
|
state: { hmrUpdates: /* @__PURE__ */ new Set() }
|
|
@@ -5216,7 +3820,6 @@ const command = {
|
|
|
5216
3820
|
//#endregion
|
|
5217
3821
|
//#region src/commands.ts
|
|
5218
3822
|
const commands = [createReactNativeCliCommand(command$1), createReactNativeCliCommand(command)];
|
|
5219
|
-
var commands_default = commands;
|
|
5220
3823
|
|
|
5221
3824
|
//#endregion
|
|
5222
|
-
module.exports =
|
|
3825
|
+
module.exports = commands;
|