0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-03-10 06:41:40 -05:00

🐛 Fix worker uri handling on release builds.

This commit is contained in:
Andrey Antukh 2020-06-08 19:07:13 +02:00
parent a4c7215fa8
commit 006bacfef0
6 changed files with 21 additions and 38 deletions

View file

@ -110,7 +110,6 @@ function readLocales() {
function readConfig(data) {
const googleClientID = process.env.UXBOX_GOOGLE_CLIENT_ID;
const publicURI = process.env.UXBOX_PUBLIC_URI;
const demoWarn = process.env.UXBOX_DEMO_WARNING;
const deployDate = process.env.UXBOX_DEPLOY_DATE;
const deployCommit = process.env.UXBOX_DEPLOY_COMMIT;
@ -123,10 +122,6 @@ function readConfig(data) {
cfg.googleClientID = googleClientID;
}
if (publicURI !== undefined) {
cfg.publicURI = publicURI;
}
if (deployDate !== undefined) {
cfg.deployDate = deployDate;
}
@ -140,26 +135,24 @@ function readConfig(data) {
return JSON.stringify(cfg);
}
const defaultManifest = {
"main": "/js/main.js",
"shared": "/js/shared.js",
"worker": "js/worker.js"
};
function readManifest() {
function readManifest(publicURI) {
try {
const path = __dirname + "/resources/public/js/manifest.json";
const content = JSON.parse(fs.readFileSync(path, {encoding: "utf8"}));
const index = {};
for (let item of content) {
index[item.name] = "/js/" + item["output-name"];
index[item.name] = publicURI + "/js/" + item["output-name"];
};
return index;
} catch (e) {
console.error("Error on reading manifest, using default.");
return defaultManifest;
return {
"main": publicURI + "/js/main.js",
"shared": publicURI + "/js/shared.js",
"worker": publicURI + "/js/worker.js"
};
}
}
@ -182,12 +175,18 @@ function templatePipeline(options) {
const output = options.output;
const ts = Math.floor(new Date());
const publicURI = process.env.UXBOX_PUBLIC_URI || "http://localhost:3449";
const th = process.env.UXBOX_THEME || "default";
const themes = ["default"];
const locales = readLocales();
const manifest = readManifest();
const config = readConfig({themes, manifest});
const manifest = readManifest(publicURI);
const config = readConfig({
workerURI: manifest.worker,
publicURI: publicURI
});
const tmpl = mustache({
ts: ts,

View file

@ -12,11 +12,13 @@
(this-as global
(let [config (obj/get global "uxboxConfig")
puri (obj/get config "publicURI" "http://localhost:3449/")
puri (obj/get config "publicURI")
wuri (obj/get config "workerURI")
gcid (obj/get config "googleClientID" true)
warn (obj/get config "demoWarning" true)]
(def default-language "en")
(def demo-warning warn)
(def google-client-id gcid)
(def worker-uri wuri)
(def public-uri puri)
(def default-theme "default")))

View file

@ -12,9 +12,7 @@
[cljs.spec.alpha :as s]
[uxbox.config :as cfg]
[uxbox.common.spec :as us]
[uxbox.util.worker :as uw])
(:import
goog.Uri))
[uxbox.util.worker :as uw]))
(defn on-error
[instance error]
@ -22,10 +20,7 @@
(defonce instance
(when (not= *target* "nodejs")
(let [uri (Uri. cfg/public-uri)]
(.setPath uri "/js/worker.js")
(.setParameterValue uri "publicURI" cfg/public-uri)
(uw/init (.toString uri) on-error))))
(uw/init cfg/worker-uri on-error)))
(defn ask!
[message]

View file

@ -25,14 +25,6 @@
[uxbox.util.worker :as w])
(:import goog.Uri))
;; --- Initialization
(this-as global
(let [location (obj/get global "location")
uri (Uri. (obj/get location "href"))
puri (.getParameterValue uri "publicURI")]
(swap! impl/config assoc :public-uri puri)))
;; --- Messages Handling
(s/def ::cmd keyword?)

View file

@ -11,10 +11,6 @@
(enable-console-print!)
;; --- Config
(defonce config (l/atom {}))
;; --- Handler
(defmulti handler :cmd)

View file

@ -33,8 +33,7 @@
(defn- request-page
[id]
(let [uri (get @impl/config :public-uri "http://localhost:3449/")
uri (str uri "/api/w/query/page")]
(let [uri "/api/w/query/page"]
(p/create
(fn [resolve reject]
(->> (http/send! {:uri uri