@lvce-editor/main-process 4.0.0 → 4.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -5,15 +5,16 @@ import { fileURLToPath } from 'node:url';
5
5
  import { inspect } from 'node:util';
6
6
  import { spawn } from 'node:child_process';
7
7
  import { Console } from 'node:console';
8
- import { createWriteStream, readFileSync } from 'node:fs';
8
+ import { createWriteStream, readFileSync, existsSync } from 'node:fs';
9
9
  import { tmpdir, homedir } from 'node:os';
10
10
  import * as NodePath from 'node:path';
11
- import { dirname } from 'node:path';
12
- import require$$1 from 'tty';
13
- import require$$1$1 from 'util';
14
- import require$$0 from 'os';
11
+ import { dirname, join as join$1 } from 'node:path';
15
12
  import { MessageChannel } from 'node:worker_threads';
16
13
 
14
+ const scheme = 'lvce-oss';
15
+ const applicationName = 'lvce-oss';
16
+ const WebView = 'lvce-oss-webview';
17
+
17
18
  function escapeStringRegexp(string) {
18
19
  if (typeof string !== 'string') {
19
20
  throw new TypeError('Expected a string');
@@ -3381,12 +3382,13 @@ const {
3381
3382
  const isLinux = platform === 'linux';
3382
3383
  const isProduction = false;
3383
3384
  const homeDirectory = homedir();
3384
- const applicationName = 'lvce-oss';
3385
+
3385
3386
  const xdgCache = env.XDG_CACHE_HOME || (homeDirectory ? join(homeDirectory, '.cache') : undefined);
3386
3387
  const xdgData = env.XDG_DATA_HOME || (homeDirectory ? join(homeDirectory, '.local', 'share') : undefined);
3387
3388
  join(xdgData || tmpdir(), applicationName);
3388
3389
  const chromeUserDataPath = xdgCache ? join(xdgCache, applicationName, 'userdata') : '';
3389
- const scheme = 'lvce-oss';
3390
+
3391
+ const useIpcForResponse = false;
3390
3392
  const getSessionId = () => {
3391
3393
  return process.env.SESSION_ID || `persist:${scheme}`;
3392
3394
  };
@@ -3596,974 +3598,6 @@ const enable$1 = parsedCliArgs => {
3596
3598
  setLocale('en');
3597
3599
  };
3598
3600
 
3599
- var src = {exports: {}};
3600
-
3601
- var browser = {exports: {}};
3602
-
3603
- /**
3604
- * Helpers.
3605
- */
3606
-
3607
- var ms;
3608
- var hasRequiredMs;
3609
-
3610
- function requireMs () {
3611
- if (hasRequiredMs) return ms;
3612
- hasRequiredMs = 1;
3613
- var s = 1000;
3614
- var m = s * 60;
3615
- var h = m * 60;
3616
- var d = h * 24;
3617
- var w = d * 7;
3618
- var y = d * 365.25;
3619
-
3620
- /**
3621
- * Parse or format the given `val`.
3622
- *
3623
- * Options:
3624
- *
3625
- * - `long` verbose formatting [false]
3626
- *
3627
- * @param {String|Number} val
3628
- * @param {Object} [options]
3629
- * @throws {Error} throw an error if val is not a non-empty string or a number
3630
- * @return {String|Number}
3631
- * @api public
3632
- */
3633
-
3634
- ms = function (val, options) {
3635
- options = options || {};
3636
- var type = typeof val;
3637
- if (type === 'string' && val.length > 0) {
3638
- return parse(val);
3639
- } else if (type === 'number' && isFinite(val)) {
3640
- return options.long ? fmtLong(val) : fmtShort(val);
3641
- }
3642
- throw new Error('val is not a non-empty string or a valid number. val=' + JSON.stringify(val));
3643
- };
3644
-
3645
- /**
3646
- * Parse the given `str` and return milliseconds.
3647
- *
3648
- * @param {String} str
3649
- * @return {Number}
3650
- * @api private
3651
- */
3652
-
3653
- function parse(str) {
3654
- str = String(str);
3655
- if (str.length > 100) {
3656
- return;
3657
- }
3658
- var match = /^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(str);
3659
- if (!match) {
3660
- return;
3661
- }
3662
- var n = parseFloat(match[1]);
3663
- var type = (match[2] || 'ms').toLowerCase();
3664
- switch (type) {
3665
- case 'years':
3666
- case 'year':
3667
- case 'yrs':
3668
- case 'yr':
3669
- case 'y':
3670
- return n * y;
3671
- case 'weeks':
3672
- case 'week':
3673
- case 'w':
3674
- return n * w;
3675
- case 'days':
3676
- case 'day':
3677
- case 'd':
3678
- return n * d;
3679
- case 'hours':
3680
- case 'hour':
3681
- case 'hrs':
3682
- case 'hr':
3683
- case 'h':
3684
- return n * h;
3685
- case 'minutes':
3686
- case 'minute':
3687
- case 'mins':
3688
- case 'min':
3689
- case 'm':
3690
- return n * m;
3691
- case 'seconds':
3692
- case 'second':
3693
- case 'secs':
3694
- case 'sec':
3695
- case 's':
3696
- return n * s;
3697
- case 'milliseconds':
3698
- case 'millisecond':
3699
- case 'msecs':
3700
- case 'msec':
3701
- case 'ms':
3702
- return n;
3703
- default:
3704
- return undefined;
3705
- }
3706
- }
3707
-
3708
- /**
3709
- * Short format for `ms`.
3710
- *
3711
- * @param {Number} ms
3712
- * @return {String}
3713
- * @api private
3714
- */
3715
-
3716
- function fmtShort(ms) {
3717
- var msAbs = Math.abs(ms);
3718
- if (msAbs >= d) {
3719
- return Math.round(ms / d) + 'd';
3720
- }
3721
- if (msAbs >= h) {
3722
- return Math.round(ms / h) + 'h';
3723
- }
3724
- if (msAbs >= m) {
3725
- return Math.round(ms / m) + 'm';
3726
- }
3727
- if (msAbs >= s) {
3728
- return Math.round(ms / s) + 's';
3729
- }
3730
- return ms + 'ms';
3731
- }
3732
-
3733
- /**
3734
- * Long format for `ms`.
3735
- *
3736
- * @param {Number} ms
3737
- * @return {String}
3738
- * @api private
3739
- */
3740
-
3741
- function fmtLong(ms) {
3742
- var msAbs = Math.abs(ms);
3743
- if (msAbs >= d) {
3744
- return plural(ms, msAbs, d, 'day');
3745
- }
3746
- if (msAbs >= h) {
3747
- return plural(ms, msAbs, h, 'hour');
3748
- }
3749
- if (msAbs >= m) {
3750
- return plural(ms, msAbs, m, 'minute');
3751
- }
3752
- if (msAbs >= s) {
3753
- return plural(ms, msAbs, s, 'second');
3754
- }
3755
- return ms + ' ms';
3756
- }
3757
-
3758
- /**
3759
- * Pluralization helper.
3760
- */
3761
-
3762
- function plural(ms, msAbs, n, name) {
3763
- var isPlural = msAbs >= n * 1.5;
3764
- return Math.round(ms / n) + ' ' + name + (isPlural ? 's' : '');
3765
- }
3766
- return ms;
3767
- }
3768
-
3769
- /**
3770
- * This is the common logic for both the Node.js and web browser
3771
- * implementations of `debug()`.
3772
- */
3773
-
3774
- var common;
3775
- var hasRequiredCommon;
3776
-
3777
- function requireCommon () {
3778
- if (hasRequiredCommon) return common;
3779
- hasRequiredCommon = 1;
3780
- function setup(env) {
3781
- createDebug.debug = createDebug;
3782
- createDebug.default = createDebug;
3783
- createDebug.coerce = coerce;
3784
- createDebug.disable = disable;
3785
- createDebug.enable = enable;
3786
- createDebug.enabled = enabled;
3787
- createDebug.humanize = requireMs();
3788
- createDebug.destroy = destroy;
3789
- Object.keys(env).forEach(key => {
3790
- createDebug[key] = env[key];
3791
- });
3792
-
3793
- /**
3794
- * The currently active debug mode names, and names to skip.
3795
- */
3796
-
3797
- createDebug.names = [];
3798
- createDebug.skips = [];
3799
-
3800
- /**
3801
- * Map of special "%n" handling functions, for the debug "format" argument.
3802
- *
3803
- * Valid key names are a single, lower or upper-case letter, i.e. "n" and "N".
3804
- */
3805
- createDebug.formatters = {};
3806
-
3807
- /**
3808
- * Selects a color for a debug namespace
3809
- * @param {String} namespace The namespace string for the debug instance to be colored
3810
- * @return {Number|String} An ANSI color code for the given namespace
3811
- * @api private
3812
- */
3813
- function selectColor(namespace) {
3814
- let hash = 0;
3815
- for (let i = 0; i < namespace.length; i++) {
3816
- hash = (hash << 5) - hash + namespace.charCodeAt(i);
3817
- hash |= 0; // Convert to 32bit integer
3818
- }
3819
- return createDebug.colors[Math.abs(hash) % createDebug.colors.length];
3820
- }
3821
- createDebug.selectColor = selectColor;
3822
-
3823
- /**
3824
- * Create a debugger with the given `namespace`.
3825
- *
3826
- * @param {String} namespace
3827
- * @return {Function}
3828
- * @api public
3829
- */
3830
- function createDebug(namespace) {
3831
- let prevTime;
3832
- let enableOverride = null;
3833
- let namespacesCache;
3834
- let enabledCache;
3835
- function debug(...args) {
3836
- // Disabled?
3837
- if (!debug.enabled) {
3838
- return;
3839
- }
3840
- const self = debug;
3841
-
3842
- // Set `diff` timestamp
3843
- const curr = Number(new Date());
3844
- const ms = curr - (prevTime || curr);
3845
- self.diff = ms;
3846
- self.prev = prevTime;
3847
- self.curr = curr;
3848
- prevTime = curr;
3849
- args[0] = createDebug.coerce(args[0]);
3850
- if (typeof args[0] !== 'string') {
3851
- // Anything else let's inspect with %O
3852
- args.unshift('%O');
3853
- }
3854
-
3855
- // Apply any `formatters` transformations
3856
- let index = 0;
3857
- args[0] = args[0].replace(/%([a-zA-Z%])/g, (match, format) => {
3858
- // If we encounter an escaped % then don't increase the array index
3859
- if (match === '%%') {
3860
- return '%';
3861
- }
3862
- index++;
3863
- const formatter = createDebug.formatters[format];
3864
- if (typeof formatter === 'function') {
3865
- const val = args[index];
3866
- match = formatter.call(self, val);
3867
-
3868
- // Now we need to remove `args[index]` since it's inlined in the `format`
3869
- args.splice(index, 1);
3870
- index--;
3871
- }
3872
- return match;
3873
- });
3874
-
3875
- // Apply env-specific formatting (colors, etc.)
3876
- createDebug.formatArgs.call(self, args);
3877
- const logFn = self.log || createDebug.log;
3878
- logFn.apply(self, args);
3879
- }
3880
- debug.namespace = namespace;
3881
- debug.useColors = createDebug.useColors();
3882
- debug.color = createDebug.selectColor(namespace);
3883
- debug.extend = extend;
3884
- debug.destroy = createDebug.destroy; // XXX Temporary. Will be removed in the next major release.
3885
-
3886
- Object.defineProperty(debug, 'enabled', {
3887
- enumerable: true,
3888
- configurable: false,
3889
- get: () => {
3890
- if (enableOverride !== null) {
3891
- return enableOverride;
3892
- }
3893
- if (namespacesCache !== createDebug.namespaces) {
3894
- namespacesCache = createDebug.namespaces;
3895
- enabledCache = createDebug.enabled(namespace);
3896
- }
3897
- return enabledCache;
3898
- },
3899
- set: v => {
3900
- enableOverride = v;
3901
- }
3902
- });
3903
-
3904
- // Env-specific initialization logic for debug instances
3905
- if (typeof createDebug.init === 'function') {
3906
- createDebug.init(debug);
3907
- }
3908
- return debug;
3909
- }
3910
- function extend(namespace, delimiter) {
3911
- const newDebug = createDebug(this.namespace + (typeof delimiter === 'undefined' ? ':' : delimiter) + namespace);
3912
- newDebug.log = this.log;
3913
- return newDebug;
3914
- }
3915
-
3916
- /**
3917
- * Enables a debug mode by namespaces. This can include modes
3918
- * separated by a colon and wildcards.
3919
- *
3920
- * @param {String} namespaces
3921
- * @api public
3922
- */
3923
- function enable(namespaces) {
3924
- createDebug.save(namespaces);
3925
- createDebug.namespaces = namespaces;
3926
- createDebug.names = [];
3927
- createDebug.skips = [];
3928
- const split = (typeof namespaces === 'string' ? namespaces : '').trim().replace(/\s+/g, ',').split(',').filter(Boolean);
3929
- for (const ns of split) {
3930
- if (ns[0] === '-') {
3931
- createDebug.skips.push(ns.slice(1));
3932
- } else {
3933
- createDebug.names.push(ns);
3934
- }
3935
- }
3936
- }
3937
-
3938
- /**
3939
- * Checks if the given string matches a namespace template, honoring
3940
- * asterisks as wildcards.
3941
- *
3942
- * @param {String} search
3943
- * @param {String} template
3944
- * @return {Boolean}
3945
- */
3946
- function matchesTemplate(search, template) {
3947
- let searchIndex = 0;
3948
- let templateIndex = 0;
3949
- let starIndex = -1;
3950
- let matchIndex = 0;
3951
- while (searchIndex < search.length) {
3952
- if (templateIndex < template.length && (template[templateIndex] === search[searchIndex] || template[templateIndex] === '*')) {
3953
- // Match character or proceed with wildcard
3954
- if (template[templateIndex] === '*') {
3955
- starIndex = templateIndex;
3956
- matchIndex = searchIndex;
3957
- templateIndex++; // Skip the '*'
3958
- } else {
3959
- searchIndex++;
3960
- templateIndex++;
3961
- }
3962
- } else if (starIndex !== -1) {
3963
- // eslint-disable-line no-negated-condition
3964
- // Backtrack to the last '*' and try to match more characters
3965
- templateIndex = starIndex + 1;
3966
- matchIndex++;
3967
- searchIndex = matchIndex;
3968
- } else {
3969
- return false; // No match
3970
- }
3971
- }
3972
-
3973
- // Handle trailing '*' in template
3974
- while (templateIndex < template.length && template[templateIndex] === '*') {
3975
- templateIndex++;
3976
- }
3977
- return templateIndex === template.length;
3978
- }
3979
-
3980
- /**
3981
- * Disable debug output.
3982
- *
3983
- * @return {String} namespaces
3984
- * @api public
3985
- */
3986
- function disable() {
3987
- const namespaces = [...createDebug.names, ...createDebug.skips.map(namespace => '-' + namespace)].join(',');
3988
- createDebug.enable('');
3989
- return namespaces;
3990
- }
3991
-
3992
- /**
3993
- * Returns true if the given mode name is enabled, false otherwise.
3994
- *
3995
- * @param {String} name
3996
- * @return {Boolean}
3997
- * @api public
3998
- */
3999
- function enabled(name) {
4000
- for (const skip of createDebug.skips) {
4001
- if (matchesTemplate(name, skip)) {
4002
- return false;
4003
- }
4004
- }
4005
- for (const ns of createDebug.names) {
4006
- if (matchesTemplate(name, ns)) {
4007
- return true;
4008
- }
4009
- }
4010
- return false;
4011
- }
4012
-
4013
- /**
4014
- * Coerce `val`.
4015
- *
4016
- * @param {Mixed} val
4017
- * @return {Mixed}
4018
- * @api private
4019
- */
4020
- function coerce(val) {
4021
- if (val instanceof Error) {
4022
- return val.stack || val.message;
4023
- }
4024
- return val;
4025
- }
4026
-
4027
- /**
4028
- * XXX DO NOT USE. This is a temporary stub function.
4029
- * XXX It WILL be removed in the next major release.
4030
- */
4031
- function destroy() {
4032
- console.warn('Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.');
4033
- }
4034
- createDebug.enable(createDebug.load());
4035
- return createDebug;
4036
- }
4037
- common = setup;
4038
- return common;
4039
- }
4040
-
4041
- /* eslint-env browser */
4042
-
4043
- var hasRequiredBrowser;
4044
-
4045
- function requireBrowser () {
4046
- if (hasRequiredBrowser) return browser.exports;
4047
- hasRequiredBrowser = 1;
4048
- (function (module, exports$1) {
4049
- /**
4050
- * This is the web browser implementation of `debug()`.
4051
- */
4052
-
4053
- exports$1.formatArgs = formatArgs;
4054
- exports$1.save = save;
4055
- exports$1.load = load;
4056
- exports$1.useColors = useColors;
4057
- exports$1.storage = localstorage();
4058
- exports$1.destroy = (() => {
4059
- let warned = false;
4060
- return () => {
4061
- if (!warned) {
4062
- warned = true;
4063
- console.warn('Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.');
4064
- }
4065
- };
4066
- })();
4067
-
4068
- /**
4069
- * Colors.
4070
- */
4071
-
4072
- exports$1.colors = ['#0000CC', '#0000FF', '#0033CC', '#0033FF', '#0066CC', '#0066FF', '#0099CC', '#0099FF', '#00CC00', '#00CC33', '#00CC66', '#00CC99', '#00CCCC', '#00CCFF', '#3300CC', '#3300FF', '#3333CC', '#3333FF', '#3366CC', '#3366FF', '#3399CC', '#3399FF', '#33CC00', '#33CC33', '#33CC66', '#33CC99', '#33CCCC', '#33CCFF', '#6600CC', '#6600FF', '#6633CC', '#6633FF', '#66CC00', '#66CC33', '#9900CC', '#9900FF', '#9933CC', '#9933FF', '#99CC00', '#99CC33', '#CC0000', '#CC0033', '#CC0066', '#CC0099', '#CC00CC', '#CC00FF', '#CC3300', '#CC3333', '#CC3366', '#CC3399', '#CC33CC', '#CC33FF', '#CC6600', '#CC6633', '#CC9900', '#CC9933', '#CCCC00', '#CCCC33', '#FF0000', '#FF0033', '#FF0066', '#FF0099', '#FF00CC', '#FF00FF', '#FF3300', '#FF3333', '#FF3366', '#FF3399', '#FF33CC', '#FF33FF', '#FF6600', '#FF6633', '#FF9900', '#FF9933', '#FFCC00', '#FFCC33'];
4073
-
4074
- /**
4075
- * Currently only WebKit-based Web Inspectors, Firefox >= v31,
4076
- * and the Firebug extension (any Firefox version) are known
4077
- * to support "%c" CSS customizations.
4078
- *
4079
- * TODO: add a `localStorage` variable to explicitly enable/disable colors
4080
- */
4081
-
4082
- // eslint-disable-next-line complexity
4083
- function useColors() {
4084
- // NB: In an Electron preload script, document will be defined but not fully
4085
- // initialized. Since we know we're in Chrome, we'll just detect this case
4086
- // explicitly
4087
- if (typeof window !== 'undefined' && window.process && (window.process.type === 'renderer' || window.process.__nwjs)) {
4088
- return true;
4089
- }
4090
-
4091
- // Internet Explorer and Edge do not support colors.
4092
- if (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)) {
4093
- return false;
4094
- }
4095
- let m;
4096
-
4097
- // Is webkit? http://stackoverflow.com/a/16459606/376773
4098
- // document is undefined in react-native: https://github.com/facebook/react-native/pull/1632
4099
- // eslint-disable-next-line no-return-assign
4100
- return typeof document !== 'undefined' && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance ||
4101
- // Is firebug? http://stackoverflow.com/a/398120/376773
4102
- typeof window !== 'undefined' && window.console && (window.console.firebug || window.console.exception && window.console.table) ||
4103
- // Is firefox >= v31?
4104
- // https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages
4105
- typeof navigator !== 'undefined' && navigator.userAgent && (m = navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)) && parseInt(m[1], 10) >= 31 ||
4106
- // Double check webkit in userAgent just in case we are in a worker
4107
- typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/);
4108
- }
4109
-
4110
- /**
4111
- * Colorize log arguments if enabled.
4112
- *
4113
- * @api public
4114
- */
4115
-
4116
- function formatArgs(args) {
4117
- args[0] = (this.useColors ? '%c' : '') + this.namespace + (this.useColors ? ' %c' : ' ') + args[0] + (this.useColors ? '%c ' : ' ') + '+' + module.exports.humanize(this.diff);
4118
- if (!this.useColors) {
4119
- return;
4120
- }
4121
- const c = 'color: ' + this.color;
4122
- args.splice(1, 0, c, 'color: inherit');
4123
-
4124
- // The final "%c" is somewhat tricky, because there could be other
4125
- // arguments passed either before or after the %c, so we need to
4126
- // figure out the correct index to insert the CSS into
4127
- let index = 0;
4128
- let lastC = 0;
4129
- args[0].replace(/%[a-zA-Z%]/g, match => {
4130
- if (match === '%%') {
4131
- return;
4132
- }
4133
- index++;
4134
- if (match === '%c') {
4135
- // We only are interested in the *last* %c
4136
- // (the user may have provided their own)
4137
- lastC = index;
4138
- }
4139
- });
4140
- args.splice(lastC, 0, c);
4141
- }
4142
-
4143
- /**
4144
- * Invokes `console.debug()` when available.
4145
- * No-op when `console.debug` is not a "function".
4146
- * If `console.debug` is not available, falls back
4147
- * to `console.log`.
4148
- *
4149
- * @api public
4150
- */
4151
- exports$1.log = console.debug || console.log || (() => {});
4152
-
4153
- /**
4154
- * Save `namespaces`.
4155
- *
4156
- * @param {String} namespaces
4157
- * @api private
4158
- */
4159
- function save(namespaces) {
4160
- try {
4161
- if (namespaces) {
4162
- exports$1.storage.setItem('debug', namespaces);
4163
- } else {
4164
- exports$1.storage.removeItem('debug');
4165
- }
4166
- } catch (error) {
4167
- // Swallow
4168
- // XXX (@Qix-) should we be logging these?
4169
- }
4170
- }
4171
-
4172
- /**
4173
- * Load `namespaces`.
4174
- *
4175
- * @return {String} returns the previously persisted debug modes
4176
- * @api private
4177
- */
4178
- function load() {
4179
- let r;
4180
- try {
4181
- r = exports$1.storage.getItem('debug') || exports$1.storage.getItem('DEBUG');
4182
- } catch (error) {
4183
- // Swallow
4184
- // XXX (@Qix-) should we be logging these?
4185
- }
4186
-
4187
- // If debug isn't set in LS, and we're in Electron, try to load $DEBUG
4188
- if (!r && typeof process !== 'undefined' && 'env' in process) {
4189
- r = process.env.DEBUG;
4190
- }
4191
- return r;
4192
- }
4193
-
4194
- /**
4195
- * Localstorage attempts to return the localstorage.
4196
- *
4197
- * This is necessary because safari throws
4198
- * when a user disables cookies/localstorage
4199
- * and you attempt to access it.
4200
- *
4201
- * @return {LocalStorage}
4202
- * @api private
4203
- */
4204
-
4205
- function localstorage() {
4206
- try {
4207
- // TVMLKit (Apple TV JS Runtime) does not have a window object, just localStorage in the global context
4208
- // The Browser also has localStorage in the global context.
4209
- return localStorage;
4210
- } catch (error) {
4211
- // Swallow
4212
- // XXX (@Qix-) should we be logging these?
4213
- }
4214
- }
4215
- module.exports = requireCommon()(exports$1);
4216
- const {
4217
- formatters
4218
- } = module.exports;
4219
-
4220
- /**
4221
- * Map %j to `JSON.stringify()`, since no Web Inspectors do that by default.
4222
- */
4223
-
4224
- formatters.j = function (v) {
4225
- try {
4226
- return JSON.stringify(v);
4227
- } catch (error) {
4228
- return '[UnexpectedJSONParseError]: ' + error.message;
4229
- }
4230
- };
4231
- } (browser, browser.exports));
4232
- return browser.exports;
4233
- }
4234
-
4235
- var node = {exports: {}};
4236
-
4237
- var hasFlag;
4238
- var hasRequiredHasFlag;
4239
-
4240
- function requireHasFlag () {
4241
- if (hasRequiredHasFlag) return hasFlag;
4242
- hasRequiredHasFlag = 1;
4243
-
4244
- hasFlag = (flag, argv = process.argv) => {
4245
- const prefix = flag.startsWith('-') ? '' : flag.length === 1 ? '-' : '--';
4246
- const position = argv.indexOf(prefix + flag);
4247
- const terminatorPosition = argv.indexOf('--');
4248
- return position !== -1 && (terminatorPosition === -1 || position < terminatorPosition);
4249
- };
4250
- return hasFlag;
4251
- }
4252
-
4253
- var supportsColor_1;
4254
- var hasRequiredSupportsColor;
4255
-
4256
- function requireSupportsColor () {
4257
- if (hasRequiredSupportsColor) return supportsColor_1;
4258
- hasRequiredSupportsColor = 1;
4259
-
4260
- const os = require$$0;
4261
- const tty = require$$1;
4262
- const hasFlag = requireHasFlag();
4263
- const {
4264
- env
4265
- } = process;
4266
- let forceColor;
4267
- if (hasFlag('no-color') || hasFlag('no-colors') || hasFlag('color=false') || hasFlag('color=never')) {
4268
- forceColor = 0;
4269
- } else if (hasFlag('color') || hasFlag('colors') || hasFlag('color=true') || hasFlag('color=always')) {
4270
- forceColor = 1;
4271
- }
4272
- if ('FORCE_COLOR' in env) {
4273
- if (env.FORCE_COLOR === 'true') {
4274
- forceColor = 1;
4275
- } else if (env.FORCE_COLOR === 'false') {
4276
- forceColor = 0;
4277
- } else {
4278
- forceColor = env.FORCE_COLOR.length === 0 ? 1 : Math.min(parseInt(env.FORCE_COLOR, 10), 3);
4279
- }
4280
- }
4281
- function translateLevel(level) {
4282
- if (level === 0) {
4283
- return false;
4284
- }
4285
- return {
4286
- level,
4287
- hasBasic: true,
4288
- has256: level >= 2,
4289
- has16m: level >= 3
4290
- };
4291
- }
4292
- function supportsColor(haveStream, streamIsTTY) {
4293
- if (forceColor === 0) {
4294
- return 0;
4295
- }
4296
- if (hasFlag('color=16m') || hasFlag('color=full') || hasFlag('color=truecolor')) {
4297
- return 3;
4298
- }
4299
- if (hasFlag('color=256')) {
4300
- return 2;
4301
- }
4302
- if (haveStream && !streamIsTTY && forceColor === undefined) {
4303
- return 0;
4304
- }
4305
- const min = forceColor || 0;
4306
- if (env.TERM === 'dumb') {
4307
- return min;
4308
- }
4309
- if (process.platform === 'win32') {
4310
- // Windows 10 build 10586 is the first Windows release that supports 256 colors.
4311
- // Windows 10 build 14931 is the first release that supports 16m/TrueColor.
4312
- const osRelease = os.release().split('.');
4313
- if (Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) {
4314
- return Number(osRelease[2]) >= 14931 ? 3 : 2;
4315
- }
4316
- return 1;
4317
- }
4318
- if ('CI' in env) {
4319
- if (['TRAVIS', 'CIRCLECI', 'APPVEYOR', 'GITLAB_CI', 'GITHUB_ACTIONS', 'BUILDKITE'].some(sign => sign in env) || env.CI_NAME === 'codeship') {
4320
- return 1;
4321
- }
4322
- return min;
4323
- }
4324
- if ('TEAMCITY_VERSION' in env) {
4325
- return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0;
4326
- }
4327
- if (env.COLORTERM === 'truecolor') {
4328
- return 3;
4329
- }
4330
- if ('TERM_PROGRAM' in env) {
4331
- const version = parseInt((env.TERM_PROGRAM_VERSION || '').split('.')[0], 10);
4332
- switch (env.TERM_PROGRAM) {
4333
- case 'iTerm.app':
4334
- return version >= 3 ? 3 : 2;
4335
- case 'Apple_Terminal':
4336
- return 2;
4337
- // No default
4338
- }
4339
- }
4340
- if (/-256(color)?$/i.test(env.TERM)) {
4341
- return 2;
4342
- }
4343
- if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM)) {
4344
- return 1;
4345
- }
4346
- if ('COLORTERM' in env) {
4347
- return 1;
4348
- }
4349
- return min;
4350
- }
4351
- function getSupportLevel(stream) {
4352
- const level = supportsColor(stream, stream && stream.isTTY);
4353
- return translateLevel(level);
4354
- }
4355
- supportsColor_1 = {
4356
- supportsColor: getSupportLevel,
4357
- stdout: translateLevel(supportsColor(true, tty.isatty(1))),
4358
- stderr: translateLevel(supportsColor(true, tty.isatty(2)))
4359
- };
4360
- return supportsColor_1;
4361
- }
4362
-
4363
- /**
4364
- * Module dependencies.
4365
- */
4366
-
4367
- var hasRequiredNode;
4368
-
4369
- function requireNode () {
4370
- if (hasRequiredNode) return node.exports;
4371
- hasRequiredNode = 1;
4372
- (function (module, exports$1) {
4373
- const tty = require$$1;
4374
- const util = require$$1$1;
4375
-
4376
- /**
4377
- * This is the Node.js implementation of `debug()`.
4378
- */
4379
-
4380
- exports$1.init = init;
4381
- exports$1.log = log;
4382
- exports$1.formatArgs = formatArgs;
4383
- exports$1.save = save;
4384
- exports$1.load = load;
4385
- exports$1.useColors = useColors;
4386
- exports$1.destroy = util.deprecate(() => {}, 'Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.');
4387
-
4388
- /**
4389
- * Colors.
4390
- */
4391
-
4392
- exports$1.colors = [6, 2, 3, 4, 5, 1];
4393
- try {
4394
- // Optional dependency (as in, doesn't need to be installed, NOT like optionalDependencies in package.json)
4395
- // eslint-disable-next-line import/no-extraneous-dependencies
4396
- const supportsColor = requireSupportsColor();
4397
- if (supportsColor && (supportsColor.stderr || supportsColor).level >= 2) {
4398
- exports$1.colors = [20, 21, 26, 27, 32, 33, 38, 39, 40, 41, 42, 43, 44, 45, 56, 57, 62, 63, 68, 69, 74, 75, 76, 77, 78, 79, 80, 81, 92, 93, 98, 99, 112, 113, 128, 129, 134, 135, 148, 149, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 178, 179, 184, 185, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 214, 215, 220, 221];
4399
- }
4400
- } catch (error) {
4401
- // Swallow - we only care if `supports-color` is available; it doesn't have to be.
4402
- }
4403
-
4404
- /**
4405
- * Build up the default `inspectOpts` object from the environment variables.
4406
- *
4407
- * $ DEBUG_COLORS=no DEBUG_DEPTH=10 DEBUG_SHOW_HIDDEN=enabled node script.js
4408
- */
4409
-
4410
- exports$1.inspectOpts = Object.keys(process.env).filter(key => {
4411
- return /^debug_/i.test(key);
4412
- }).reduce((obj, key) => {
4413
- // Camel-case
4414
- const prop = key.substring(6).toLowerCase().replace(/_([a-z])/g, (_, k) => {
4415
- return k.toUpperCase();
4416
- });
4417
-
4418
- // Coerce string value into JS value
4419
- let val = process.env[key];
4420
- if (/^(yes|on|true|enabled)$/i.test(val)) {
4421
- val = true;
4422
- } else if (/^(no|off|false|disabled)$/i.test(val)) {
4423
- val = false;
4424
- } else if (val === 'null') {
4425
- val = null;
4426
- } else {
4427
- val = Number(val);
4428
- }
4429
- obj[prop] = val;
4430
- return obj;
4431
- }, {});
4432
-
4433
- /**
4434
- * Is stdout a TTY? Colored output is enabled when `true`.
4435
- */
4436
-
4437
- function useColors() {
4438
- return 'colors' in exports$1.inspectOpts ? Boolean(exports$1.inspectOpts.colors) : tty.isatty(process.stderr.fd);
4439
- }
4440
-
4441
- /**
4442
- * Adds ANSI color escape codes if enabled.
4443
- *
4444
- * @api public
4445
- */
4446
-
4447
- function formatArgs(args) {
4448
- const {
4449
- namespace: name,
4450
- useColors
4451
- } = this;
4452
- if (useColors) {
4453
- const c = this.color;
4454
- const colorCode = '\u001B[3' + (c < 8 ? c : '8;5;' + c);
4455
- const prefix = ` ${colorCode};1m${name} \u001B[0m`;
4456
- args[0] = prefix + args[0].split('\n').join('\n' + prefix);
4457
- args.push(colorCode + 'm+' + module.exports.humanize(this.diff) + '\u001B[0m');
4458
- } else {
4459
- args[0] = getDate() + name + ' ' + args[0];
4460
- }
4461
- }
4462
- function getDate() {
4463
- if (exports$1.inspectOpts.hideDate) {
4464
- return '';
4465
- }
4466
- return new Date().toISOString() + ' ';
4467
- }
4468
-
4469
- /**
4470
- * Invokes `util.formatWithOptions()` with the specified arguments and writes to stderr.
4471
- */
4472
-
4473
- function log(...args) {
4474
- return process.stderr.write(util.formatWithOptions(exports$1.inspectOpts, ...args) + '\n');
4475
- }
4476
-
4477
- /**
4478
- * Save `namespaces`.
4479
- *
4480
- * @param {String} namespaces
4481
- * @api private
4482
- */
4483
- function save(namespaces) {
4484
- if (namespaces) {
4485
- process.env.DEBUG = namespaces;
4486
- } else {
4487
- // If you set a process.env field to null or undefined, it gets cast to the
4488
- // string 'null' or 'undefined'. Just delete instead.
4489
- delete process.env.DEBUG;
4490
- }
4491
- }
4492
-
4493
- /**
4494
- * Load `namespaces`.
4495
- *
4496
- * @return {String} returns the previously persisted debug modes
4497
- * @api private
4498
- */
4499
-
4500
- function load() {
4501
- return process.env.DEBUG;
4502
- }
4503
-
4504
- /**
4505
- * Init logic for `debug` instances.
4506
- *
4507
- * Create a new `inspectOpts` object in case `useColors` is set
4508
- * differently for a particular `debug` instance.
4509
- */
4510
-
4511
- function init(debug) {
4512
- debug.inspectOpts = {};
4513
- const keys = Object.keys(exports$1.inspectOpts);
4514
- for (let i = 0; i < keys.length; i++) {
4515
- debug.inspectOpts[keys[i]] = exports$1.inspectOpts[keys[i]];
4516
- }
4517
- }
4518
- module.exports = requireCommon()(exports$1);
4519
- const {
4520
- formatters
4521
- } = module.exports;
4522
-
4523
- /**
4524
- * Map %o to `util.inspect()`, all on a single line.
4525
- */
4526
-
4527
- formatters.o = function (v) {
4528
- this.inspectOpts.colors = this.useColors;
4529
- return util.inspect(v, this.inspectOpts).split('\n').map(str => str.trim()).join(' ');
4530
- };
4531
-
4532
- /**
4533
- * Map %O to `util.inspect()`, allowing multiple lines if needed.
4534
- */
4535
-
4536
- formatters.O = function (v) {
4537
- this.inspectOpts.colors = this.useColors;
4538
- return util.inspect(v, this.inspectOpts);
4539
- };
4540
- } (node, node.exports));
4541
- return node.exports;
4542
- }
4543
-
4544
- /**
4545
- * Detect Electron renderer / nwjs process, which is node, but we should
4546
- * treat as a browser.
4547
- */
4548
-
4549
- var hasRequiredSrc;
4550
-
4551
- function requireSrc () {
4552
- if (hasRequiredSrc) return src.exports;
4553
- hasRequiredSrc = 1;
4554
- if (typeof process === 'undefined' || process.type === 'renderer' || process.browser === true || process.__nwjs) {
4555
- src.exports = requireBrowser();
4556
- } else {
4557
- src.exports = requireNode();
4558
- }
4559
- return src.exports;
4560
- }
4561
-
4562
- var srcExports = requireSrc();
4563
- const debugModule = /*@__PURE__*/getDefaultExportFromCjs(srcExports);
4564
-
4565
- const debug = debugModule('main-process');
4566
-
4567
3601
  const BeforeQuit = 'before-quit';
4568
3602
  const SecondInstance = 'second-instance';
4569
3603
  const WindowAllClosed = 'window-all-closed';
@@ -4619,7 +3653,6 @@ const setShutDown = () => {
4619
3653
  // TODO move this function to shared process
4620
3654
  const handleBeforeQuit = () => {
4621
3655
  setShutDown();
4622
- debug('[info] before quit');
4623
3656
  };
4624
3657
 
4625
3658
  const handleReady = async (parsedArgs, workingDirectory) => {
@@ -4869,7 +3902,6 @@ const parseCliArgs = argv => {
4869
3902
  sandbox: false
4870
3903
  }
4871
3904
  };
4872
- debug('[info] parsing argv');
4873
3905
  const relevantArgv = argv.slice(1);
4874
3906
  const parsedArgs = minimist(relevantArgv, CLI_OPTIONS);
4875
3907
  // TODO tree-shake this out
@@ -4881,9 +3913,7 @@ const parseCliArgs = argv => {
4881
3913
 
4882
3914
  const handleSecondInstance = async (event, commandLine, workingDirectory, additionalData // additionalData is the actual process.argv https://github.com/electron/electron/pull/30891
4883
3915
  ) => {
4884
- debug('[info] second instance');
4885
3916
  const parsedArgs = parseCliArgs(additionalData);
4886
- debug('[info] second instance args', additionalData, parsedArgs);
4887
3917
  const moduleId = canHandleFastCliArgs(parsedArgs);
4888
3918
  const handled = await handleFastCliArgs(moduleId, parsedArgs); // TODO don't like the side effect here
4889
3919
  if (handled) {
@@ -4907,6 +3937,9 @@ const openPath = async path => {
4907
3937
  // TODO handle error
4908
3938
  await shell.openPath(path);
4909
3939
  };
3940
+ const openExternal$1 = async url => {
3941
+ await shell.openExternal(url);
3942
+ };
4910
3943
 
4911
3944
  const ContextMenu = 'context-menu';
4912
3945
  const WillNavigate = 'will-navigate';
@@ -4966,7 +3999,7 @@ const handleWebContentsWindowOpen = ({
4966
3999
  url
4967
4000
  }) => {
4968
4001
  // @ts-ignore
4969
- void undefined(url);
4002
+ void openExternal$1(url);
4970
4003
  return {
4971
4004
  action: Deny
4972
4005
  };
@@ -5006,9 +4039,9 @@ const isProtocolHandleApiSupported = protocol => {
5006
4039
  return false;
5007
4040
  };
5008
4041
 
5009
- const WebView = 'lvce-oss-webview';
5010
4042
 
5011
- const privilegedSchems = [{
4043
+
4044
+ const privilegedSchemes = [{
5012
4045
  privileges: {
5013
4046
  codeCache: true,
5014
4047
  secure: true,
@@ -5036,7 +4069,7 @@ const handle = (protocol, name, handleRequest) => {
5036
4069
  throw new Error('protocol.handle api is not supported');
5037
4070
  };
5038
4071
  const enable = protocol => {
5039
- protocol.registerSchemesAsPrivileged(privilegedSchems);
4072
+ protocol.registerSchemesAsPrivileged(privilegedSchemes);
5040
4073
  };
5041
4074
 
5042
4075
  const requestSingleInstanceLock = argv => {
@@ -5079,7 +4112,6 @@ const hydrate = async (isLinux, chromeUserDataPath, argv) => {
5079
4112
  }
5080
4113
  const hasLock = requestSingleInstanceLock(argv);
5081
4114
  if (!hasLock) {
5082
- debug('[info] quitting because no lock');
5083
4115
  exit();
5084
4116
  return;
5085
4117
  }
@@ -5107,7 +4139,6 @@ const hydrate = async (isLinux, chromeUserDataPath, argv) => {
5107
4139
  await whenReady();
5108
4140
  mark(AppReady);
5109
4141
  await handleReady(parsedCliArgs, cwd());
5110
- debug('[info] app window created');
5111
4142
  };
5112
4143
 
5113
4144
  const {
@@ -5147,12 +4178,50 @@ const handlePermissionCheck$1 = (webContents, permission, origin, details) => {
5147
4178
  return isAllowed;
5148
4179
  };
5149
4180
 
5150
- /**
5151
- *
5152
- * @param {string} url
5153
- * @param {any} request
5154
- */
5155
- const getElectronFileResponse = async (url, request) => {
4181
+ let config;
4182
+ const createConfig = () => {
4183
+ const configPath = join$1(root, 'config.json');
4184
+ const config = readFileSync(configPath, 'utf8');
4185
+ const parsedConfig = JSON.parse(config);
4186
+ return parsedConfig;
4187
+ };
4188
+ const getOrCreateConfig = () => {
4189
+ if (!config) {
4190
+ config = createConfig();
4191
+ }
4192
+ return config;
4193
+ };
4194
+
4195
+ const getElectronFileResponseConfig = async (url, request) => {
4196
+ const parsedConfig = getOrCreateConfig();
4197
+ const {
4198
+ files,
4199
+ headers
4200
+ } = parsedConfig;
4201
+ const relative = url.slice(scheme.length + 4);
4202
+ const actual = relative === '/' ? '/index.html' : relative;
4203
+ const match = files[actual];
4204
+ if (!match) {
4205
+ return new Response('Not Found', {
4206
+ status: 404
4207
+ });
4208
+ }
4209
+ const responseHeaders = headers[match];
4210
+ const absolutePath = join$1(root, 'static', actual);
4211
+ if (!existsSync(absolutePath)) {
4212
+ return new Response('Not Found', {
4213
+ status: 404
4214
+ });
4215
+ }
4216
+ const content = readFileSync(absolutePath, 'utf8');
4217
+ const response = new Response(content, {
4218
+ headers: responseHeaders,
4219
+ status: 200
4220
+ });
4221
+ return response;
4222
+ };
4223
+
4224
+ const getElectronFileResponseIpc = async (url, request) => {
5156
4225
  const {
5157
4226
  body,
5158
4227
  init
@@ -5161,6 +4230,13 @@ const getElectronFileResponse = async (url, request) => {
5161
4230
  return response;
5162
4231
  };
5163
4232
 
4233
+ const getElectronFileResponse = async (url, request) => {
4234
+ if (useIpcForResponse()) {
4235
+ return getElectronFileResponseIpc(url, request);
4236
+ }
4237
+ return getElectronFileResponseConfig(url);
4238
+ };
4239
+
5164
4240
  /**
5165
4241
  *
5166
4242
  * @param {Headers} headers
@@ -6839,7 +5915,6 @@ const cancelNavigation = view => {
6839
5915
  webContents
6840
5916
  } = view;
6841
5917
  setCanceled(webContents.id);
6842
- debug(`[main process] canceled navigation to ${webContents.getURL()}`);
6843
5918
  webContents.stop();
6844
5919
  if (webContents.navigationHistory.canGoBack()) {
6845
5920
  webContents.navigationHistory.goBack();
@@ -6849,7 +5924,6 @@ const show = id => {
6849
5924
  // console.log('[main-process] show browser view', id)
6850
5925
  const state = get$3(id);
6851
5926
  if (!state) {
6852
- debug('[main-process] failed to show browser view', id);
6853
5927
  return;
6854
5928
  }
6855
5929
  const {
@@ -6872,7 +5946,6 @@ const addToWindow = (browserWindowId, browserViewId) => {
6872
5946
  const hide = id => {
6873
5947
  const state = get$3(id);
6874
5948
  if (!state) {
6875
- debug('[main-process] failed to hide browser view', id);
6876
5949
  return;
6877
5950
  }
6878
5951
  const {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/main-process",
3
- "version": "4.0.0",
3
+ "version": "4.2.0",
4
4
  "keywords": [
5
5
  "lvce-editor",
6
6
  "electron"