@lvce-editor/renderer-process 30.41.0 → 30.41.1

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);
@@ -3244,6 +3181,69 @@ const create$A = async ({
3244
3181
 
3245
3182
  const commandMapRef = {};
3246
3183
 
3184
+ const Web = 1;
3185
+ const Electron$1 = 2;
3186
+ const Remote = 3;
3187
+
3188
+ /**
3189
+ * @returns {number}
3190
+ */
3191
+ const getPlatform = () => {
3192
+ // @ts-expect-error
3193
+ if (typeof PLATFORM !== 'undefined') {
3194
+ // @ts-expect-error
3195
+ return PLATFORM;
3196
+ }
3197
+ // @ts-ignore
3198
+ if (typeof process !== 'undefined' && process.env.NODE_ENV === 'test') {
3199
+ return Remote;
3200
+ }
3201
+ if (globalThis.isElectron) {
3202
+ return Electron$1;
3203
+ }
3204
+ if (typeof location !== 'undefined' && location.search === '?web') {
3205
+ return Web;
3206
+ }
3207
+ return Remote;
3208
+ };
3209
+ const platform = getPlatform();
3210
+
3211
+ const getAssetDir = () => {
3212
+ // @ts-expect-error
3213
+ if (typeof ASSET_DIR !== 'undefined') {
3214
+ // @ts-expect-error
3215
+ return ASSET_DIR;
3216
+ }
3217
+ if (platform === Electron$1) {
3218
+ return '../../../../..';
3219
+ }
3220
+ return '';
3221
+ };
3222
+ const assetDir = getAssetDir();
3223
+
3224
+ const getConfiguredWorkerUrl = key => {
3225
+ if (typeof location === 'undefined' || typeof document === 'undefined') {
3226
+ return '';
3227
+ }
3228
+ const configElement = document.getElementById('Config');
3229
+ if (!configElement) {
3230
+ return '';
3231
+ }
3232
+ const text = configElement.textContent;
3233
+ if (!text) {
3234
+ return '';
3235
+ }
3236
+ const config = JSON.parse(text);
3237
+ return config[key] || '';
3238
+ };
3239
+
3240
+ const getConfiguredDragAndDropWorkerUrl = () => {
3241
+ const workerUrls = getConfiguredWorkerUrl('workerUrls');
3242
+ return workerUrls?.['develop.dragAndDropWorkerPath'] || '';
3243
+ };
3244
+
3245
+ const dragAndDropWorkerUrl = getConfiguredDragAndDropWorkerUrl() || `${assetDir}/packages/renderer-worker/node_modules/@lvce-editor/drag-and-drop-worker/dist/dragAndDropWorkerMain.js`;
3246
+
3247
3247
  const success = value => {
3248
3248
  return {
3249
3249
  ok: true,
@@ -3260,15 +3260,21 @@ const isError = result => {
3260
3260
  return !result.ok;
3261
3261
  };
3262
3262
 
3263
- const launchWorker = async ({
3264
- name,
3265
- url
3266
- }) => {
3263
+ const launchDragAndDropWorker = async () => {
3267
3264
  try {
3268
- const rpc = await create$C({
3265
+ const {
3266
+ port1,
3267
+ port2
3268
+ } = new MessageChannel();
3269
+ await create$B({
3270
+ commandMap: {},
3271
+ name: 'Drag And Drop Worker',
3272
+ port: port1,
3273
+ url: dragAndDropWorkerUrl
3274
+ });
3275
+ const rpc = await create$D({
3269
3276
  commandMap: commandMapRef,
3270
- name,
3271
- url
3277
+ messagePort: port2
3272
3278
  });
3273
3279
  return success(rpc);
3274
3280
  } catch (error$1) {
@@ -3276,13 +3282,6 @@ const launchWorker = async ({
3276
3282
  }
3277
3283
  };
3278
3284
 
3279
- const launchDragAndDropWorker = async () => {
3280
- return launchWorker({
3281
- name: 'Drag And Drop Worker',
3282
- url: dragAndDropWorkerUrl
3283
- });
3284
- };
3285
-
3286
3285
  const state$b = {
3287
3286
  rpc: undefined
3288
3287
  };
@@ -3438,6 +3437,182 @@ const showSaveFilePicker = options => {
3438
3437
  return window.showSaveFilePicker(options);
3439
3438
  };
3440
3439
 
3440
+ const launchWorker = async ({
3441
+ name,
3442
+ url
3443
+ }) => {
3444
+ try {
3445
+ const rpc = await create$C({
3446
+ commandMap: commandMapRef,
3447
+ name,
3448
+ url
3449
+ });
3450
+ return success(rpc);
3451
+ } catch (error$1) {
3452
+ return error(error$1);
3453
+ }
3454
+ };
3455
+
3456
+ const getConfiguredRendererWorkerUrl = () => {
3457
+ return getConfiguredWorkerUrl('rendererWorkerUrl');
3458
+ };
3459
+
3460
+ const rendererWorkerUrl = getConfiguredRendererWorkerUrl() || `${assetDir}/packages/renderer-worker/src/rendererWorkerMain.ts`;
3461
+
3462
+ const getName = platform => {
3463
+ switch (platform) {
3464
+ case Electron$1:
3465
+ return 'Renderer Worker (Electron)';
3466
+ case Web:
3467
+ return 'Renderer Worker (Web)';
3468
+ default:
3469
+ return 'Renderer Worker';
3470
+ }
3471
+ };
3472
+ const launchRendererWorker = async () => {
3473
+ const name = getName(platform);
3474
+ return launchWorker({
3475
+ name,
3476
+ url: rendererWorkerUrl
3477
+ });
3478
+ };
3479
+
3480
+ const selector = 'script.RendererWorkerTrace';
3481
+ const state$a = {
3482
+ enabled: false,
3483
+ entries: []
3484
+ };
3485
+ const serialize = value => {
3486
+ const seen = new WeakSet();
3487
+ const text = JSON.stringify(value, (_key, currentValue) => {
3488
+ if (typeof currentValue === 'bigint') {
3489
+ return `${currentValue}n`;
3490
+ }
3491
+ if (typeof currentValue !== 'object' || currentValue === null) {
3492
+ return currentValue;
3493
+ }
3494
+ if (seen.has(currentValue)) {
3495
+ return '[Circular]';
3496
+ }
3497
+ seen.add(currentValue);
3498
+ if (currentValue instanceof ArrayBuffer) {
3499
+ return {
3500
+ byteLength: currentValue.byteLength,
3501
+ type: 'ArrayBuffer'
3502
+ };
3503
+ }
3504
+ if (ArrayBuffer.isView(currentValue)) {
3505
+ return {
3506
+ byteLength: currentValue.byteLength,
3507
+ type: currentValue.constructor.name
3508
+ };
3509
+ }
3510
+ if (currentValue instanceof Error) {
3511
+ return {
3512
+ message: currentValue.message,
3513
+ name: currentValue.name,
3514
+ stack: currentValue.stack
3515
+ };
3516
+ }
3517
+ if (currentValue.constructor?.name === 'MessagePort') {
3518
+ return {
3519
+ type: 'MessagePort'
3520
+ };
3521
+ }
3522
+ return currentValue;
3523
+ });
3524
+ return JSON.parse(text);
3525
+ };
3526
+ const isCommand = value => {
3527
+ return typeof value === 'object' && value !== null && 'method' in value && typeof value.method === 'string';
3528
+ };
3529
+ const initialize = search => {
3530
+ const searchParams = new URLSearchParams(search);
3531
+ state$a.enabled = searchParams.has('traceRendererWorker');
3532
+ state$a.entries = [];
3533
+ };
3534
+ const record = (direction, method, params) => {
3535
+ if (!state$a.enabled) {
3536
+ return;
3537
+ }
3538
+ state$a.entries.push({
3539
+ direction,
3540
+ method,
3541
+ params: serialize(params),
3542
+ timestamp: performance.now()
3543
+ });
3544
+ };
3545
+ const listen = rpc => {
3546
+ if (!state$a.enabled) {
3547
+ return;
3548
+ }
3549
+ const ipc = rpc.ipc;
3550
+ if (!ipc) {
3551
+ return;
3552
+ }
3553
+ ipc.addEventListener('message', event => {
3554
+ const message = ipc.getData(event);
3555
+ if (isCommand(message)) {
3556
+ record('received', message.method, message.params || []);
3557
+ }
3558
+ });
3559
+ };
3560
+ const exportToDom = () => {
3561
+ if (!state$a.enabled) {
3562
+ return;
3563
+ }
3564
+ const existing = document.querySelector(selector);
3565
+ const script = existing || document.createElement('script');
3566
+ script.className = 'RendererWorkerTrace';
3567
+ script.type = 'application/json';
3568
+ script.textContent = JSON.stringify({
3569
+ entries: state$a.entries,
3570
+ version: 1
3571
+ });
3572
+ if (!existing) {
3573
+ document.body.append(script);
3574
+ }
3575
+ };
3576
+ const scheduleExport = () => {
3577
+ if (!state$a.enabled) {
3578
+ return;
3579
+ }
3580
+ queueMicrotask(exportToDom);
3581
+ };
3582
+
3583
+ const state$9 = {
3584
+ rpc: undefined
3585
+ };
3586
+ const hydrate$3 = async () => {
3587
+ const result = await launchRendererWorker();
3588
+ if (isError(result)) {
3589
+ state$9.rpc = undefined;
3590
+ return result;
3591
+ }
3592
+ state$9.rpc = result.value;
3593
+ listen(result.value);
3594
+ return success(undefined);
3595
+ };
3596
+ const send$1 = (method, ...params) => {
3597
+ record('sent', method, params);
3598
+ // @ts-ignore
3599
+ state$9.rpc.send(method, ...params);
3600
+ };
3601
+ const invoke$1 = (method, ...params) => {
3602
+ record('sent', method, params);
3603
+ // @ts-ignore
3604
+ return state$9.rpc.invoke(method, ...params);
3605
+ };
3606
+ const invokeAndTransfer = (method, ...params) => {
3607
+ record('sent', method, params);
3608
+ // @ts-ignore
3609
+ return state$9.rpc.invokeAndTransfer(method, ...params);
3610
+ };
3611
+
3612
+ const writeFile = (uri, content) => {
3613
+ return invoke$1('FileSystem.writeFile', uri, content);
3614
+ };
3615
+
3441
3616
  const requestPermission = (handle, options) => {
3442
3617
  return handle.requestPermission(options);
3443
3618
  };
@@ -3483,7 +3658,7 @@ const setPathName = pathName => {
3483
3658
  }
3484
3659
  history.pushState(null, '', pathName);
3485
3660
  };
3486
- const hydrate$3 = () => {
3661
+ const hydrate$2 = () => {
3487
3662
  // addEventListener('popstate', handlePopState)
3488
3663
  };
3489
3664
 
@@ -3866,162 +4041,6 @@ const has = name => {
3866
4041
  return ipcs[name];
3867
4042
  };
3868
4043
 
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
4044
  const create$u = async ({
4026
4045
  method,
4027
4046
  ...options
@@ -9906,6 +9925,10 @@ const unmock = () => {
9906
9925
  Element.prototype.releasePointerCapture = originalPointerCapture.releasePointerCapture;
9907
9926
  };
9908
9927
 
9928
+ const addHandle = (uri, handle) => {
9929
+ return invoke$1('PersistentFileHandle.addHandle', uri, handle);
9930
+ };
9931
+
9909
9932
  const forwardRendererWorkerCommand = (method, ...params) => {
9910
9933
  send$1(method, ...params);
9911
9934
  };
@@ -10196,8 +10219,10 @@ const commandMap = {
10196
10219
  'FilePicker.showDirectoryPicker': showDirectoryPicker,
10197
10220
  'FilePicker.showFilePicker': showFilePicker,
10198
10221
  'FilePicker.showSaveFilePicker': showSaveFilePicker,
10222
+ 'FileSystem.writeFile': writeFile,
10199
10223
  'FileSystemHandle.addFileHandle': addFileHandle,
10200
10224
  'FileSystemHandle.getFileHandles': getFileHandles,
10225
+ 'FileSystemHandle.getFilePathElectron': getFilePathElectron,
10201
10226
  'FileSystemHandle.requestPermission': requestPermission,
10202
10227
  'GetFilePathElectron.getFilePathElectron': getFilePathElectron,
10203
10228
  'HandleMessagePort.handleMessagePort': handleMessagePort,
@@ -10208,7 +10233,7 @@ const commandMap = {
10208
10233
  'Layout.getBounds': getBounds,
10209
10234
  'Location.getHref': getHref,
10210
10235
  'Location.getPathName': getPathName,
10211
- 'Location.hydrate': hydrate$3,
10236
+ 'Location.hydrate': hydrate$2,
10212
10237
  'Location.setPathName': setPathName,
10213
10238
  'MeasureTextBlockHeight.measureTextBlockHeight': measureTextBlockHeight,
10214
10239
  'MeasureTextHeight.measureTextHeight': measureTextHeight,
@@ -10227,6 +10252,7 @@ const commandMap = {
10227
10252
  'Open.redirectToUrl': redirectToUrl,
10228
10253
  'Performance.getMemory': getMemory,
10229
10254
  'Performance.measureUserAgentSpecificMemory': measureUserAgentSpecificMemory,
10255
+ 'PersistentFileHandle.addHandle': addHandle,
10230
10256
  'PointerCapture.mock': mock,
10231
10257
  'PointerCapture.unmock': unmock,
10232
10258
  'Prompt.prompt': prompt,
@@ -10633,7 +10659,7 @@ const hydrate = async () => {
10633
10659
  return success(undefined);
10634
10660
  };
10635
10661
 
10636
- const requiredWorkerFns = [hydrate$2, hydrate$4];
10662
+ const requiredWorkerFns = [hydrate$3, hydrate$4];
10637
10663
  const additionalWorkerFns = [hydrate$1, hydrate];
10638
10664
  const call = fn => {
10639
10665
  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.1",
4
4
  "keywords": [
5
5
  "lvce-editor",
6
6
  "renderer-process"