@lvce-editor/renderer-process 30.67.0 → 30.67.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.
- package/dist/rendererProcessMain.js +52 -19
- package/package.json +1 -1
|
@@ -1559,10 +1559,39 @@ const Web = 1;
|
|
|
1559
1559
|
const Electron$1 = 2;
|
|
1560
1560
|
const Remote = 3;
|
|
1561
1561
|
|
|
1562
|
+
const getConfiguredWorkerUrl = key => {
|
|
1563
|
+
if (typeof location === 'undefined' || typeof document === 'undefined') {
|
|
1564
|
+
return '';
|
|
1565
|
+
}
|
|
1566
|
+
const configElement = document.getElementById('Config');
|
|
1567
|
+
if (!configElement) {
|
|
1568
|
+
return '';
|
|
1569
|
+
}
|
|
1570
|
+
const text = configElement.textContent;
|
|
1571
|
+
if (!text) {
|
|
1572
|
+
return '';
|
|
1573
|
+
}
|
|
1574
|
+
const config = JSON.parse(text);
|
|
1575
|
+
if (key === 'workerUrls') {
|
|
1576
|
+
return config.workerUrls || {};
|
|
1577
|
+
}
|
|
1578
|
+
return config[key] || '';
|
|
1579
|
+
};
|
|
1580
|
+
|
|
1562
1581
|
/**
|
|
1563
1582
|
* @returns {number}
|
|
1564
1583
|
*/
|
|
1565
1584
|
const getPlatform = () => {
|
|
1585
|
+
const configuredPlatform = getConfiguredWorkerUrl('platform');
|
|
1586
|
+
if (configuredPlatform === 'electron') {
|
|
1587
|
+
return Electron$1;
|
|
1588
|
+
}
|
|
1589
|
+
if (configuredPlatform === 'web') {
|
|
1590
|
+
return Web;
|
|
1591
|
+
}
|
|
1592
|
+
if (configuredPlatform === 'remote') {
|
|
1593
|
+
return Remote;
|
|
1594
|
+
}
|
|
1566
1595
|
// @ts-expect-error
|
|
1567
1596
|
if (typeof PLATFORM !== 'undefined') {
|
|
1568
1597
|
// @ts-expect-error
|
|
@@ -1583,6 +1612,10 @@ const getPlatform = () => {
|
|
|
1583
1612
|
const platform = getPlatform();
|
|
1584
1613
|
|
|
1585
1614
|
const getAssetDir = () => {
|
|
1615
|
+
const configuredAssetDir = getConfiguredWorkerUrl('assetDir');
|
|
1616
|
+
if (configuredAssetDir) {
|
|
1617
|
+
return configuredAssetDir;
|
|
1618
|
+
}
|
|
1586
1619
|
// @ts-expect-error
|
|
1587
1620
|
if (typeof ASSET_DIR !== 'undefined') {
|
|
1588
1621
|
// @ts-expect-error
|
|
@@ -1595,22 +1628,6 @@ const getAssetDir = () => {
|
|
|
1595
1628
|
};
|
|
1596
1629
|
const assetDir = getAssetDir();
|
|
1597
1630
|
|
|
1598
|
-
const getConfiguredWorkerUrl = key => {
|
|
1599
|
-
if (typeof location === 'undefined' || typeof document === 'undefined') {
|
|
1600
|
-
return '';
|
|
1601
|
-
}
|
|
1602
|
-
const configElement = document.getElementById('Config');
|
|
1603
|
-
if (!configElement) {
|
|
1604
|
-
return '';
|
|
1605
|
-
}
|
|
1606
|
-
const text = configElement.textContent;
|
|
1607
|
-
if (!text) {
|
|
1608
|
-
return '';
|
|
1609
|
-
}
|
|
1610
|
-
const config = JSON.parse(text);
|
|
1611
|
-
return config[key] || '';
|
|
1612
|
-
};
|
|
1613
|
-
|
|
1614
1631
|
const getConfiguredRendererWorkerUrl = () => {
|
|
1615
1632
|
return getConfiguredWorkerUrl('rendererWorkerUrl');
|
|
1616
1633
|
};
|
|
@@ -1629,9 +1646,15 @@ const getName = platform => {
|
|
|
1629
1646
|
};
|
|
1630
1647
|
const launchRendererWorker = async () => {
|
|
1631
1648
|
const name = getName(platform);
|
|
1649
|
+
const url = new URL(rendererWorkerUrl, location.href);
|
|
1650
|
+
url.searchParams.set('config', JSON.stringify({
|
|
1651
|
+
assetDir: assetDir,
|
|
1652
|
+
platform: platform,
|
|
1653
|
+
workerUrls: getConfiguredWorkerUrl('workerUrls')
|
|
1654
|
+
}));
|
|
1632
1655
|
return launchWorker({
|
|
1633
1656
|
name,
|
|
1634
|
-
url:
|
|
1657
|
+
url: url.href
|
|
1635
1658
|
});
|
|
1636
1659
|
};
|
|
1637
1660
|
|
|
@@ -4116,7 +4139,12 @@ const clear$3 = () => {
|
|
|
4116
4139
|
};
|
|
4117
4140
|
|
|
4118
4141
|
const getConfiguredEditorWorkerUrl = () => {
|
|
4119
|
-
|
|
4142
|
+
const editorWorkerUrl = getConfiguredWorkerUrl('editorWorkerUrl');
|
|
4143
|
+
if (editorWorkerUrl) {
|
|
4144
|
+
return editorWorkerUrl;
|
|
4145
|
+
}
|
|
4146
|
+
const workerUrls = getConfiguredWorkerUrl('workerUrls');
|
|
4147
|
+
return workerUrls?.['develop.editorWorkerPath'] || '';
|
|
4120
4148
|
};
|
|
4121
4149
|
|
|
4122
4150
|
const editorWorkerUrl = getConfiguredEditorWorkerUrl() || `${assetDir}/packages/renderer-worker/node_modules/@lvce-editor/editor-worker/dist/editorWorkerMain.js`;
|
|
@@ -4541,7 +4569,12 @@ const hydrate$2 = async () => {
|
|
|
4541
4569
|
};
|
|
4542
4570
|
|
|
4543
4571
|
const getConfiguredSyntaxHighlightingWorkerUrl = () => {
|
|
4544
|
-
|
|
4572
|
+
const syntaxHighlightingWorkerUrl = getConfiguredWorkerUrl('syntaxHighlightingWorkerUrl');
|
|
4573
|
+
if (syntaxHighlightingWorkerUrl) {
|
|
4574
|
+
return syntaxHighlightingWorkerUrl;
|
|
4575
|
+
}
|
|
4576
|
+
const workerUrls = getConfiguredWorkerUrl('workerUrls');
|
|
4577
|
+
return workerUrls?.['developer.syntaxHighlightingWorkerPath'] || '';
|
|
4545
4578
|
};
|
|
4546
4579
|
|
|
4547
4580
|
const syntaxHighlightingWorkerUrl = getConfiguredSyntaxHighlightingWorkerUrl() || `${assetDir}/packages/renderer-worker/node_modules/@lvce-editor/syntax-highlighting-worker/dist/syntaxHighlightingWorkerMain.js`;
|