mirror of
https://github.com/penpot/penpot.git
synced 2025-12-11 22:14:05 +01:00
⏪ Restore the dashboard thumbnail rendering using wasm (#7796)
* Revert "🐛 Rollback esm worker (#7792)"
This reverts commit 0120a5335b.
* 🐛 Fix incorrect manifest reading on building worker
This commit is contained in:
@@ -180,7 +180,7 @@ export async function watch(baseDir, predicate, callback) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async function readManifestFile(path) {
|
async function readManifestFile() {
|
||||||
const manifestPath = "resources/public/js/manifest.json";
|
const manifestPath = "resources/public/js/manifest.json";
|
||||||
let content = await fs.readFile(manifestPath, { encoding: "utf8" });
|
let content = await fs.readFile(manifestPath, { encoding: "utf8" });
|
||||||
return JSON.parse(content);
|
return JSON.parse(content);
|
||||||
@@ -189,27 +189,19 @@ async function readManifestFile(path) {
|
|||||||
async function readShadowManifest() {
|
async function readShadowManifest() {
|
||||||
const ts = Date.now();
|
const ts = Date.now();
|
||||||
try {
|
try {
|
||||||
const content1 = await readManifestFile(
|
const content = await readManifestFile();
|
||||||
"resources/public/js/manifest.json",
|
|
||||||
);
|
|
||||||
const content2 = await readManifestFile(
|
|
||||||
"resources/public/js/worker/manifest.json",
|
|
||||||
);
|
|
||||||
|
|
||||||
const index = {
|
const index = {
|
||||||
ts: ts,
|
ts: ts,
|
||||||
config: "js/config.js?ts=" + ts,
|
config: "js/config.js?ts=" + ts,
|
||||||
polyfills: "js/polyfills.js?ts=" + ts,
|
polyfills: "js/polyfills.js?ts=" + ts,
|
||||||
|
worker_main: "js/worker/main.js?ts=" + ts,
|
||||||
};
|
};
|
||||||
|
|
||||||
for (let item of content1) {
|
for (let item of content) {
|
||||||
index[item.name] = "js/" + item["output-name"];
|
index[item.name] = "js/" + item["output-name"];
|
||||||
}
|
}
|
||||||
|
|
||||||
for (let item of content2) {
|
|
||||||
index["worker_" + item.name] = "js/worker/" + item["output-name"];
|
|
||||||
}
|
|
||||||
|
|
||||||
return index;
|
return index;
|
||||||
} catch (cause) {
|
} catch (cause) {
|
||||||
return {
|
return {
|
||||||
|
|||||||
@@ -83,7 +83,7 @@
|
|||||||
:source-map-detail-level :all}}}
|
:source-map-detail-level :all}}}
|
||||||
|
|
||||||
:worker
|
:worker
|
||||||
{:target :browser
|
{:target :esm
|
||||||
:output-dir "resources/public/js/worker/"
|
:output-dir "resources/public/js/worker/"
|
||||||
:asset-path "/js/worker"
|
:asset-path "/js/worker"
|
||||||
:devtools {:browser-inject :main
|
:devtools {:browser-inject :main
|
||||||
|
|||||||
@@ -18,6 +18,7 @@
|
|||||||
[app.main.data.notifications :as ntf]
|
[app.main.data.notifications :as ntf]
|
||||||
[app.main.data.project :as dpj]
|
[app.main.data.project :as dpj]
|
||||||
[app.main.data.team :as dtm]
|
[app.main.data.team :as dtm]
|
||||||
|
[app.main.features :as features]
|
||||||
[app.main.fonts :as fonts]
|
[app.main.fonts :as fonts]
|
||||||
[app.main.rasterizer :as thr]
|
[app.main.rasterizer :as thr]
|
||||||
[app.main.refs :as refs]
|
[app.main.refs :as refs]
|
||||||
@@ -58,17 +59,22 @@
|
|||||||
|
|
||||||
(defn render-thumbnail
|
(defn render-thumbnail
|
||||||
[file-id revn]
|
[file-id revn]
|
||||||
(->> (mw/ask! {:cmd :thumbnails/generate-for-file
|
(if (features/active-feature? @st/state "render-wasm/v1")
|
||||||
:revn revn
|
(->> (mw/ask! {:cmd :thumbnails/generate-for-file-wasm
|
||||||
:file-id file-id
|
:revn revn
|
||||||
:width thumbnail-width})
|
:file-id file-id
|
||||||
(rx/mapcat
|
:width thumbnail-width}))
|
||||||
(fn [{:keys [fonts] :as result}]
|
(->> (mw/ask! {:cmd :thumbnails/generate-for-file
|
||||||
(->> (fonts/render-font-styles fonts)
|
:revn revn
|
||||||
(rx/map (fn [styles]
|
:file-id file-id
|
||||||
(-> result
|
:width thumbnail-width})
|
||||||
(assoc :styles styles
|
(rx/mapcat
|
||||||
:width thumbnail-width)))))))))
|
(fn [{:keys [fonts] :as result}]
|
||||||
|
(->> (fonts/render-font-styles fonts)
|
||||||
|
(rx/map (fn [styles]
|
||||||
|
(-> result
|
||||||
|
(assoc :styles styles
|
||||||
|
:width thumbnail-width))))))))))
|
||||||
|
|
||||||
(defn- ask-for-thumbnail
|
(defn- ask-for-thumbnail
|
||||||
"Creates some hooks to handle the files thumbnails cache"
|
"Creates some hooks to handle the files thumbnails cache"
|
||||||
|
|||||||
@@ -89,7 +89,7 @@
|
|||||||
(defn init
|
(defn init
|
||||||
"Return a initialized webworker instance."
|
"Return a initialized webworker instance."
|
||||||
[path on-error]
|
[path on-error]
|
||||||
(let [instance (js/Worker. path)
|
(let [instance (js/Worker. path #js {:type "module"})
|
||||||
bus (rx/subject)
|
bus (rx/subject)
|
||||||
worker (Worker. instance (rx/to-observable bus))
|
worker (Worker. instance (rx/to-observable bus))
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user