@lvce-editor/renderer-process 30.41.0 → 30.41.2

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.
@@ -2039,69 +2039,6 @@ const unregisterView = uid => {
2039
2039
  viewRpcIds.delete(uid);
2040
2040
  };
2041
2041
 
2042
- const Web = 1;
2043
- const Electron$1 = 2;
2044
- const Remote = 3;
2045
-
2046
- /**
2047
- * @returns {number}
2048
- */
2049
- const getPlatform = () => {
2050
- // @ts-expect-error
2051
- if (typeof PLATFORM !== 'undefined') {
2052
- // @ts-expect-error
2053
- return PLATFORM;
2054
- }
2055
- // @ts-ignore
2056
- if (typeof process !== 'undefined' && process.env.NODE_ENV === 'test') {
2057
- return Remote;
2058
- }
2059
- if (globalThis.isElectron) {
2060
- return Electron$1;
2061
- }
2062
- if (typeof location !== 'undefined' && location.search === '?web') {
2063
- return Web;
2064
- }
2065
- return Remote;
2066
- };
2067
- const platform = getPlatform();
2068
-
2069
- const getAssetDir = () => {
2070
- // @ts-expect-error
2071
- if (typeof ASSET_DIR !== 'undefined') {
2072
- // @ts-expect-error
2073
- return ASSET_DIR;
2074
- }
2075
- if (platform === Electron$1) {
2076
- return '../../../../..';
2077
- }
2078
- return '';
2079
- };
2080
- const assetDir = getAssetDir();
2081
-
2082
- const getConfiguredWorkerUrl = key => {
2083
- if (typeof location === 'undefined' || typeof document === 'undefined') {
2084
- return '';
2085
- }
2086
- const configElement = document.getElementById('Config');
2087
- if (!configElement) {
2088
- return '';
2089
- }
2090
- const text = configElement.textContent;
2091
- if (!text) {
2092
- return '';
2093
- }
2094
- const config = JSON.parse(text);
2095
- return config[key] || '';
2096
- };
2097
-
2098
- const getConfiguredDragAndDropWorkerUrl = () => {
2099
- const workerUrls = getConfiguredWorkerUrl('workerUrls');
2100
- return workerUrls?.['develop.dragAndDropWorkerPath'] || '';
2101
- };
2102
-
2103
- const dragAndDropWorkerUrl = getConfiguredDragAndDropWorkerUrl() || `${assetDir}/packages/renderer-worker/node_modules/@lvce-editor/drag-and-drop-worker/dist/dragAndDropWorkerMain.js`;
2104
-
2105
2042
  const normalizeLine = line => {
2106
2043
  if (line.startsWith('Error: ')) {
2107
2044
  return line.slice('Error: '.length);
@@ -2448,7 +2385,6 @@ class IpcChildWithElectronWindow extends Ipc {
2448
2385
  return;
2449
2386
  }
2450
2387
  callback(event);
2451
- this._rawIpc.removeEventListener('message', wrapped);
2452
2388
  };
2453
2389
  this._rawIpc.addEventListener('message', wrapped);
2454
2390
  }
@@ -3244,6 +3180,69 @@ const create$A = async ({
3244
3180
 
3245
3181
  const commandMapRef = {};
3246
3182
 
3183
+ const Web = 1;
3184
+ const Electron$1 = 2;
3185
+ const Remote = 3;
3186
+
3187
+ /**
3188
+ * @returns {number}
3189
+ */
3190
+ const getPlatform = () => {
3191
+ // @ts-expect-error
3192
+ if (typeof PLATFORM !== 'undefined') {
3193
+ // @ts-expect-error
3194
+ return PLATFORM;
3195
+ }
3196
+ // @ts-ignore
3197
+ if (typeof process !== 'undefined' && process.env.NODE_ENV === 'test') {
3198
+ return Remote;
3199
+ }
3200
+ if (globalThis.isElectron) {
3201
+ return Electron$1;
3202
+ }
3203
+ if (typeof location !== 'undefined' && location.search === '?web') {
3204
+ return Web;
3205
+ }
3206
+ return Remote;
3207
+ };
3208
+ const platform = getPlatform();
3209
+
3210
+ const getAssetDir = () => {
3211
+ // @ts-expect-error
3212
+ if (typeof ASSET_DIR !== 'undefined') {
3213
+ // @ts-expect-error
3214
+ return ASSET_DIR;
3215
+ }
3216
+ if (platform === Electron$1) {
3217
+ return '../../../../..';
3218
+ }
3219
+ return '';
3220
+ };
3221
+ const assetDir = getAssetDir();
3222
+
3223
+ const getConfiguredWorkerUrl = key => {
3224
+ if (typeof location === 'undefined' || typeof document === 'undefined') {
3225
+ return '';
3226
+ }
3227
+ const configElement = document.getElementById('Config');
3228
+ if (!configElement) {
3229
+ return '';
3230
+ }
3231
+ const text = configElement.textContent;
3232
+ if (!text) {
3233
+ return '';
3234
+ }
3235
+ const config = JSON.parse(text);
3236
+ return config[key] || '';
3237
+ };
3238
+
3239
+ const getConfiguredDragAndDropWorkerUrl = () => {
3240
+ const workerUrls = getConfiguredWorkerUrl('workerUrls');
3241
+ return workerUrls?.['develop.dragAndDropWorkerPath'] || '';
3242
+ };
3243
+
3244
+ const dragAndDropWorkerUrl = getConfiguredDragAndDropWorkerUrl() || `${assetDir}/packages/renderer-worker/node_modules/@lvce-editor/drag-and-drop-worker/dist/dragAndDropWorkerMain.js`;
3245
+
3247
3246
  const success = value => {
3248
3247
  return {
3249
3248
  ok: true,
@@ -3260,15 +3259,21 @@ const isError = result => {
3260
3259
  return !result.ok;
3261
3260
  };
3262
3261
 
3263
- const launchWorker = async ({
3264
- name,
3265
- url
3266
- }) => {
3262
+ const launchDragAndDropWorker = async () => {
3267
3263
  try {
3268
- const rpc = await create$C({
3264
+ const {
3265
+ port1,
3266
+ port2
3267
+ } = new MessageChannel();
3268
+ await create$B({
3269
+ commandMap: {},
3270
+ name: 'Drag And Drop Worker',
3271
+ port: port1,
3272
+ url: dragAndDropWorkerUrl
3273
+ });
3274
+ const rpc = await create$D({
3269
3275
  commandMap: commandMapRef,
3270
- name,
3271
- url
3276
+ messagePort: port2
3272
3277
  });
3273
3278
  return success(rpc);
3274
3279
  } catch (error$1) {
@@ -3276,13 +3281,6 @@ const launchWorker = async ({
3276
3281
  }
3277
3282
  };
3278
3283
 
3279
- const launchDragAndDropWorker = async () => {
3280
- return launchWorker({
3281
- name: 'Drag And Drop Worker',
3282
- url: dragAndDropWorkerUrl
3283
- });
3284
- };
3285
-
3286
3284
  const state$b = {
3287
3285
  rpc: undefined
3288
3286
  };
@@ -3438,6 +3436,182 @@ const showSaveFilePicker = options => {
3438
3436
  return window.showSaveFilePicker(options);
3439
3437
  };
3440
3438
 
3439
+ const launchWorker = async ({
3440
+ name,
3441
+ url
3442
+ }) => {
3443
+ try {
3444
+ const rpc = await create$C({
3445
+ commandMap: commandMapRef,
3446
+ name,
3447
+ url
3448
+ });
3449
+ return success(rpc);
3450
+ } catch (error$1) {
3451
+ return error(error$1);
3452
+ }
3453
+ };
3454
+
3455
+ const getConfiguredRendererWorkerUrl = () => {
3456
+ return getConfiguredWorkerUrl('rendererWorkerUrl');
3457
+ };
3458
+
3459
+ const rendererWorkerUrl = getConfiguredRendererWorkerUrl() || `${assetDir}/packages/renderer-worker/src/rendererWorkerMain.ts`;
3460
+
3461
+ const getName = platform => {
3462
+ switch (platform) {
3463
+ case Electron$1:
3464
+ return 'Renderer Worker (Electron)';
3465
+ case Web:
3466
+ return 'Renderer Worker (Web)';
3467
+ default:
3468
+ return 'Renderer Worker';
3469
+ }
3470
+ };
3471
+ const launchRendererWorker = async () => {
3472
+ const name = getName(platform);
3473
+ return launchWorker({
3474
+ name,
3475
+ url: rendererWorkerUrl
3476
+ });
3477
+ };
3478
+
3479
+ const selector = 'script.RendererWorkerTrace';
3480
+ const state$a = {
3481
+ enabled: false,
3482
+ entries: []
3483
+ };
3484
+ const serialize = value => {
3485
+ const seen = new WeakSet();
3486
+ const text = JSON.stringify(value, (_key, currentValue) => {
3487
+ if (typeof currentValue === 'bigint') {
3488
+ return `${currentValue}n`;
3489
+ }
3490
+ if (typeof currentValue !== 'object' || currentValue === null) {
3491
+ return currentValue;
3492
+ }
3493
+ if (seen.has(currentValue)) {
3494
+ return '[Circular]';
3495
+ }
3496
+ seen.add(currentValue);
3497
+ if (currentValue instanceof ArrayBuffer) {
3498
+ return {
3499
+ byteLength: currentValue.byteLength,
3500
+ type: 'ArrayBuffer'
3501
+ };
3502
+ }
3503
+ if (ArrayBuffer.isView(currentValue)) {
3504
+ return {
3505
+ byteLength: currentValue.byteLength,
3506
+ type: currentValue.constructor.name
3507
+ };
3508
+ }
3509
+ if (currentValue instanceof Error) {
3510
+ return {
3511
+ message: currentValue.message,
3512
+ name: currentValue.name,
3513
+ stack: currentValue.stack
3514
+ };
3515
+ }
3516
+ if (currentValue.constructor?.name === 'MessagePort') {
3517
+ return {
3518
+ type: 'MessagePort'
3519
+ };
3520
+ }
3521
+ return currentValue;
3522
+ });
3523
+ return JSON.parse(text);
3524
+ };
3525
+ const isCommand = value => {
3526
+ return typeof value === 'object' && value !== null && 'method' in value && typeof value.method === 'string';
3527
+ };
3528
+ const initialize = search => {
3529
+ const searchParams = new URLSearchParams(search);
3530
+ state$a.enabled = searchParams.has('traceRendererWorker');
3531
+ state$a.entries = [];
3532
+ };
3533
+ const record = (direction, method, params) => {
3534
+ if (!state$a.enabled) {
3535
+ return;
3536
+ }
3537
+ state$a.entries.push({
3538
+ direction,
3539
+ method,
3540
+ params: serialize(params),
3541
+ timestamp: performance.now()
3542
+ });
3543
+ };
3544
+ const listen = rpc => {
3545
+ if (!state$a.enabled) {
3546
+ return;
3547
+ }
3548
+ const ipc = rpc.ipc;
3549
+ if (!ipc) {
3550
+ return;
3551
+ }
3552
+ ipc.addEventListener('message', event => {
3553
+ const message = ipc.getData(event);
3554
+ if (isCommand(message)) {
3555
+ record('received', message.method, message.params || []);
3556
+ }
3557
+ });
3558
+ };
3559
+ const exportToDom = () => {
3560
+ if (!state$a.enabled) {
3561
+ return;
3562
+ }
3563
+ const existing = document.querySelector(selector);
3564
+ const script = existing || document.createElement('script');
3565
+ script.className = 'RendererWorkerTrace';
3566
+ script.type = 'application/json';
3567
+ script.textContent = JSON.stringify({
3568
+ entries: state$a.entries,
3569
+ version: 1
3570
+ });
3571
+ if (!existing) {
3572
+ document.body.append(script);
3573
+ }
3574
+ };
3575
+ const scheduleExport = () => {
3576
+ if (!state$a.enabled) {
3577
+ return;
3578
+ }
3579
+ queueMicrotask(exportToDom);
3580
+ };
3581
+
3582
+ const state$9 = {
3583
+ rpc: undefined
3584
+ };
3585
+ const hydrate$3 = async () => {
3586
+ const result = await launchRendererWorker();
3587
+ if (isError(result)) {
3588
+ state$9.rpc = undefined;
3589
+ return result;
3590
+ }
3591
+ state$9.rpc = result.value;
3592
+ listen(result.value);
3593
+ return success(undefined);
3594
+ };
3595
+ const send$1 = (method, ...params) => {
3596
+ record('sent', method, params);
3597
+ // @ts-ignore
3598
+ state$9.rpc.send(method, ...params);
3599
+ };
3600
+ const invoke$1 = (method, ...params) => {
3601
+ record('sent', method, params);
3602
+ // @ts-ignore
3603
+ return state$9.rpc.invoke(method, ...params);
3604
+ };
3605
+ const invokeAndTransfer = (method, ...params) => {
3606
+ record('sent', method, params);
3607
+ // @ts-ignore
3608
+ return state$9.rpc.invokeAndTransfer(method, ...params);
3609
+ };
3610
+
3611
+ const writeFile = (uri, content) => {
3612
+ return invoke$1('FileSystem.writeFile', uri, content);
3613
+ };
3614
+
3441
3615
  const requestPermission = (handle, options) => {
3442
3616
  return handle.requestPermission(options);
3443
3617
  };
@@ -3483,7 +3657,7 @@ const setPathName = pathName => {
3483
3657
  }
3484
3658
  history.pushState(null, '', pathName);
3485
3659
  };
3486
- const hydrate$3 = () => {
3660
+ const hydrate$2 = () => {
3487
3661
  // addEventListener('popstate', handlePopState)
3488
3662
  };
3489
3663
 
@@ -3866,162 +4040,6 @@ const has = name => {
3866
4040
  return ipcs[name];
3867
4041
  };
3868
4042
 
3869
- const getConfiguredRendererWorkerUrl = () => {
3870
- return getConfiguredWorkerUrl('rendererWorkerUrl');
3871
- };
3872
-
3873
- const rendererWorkerUrl = getConfiguredRendererWorkerUrl() || `${assetDir}/packages/renderer-worker/src/rendererWorkerMain.ts`;
3874
-
3875
- const getName = platform => {
3876
- switch (platform) {
3877
- case Electron$1:
3878
- return 'Renderer Worker (Electron)';
3879
- case Web:
3880
- return 'Renderer Worker (Web)';
3881
- default:
3882
- return 'Renderer Worker';
3883
- }
3884
- };
3885
- const launchRendererWorker = async () => {
3886
- const name = getName(platform);
3887
- return launchWorker({
3888
- name,
3889
- url: rendererWorkerUrl
3890
- });
3891
- };
3892
-
3893
- const selector = 'script.RendererWorkerTrace';
3894
- const state$a = {
3895
- enabled: false,
3896
- entries: []
3897
- };
3898
- const serialize = value => {
3899
- const seen = new WeakSet();
3900
- const text = JSON.stringify(value, (_key, currentValue) => {
3901
- if (typeof currentValue === 'bigint') {
3902
- return `${currentValue}n`;
3903
- }
3904
- if (typeof currentValue !== 'object' || currentValue === null) {
3905
- return currentValue;
3906
- }
3907
- if (seen.has(currentValue)) {
3908
- return '[Circular]';
3909
- }
3910
- seen.add(currentValue);
3911
- if (currentValue instanceof ArrayBuffer) {
3912
- return {
3913
- byteLength: currentValue.byteLength,
3914
- type: 'ArrayBuffer'
3915
- };
3916
- }
3917
- if (ArrayBuffer.isView(currentValue)) {
3918
- return {
3919
- byteLength: currentValue.byteLength,
3920
- type: currentValue.constructor.name
3921
- };
3922
- }
3923
- if (currentValue instanceof Error) {
3924
- return {
3925
- message: currentValue.message,
3926
- name: currentValue.name,
3927
- stack: currentValue.stack
3928
- };
3929
- }
3930
- if (currentValue.constructor?.name === 'MessagePort') {
3931
- return {
3932
- type: 'MessagePort'
3933
- };
3934
- }
3935
- return currentValue;
3936
- });
3937
- return JSON.parse(text);
3938
- };
3939
- const isCommand = value => {
3940
- return typeof value === 'object' && value !== null && 'method' in value && typeof value.method === 'string';
3941
- };
3942
- const initialize = search => {
3943
- const searchParams = new URLSearchParams(search);
3944
- state$a.enabled = searchParams.has('traceRendererWorker');
3945
- state$a.entries = [];
3946
- };
3947
- const record = (direction, method, params) => {
3948
- if (!state$a.enabled) {
3949
- return;
3950
- }
3951
- state$a.entries.push({
3952
- direction,
3953
- method,
3954
- params: serialize(params),
3955
- timestamp: performance.now()
3956
- });
3957
- };
3958
- const listen = rpc => {
3959
- if (!state$a.enabled) {
3960
- return;
3961
- }
3962
- const ipc = rpc.ipc;
3963
- if (!ipc) {
3964
- return;
3965
- }
3966
- ipc.addEventListener('message', event => {
3967
- const message = ipc.getData(event);
3968
- if (isCommand(message)) {
3969
- record('received', message.method, message.params || []);
3970
- }
3971
- });
3972
- };
3973
- const exportToDom = () => {
3974
- if (!state$a.enabled) {
3975
- return;
3976
- }
3977
- const existing = document.querySelector(selector);
3978
- const script = existing || document.createElement('script');
3979
- script.className = 'RendererWorkerTrace';
3980
- script.type = 'application/json';
3981
- script.textContent = JSON.stringify({
3982
- entries: state$a.entries,
3983
- version: 1
3984
- });
3985
- if (!existing) {
3986
- document.body.append(script);
3987
- }
3988
- };
3989
- const scheduleExport = () => {
3990
- if (!state$a.enabled) {
3991
- return;
3992
- }
3993
- queueMicrotask(exportToDom);
3994
- };
3995
-
3996
- const state$9 = {
3997
- rpc: undefined
3998
- };
3999
- const hydrate$2 = async () => {
4000
- const result = await launchRendererWorker();
4001
- if (isError(result)) {
4002
- state$9.rpc = undefined;
4003
- return result;
4004
- }
4005
- state$9.rpc = result.value;
4006
- listen(result.value);
4007
- return success(undefined);
4008
- };
4009
- const send$1 = (method, ...params) => {
4010
- record('sent', method, params);
4011
- // @ts-ignore
4012
- state$9.rpc.send(method, ...params);
4013
- };
4014
- const invoke$1 = (method, ...params) => {
4015
- record('sent', method, params);
4016
- // @ts-ignore
4017
- return state$9.rpc.invoke(method, ...params);
4018
- };
4019
- const invokeAndTransfer = (method, ...params) => {
4020
- record('sent', method, params);
4021
- // @ts-ignore
4022
- return state$9.rpc.invokeAndTransfer(method, ...params);
4023
- };
4024
-
4025
4043
  const create$u = async ({
4026
4044
  method,
4027
4045
  ...options
@@ -9906,6 +9924,10 @@ const unmock = () => {
9906
9924
  Element.prototype.releasePointerCapture = originalPointerCapture.releasePointerCapture;
9907
9925
  };
9908
9926
 
9927
+ const addHandle = (uri, handle) => {
9928
+ return invoke$1('PersistentFileHandle.addHandle', uri, handle);
9929
+ };
9930
+
9909
9931
  const forwardRendererWorkerCommand = (method, ...params) => {
9910
9932
  send$1(method, ...params);
9911
9933
  };
@@ -10196,8 +10218,10 @@ const commandMap = {
10196
10218
  'FilePicker.showDirectoryPicker': showDirectoryPicker,
10197
10219
  'FilePicker.showFilePicker': showFilePicker,
10198
10220
  'FilePicker.showSaveFilePicker': showSaveFilePicker,
10221
+ 'FileSystem.writeFile': writeFile,
10199
10222
  'FileSystemHandle.addFileHandle': addFileHandle,
10200
10223
  'FileSystemHandle.getFileHandles': getFileHandles,
10224
+ 'FileSystemHandle.getFilePathElectron': getFilePathElectron,
10201
10225
  'FileSystemHandle.requestPermission': requestPermission,
10202
10226
  'GetFilePathElectron.getFilePathElectron': getFilePathElectron,
10203
10227
  'HandleMessagePort.handleMessagePort': handleMessagePort,
@@ -10208,7 +10232,7 @@ const commandMap = {
10208
10232
  'Layout.getBounds': getBounds,
10209
10233
  'Location.getHref': getHref,
10210
10234
  'Location.getPathName': getPathName,
10211
- 'Location.hydrate': hydrate$3,
10235
+ 'Location.hydrate': hydrate$2,
10212
10236
  'Location.setPathName': setPathName,
10213
10237
  'MeasureTextBlockHeight.measureTextBlockHeight': measureTextBlockHeight,
10214
10238
  'MeasureTextHeight.measureTextHeight': measureTextHeight,
@@ -10227,6 +10251,7 @@ const commandMap = {
10227
10251
  'Open.redirectToUrl': redirectToUrl,
10228
10252
  'Performance.getMemory': getMemory,
10229
10253
  'Performance.measureUserAgentSpecificMemory': measureUserAgentSpecificMemory,
10254
+ 'PersistentFileHandle.addHandle': addHandle,
10230
10255
  'PointerCapture.mock': mock,
10231
10256
  'PointerCapture.unmock': unmock,
10232
10257
  'Prompt.prompt': prompt,
@@ -10633,7 +10658,7 @@ const hydrate = async () => {
10633
10658
  return success(undefined);
10634
10659
  };
10635
10660
 
10636
- const requiredWorkerFns = [hydrate$2, hydrate$4];
10661
+ const requiredWorkerFns = [hydrate$3, hydrate$4];
10637
10662
  const additionalWorkerFns = [hydrate$1, hydrate];
10638
10663
  const call = fn => {
10639
10664
  return fn();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/renderer-process",
3
- "version": "30.41.0",
3
+ "version": "30.41.2",
4
4
  "keywords": [
5
5
  "lvce-editor",
6
6
  "renderer-process"