@lvce-editor/shared-process 0.33.10 → 0.33.12

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/shared-process",
3
- "version": "0.33.10",
3
+ "version": "0.33.12",
4
4
  "main": "index.js",
5
5
  "type": "module",
6
6
  "keywords": [
@@ -18,7 +18,7 @@
18
18
  },
19
19
  "dependencies": {
20
20
  "@lvce-editor/assert": "^1.3.0",
21
- "@lvce-editor/extension-host-helper-process": "0.33.10",
21
+ "@lvce-editor/extension-host-helper-process": "0.33.12",
22
22
  "@lvce-editor/ipc": "^10.2.1",
23
23
  "@lvce-editor/json-rpc": "^3.0.0",
24
24
  "@lvce-editor/jsonc-parser": "^1.4.0",
@@ -25,7 +25,7 @@ const getFrameAncestors = () => {
25
25
  export const value = GetContentSecurityPolicy.getContentSecurityPolicy([
26
26
  `default-src 'none'`,
27
27
  `font-src 'self'`,
28
- `img-src 'self' https: data:`, // TODO maybe disallow https and data images
28
+ `img-src 'self' https: data: blob:`, // TODO maybe disallow https and data images
29
29
  `media-src 'self'`,
30
30
  `script-src 'self'`,
31
31
  `style-src 'self'`,
@@ -73,21 +73,21 @@ const clean = async (root) => {
73
73
  /**
74
74
  * @param {string} root
75
75
  */
76
- const copyStaticFiles = async (root, commitHash) => {
77
- await FileSystem.copy(Path.join(root, 'node_modules', '@lvce-editor', 'server', 'static'), Path.join(root, 'dist'));
76
+ const copyStaticFiles = async (root, serverStaticPath) => {
77
+ await FileSystem.copy(serverStaticPath, Path.join(root, 'dist'));
78
78
  };
79
79
  const applyOverridesRendererProcess = async ({ root, commitHash, pathPrefix }) => {
80
80
  await replace(Path.join(root, 'dist', commitHash, 'packages', 'renderer-process', 'dist', 'rendererProcessMain.js'), 'platform = Remote;', 'platform = Web');
81
81
  await replace(Path.join(root, 'dist', commitHash, 'packages', 'renderer-process', 'dist', 'rendererProcessMain.js'), `/${commitHash}`, `${pathPrefix}/${commitHash}`);
82
82
  };
83
- const applyOverrides = async ({ root, commitHash, pathPrefix }) => {
83
+ const applyOverrides = async ({ root, commitHash, pathPrefix, serverStaticPath }) => {
84
84
  await applyOverridesRendererProcess({ root, commitHash, pathPrefix });
85
85
  await replace(Path.join(root, 'dist', commitHash, 'packages', 'renderer-worker', 'dist', 'rendererWorkerMain.js'), 'platform = Remote;', 'platform = Web$1;');
86
86
  await replace(Path.join(root, 'dist', commitHash, 'packages', 'renderer-worker', 'dist', 'rendererWorkerMain.js'), `/${commitHash}`, `${pathPrefix}/${commitHash}`);
87
87
  await replace(Path.join(root, 'dist', commitHash, 'packages', 'renderer-worker', 'dist', 'rendererWorkerMain.js'), `return \`\${assetDir}/extensions/builtin.theme-\${colorThemeId}/color-theme.json\``, `return \`\${assetDir}/themes/\${colorThemeId}.json\``);
88
88
  await replace(Path.join(root, 'dist', commitHash, 'packages', 'extension-host-worker', 'dist', 'extensionHostWorkerMain.js'), `/${commitHash}`, `${pathPrefix}/${commitHash}`);
89
89
  await replace(Path.join(root, 'dist', commitHash, 'packages', 'renderer-worker', 'dist', 'rendererWorkerMain.js'), `return \`\${assetDir}/extensions/builtin.\${iconThemeId}/icon-theme.json\``, `return \`\${assetDir}/icon-themes/\${iconThemeId}.json\``);
90
- const extensionDirents = await FileSystem.readDir(Path.join(root, 'node_modules', '@lvce-editor', 'server', 'static', commitHash, 'extensions'));
90
+ const extensionDirents = await FileSystem.readDir(Path.join(serverStaticPath, commitHash, 'extensions'));
91
91
  const languageBasicsDirents = extensionDirents.filter(isLanguageBasics);
92
92
  const themeDirents = extensionDirents.filter(isTheme);
93
93
  const iconThemeDirents = extensionDirents.filter(isIconTheme);
@@ -115,7 +115,7 @@ const applyOverrides = async ({ root, commitHash, pathPrefix }) => {
115
115
  * @param {string} dirent
116
116
  */
117
117
  const getManifestPath = (dirent) => {
118
- return Path.join(root, 'node_modules', '@lvce-editor', 'server', 'static', commitHash, 'extensions', dirent, 'extension.json');
118
+ return Path.join(serverStaticPath, commitHash, 'extensions', dirent, 'extension.json');
119
119
  };
120
120
  const manifestPaths = languageBasicsDirents.map(getManifestPath);
121
121
  const manifests = await Promise.all(manifestPaths.map(readExtensionManifest));
@@ -124,17 +124,17 @@ const applyOverrides = async ({ root, commitHash, pathPrefix }) => {
124
124
  const webViews = manifests.flatMap(getWebViews);
125
125
  await JsonFile.writeJson(Path.join(root, 'dist', commitHash, 'config', 'webViews.json'), webViews);
126
126
  for (const languageBasicsDirent of languageBasicsDirents) {
127
- await FileSystem.copy(Path.join(root, 'node_modules', '@lvce-editor', 'server', 'static', commitHash, 'extensions', languageBasicsDirent), Path.join(root, 'dist', commitHash, 'extensions', languageBasicsDirent));
127
+ await FileSystem.copy(Path.join(serverStaticPath, commitHash, 'extensions', languageBasicsDirent), Path.join(root, 'dist', commitHash, 'extensions', languageBasicsDirent));
128
128
  }
129
129
  for (const themeDirent of themeDirents) {
130
130
  const themeId = getThemeName(themeDirent);
131
- await FileSystem.copy(Path.join(root, 'node_modules', '@lvce-editor', 'server', 'static', commitHash, 'extensions', themeDirent, 'color-theme.json'), Path.join(root, 'dist', commitHash, 'themes', `${themeId}.json`));
131
+ await FileSystem.copy(Path.join(serverStaticPath, commitHash, 'extensions', themeDirent, 'color-theme.json'), Path.join(root, 'dist', commitHash, 'themes', `${themeId}.json`));
132
132
  }
133
133
  const themeIds = mergeThemes(themeDirents.map(getThemeName), []);
134
134
  await JsonFile.writeJson(Path.join(root, 'dist', commitHash, 'config', 'themes.json'), themeIds);
135
135
  for (const iconThemeDirent of iconThemeDirents) {
136
136
  const iconThemeId = iconThemeDirent.slice('builtin.'.length);
137
- await FileSystem.copy(Path.join(root, 'node_modules', '@lvce-editor', 'server', 'static', commitHash, 'extensions', iconThemeDirent, 'icon-theme.json'), Path.join(root, 'dist', commitHash, 'icon-themes', `${iconThemeId}.json`));
137
+ await FileSystem.copy(Path.join(serverStaticPath, commitHash, 'extensions', iconThemeDirent, 'icon-theme.json'), Path.join(root, 'dist', commitHash, 'icon-themes', `${iconThemeId}.json`));
138
138
  }
139
139
  await replace(Path.join(root, 'dist', 'index.html'), `/${commitHash}`, `${pathPrefix}/${commitHash}`);
140
140
  if (pathPrefix) {
@@ -340,36 +340,51 @@ const addTestFiles = async ({ testPath, commitHash, root, pathPrefix }) => {
340
340
  const testOverviewHtml = generateTestOverviewHtml(testFiles);
341
341
  await FileSystem.writeFile(`${root}/dist/tests/index.html`, testOverviewHtml);
342
342
  };
343
+ const resolveServerStaticPath = (root) => {
344
+ const guessOne = Path.join(root, 'node_modules', '@lvce-editor', 'server', 'static');
345
+ if (existsSync(guessOne)) {
346
+ return guessOne;
347
+ }
348
+ const guessTwo = Path.join(root, 'packages', 'build', 'node_modules', '@lvce-editor', 'server', 'static');
349
+ if (existsSync(guessTwo)) {
350
+ return guessTwo;
351
+ }
352
+ throw new Error(`server static path not found`);
353
+ };
343
354
  /**
344
355
  *
345
- * @param {{root:string, pathPrefix:string , extensionPath:string, testPath:string, useSimpleWebExtensionFile?:boolean }} param0
356
+ * @param {{root:string, pathPrefix:string , extensionPath:string, testPath:string, useSimpleWebExtensionFile?:boolean, serverStaticPath?:string }} param0
346
357
  */
347
- export const exportStatic = async ({ root, pathPrefix, extensionPath, testPath, useSimpleWebExtensionFile }) => {
358
+ export const exportStatic = async ({ root, pathPrefix, extensionPath, testPath, useSimpleWebExtensionFile, serverStaticPath }) => {
348
359
  if (!existsSync(root)) {
349
360
  throw new Error(`root path does not exist: ${root}`);
350
361
  }
351
362
  if (!existsSync(extensionPath)) {
352
363
  throw new Error(`extension path does not exist: ${extensionPath}`);
353
364
  }
365
+ if (!serverStaticPath) {
366
+ serverStaticPath = resolveServerStaticPath(root);
367
+ }
354
368
  if (pathPrefix === 'auto') {
355
369
  const extensionJson = await readExtensionManifest(Path.join(extensionPath, 'extension.json'));
356
370
  const { id } = extensionJson;
357
371
  const [author, name] = id.split('.');
358
372
  pathPrefix = `/${name}`;
359
373
  }
360
- const dirents = await FileSystem.readDir(Path.join(root, 'node_modules', '@lvce-editor', 'server', 'static'));
374
+ const dirents = await FileSystem.readDir(serverStaticPath);
361
375
  const commitHash = dirents.find(isCommitHash) || '';
362
376
  console.time('clean');
363
377
  await clean(root);
364
378
  console.timeEnd('clean');
365
379
  console.time('copyStaticFiles');
366
- await copyStaticFiles(root, commitHash);
380
+ await copyStaticFiles(root, serverStaticPath);
367
381
  console.timeEnd('copyStaticFiles');
368
382
  console.time('applyOverrides');
369
383
  await applyOverrides({
370
384
  root,
371
385
  commitHash,
372
386
  pathPrefix,
387
+ serverStaticPath,
373
388
  });
374
389
  console.timeEnd('applyOverrides');
375
390
  console.time('addExtension');
@@ -41,9 +41,9 @@ export const getAppImageName = () => {
41
41
  export const getSetupName = () => {
42
42
  return 'Lvce-Setup';
43
43
  };
44
- export const version = '0.33.10';
45
- export const commit = '65becc8';
46
- export const date = '2024-09-07T20:14:21.000Z';
44
+ export const version = '0.33.12';
45
+ export const commit = 'd8ce5d8';
46
+ export const date = '2024-09-08T19:48:59.000Z';
47
47
  export const getVersion = () => {
48
48
  return version;
49
49
  };