mirror of
https://github.com/penpot/penpot.git
synced 2025-01-08 07:50:43 -05:00
feat(frontend): remove bide dependency
This commit is contained in:
parent
1bf12a7338
commit
0115a86b24
7 changed files with 73 additions and 13 deletions
|
@ -4,19 +4,17 @@
|
|||
com.cognitect/transit-cljs {:mvn/version "0.8.256"}
|
||||
|
||||
funcool/rumext {:git/url "https://github.com/funcool/rumext.git",
|
||||
:sha "3d598e749ba429eae6544e532fc9f81369b307f5"}
|
||||
:sha "3d598e749ba429eae6544e532fc9f81369b307f5"
|
||||
:exclusions [org.omcljs/om sablono/sablono]}
|
||||
|
||||
cljsjs/react {:mvn/version "16.8.6-0"}
|
||||
cljsjs/react-dom {:mvn/version "16.8.6-0"}
|
||||
cljsjs/react-dom-server {:mvn/version "16.8.6-0"}
|
||||
|
||||
environ/environ {:mvn/version "1.1.0"}
|
||||
|
||||
metosin/reitit-core {:mvn/version "0.3.9"}
|
||||
metosin/reitit-frontend {:mvn/version "0.3.9"}
|
||||
|
||||
funcool/beicon {:mvn/version "5.0.0"}
|
||||
funcool/bide {:mvn/version "1.6.1-SNAPSHOT"}
|
||||
funcool/cuerdas {:mvn/version "2.2.0"}
|
||||
funcool/lentes {:mvn/version "1.2.0"}
|
||||
funcool/potok {:mvn/version "2.3.0"}
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
[uxbox.main.ui.lightbox :refer [lightbox]]
|
||||
[uxbox.main.ui.loader :refer [loader]]
|
||||
[uxbox.util.dom :as dom]
|
||||
[uxbox.util.html-history :as html-history]
|
||||
[uxbox.util.html.history :as html-history]
|
||||
[uxbox.util.i18n :as i18n :refer [tr]]
|
||||
[uxbox.util.messages :as uum]
|
||||
[uxbox.util.router :as rt]
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
[uxbox.main.ui.workspace :refer [workspace]]
|
||||
[uxbox.util.data :refer [parse-int uuid-str?]]
|
||||
[uxbox.util.dom :as dom]
|
||||
[uxbox.util.html-history :as html-history]
|
||||
[uxbox.util.html.history :as html-history]
|
||||
[uxbox.util.i18n :refer [tr]]
|
||||
[uxbox.util.messages :as uum]
|
||||
[uxbox.util.router :as rt]
|
||||
|
|
60
frontend/src/uxbox/util/html/TokenTransformer.js
Normal file
60
frontend/src/uxbox/util/html/TokenTransformer.js
Normal file
|
@ -0,0 +1,60 @@
|
|||
/**
|
||||
* TokenTransformer
|
||||
*
|
||||
* @author Paul Anderson <paul@andersonpaul.com>, 2018
|
||||
* @license BSD License <https://opensource.org/licenses/BSD-2-Clause>
|
||||
*/
|
||||
|
||||
goog.provide('uxbox.util.html.TokenTransformer');
|
||||
goog.require('goog.history.Html5History');
|
||||
|
||||
goog.scope(function() {
|
||||
/**
|
||||
* A goog.history.Html5History.TokenTransformer implementation that
|
||||
* includes the query string in the token.
|
||||
*
|
||||
* The implementation of token<->url transforms in
|
||||
* `goog.history.Html5History`, when useFragment is false and no custom
|
||||
* transformer is supplied, assumes that a token is equivalent to
|
||||
* `window.location.pathname` minus any configured path prefix. Since
|
||||
* bide allows constructing urls that include a query string, we want
|
||||
* to be able to store those as tokens.
|
||||
*
|
||||
* Addresses funcool/bide#15.
|
||||
*
|
||||
* @constructor
|
||||
* @implements {goog.history.Html5History.TokenTransformer}
|
||||
*/
|
||||
uxbox.util.html.TokenTransformer = function () {};
|
||||
|
||||
/**
|
||||
* Retrieves a history token given the path prefix and
|
||||
* `window.location` object.
|
||||
*
|
||||
* @param {string} pathPrefix The path prefix to use when storing token
|
||||
* in a path; always begin with a slash.
|
||||
* @param {Location} location The `window.location` object.
|
||||
* Treat this object as read-only.
|
||||
* @return {string} token The history token.
|
||||
*/
|
||||
uxbox.util.html.TokenTransformer.prototype.retrieveToken = function(pathPrefix, location) {
|
||||
return location.pathname.substr(pathPrefix.length) + location.search;
|
||||
};
|
||||
|
||||
/**
|
||||
* Creates a URL to be pushed into HTML5 history stack when storing
|
||||
* token without using hash fragment.
|
||||
*
|
||||
* @param {string} token The history token.
|
||||
* @param {string} pathPrefix The path prefix to use when storing token
|
||||
* in a path; always begin with a slash.
|
||||
* @param {Location} location The `window.location` object.
|
||||
* Treat this object as read-only.
|
||||
* @return {string} url The complete URL string from path onwards
|
||||
* (without {@code protocol://host:port} part); must begin with a
|
||||
* slash.
|
||||
*/
|
||||
uxbox.util.html.TokenTransformer.prototype.createUrl = function(token, pathPrefix, location) {
|
||||
return pathPrefix + token;
|
||||
};
|
||||
});
|
|
@ -2,23 +2,25 @@
|
|||
;; License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
;; file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
;;
|
||||
;; Copyright (c) 2015-2017 Andrey Antukh <niwi@niwi.nz>
|
||||
;; Copyright (c) 2019 Andrey Antukh <niwi@niwi.nz>
|
||||
|
||||
(ns uxbox.util.html-history
|
||||
(ns uxbox.util.html.history
|
||||
"A singleton abstraction for the html5 fragment based history."
|
||||
(:require [goog.events :as e])
|
||||
(:import bide.impl.TokenTransformer
|
||||
(:import uxbox.util.html.TokenTransformer
|
||||
goog.history.Html5History
|
||||
goog.history.EventType))
|
||||
|
||||
(defonce +instance+
|
||||
(defonce ^:private +instance+
|
||||
(doto (Html5History. nil (TokenTransformer.))
|
||||
(.setUseFragment true)
|
||||
(.setEnabled true)))
|
||||
|
||||
(defonce path (atom (.getToken +instance+)))
|
||||
|
||||
(e/listen +instance+ EventType.NAVIGATE #(reset! path (.-token %)))
|
||||
(defonce ^:private +instance-sem+
|
||||
(e/listen +instance+ EventType.NAVIGATE
|
||||
#(reset! path (.-token %))))
|
||||
|
||||
(defn set-path!
|
||||
[path]
|
|
@ -8,7 +8,7 @@
|
|||
(:require [reitit.core :as r]
|
||||
[cuerdas.core :as str]
|
||||
[potok.core :as ptk]
|
||||
[uxbox.util.html-history :as html-history])
|
||||
[uxbox.util.html.history :as html-history])
|
||||
(:import goog.Uri
|
||||
goog.Uri.QueryData))
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
[rumext.core :as mx :include-macros true]
|
||||
[uxbox.config]
|
||||
[uxbox.util.dom :as dom]
|
||||
[uxbox.util.html-history :as html-history]
|
||||
[uxbox.util.html.history :as html-history]
|
||||
[uxbox.util.i18n :as i18n :refer [tr]]
|
||||
[uxbox.util.messages :as uum]
|
||||
[uxbox.util.router :as rt]
|
||||
|
|
Loading…
Reference in a new issue