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";
|
||||
let content = await fs.readFile(manifestPath, { encoding: "utf8" });
|
||||
return JSON.parse(content);
|
||||
@@ -189,27 +189,19 @@ async function readManifestFile(path) {
|
||||
async function readShadowManifest() {
|
||||
const ts = Date.now();
|
||||
try {
|
||||
const content1 = await readManifestFile(
|
||||
"resources/public/js/manifest.json",
|
||||
);
|
||||
const content2 = await readManifestFile(
|
||||
"resources/public/js/worker/manifest.json",
|
||||
);
|
||||
const content = await readManifestFile();
|
||||
|
||||
const index = {
|
||||
ts: ts,
|
||||
config: "js/config.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"];
|
||||
}
|
||||
|
||||
for (let item of content2) {
|
||||
index["worker_" + item.name] = "js/worker/" + item["output-name"];
|
||||
}
|
||||
|
||||
return index;
|
||||
} catch (cause) {
|
||||
return {
|
||||
|
||||
@@ -83,7 +83,7 @@
|
||||
:source-map-detail-level :all}}}
|
||||
|
||||
:worker
|
||||
{:target :browser
|
||||
{:target :esm
|
||||
:output-dir "resources/public/js/worker/"
|
||||
:asset-path "/js/worker"
|
||||
:devtools {:browser-inject :main
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
[app.main.data.notifications :as ntf]
|
||||
[app.main.data.project :as dpj]
|
||||
[app.main.data.team :as dtm]
|
||||
[app.main.features :as features]
|
||||
[app.main.fonts :as fonts]
|
||||
[app.main.rasterizer :as thr]
|
||||
[app.main.refs :as refs]
|
||||
@@ -58,6 +59,11 @@
|
||||
|
||||
(defn render-thumbnail
|
||||
[file-id revn]
|
||||
(if (features/active-feature? @st/state "render-wasm/v1")
|
||||
(->> (mw/ask! {:cmd :thumbnails/generate-for-file-wasm
|
||||
:revn revn
|
||||
:file-id file-id
|
||||
:width thumbnail-width}))
|
||||
(->> (mw/ask! {:cmd :thumbnails/generate-for-file
|
||||
:revn revn
|
||||
:file-id file-id
|
||||
@@ -68,7 +74,7 @@
|
||||
(rx/map (fn [styles]
|
||||
(-> result
|
||||
(assoc :styles styles
|
||||
:width thumbnail-width)))))))))
|
||||
:width thumbnail-width))))))))))
|
||||
|
||||
(defn- ask-for-thumbnail
|
||||
"Creates some hooks to handle the files thumbnails cache"
|
||||
|
||||
@@ -89,7 +89,7 @@
|
||||
(defn init
|
||||
"Return a initialized webworker instance."
|
||||
[path on-error]
|
||||
(let [instance (js/Worker. path)
|
||||
(let [instance (js/Worker. path #js {:type "module"})
|
||||
bus (rx/subject)
|
||||
worker (Worker. instance (rx/to-observable bus))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user