Don't track out

This commit is contained in:
Scott Richmond 2023-11-16 13:24:47 -05:00
parent 3273ab4385
commit e276298f4e
163 changed files with 1 additions and 102545 deletions

1
.gitignore vendored
View File

@ -20,3 +20,4 @@ pom.xml.asc
/sandbox /sandbox
ludus.sublime-workspace ludus.sublime-workspace
/ludus /ludus
/out/

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@ -1,206 +0,0 @@
;; Copyright (c) Rich Hickey. All rights reserved.
;; The use and distribution terms for this software are covered by the
;; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)
;; which can be found in the file epl-v10.html at the root of this distribution.
;; By using this software in any fashion, you are agreeing to be bound by
;; the terms of this license.
;; You must not remove this notice, or any other, from this software.
(ns cljs.repl
(:require-macros cljs.repl)
(:require [cljs.spec.alpha :as spec]
[goog.string :as gstring]
[goog.string.format]))
(defn print-doc [{n :ns nm :name :as m}]
(println "-------------------------")
(println (or (:spec m) (str (when-let [ns (:ns m)] (str ns "/")) (:name m))))
(when (:protocol m)
(println "Protocol"))
(cond
(:forms m) (doseq [f (:forms m)]
(println " " f))
(:arglists m) (let [arglists (:arglists m)]
(if (or (:macro m)
(:repl-special-function m))
(prn arglists)
(prn
(if (= 'quote (first arglists))
(second arglists)
arglists)))))
(if (:special-form m)
(do
(println "Special Form")
(println " " (:doc m))
(if (contains? m :url)
(when (:url m)
(println (str "\n Please see http://clojure.org/" (:url m))))
(println (str "\n Please see http://clojure.org/special_forms#"
(:name m)))))
(do
(when (:macro m)
(println "Macro"))
(when (:spec m)
(println "Spec"))
(when (:repl-special-function m)
(println "REPL Special Function"))
(println " " (:doc m))
(when (:protocol m)
(doseq [[name {:keys [doc arglists]}] (:methods m)]
(println)
(println " " name)
(println " " arglists)
(when doc
(println " " doc))))
(when n
(when-let [fnspec (spec/get-spec (symbol (str (ns-name n)) (name nm)))]
(print "Spec")
(doseq [role [:args :ret :fn]]
(when-let [spec (get fnspec role)]
(print (str "\n " (name role) ":") (spec/describe spec)))))))))
(defn Error->map
"Constructs a data representation for a Error with keys:
:cause - root cause message
:phase - error phase
:via - cause chain, with cause keys:
:type - exception class symbol
:message - exception message
:data - ex-data
:at - top stack element
:trace - root cause stack elements"
[o]
(Throwable->map o))
(defn ex-triage
"Returns an analysis of the phase, error, cause, and location of an error that occurred
based on Throwable data, as returned by Throwable->map. All attributes other than phase
are optional:
:clojure.error/phase - keyword phase indicator, one of:
:read-source :compile-syntax-check :compilation :macro-syntax-check :macroexpansion
:execution :read-eval-result :print-eval-result
:clojure.error/source - file name (no path)
:clojure.error/line - integer line number
:clojure.error/column - integer column number
:clojure.error/symbol - symbol being expanded/compiled/invoked
:clojure.error/class - cause exception class symbol
:clojure.error/cause - cause exception message
:clojure.error/spec - explain-data for spec error"
[datafied-throwable]
(let [{:keys [via trace phase] :or {phase :execution}} datafied-throwable
{:keys [type message data]} (last via)
{:cljs.spec.alpha/keys [problems fn] :cljs.spec.test.alpha/keys [caller]} data
{:keys [:clojure.error/source] :as top-data} (:data (first via))]
(assoc
(case phase
:read-source
(let [{:keys [:clojure.error/line :clojure.error/column]} data]
(cond-> (merge (-> via second :data) top-data)
source (assoc :clojure.error/source source)
(#{"NO_SOURCE_FILE" "NO_SOURCE_PATH"} source) (dissoc :clojure.error/source)
message (assoc :clojure.error/cause message)))
(:compile-syntax-check :compilation :macro-syntax-check :macroexpansion)
(cond-> top-data
source (assoc :clojure.error/source source)
(#{"NO_SOURCE_FILE" "NO_SOURCE_PATH"} source) (dissoc :clojure.error/source)
type (assoc :clojure.error/class type)
message (assoc :clojure.error/cause message)
problems (assoc :clojure.error/spec data))
(:read-eval-result :print-eval-result)
(let [[source method file line] (-> trace first)]
(cond-> top-data
line (assoc :clojure.error/line line)
file (assoc :clojure.error/source file)
(and source method) (assoc :clojure.error/symbol (vector #_java-loc->source source method))
type (assoc :clojure.error/class type)
message (assoc :clojure.error/cause message)))
:execution
(let [[source method file line] (->> trace #_(drop-while #(core-class? (name (first %)))) first)
file (first (remove #(or (nil? %) (#{"NO_SOURCE_FILE" "NO_SOURCE_PATH"} %)) [(:file caller) file]))
err-line (or (:line caller) line)]
(cond-> {:clojure.error/class type}
err-line (assoc :clojure.error/line err-line)
message (assoc :clojure.error/cause message)
(or fn (and source method)) (assoc :clojure.error/symbol (or fn (vector #_java-loc->source source method)))
file (assoc :clojure.error/source file)
problems (assoc :clojure.error/spec data))))
:clojure.error/phase phase)))
(defn ex-str
"Returns a string from exception data, as produced by ex-triage.
The first line summarizes the exception phase and location.
The subsequent lines describe the cause."
[{:clojure.error/keys [phase source line column symbol class cause spec] :as triage-data}]
(let [loc (str (or source "<cljs repl>") ":" (or line 1) (if column (str ":" column) ""))
class-name (name (or class ""))
simple-class class-name
cause-type (if (contains? #{"Exception" "RuntimeException"} simple-class)
"" ;; omit, not useful
(str " (" simple-class ")"))
format gstring/format]
(case phase
:read-source
(format "Syntax error reading source at (%s).\n%s\n" loc cause)
:macro-syntax-check
(format "Syntax error macroexpanding %sat (%s).\n%s"
(if symbol (str symbol " ") "")
loc
(if spec
(with-out-str
(spec/explain-out
(if true #_(= s/*explain-out* s/explain-printer)
(update spec ::spec/problems
(fn [probs] (map #(dissoc % :in) probs)))
spec)))
(format "%s\n" cause)))
:macroexpansion
(format "Unexpected error%s macroexpanding %sat (%s).\n%s\n"
cause-type
(if symbol (str symbol " ") "")
loc
cause)
:compile-syntax-check
(format "Syntax error%s compiling %sat (%s).\n%s\n"
cause-type
(if symbol (str symbol " ") "")
loc
cause)
:compilation
(format "Unexpected error%s compiling %sat (%s).\n%s\n"
cause-type
(if symbol (str symbol " ") "")
loc
cause)
:read-eval-result
(format "Error reading eval result%s at %s (%s).\n%s\n" cause-type symbol loc cause)
:print-eval-result
(format "Error printing return value%s at %s (%s).\n%s\n" cause-type symbol loc cause)
:execution
(if spec
(format "Execution error - invalid arguments to %s at (%s).\n%s"
symbol
loc
(with-out-str
(spec/explain-out
(if true #_(= s/*explain-out* s/explain-printer)
(update spec ::spec/problems
(fn [probs] (map #(dissoc % :in) probs)))
spec))))
(format "Execution error%s at %s(%s).\n%s\n"
cause-type
(if symbol (str symbol " ") "")
loc
cause)))))
(defn error->str [error]
(ex-str (ex-triage (Error->map error))))

File diff suppressed because one or more lines are too long

View File

@ -1,601 +0,0 @@
// Compiled by ClojureScript 1.11.121 {:optimizations :none}
goog.provide('cljs.repl');
goog.require('cljs.core');
goog.require('cljs.spec.alpha');
goog.require('goog.string');
goog.require('goog.string.format');
cljs.repl.print_doc = (function cljs$repl$print_doc(p__1484){
var map__1485 = p__1484;
var map__1485__$1 = cljs.core.__destructure_map.call(null,map__1485);
var m = map__1485__$1;
var n = cljs.core.get.call(null,map__1485__$1,new cljs.core.Keyword(null,"ns","ns",441598760));
var nm = cljs.core.get.call(null,map__1485__$1,new cljs.core.Keyword(null,"name","name",1843675177));
cljs.core.println.call(null,"-------------------------");
cljs.core.println.call(null,(function (){var or__4998__auto__ = new cljs.core.Keyword(null,"spec","spec",347520401).cljs$core$IFn$_invoke$arity$1(m);
if(cljs.core.truth_(or__4998__auto__)){
return or__4998__auto__;
} else {
return [(function (){var temp__5804__auto__ = new cljs.core.Keyword(null,"ns","ns",441598760).cljs$core$IFn$_invoke$arity$1(m);
if(cljs.core.truth_(temp__5804__auto__)){
var ns = temp__5804__auto__;
return [cljs.core.str.cljs$core$IFn$_invoke$arity$1(ns),"/"].join('');
} else {
return null;
}
})(),cljs.core.str.cljs$core$IFn$_invoke$arity$1(new cljs.core.Keyword(null,"name","name",1843675177).cljs$core$IFn$_invoke$arity$1(m))].join('');
}
})());
if(cljs.core.truth_(new cljs.core.Keyword(null,"protocol","protocol",652470118).cljs$core$IFn$_invoke$arity$1(m))){
cljs.core.println.call(null,"Protocol");
} else {
}
if(cljs.core.truth_(new cljs.core.Keyword(null,"forms","forms",2045992350).cljs$core$IFn$_invoke$arity$1(m))){
var seq__1486_1514 = cljs.core.seq.call(null,new cljs.core.Keyword(null,"forms","forms",2045992350).cljs$core$IFn$_invoke$arity$1(m));
var chunk__1487_1515 = null;
var count__1488_1516 = (0);
var i__1489_1517 = (0);
while(true){
if((i__1489_1517 < count__1488_1516)){
var f_1518 = cljs.core._nth.call(null,chunk__1487_1515,i__1489_1517);
cljs.core.println.call(null," ",f_1518);
var G__1519 = seq__1486_1514;
var G__1520 = chunk__1487_1515;
var G__1521 = count__1488_1516;
var G__1522 = (i__1489_1517 + (1));
seq__1486_1514 = G__1519;
chunk__1487_1515 = G__1520;
count__1488_1516 = G__1521;
i__1489_1517 = G__1522;
continue;
} else {
var temp__5804__auto___1523 = cljs.core.seq.call(null,seq__1486_1514);
if(temp__5804__auto___1523){
var seq__1486_1524__$1 = temp__5804__auto___1523;
if(cljs.core.chunked_seq_QMARK_.call(null,seq__1486_1524__$1)){
var c__5521__auto___1525 = cljs.core.chunk_first.call(null,seq__1486_1524__$1);
var G__1526 = cljs.core.chunk_rest.call(null,seq__1486_1524__$1);
var G__1527 = c__5521__auto___1525;
var G__1528 = cljs.core.count.call(null,c__5521__auto___1525);
var G__1529 = (0);
seq__1486_1514 = G__1526;
chunk__1487_1515 = G__1527;
count__1488_1516 = G__1528;
i__1489_1517 = G__1529;
continue;
} else {
var f_1530 = cljs.core.first.call(null,seq__1486_1524__$1);
cljs.core.println.call(null," ",f_1530);
var G__1531 = cljs.core.next.call(null,seq__1486_1524__$1);
var G__1532 = null;
var G__1533 = (0);
var G__1534 = (0);
seq__1486_1514 = G__1531;
chunk__1487_1515 = G__1532;
count__1488_1516 = G__1533;
i__1489_1517 = G__1534;
continue;
}
} else {
}
}
break;
}
} else {
if(cljs.core.truth_(new cljs.core.Keyword(null,"arglists","arglists",1661989754).cljs$core$IFn$_invoke$arity$1(m))){
var arglists_1535 = new cljs.core.Keyword(null,"arglists","arglists",1661989754).cljs$core$IFn$_invoke$arity$1(m);
if(cljs.core.truth_((function (){var or__4998__auto__ = new cljs.core.Keyword(null,"macro","macro",-867863404).cljs$core$IFn$_invoke$arity$1(m);
if(cljs.core.truth_(or__4998__auto__)){
return or__4998__auto__;
} else {
return new cljs.core.Keyword(null,"repl-special-function","repl-special-function",1262603725).cljs$core$IFn$_invoke$arity$1(m);
}
})())){
cljs.core.prn.call(null,arglists_1535);
} else {
cljs.core.prn.call(null,((cljs.core._EQ_.call(null,new cljs.core.Symbol(null,"quote","quote",1377916282,null),cljs.core.first.call(null,arglists_1535)))?cljs.core.second.call(null,arglists_1535):arglists_1535));
}
} else {
}
}
if(cljs.core.truth_(new cljs.core.Keyword(null,"special-form","special-form",-1326536374).cljs$core$IFn$_invoke$arity$1(m))){
cljs.core.println.call(null,"Special Form");
cljs.core.println.call(null," ",new cljs.core.Keyword(null,"doc","doc",1913296891).cljs$core$IFn$_invoke$arity$1(m));
if(cljs.core.contains_QMARK_.call(null,m,new cljs.core.Keyword(null,"url","url",276297046))){
if(cljs.core.truth_(new cljs.core.Keyword(null,"url","url",276297046).cljs$core$IFn$_invoke$arity$1(m))){
return cljs.core.println.call(null,["\n Please see http://clojure.org/",cljs.core.str.cljs$core$IFn$_invoke$arity$1(new cljs.core.Keyword(null,"url","url",276297046).cljs$core$IFn$_invoke$arity$1(m))].join(''));
} else {
return null;
}
} else {
return cljs.core.println.call(null,["\n Please see http://clojure.org/special_forms#",cljs.core.str.cljs$core$IFn$_invoke$arity$1(new cljs.core.Keyword(null,"name","name",1843675177).cljs$core$IFn$_invoke$arity$1(m))].join(''));
}
} else {
if(cljs.core.truth_(new cljs.core.Keyword(null,"macro","macro",-867863404).cljs$core$IFn$_invoke$arity$1(m))){
cljs.core.println.call(null,"Macro");
} else {
}
if(cljs.core.truth_(new cljs.core.Keyword(null,"spec","spec",347520401).cljs$core$IFn$_invoke$arity$1(m))){
cljs.core.println.call(null,"Spec");
} else {
}
if(cljs.core.truth_(new cljs.core.Keyword(null,"repl-special-function","repl-special-function",1262603725).cljs$core$IFn$_invoke$arity$1(m))){
cljs.core.println.call(null,"REPL Special Function");
} else {
}
cljs.core.println.call(null," ",new cljs.core.Keyword(null,"doc","doc",1913296891).cljs$core$IFn$_invoke$arity$1(m));
if(cljs.core.truth_(new cljs.core.Keyword(null,"protocol","protocol",652470118).cljs$core$IFn$_invoke$arity$1(m))){
var seq__1490_1536 = cljs.core.seq.call(null,new cljs.core.Keyword(null,"methods","methods",453930866).cljs$core$IFn$_invoke$arity$1(m));
var chunk__1491_1537 = null;
var count__1492_1538 = (0);
var i__1493_1539 = (0);
while(true){
if((i__1493_1539 < count__1492_1538)){
var vec__1502_1540 = cljs.core._nth.call(null,chunk__1491_1537,i__1493_1539);
var name_1541 = cljs.core.nth.call(null,vec__1502_1540,(0),null);
var map__1505_1542 = cljs.core.nth.call(null,vec__1502_1540,(1),null);
var map__1505_1543__$1 = cljs.core.__destructure_map.call(null,map__1505_1542);
var doc_1544 = cljs.core.get.call(null,map__1505_1543__$1,new cljs.core.Keyword(null,"doc","doc",1913296891));
var arglists_1545 = cljs.core.get.call(null,map__1505_1543__$1,new cljs.core.Keyword(null,"arglists","arglists",1661989754));
cljs.core.println.call(null);
cljs.core.println.call(null," ",name_1541);
cljs.core.println.call(null," ",arglists_1545);
if(cljs.core.truth_(doc_1544)){
cljs.core.println.call(null," ",doc_1544);
} else {
}
var G__1546 = seq__1490_1536;
var G__1547 = chunk__1491_1537;
var G__1548 = count__1492_1538;
var G__1549 = (i__1493_1539 + (1));
seq__1490_1536 = G__1546;
chunk__1491_1537 = G__1547;
count__1492_1538 = G__1548;
i__1493_1539 = G__1549;
continue;
} else {
var temp__5804__auto___1550 = cljs.core.seq.call(null,seq__1490_1536);
if(temp__5804__auto___1550){
var seq__1490_1551__$1 = temp__5804__auto___1550;
if(cljs.core.chunked_seq_QMARK_.call(null,seq__1490_1551__$1)){
var c__5521__auto___1552 = cljs.core.chunk_first.call(null,seq__1490_1551__$1);
var G__1553 = cljs.core.chunk_rest.call(null,seq__1490_1551__$1);
var G__1554 = c__5521__auto___1552;
var G__1555 = cljs.core.count.call(null,c__5521__auto___1552);
var G__1556 = (0);
seq__1490_1536 = G__1553;
chunk__1491_1537 = G__1554;
count__1492_1538 = G__1555;
i__1493_1539 = G__1556;
continue;
} else {
var vec__1506_1557 = cljs.core.first.call(null,seq__1490_1551__$1);
var name_1558 = cljs.core.nth.call(null,vec__1506_1557,(0),null);
var map__1509_1559 = cljs.core.nth.call(null,vec__1506_1557,(1),null);
var map__1509_1560__$1 = cljs.core.__destructure_map.call(null,map__1509_1559);
var doc_1561 = cljs.core.get.call(null,map__1509_1560__$1,new cljs.core.Keyword(null,"doc","doc",1913296891));
var arglists_1562 = cljs.core.get.call(null,map__1509_1560__$1,new cljs.core.Keyword(null,"arglists","arglists",1661989754));
cljs.core.println.call(null);
cljs.core.println.call(null," ",name_1558);
cljs.core.println.call(null," ",arglists_1562);
if(cljs.core.truth_(doc_1561)){
cljs.core.println.call(null," ",doc_1561);
} else {
}
var G__1563 = cljs.core.next.call(null,seq__1490_1551__$1);
var G__1564 = null;
var G__1565 = (0);
var G__1566 = (0);
seq__1490_1536 = G__1563;
chunk__1491_1537 = G__1564;
count__1492_1538 = G__1565;
i__1493_1539 = G__1566;
continue;
}
} else {
}
}
break;
}
} else {
}
if(cljs.core.truth_(n)){
var temp__5804__auto__ = cljs.spec.alpha.get_spec.call(null,cljs.core.symbol.call(null,cljs.core.str.cljs$core$IFn$_invoke$arity$1(cljs.core.ns_name.call(null,n)),cljs.core.name.call(null,nm)));
if(cljs.core.truth_(temp__5804__auto__)){
var fnspec = temp__5804__auto__;
cljs.core.print.call(null,"Spec");
var seq__1510 = cljs.core.seq.call(null,new cljs.core.PersistentVector(null, 3, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Keyword(null,"args","args",1315556576),new cljs.core.Keyword(null,"ret","ret",-468222814),new cljs.core.Keyword(null,"fn","fn",-1175266204)], null));
var chunk__1511 = null;
var count__1512 = (0);
var i__1513 = (0);
while(true){
if((i__1513 < count__1512)){
var role = cljs.core._nth.call(null,chunk__1511,i__1513);
var temp__5804__auto___1567__$1 = cljs.core.get.call(null,fnspec,role);
if(cljs.core.truth_(temp__5804__auto___1567__$1)){
var spec_1568 = temp__5804__auto___1567__$1;
cljs.core.print.call(null,["\n ",cljs.core.name.call(null,role),":"].join(''),cljs.spec.alpha.describe.call(null,spec_1568));
} else {
}
var G__1569 = seq__1510;
var G__1570 = chunk__1511;
var G__1571 = count__1512;
var G__1572 = (i__1513 + (1));
seq__1510 = G__1569;
chunk__1511 = G__1570;
count__1512 = G__1571;
i__1513 = G__1572;
continue;
} else {
var temp__5804__auto____$1 = cljs.core.seq.call(null,seq__1510);
if(temp__5804__auto____$1){
var seq__1510__$1 = temp__5804__auto____$1;
if(cljs.core.chunked_seq_QMARK_.call(null,seq__1510__$1)){
var c__5521__auto__ = cljs.core.chunk_first.call(null,seq__1510__$1);
var G__1573 = cljs.core.chunk_rest.call(null,seq__1510__$1);
var G__1574 = c__5521__auto__;
var G__1575 = cljs.core.count.call(null,c__5521__auto__);
var G__1576 = (0);
seq__1510 = G__1573;
chunk__1511 = G__1574;
count__1512 = G__1575;
i__1513 = G__1576;
continue;
} else {
var role = cljs.core.first.call(null,seq__1510__$1);
var temp__5804__auto___1577__$2 = cljs.core.get.call(null,fnspec,role);
if(cljs.core.truth_(temp__5804__auto___1577__$2)){
var spec_1578 = temp__5804__auto___1577__$2;
cljs.core.print.call(null,["\n ",cljs.core.name.call(null,role),":"].join(''),cljs.spec.alpha.describe.call(null,spec_1578));
} else {
}
var G__1579 = cljs.core.next.call(null,seq__1510__$1);
var G__1580 = null;
var G__1581 = (0);
var G__1582 = (0);
seq__1510 = G__1579;
chunk__1511 = G__1580;
count__1512 = G__1581;
i__1513 = G__1582;
continue;
}
} else {
return null;
}
}
break;
}
} else {
return null;
}
} else {
return null;
}
}
});
/**
* Constructs a data representation for a Error with keys:
* :cause - root cause message
* :phase - error phase
* :via - cause chain, with cause keys:
* :type - exception class symbol
* :message - exception message
* :data - ex-data
* :at - top stack element
* :trace - root cause stack elements
*/
cljs.repl.Error__GT_map = (function cljs$repl$Error__GT_map(o){
return cljs.core.Throwable__GT_map.call(null,o);
});
/**
* Returns an analysis of the phase, error, cause, and location of an error that occurred
* based on Throwable data, as returned by Throwable->map. All attributes other than phase
* are optional:
* :clojure.error/phase - keyword phase indicator, one of:
* :read-source :compile-syntax-check :compilation :macro-syntax-check :macroexpansion
* :execution :read-eval-result :print-eval-result
* :clojure.error/source - file name (no path)
* :clojure.error/line - integer line number
* :clojure.error/column - integer column number
* :clojure.error/symbol - symbol being expanded/compiled/invoked
* :clojure.error/class - cause exception class symbol
* :clojure.error/cause - cause exception message
* :clojure.error/spec - explain-data for spec error
*/
cljs.repl.ex_triage = (function cljs$repl$ex_triage(datafied_throwable){
var map__1585 = datafied_throwable;
var map__1585__$1 = cljs.core.__destructure_map.call(null,map__1585);
var via = cljs.core.get.call(null,map__1585__$1,new cljs.core.Keyword(null,"via","via",-1904457336));
var trace = cljs.core.get.call(null,map__1585__$1,new cljs.core.Keyword(null,"trace","trace",-1082747415));
var phase = cljs.core.get.call(null,map__1585__$1,new cljs.core.Keyword(null,"phase","phase",575722892),new cljs.core.Keyword(null,"execution","execution",253283524));
var map__1586 = cljs.core.last.call(null,via);
var map__1586__$1 = cljs.core.__destructure_map.call(null,map__1586);
var type = cljs.core.get.call(null,map__1586__$1,new cljs.core.Keyword(null,"type","type",1174270348));
var message = cljs.core.get.call(null,map__1586__$1,new cljs.core.Keyword(null,"message","message",-406056002));
var data = cljs.core.get.call(null,map__1586__$1,new cljs.core.Keyword(null,"data","data",-232669377));
var map__1587 = data;
var map__1587__$1 = cljs.core.__destructure_map.call(null,map__1587);
var problems = cljs.core.get.call(null,map__1587__$1,new cljs.core.Keyword("cljs.spec.alpha","problems","cljs.spec.alpha/problems",447400814));
var fn = cljs.core.get.call(null,map__1587__$1,new cljs.core.Keyword("cljs.spec.alpha","fn","cljs.spec.alpha/fn",408600443));
var caller = cljs.core.get.call(null,map__1587__$1,new cljs.core.Keyword("cljs.spec.test.alpha","caller","cljs.spec.test.alpha/caller",-398302390));
var map__1588 = new cljs.core.Keyword(null,"data","data",-232669377).cljs$core$IFn$_invoke$arity$1(cljs.core.first.call(null,via));
var map__1588__$1 = cljs.core.__destructure_map.call(null,map__1588);
var top_data = map__1588__$1;
var source = cljs.core.get.call(null,map__1588__$1,new cljs.core.Keyword("clojure.error","source","clojure.error/source",-2011936397));
return cljs.core.assoc.call(null,(function (){var G__1589 = phase;
var G__1589__$1 = (((G__1589 instanceof cljs.core.Keyword))?G__1589.fqn:null);
switch (G__1589__$1) {
case "read-source":
var map__1590 = data;
var map__1590__$1 = cljs.core.__destructure_map.call(null,map__1590);
var line = cljs.core.get.call(null,map__1590__$1,new cljs.core.Keyword("clojure.error","line","clojure.error/line",-1816287471));
var column = cljs.core.get.call(null,map__1590__$1,new cljs.core.Keyword("clojure.error","column","clojure.error/column",304721553));
var G__1591 = cljs.core.merge.call(null,new cljs.core.Keyword(null,"data","data",-232669377).cljs$core$IFn$_invoke$arity$1(cljs.core.second.call(null,via)),top_data);
var G__1591__$1 = (cljs.core.truth_(source)?cljs.core.assoc.call(null,G__1591,new cljs.core.Keyword("clojure.error","source","clojure.error/source",-2011936397),source):G__1591);
var G__1591__$2 = (cljs.core.truth_(new cljs.core.PersistentHashSet(null, new cljs.core.PersistentArrayMap(null, 2, ["NO_SOURCE_PATH",null,"NO_SOURCE_FILE",null], null), null).call(null,source))?cljs.core.dissoc.call(null,G__1591__$1,new cljs.core.Keyword("clojure.error","source","clojure.error/source",-2011936397)):G__1591__$1);
if(cljs.core.truth_(message)){
return cljs.core.assoc.call(null,G__1591__$2,new cljs.core.Keyword("clojure.error","cause","clojure.error/cause",-1879175742),message);
} else {
return G__1591__$2;
}
break;
case "compile-syntax-check":
case "compilation":
case "macro-syntax-check":
case "macroexpansion":
var G__1592 = top_data;
var G__1592__$1 = (cljs.core.truth_(source)?cljs.core.assoc.call(null,G__1592,new cljs.core.Keyword("clojure.error","source","clojure.error/source",-2011936397),source):G__1592);
var G__1592__$2 = (cljs.core.truth_(new cljs.core.PersistentHashSet(null, new cljs.core.PersistentArrayMap(null, 2, ["NO_SOURCE_PATH",null,"NO_SOURCE_FILE",null], null), null).call(null,source))?cljs.core.dissoc.call(null,G__1592__$1,new cljs.core.Keyword("clojure.error","source","clojure.error/source",-2011936397)):G__1592__$1);
var G__1592__$3 = (cljs.core.truth_(type)?cljs.core.assoc.call(null,G__1592__$2,new cljs.core.Keyword("clojure.error","class","clojure.error/class",278435890),type):G__1592__$2);
var G__1592__$4 = (cljs.core.truth_(message)?cljs.core.assoc.call(null,G__1592__$3,new cljs.core.Keyword("clojure.error","cause","clojure.error/cause",-1879175742),message):G__1592__$3);
if(cljs.core.truth_(problems)){
return cljs.core.assoc.call(null,G__1592__$4,new cljs.core.Keyword("clojure.error","spec","clojure.error/spec",2055032595),data);
} else {
return G__1592__$4;
}
break;
case "read-eval-result":
case "print-eval-result":
var vec__1593 = cljs.core.first.call(null,trace);
var source__$1 = cljs.core.nth.call(null,vec__1593,(0),null);
var method = cljs.core.nth.call(null,vec__1593,(1),null);
var file = cljs.core.nth.call(null,vec__1593,(2),null);
var line = cljs.core.nth.call(null,vec__1593,(3),null);
var G__1596 = top_data;
var G__1596__$1 = (cljs.core.truth_(line)?cljs.core.assoc.call(null,G__1596,new cljs.core.Keyword("clojure.error","line","clojure.error/line",-1816287471),line):G__1596);
var G__1596__$2 = (cljs.core.truth_(file)?cljs.core.assoc.call(null,G__1596__$1,new cljs.core.Keyword("clojure.error","source","clojure.error/source",-2011936397),file):G__1596__$1);
var G__1596__$3 = (cljs.core.truth_((function (){var and__4996__auto__ = source__$1;
if(cljs.core.truth_(and__4996__auto__)){
return method;
} else {
return and__4996__auto__;
}
})())?cljs.core.assoc.call(null,G__1596__$2,new cljs.core.Keyword("clojure.error","symbol","clojure.error/symbol",1544821994),(new cljs.core.PersistentVector(null,2,(5),cljs.core.PersistentVector.EMPTY_NODE,[source__$1,method],null))):G__1596__$2);
var G__1596__$4 = (cljs.core.truth_(type)?cljs.core.assoc.call(null,G__1596__$3,new cljs.core.Keyword("clojure.error","class","clojure.error/class",278435890),type):G__1596__$3);
if(cljs.core.truth_(message)){
return cljs.core.assoc.call(null,G__1596__$4,new cljs.core.Keyword("clojure.error","cause","clojure.error/cause",-1879175742),message);
} else {
return G__1596__$4;
}
break;
case "execution":
var vec__1597 = cljs.core.first.call(null,trace);
var source__$1 = cljs.core.nth.call(null,vec__1597,(0),null);
var method = cljs.core.nth.call(null,vec__1597,(1),null);
var file = cljs.core.nth.call(null,vec__1597,(2),null);
var line = cljs.core.nth.call(null,vec__1597,(3),null);
var file__$1 = cljs.core.first.call(null,cljs.core.remove.call(null,(function (p1__1584_SHARP_){
var or__4998__auto__ = (p1__1584_SHARP_ == null);
if(or__4998__auto__){
return or__4998__auto__;
} else {
return new cljs.core.PersistentHashSet(null, new cljs.core.PersistentArrayMap(null, 2, ["NO_SOURCE_PATH",null,"NO_SOURCE_FILE",null], null), null).call(null,p1__1584_SHARP_);
}
}),new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Keyword(null,"file","file",-1269645878).cljs$core$IFn$_invoke$arity$1(caller),file], null)));
var err_line = (function (){var or__4998__auto__ = new cljs.core.Keyword(null,"line","line",212345235).cljs$core$IFn$_invoke$arity$1(caller);
if(cljs.core.truth_(or__4998__auto__)){
return or__4998__auto__;
} else {
return line;
}
})();
var G__1600 = new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword("clojure.error","class","clojure.error/class",278435890),type], null);
var G__1600__$1 = (cljs.core.truth_(err_line)?cljs.core.assoc.call(null,G__1600,new cljs.core.Keyword("clojure.error","line","clojure.error/line",-1816287471),err_line):G__1600);
var G__1600__$2 = (cljs.core.truth_(message)?cljs.core.assoc.call(null,G__1600__$1,new cljs.core.Keyword("clojure.error","cause","clojure.error/cause",-1879175742),message):G__1600__$1);
var G__1600__$3 = (cljs.core.truth_((function (){var or__4998__auto__ = fn;
if(cljs.core.truth_(or__4998__auto__)){
return or__4998__auto__;
} else {
var and__4996__auto__ = source__$1;
if(cljs.core.truth_(and__4996__auto__)){
return method;
} else {
return and__4996__auto__;
}
}
})())?cljs.core.assoc.call(null,G__1600__$2,new cljs.core.Keyword("clojure.error","symbol","clojure.error/symbol",1544821994),(function (){var or__4998__auto__ = fn;
if(cljs.core.truth_(or__4998__auto__)){
return or__4998__auto__;
} else {
return (new cljs.core.PersistentVector(null,2,(5),cljs.core.PersistentVector.EMPTY_NODE,[source__$1,method],null));
}
})()):G__1600__$2);
var G__1600__$4 = (cljs.core.truth_(file__$1)?cljs.core.assoc.call(null,G__1600__$3,new cljs.core.Keyword("clojure.error","source","clojure.error/source",-2011936397),file__$1):G__1600__$3);
if(cljs.core.truth_(problems)){
return cljs.core.assoc.call(null,G__1600__$4,new cljs.core.Keyword("clojure.error","spec","clojure.error/spec",2055032595),data);
} else {
return G__1600__$4;
}
break;
default:
throw (new Error(["No matching clause: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(G__1589__$1)].join('')));
}
})(),new cljs.core.Keyword("clojure.error","phase","clojure.error/phase",275140358),phase);
});
/**
* Returns a string from exception data, as produced by ex-triage.
* The first line summarizes the exception phase and location.
* The subsequent lines describe the cause.
*/
cljs.repl.ex_str = (function cljs$repl$ex_str(p__1604){
var map__1605 = p__1604;
var map__1605__$1 = cljs.core.__destructure_map.call(null,map__1605);
var triage_data = map__1605__$1;
var phase = cljs.core.get.call(null,map__1605__$1,new cljs.core.Keyword("clojure.error","phase","clojure.error/phase",275140358));
var source = cljs.core.get.call(null,map__1605__$1,new cljs.core.Keyword("clojure.error","source","clojure.error/source",-2011936397));
var line = cljs.core.get.call(null,map__1605__$1,new cljs.core.Keyword("clojure.error","line","clojure.error/line",-1816287471));
var column = cljs.core.get.call(null,map__1605__$1,new cljs.core.Keyword("clojure.error","column","clojure.error/column",304721553));
var symbol = cljs.core.get.call(null,map__1605__$1,new cljs.core.Keyword("clojure.error","symbol","clojure.error/symbol",1544821994));
var class$ = cljs.core.get.call(null,map__1605__$1,new cljs.core.Keyword("clojure.error","class","clojure.error/class",278435890));
var cause = cljs.core.get.call(null,map__1605__$1,new cljs.core.Keyword("clojure.error","cause","clojure.error/cause",-1879175742));
var spec = cljs.core.get.call(null,map__1605__$1,new cljs.core.Keyword("clojure.error","spec","clojure.error/spec",2055032595));
var loc = [cljs.core.str.cljs$core$IFn$_invoke$arity$1((function (){var or__4998__auto__ = source;
if(cljs.core.truth_(or__4998__auto__)){
return or__4998__auto__;
} else {
return "<cljs repl>";
}
})()),":",cljs.core.str.cljs$core$IFn$_invoke$arity$1((function (){var or__4998__auto__ = line;
if(cljs.core.truth_(or__4998__auto__)){
return or__4998__auto__;
} else {
return (1);
}
})()),(cljs.core.truth_(column)?[":",cljs.core.str.cljs$core$IFn$_invoke$arity$1(column)].join(''):"")].join('');
var class_name = cljs.core.name.call(null,(function (){var or__4998__auto__ = class$;
if(cljs.core.truth_(or__4998__auto__)){
return or__4998__auto__;
} else {
return "";
}
})());
var simple_class = class_name;
var cause_type = ((cljs.core.contains_QMARK_.call(null,new cljs.core.PersistentHashSet(null, new cljs.core.PersistentArrayMap(null, 2, ["RuntimeException",null,"Exception",null], null), null),simple_class))?"":[" (",simple_class,")"].join(''));
var format = goog.string.format;
var G__1606 = phase;
var G__1606__$1 = (((G__1606 instanceof cljs.core.Keyword))?G__1606.fqn:null);
switch (G__1606__$1) {
case "read-source":
return format.call(null,"Syntax error reading source at (%s).\n%s\n",loc,cause);
break;
case "macro-syntax-check":
return format.call(null,"Syntax error macroexpanding %sat (%s).\n%s",(cljs.core.truth_(symbol)?[cljs.core.str.cljs$core$IFn$_invoke$arity$1(symbol)," "].join(''):""),loc,(cljs.core.truth_(spec)?(function (){var sb__5643__auto__ = (new goog.string.StringBuffer());
var _STAR_print_newline_STAR__orig_val__1607_1616 = cljs.core._STAR_print_newline_STAR_;
var _STAR_print_fn_STAR__orig_val__1608_1617 = cljs.core._STAR_print_fn_STAR_;
var _STAR_print_newline_STAR__temp_val__1609_1618 = true;
var _STAR_print_fn_STAR__temp_val__1610_1619 = (function (x__5644__auto__){
return sb__5643__auto__.append(x__5644__auto__);
});
(cljs.core._STAR_print_newline_STAR_ = _STAR_print_newline_STAR__temp_val__1609_1618);
(cljs.core._STAR_print_fn_STAR_ = _STAR_print_fn_STAR__temp_val__1610_1619);
try{cljs.spec.alpha.explain_out.call(null,cljs.core.update.call(null,spec,new cljs.core.Keyword("cljs.spec.alpha","problems","cljs.spec.alpha/problems",447400814),(function (probs){
return cljs.core.map.call(null,(function (p1__1602_SHARP_){
return cljs.core.dissoc.call(null,p1__1602_SHARP_,new cljs.core.Keyword(null,"in","in",-1531184865));
}),probs);
}))
);
}finally {(cljs.core._STAR_print_fn_STAR_ = _STAR_print_fn_STAR__orig_val__1608_1617);
(cljs.core._STAR_print_newline_STAR_ = _STAR_print_newline_STAR__orig_val__1607_1616);
}
return cljs.core.str.cljs$core$IFn$_invoke$arity$1(sb__5643__auto__);
})():format.call(null,"%s\n",cause)));
break;
case "macroexpansion":
return format.call(null,"Unexpected error%s macroexpanding %sat (%s).\n%s\n",cause_type,(cljs.core.truth_(symbol)?[cljs.core.str.cljs$core$IFn$_invoke$arity$1(symbol)," "].join(''):""),loc,cause);
break;
case "compile-syntax-check":
return format.call(null,"Syntax error%s compiling %sat (%s).\n%s\n",cause_type,(cljs.core.truth_(symbol)?[cljs.core.str.cljs$core$IFn$_invoke$arity$1(symbol)," "].join(''):""),loc,cause);
break;
case "compilation":
return format.call(null,"Unexpected error%s compiling %sat (%s).\n%s\n",cause_type,(cljs.core.truth_(symbol)?[cljs.core.str.cljs$core$IFn$_invoke$arity$1(symbol)," "].join(''):""),loc,cause);
break;
case "read-eval-result":
return format.call(null,"Error reading eval result%s at %s (%s).\n%s\n",cause_type,symbol,loc,cause);
break;
case "print-eval-result":
return format.call(null,"Error printing return value%s at %s (%s).\n%s\n",cause_type,symbol,loc,cause);
break;
case "execution":
if(cljs.core.truth_(spec)){
return format.call(null,"Execution error - invalid arguments to %s at (%s).\n%s",symbol,loc,(function (){var sb__5643__auto__ = (new goog.string.StringBuffer());
var _STAR_print_newline_STAR__orig_val__1611_1620 = cljs.core._STAR_print_newline_STAR_;
var _STAR_print_fn_STAR__orig_val__1612_1621 = cljs.core._STAR_print_fn_STAR_;
var _STAR_print_newline_STAR__temp_val__1613_1622 = true;
var _STAR_print_fn_STAR__temp_val__1614_1623 = (function (x__5644__auto__){
return sb__5643__auto__.append(x__5644__auto__);
});
(cljs.core._STAR_print_newline_STAR_ = _STAR_print_newline_STAR__temp_val__1613_1622);
(cljs.core._STAR_print_fn_STAR_ = _STAR_print_fn_STAR__temp_val__1614_1623);
try{cljs.spec.alpha.explain_out.call(null,cljs.core.update.call(null,spec,new cljs.core.Keyword("cljs.spec.alpha","problems","cljs.spec.alpha/problems",447400814),(function (probs){
return cljs.core.map.call(null,(function (p1__1603_SHARP_){
return cljs.core.dissoc.call(null,p1__1603_SHARP_,new cljs.core.Keyword(null,"in","in",-1531184865));
}),probs);
}))
);
}finally {(cljs.core._STAR_print_fn_STAR_ = _STAR_print_fn_STAR__orig_val__1612_1621);
(cljs.core._STAR_print_newline_STAR_ = _STAR_print_newline_STAR__orig_val__1611_1620);
}
return cljs.core.str.cljs$core$IFn$_invoke$arity$1(sb__5643__auto__);
})());
} else {
return format.call(null,"Execution error%s at %s(%s).\n%s\n",cause_type,(cljs.core.truth_(symbol)?[cljs.core.str.cljs$core$IFn$_invoke$arity$1(symbol)," "].join(''):""),loc,cause);
}
break;
default:
throw (new Error(["No matching clause: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(G__1606__$1)].join('')));
}
});
cljs.repl.error__GT_str = (function cljs$repl$error__GT_str(error){
return cljs.repl.ex_str.call(null,cljs.repl.ex_triage.call(null,cljs.repl.Error__GT_map.call(null,error)));
});
//# sourceMappingURL=repl.js.map

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@ -1,183 +0,0 @@
; Copyright (c) Rich Hickey. All rights reserved.
; The use and distribution terms for this software are covered by the
; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)
; which can be found in the file epl-v10.html at the root of this distribution.
; By using this software in any fashion, you are agreeing to be bound by
; the terms of this license.
; You must not remove this notice, or any other, from this software.
(ns cljs.spec.gen.alpha
(:refer-clojure :exclude [boolean cat hash-map list map not-empty set vector
char double int keyword symbol string uuid delay shuffle])
(:require-macros [cljs.core :as c]
[cljs.spec.gen.alpha :as gen :refer [dynaload lazy-combinators lazy-prims]])
(:require [cljs.core :as c])
(:import (goog Uri)))
(deftype LazyVar [f ^:mutable cached]
IDeref
(-deref [this]
(if-not (nil? cached)
cached
(let [x (f)]
(when-not (nil? x)
(set! cached x))
x))))
(def ^:private quick-check-ref
(dynaload 'clojure.test.check/quick-check))
(defn quick-check
[& args]
(apply @quick-check-ref args))
(def ^:private for-all*-ref
(dynaload 'clojure.test.check.properties/for-all*))
(defn for-all*
"Dynamically loaded clojure.test.check.properties/for-all*."
[& args]
(apply @for-all*-ref args))
(let [g? (dynaload 'clojure.test.check.generators/generator?)
g (dynaload 'clojure.test.check.generators/generate)
mkg (dynaload 'clojure.test.check.generators/->Generator)]
(defn- generator?
[x]
(@g? x))
(defn- generator
[gfn]
(@mkg gfn))
(defn generate
"Generate a single value using generator."
[generator]
(@g generator)))
(defn ^:skip-wiki delay-impl
[gfnd]
;;N.B. depends on test.check impl details
(generator (fn [rnd size]
((:gen @gfnd) rnd size))))
;(defn gen-for-name
; "Dynamically loads test.check generator named s."
; [s]
; (let [g (dynaload s)]
; (if (generator? g)
; g
; (throw (js/Error. (str "Var " s " is not a generator"))))))
(lazy-combinators hash-map list map not-empty set vector vector-distinct fmap elements
bind choose one-of such-that tuple sample return
large-integer* double* frequency shuffle)
(lazy-prims any any-printable boolean char char-alpha char-alphanumeric char-ascii double
int keyword keyword-ns large-integer ratio simple-type simple-type-printable
string string-ascii string-alphanumeric symbol symbol-ns uuid)
(defn cat
"Returns a generator of a sequence catenated from results of
gens, each of which should generate something sequential."
[& gens]
(fmap #(apply concat %)
(apply tuple gens)))
(defn- ^boolean qualified? [ident] (not (nil? (namespace ident))))
(def ^:private
gen-builtins
(c/delay
(let [simple (simple-type-printable)]
{any? (one-of [(return nil) (any-printable)])
some? (such-that some? (any-printable))
number? (one-of [(large-integer) (double)])
integer? (large-integer)
int? (large-integer)
pos-int? (large-integer* {:min 1})
neg-int? (large-integer* {:max -1})
nat-int? (large-integer* {:min 0})
float? (double)
double? (double)
string? (string-alphanumeric)
ident? (one-of [(keyword-ns) (symbol-ns)])
simple-ident? (one-of [(keyword) (symbol)])
qualified-ident? (such-that qualified? (one-of [(keyword-ns) (symbol-ns)]))
keyword? (keyword-ns)
simple-keyword? (keyword)
qualified-keyword? (such-that qualified? (keyword-ns))
symbol? (symbol-ns)
simple-symbol? (symbol)
qualified-symbol? (such-that qualified? (symbol-ns))
uuid? (uuid)
uri? (fmap #(Uri. (str "http://" % ".com")) (uuid))
inst? (fmap #(js/Date. %)
(large-integer))
seqable? (one-of [(return nil)
(list simple)
(vector simple)
(map simple simple)
(set simple)
(string-alphanumeric)])
indexed? (vector simple)
map? (map simple simple)
vector? (vector simple)
list? (list simple)
seq? (list simple)
char? (char)
set? (set simple)
nil? (return nil)
false? (return false)
true? (return true)
boolean? (boolean)
zero? (return 0)
;rational? (one-of [(large-integer) (ratio)])
coll? (one-of [(map simple simple)
(list simple)
(vector simple)
(set simple)])
empty? (elements [nil '() [] {} #{}])
associative? (one-of [(map simple simple) (vector simple)])
sequential? (one-of [(list simple) (vector simple)])
;ratio? (such-that ratio? (ratio))
})))
(defn gen-for-pred
"Given a predicate, returns a built-in generator if one exists."
[pred]
(if (set? pred)
(elements pred)
(get @gen-builtins pred)))
(comment
(require 'clojure.test.check)
(require 'clojure.test.check.properties)
(require 'cljs.spec.gen)
(in-ns 'cljs.spec.gen)
;; combinators, see call to lazy-combinators above for complete list
(generate (one-of [(gen-for-pred integer?) (gen-for-pred string?)]))
(generate (such-that #(< 10000 %) (gen-for-pred integer?)))
(let [reqs {:a (gen-for-pred number?)
:b (gen-for-pred keyword?)}
opts {:c (gen-for-pred string?)}]
(generate (bind (choose 0 (count opts))
#(let [args (concat (seq reqs) (c/shuffle (seq opts)))]
(->> args
(take (+ % (count reqs)))
(mapcat identity)
(apply hash-map))))))
(generate (cat (list (gen-for-pred string?))
(list (gen-for-pred integer?))))
;; load your own generator
;(gen-for-name 'clojure.test.check.generators/int)
;; failure modes
;(gen-for-name 'unqualified)
;(gen-for-name 'clojure.core/+)
;(gen-for-name 'clojure.core/name-does-not-exist)
;(gen-for-name 'ns.does.not.exist/f)
)

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@ -1,119 +0,0 @@
goog.addDependency("base.js", ['goog'], []);
goog.addDependency("debug/error.js", ['goog.debug.Error'], []);
goog.addDependency("dom/nodetype.js", ['goog.dom.NodeType'], []);
goog.addDependency("asserts/asserts.js", ['goog.asserts'], ['goog.debug.Error', 'goog.dom.NodeType']);
goog.addDependency("dom/htmlelement.js", ['goog.dom.HtmlElement'], []);
goog.addDependency("dom/tagname.js", ['goog.dom.TagName'], ['goog.dom.HtmlElement']);
goog.addDependency("dom/element.js", ['goog.dom.element'], ['goog.dom.NodeType', 'goog.dom.TagName']);
goog.addDependency("asserts/dom.js", ['goog.asserts.dom'], ['goog.dom.TagName', 'goog.asserts', 'goog.dom.element']);
goog.addDependency("dom/asserts.js", ['goog.dom.asserts'], ['goog.asserts']);
goog.addDependency("functions/functions.js", ['goog.functions'], []);
goog.addDependency("string/typedstring.js", ['goog.string.TypedString'], []);
goog.addDependency("string/const.js", ['goog.string.Const'], ['goog.asserts', 'goog.string.TypedString']);
goog.addDependency("html/trustedtypes.js", ['goog.html.trustedtypes'], []);
goog.addDependency("html/safescript.js", ['goog.html.SafeScript'], ['goog.string.Const', 'goog.string.TypedString', 'goog.html.trustedtypes', 'goog.asserts']);
goog.addDependency("fs/url.js", ['goog.fs.url'], []);
goog.addDependency("fs/blob.js", ['goog.fs.blob'], []);
goog.addDependency("html/trustedresourceurl.js", ['goog.html.TrustedResourceUrl'], ['goog.asserts', 'goog.fs.blob', 'goog.fs.url', 'goog.html.SafeScript', 'goog.html.trustedtypes', 'goog.string.Const', 'goog.string.TypedString']);
goog.addDependency("string/internal.js", ['goog.string.internal'], []);
goog.addDependency("html/safeurl.js", ['goog.html.SafeUrl'], ['goog.asserts', 'goog.fs.url', 'goog.html.TrustedResourceUrl', 'goog.string.Const', 'goog.string.TypedString', 'goog.string.internal']);
goog.addDependency("html/safestyle.js", ['goog.html.SafeStyle'], ['goog.string.Const', 'goog.html.SafeUrl', 'goog.string.TypedString', 'goog.asserts', 'goog.string.internal']);
goog.addDependency("object/object.js", ['goog.object'], []);
goog.addDependency("html/safestylesheet.js", ['goog.html.SafeStyleSheet'], ['goog.string.Const', 'goog.html.SafeStyle', 'goog.string.TypedString', 'goog.object', 'goog.asserts', 'goog.string.internal']);
goog.addDependency("flags/flags.js", ['goog.flags'], []);
goog.addDependency("labs/useragent/useragent.js", ['goog.labs.userAgent'], ['goog.flags']);
goog.addDependency("labs/useragent/util.js", ['goog.labs.userAgent.util'], ['goog.string.internal', 'goog.labs.userAgent']);
goog.addDependency("labs/useragent/highentropy/highentropyvalue.js", ['goog.labs.userAgent.highEntropy.highEntropyValue'], ['goog.labs.userAgent.util', 'goog.string.internal']);
goog.addDependency("labs/useragent/highentropy/highentropydata.js", ['goog.labs.userAgent.highEntropy.highEntropyData'], ['goog.labs.userAgent.highEntropy.highEntropyValue']);
goog.addDependency("labs/useragent/browser.js", ['goog.labs.userAgent.browser'], ['goog.labs.userAgent.util', 'goog.labs.userAgent.highEntropy.highEntropyValue', 'goog.asserts', 'goog.string.internal', 'goog.labs.userAgent.highEntropy.highEntropyData', 'goog.labs.userAgent']);
goog.addDependency("array/array.js", ['goog.array'], ['goog.asserts']);
goog.addDependency("dom/tags.js", ['goog.dom.tags'], ['goog.object']);
goog.addDependency("html/safehtml.js", ['goog.html.SafeHtml'], ['goog.string.Const', 'goog.html.SafeScript', 'goog.html.SafeStyle', 'goog.html.SafeStyleSheet', 'goog.html.SafeUrl', 'goog.dom.TagName', 'goog.html.TrustedResourceUrl', 'goog.string.TypedString', 'goog.asserts', 'goog.labs.userAgent.browser', 'goog.array', 'goog.object', 'goog.string.internal', 'goog.dom.tags', 'goog.html.trustedtypes']);
goog.addDependency("html/uncheckedconversions.js", ['goog.html.uncheckedconversions'], ['goog.asserts', 'goog.html.SafeHtml', 'goog.html.SafeScript', 'goog.html.SafeStyle', 'goog.html.SafeStyleSheet', 'goog.html.SafeUrl', 'goog.html.TrustedResourceUrl', 'goog.string.Const', 'goog.string.internal']);
goog.addDependency("dom/safe.js", ['goog.dom.safe', 'goog.dom.safe.InsertAdjacentHtmlPosition'], ['goog.asserts', 'goog.asserts.dom', 'goog.dom.asserts', 'goog.functions', 'goog.html.SafeHtml', 'goog.html.SafeScript', 'goog.html.SafeStyle', 'goog.html.SafeUrl', 'goog.html.TrustedResourceUrl', 'goog.html.uncheckedconversions', 'goog.string.Const', 'goog.string.internal']);
goog.addDependency("string/string.js", ['goog.string', 'goog.string.Unicode'], ['goog.dom.safe', 'goog.html.uncheckedconversions', 'goog.string.Const', 'goog.string.internal']);
goog.addDependency("collections/maps.js", ['goog.collections.maps'], []);
goog.addDependency("structs/structs.js", ['goog.structs'], ['goog.array', 'goog.object']);
goog.addDependency("uri/utils.js", ['goog.uri.utils', 'goog.uri.utils.ComponentIndex', 'goog.uri.utils.QueryArray', 'goog.uri.utils.QueryValue', 'goog.uri.utils.StandardQueryParam'], ['goog.asserts', 'goog.string']);
goog.addDependency("uri/uri.js", ['goog.Uri', 'goog.Uri.QueryData'], ['goog.array', 'goog.asserts', 'goog.collections.maps', 'goog.string', 'goog.structs', 'goog.uri.utils', 'goog.uri.utils.ComponentIndex', 'goog.uri.utils.StandardQueryParam']);
goog.addDependency("reflect/reflect.js", ['goog.reflect'], []);
goog.addDependency("math/integer.js", ['goog.math.Integer'], ['goog.reflect']);
goog.addDependency("string/stringbuffer.js", ['goog.string.StringBuffer'], []);
goog.addDependency("math/long.js", ['goog.math.Long'], ['goog.asserts', 'goog.reflect']);
goog.addDependency("../cljs/core.js", ['cljs.core'], ['goog.string', 'goog.Uri', 'goog.object', 'goog.math.Integer', 'goog.string.StringBuffer', 'goog.array', 'goog.math.Long']);
goog.addDependency("labs/useragent/engine.js", ['goog.labs.userAgent.engine'], ['goog.array', 'goog.string.internal', 'goog.labs.userAgent.util']);
goog.addDependency("labs/useragent/platform.js", ['goog.labs.userAgent.platform'], ['goog.string.internal', 'goog.labs.userAgent.util', 'goog.labs.userAgent.highEntropy.highEntropyValue', 'goog.labs.userAgent.highEntropy.highEntropyData', 'goog.labs.userAgent']);
goog.addDependency("useragent/useragent.js", ['goog.userAgent'], ['goog.labs.userAgent.browser', 'goog.labs.userAgent.engine', 'goog.labs.userAgent.platform', 'goog.labs.userAgent.util', 'goog.reflect', 'goog.string.internal']);
goog.addDependency("dom/browserfeature.js", ['goog.dom.BrowserFeature'], ['goog.userAgent']);
goog.addDependency("math/math.js", ['goog.math'], ['goog.asserts']);
goog.addDependency("math/coordinate.js", ['goog.math.Coordinate'], ['goog.math']);
goog.addDependency("math/size.js", ['goog.math.Size'], []);
goog.addDependency("dom/dom.js", ['goog.dom', 'goog.dom.Appendable', 'goog.dom.DomHelper'], ['goog.array', 'goog.asserts', 'goog.asserts.dom', 'goog.dom.BrowserFeature', 'goog.dom.NodeType', 'goog.dom.TagName', 'goog.dom.safe', 'goog.html.SafeHtml', 'goog.html.uncheckedconversions', 'goog.math.Coordinate', 'goog.math.Size', 'goog.object', 'goog.string', 'goog.string.Const', 'goog.string.Unicode', 'goog.userAgent']);
goog.addDependency("useragent/product.js", ['goog.userAgent.product'], ['goog.labs.userAgent.browser', 'goog.labs.userAgent.platform', 'goog.userAgent']);
goog.addDependency("json/json.js", ['goog.json', 'goog.json.Replacer', 'goog.json.Reviver', 'goog.json.Serializer'], []);
goog.addDependency("debug/errorcontext.js", ['goog.debug.errorcontext'], []);
goog.addDependency("debug/debug.js", ['goog.debug'], ['goog.array', 'goog.debug.errorcontext']);
goog.addDependency("log/log.js", ['goog.log', 'goog.log.Level', 'goog.log.LogBuffer', 'goog.log.LogRecord', 'goog.log.Logger'], ['goog.asserts', 'goog.debug']);
goog.addDependency("net/xpc/xpc.js", ['goog.net.xpc', 'goog.net.xpc.CfgFields', 'goog.net.xpc.ChannelStates', 'goog.net.xpc.TransportNames', 'goog.net.xpc.TransportTypes', 'goog.net.xpc.UriCfgFields'], ['goog.log']);
goog.addDependency("promise/thenable.js", ['goog.Thenable'], []);
goog.addDependency("async/freelist.js", ['goog.async.FreeList'], []);
goog.addDependency("async/workqueue.js", ['goog.async.WorkQueue'], ['goog.async.FreeList', 'goog.asserts']);
goog.addDependency("debug/asyncstacktag.js", ['goog.debug.asyncStackTag'], ['goog.asserts']);
goog.addDependency("debug/entrypointregistry.js", ['goog.debug.EntryPointMonitor', 'goog.debug.entryPointRegistry'], ['goog.asserts']);
goog.addDependency("async/nexttick.js", ['goog.async.nextTick'], ['goog.debug.entryPointRegistry', 'goog.dom', 'goog.dom.TagName', 'goog.functions', 'goog.labs.userAgent.browser', 'goog.labs.userAgent.engine']);
goog.addDependency("async/throwexception.js", ['goog.async.throwException'], []);
goog.addDependency("async/run.js", ['goog.async.run'], ['goog.async.WorkQueue', 'goog.debug.asyncStackTag', 'goog.async.nextTick', 'goog.async.throwException']);
goog.addDependency("promise/resolver.js", ['goog.promise.Resolver'], []);
goog.addDependency("promise/promise.js", ['goog.Promise'], ['goog.Thenable', 'goog.asserts', 'goog.async.FreeList', 'goog.async.run', 'goog.async.throwException', 'goog.debug.Error', 'goog.debug.asyncStackTag', 'goog.functions', 'goog.promise.Resolver']);
goog.addDependency("disposable/idisposable.js", ['goog.disposable.IDisposable'], []);
goog.addDependency("disposable/dispose.js", ['goog.dispose'], []);
goog.addDependency("disposable/disposeall.js", ['goog.disposeAll'], ['goog.dispose']);
goog.addDependency("disposable/disposable.js", ['goog.Disposable'], ['goog.disposable.IDisposable', 'goog.dispose', 'goog.disposeAll']);
goog.addDependency("events/eventid.js", ['goog.events.EventId'], []);
goog.addDependency("events/event.js", ['goog.events.Event'], ['goog.Disposable', 'goog.events.EventId']);
goog.addDependency("events/browserfeature.js", ['goog.events.BrowserFeature'], []);
goog.addDependency("events/eventtypehelpers.js", ['goog.events.eventTypeHelpers'], ['goog.events.BrowserFeature', 'goog.userAgent']);
goog.addDependency("events/eventtype.js", ['goog.events.EventType'], ['goog.events.eventTypeHelpers', 'goog.userAgent']);
goog.addDependency("events/browserevent.js", ['goog.events.BrowserEvent', 'goog.events.BrowserEvent.MouseButton', 'goog.events.BrowserEvent.PointerType'], ['goog.debug', 'goog.events.Event', 'goog.events.EventType', 'goog.reflect', 'goog.userAgent']);
goog.addDependency("events/listenable.js", ['goog.events.Listenable'], []);
goog.addDependency("events/listenablekey.js", ['goog.events.ListenableKey'], []);
goog.addDependency("events/listener.js", ['goog.events.Listener'], ['goog.events.ListenableKey']);
goog.addDependency("events/listenermap.js", ['goog.events.ListenerMap'], ['goog.array', 'goog.events.Listener', 'goog.object']);
goog.addDependency("events/events.js", ['goog.events', 'goog.events.CaptureSimulationMode', 'goog.events.Key', 'goog.events.ListenableType'], ['goog.asserts', 'goog.debug.entryPointRegistry', 'goog.events.BrowserEvent', 'goog.events.BrowserFeature', 'goog.events.Listenable', 'goog.events.ListenerMap']);
goog.addDependency("events/eventtarget.js", ['goog.events.EventTarget'], ['goog.Disposable', 'goog.asserts', 'goog.events', 'goog.events.Event', 'goog.events.Listenable', 'goog.events.ListenerMap', 'goog.object']);
goog.addDependency("timer/timer.js", ['goog.Timer'], ['goog.Promise', 'goog.events.EventTarget']);
goog.addDependency("json/hybrid.js", ['goog.json.hybrid'], ['goog.asserts', 'goog.json']);
goog.addDependency("net/errorcode.js", ['goog.net.ErrorCode'], []);
goog.addDependency("net/eventtype.js", ['goog.net.EventType'], []);
goog.addDependency("net/httpstatus.js", ['goog.net.HttpStatus'], []);
goog.addDependency("net/xhrlike.js", ['goog.net.XhrLike'], []);
goog.addDependency("net/xmlhttpfactory.js", ['goog.net.XmlHttpFactory'], ['goog.net.XhrLike']);
goog.addDependency("net/wrapperxmlhttpfactory.js", ['goog.net.WrapperXmlHttpFactory'], ['goog.net.XhrLike', 'goog.net.XmlHttpFactory']);
goog.addDependency("net/xmlhttp.js", ['goog.net.DefaultXmlHttpFactory', 'goog.net.XmlHttp', 'goog.net.XmlHttp.OptionType', 'goog.net.XmlHttp.ReadyState', 'goog.net.XmlHttpDefines'], ['goog.asserts', 'goog.net.WrapperXmlHttpFactory', 'goog.net.XmlHttpFactory']);
goog.addDependency("net/xhrio.js", ['goog.net.XhrIo', 'goog.net.XhrIo.ResponseType'], ['goog.Timer', 'goog.array', 'goog.asserts', 'goog.collections.maps', 'goog.debug.entryPointRegistry', 'goog.events.EventTarget', 'goog.json.hybrid', 'goog.log', 'goog.net.ErrorCode', 'goog.net.EventType', 'goog.net.HttpStatus', 'goog.net.XmlHttp', 'goog.object', 'goog.string', 'goog.uri.utils', 'goog.userAgent']);
goog.addDependency("mochikit/async/deferred.js", ['goog.async.Deferred', 'goog.async.Deferred.AlreadyCalledError', 'goog.async.Deferred.CanceledError'], ['goog.Promise', 'goog.Thenable', 'goog.array', 'goog.asserts', 'goog.debug.Error']);
goog.addDependency("async/delay.js", ['goog.async.Delay'], ['goog.Disposable', 'goog.Timer']);
goog.addDependency("events/eventhandler.js", ['goog.events.EventHandler'], ['goog.Disposable', 'goog.events', 'goog.object']);
goog.addDependency("html/legacyconversions.js", ['goog.html.legacyconversions'], ['goog.html.SafeHtml', 'goog.html.SafeScript', 'goog.html.SafeStyle', 'goog.html.SafeStyleSheet', 'goog.html.SafeUrl', 'goog.html.TrustedResourceUrl']);
goog.addDependency("messaging/messagechannel.js", ['goog.messaging.MessageChannel'], []);
goog.addDependency("messaging/abstractchannel.js", ['goog.messaging.AbstractChannel'], ['goog.Disposable', 'goog.json', 'goog.log', 'goog.messaging.MessageChannel']);
goog.addDependency("net/xpc/crosspagechannelrole.js", ['goog.net.xpc.CrossPageChannelRole'], []);
goog.addDependency("net/xpc/transport.js", ['goog.net.xpc.Transport'], ['goog.Disposable', 'goog.dom', 'goog.net.xpc.TransportNames']);
goog.addDependency("net/xpc/nativemessagingtransport.js", ['goog.net.xpc.NativeMessagingTransport'], ['goog.Timer', 'goog.asserts', 'goog.async.Deferred', 'goog.dispose', 'goog.events', 'goog.events.EventHandler', 'goog.log', 'goog.net.xpc', 'goog.net.xpc.CrossPageChannelRole', 'goog.net.xpc.Transport', 'goog.net.xpc.TransportTypes']);
goog.addDependency("net/xpc/crosspagechannel.js", ['goog.net.xpc.CrossPageChannel'], ['goog.Uri', 'goog.async.Deferred', 'goog.async.Delay', 'goog.dispose', 'goog.dom', 'goog.dom.TagName', 'goog.dom.safe', 'goog.events', 'goog.events.EventHandler', 'goog.events.EventType', 'goog.functions', 'goog.html.legacyconversions', 'goog.json', 'goog.log', 'goog.messaging.AbstractChannel', 'goog.net.xpc', 'goog.net.xpc.CfgFields', 'goog.net.xpc.ChannelStates', 'goog.net.xpc.CrossPageChannelRole', 'goog.net.xpc.NativeMessagingTransport', 'goog.net.xpc.TransportTypes', 'goog.net.xpc.UriCfgFields', 'goog.string', 'goog.uri.utils', 'goog.userAgent']);
goog.addDependency("net/websocket.js", ['goog.net.WebSocket', 'goog.net.WebSocket.ErrorEvent', 'goog.net.WebSocket.EventType', 'goog.net.WebSocket.MessageEvent'], ['goog.Timer', 'goog.asserts', 'goog.debug.entryPointRegistry', 'goog.events', 'goog.events.Event', 'goog.events.EventTarget', 'goog.log']);
goog.addDependency("../clojure/browser/event.js", ['clojure.browser.event'], ['cljs.core', 'goog.events.EventTarget', 'goog.events.EventType', 'goog.events']);
goog.addDependency("../clojure/browser/net.js", ['clojure.browser.net'], ['goog.net.xpc.CfgFields', 'goog.net.XhrIo', 'goog.json', 'goog.Uri', 'cljs.core', 'goog.object', 'goog.net.EventType', 'goog.net.xpc.CrossPageChannel', 'goog.net.WebSocket', 'clojure.browser.event']);
goog.addDependency("string/stringformat.js", ['goog.string.format'], ['goog.string']);
goog.addDependency("../clojure/string.js", ['clojure.string'], ['goog.string', 'cljs.core', 'goog.string.StringBuffer']);
goog.addDependency("../clojure/walk.js", ['clojure.walk'], ['cljs.core']);
goog.addDependency("../cljs/spec/gen/alpha.js", ['cljs.spec.gen.alpha'], ['goog.Uri', 'cljs.core']);
goog.addDependency("../cljs/spec/alpha.js", ['cljs.spec.alpha'], ['cljs.core', 'goog.object', 'clojure.string', 'clojure.walk', 'cljs.spec.gen.alpha']);
goog.addDependency("../cljs/repl.js", ['cljs.repl'], ['goog.string', 'cljs.core', 'goog.string.format', 'cljs.spec.alpha']);
goog.addDependency("../clojure/browser/repl.js", ['clojure.browser.repl'], ['goog.dom', 'goog.userAgent.product', 'goog.json', 'cljs.core', 'goog.object', 'clojure.browser.net', 'cljs.repl', 'goog.array', 'clojure.browser.event']);
goog.addDependency("../clojure/browser/repl/preload.js", ['clojure.browser.repl.preload'], ['clojure.browser.repl', 'cljs.core']);
goog.addDependency("../process/env.js", ['process.env'], ['cljs.core']);
goog.addDependency("debug/errorhandler.js", ['goog.debug.ErrorHandler', 'goog.debug.ErrorHandler.ProtectedFunctionError'], ['goog.Disposable', 'goog.asserts', 'goog.debug.EntryPointMonitor', 'goog.debug.Error']);
goog.addDependency("events/eventwrapper.js", ['goog.events.EventWrapper'], []);
goog.addDependency("events/eventlike.js", ['goog.events.EventLike'], []);
goog.addDependency("../ludus/core.js", ['ludus.core'], ['cljs.core']);

View File

@ -1 +0,0 @@
{:browser-repl true, :main ludus.core, :output-to "out/main.js", :output-dir "out", :aot-cache true}

View File

@ -1,101 +0,0 @@
;; Copyright (c) Rich Hickey. All rights reserved.
;; The use and distribution terms for this software are covered by the
;; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)
;; which can be found in the file epl-v10.html at the root of this distribution.
;; By using this software in any fashion, you are agreeing to be bound by
;; the terms of this license.
;; You must not remove this notice, or any other, from this software.
(ns ^{:doc "This namespace contains functions to work with browser
events. It is based on the Google Closure Library event system."
:author "Bobby Calderwood"}
clojure.browser.event
(:require [goog.events :as events])
(:import (goog.events EventTarget EventType)))
(defprotocol IEventType
(event-types [this]))
(extend-protocol IEventType
EventTarget
(event-types
[this]
(into {}
(map
(fn [[k v]]
[(keyword (.toLowerCase k))
v])
(merge
(js->clj EventType))))))
(when (exists? js/Element)
(extend-protocol IEventType
js/Element
(event-types
[this]
(into {}
(map
(fn [[k v]]
[(keyword (.toLowerCase k))
v])
(merge
(js->clj EventType)))))))
(defn listen
([src type fn]
(listen src type fn false))
([src type fn capture?]
(events/listen src
(get (event-types src) type type)
fn
capture?)))
(defn listen-once
([src type fn]
(listen-once src type fn false))
([src type fn capture?]
(events/listenOnce src
(get (event-types src) type type)
fn
capture?)))
(defn unlisten
([src type fn]
(unlisten src type fn false))
([src type fn capture?]
(events/unlisten src
(get (event-types src) type type)
fn
capture?)))
(defn unlisten-by-key
[key]
(events/unlistenByKey key))
(defn dispatch-event
[src event]
(events/dispatchEvent src event))
(defn expose [e]
(events/expose e))
(defn fire-listeners
[obj type capture event])
(defn total-listener-count []
(events/getTotalListenerCount))
;; TODO
(defn get-listener [src type listener opt_capt opt_handler]); ⇒ ?Listener
(defn all-listeners [obj type capture]); ⇒ Array.<Listener>
(defn unique-event-id [event-type]); ⇒ string
(defn has-listener [obj opt_type opt_capture]); ⇒ boolean
;; TODO? (defn listen-with-wrapper [src wrapper listener opt_capt opt_handler])
;; TODO? (defn protect-browser-event-entry-point [errorHandler])
(defn remove-all [opt_obj opt_type opt_capt]); ⇒ number
;; TODO? (defn unlisten-with-wrapper [src wrapper listener opt_capt opt_handler])

File diff suppressed because one or more lines are too long

View File

@ -1,172 +0,0 @@
// Compiled by ClojureScript 1.11.121 {:optimizations :none}
goog.provide('clojure.browser.event');
goog.require('cljs.core');
goog.require('goog.events');
goog.require('goog.events.EventTarget');
goog.require('goog.events.EventType');
/**
* @interface
*/
clojure.browser.event.IEventType = function(){};
var clojure$browser$event$IEventType$event_types$dyn_530 = (function (this$){
var x__5346__auto__ = (((this$ == null))?null:this$);
var m__5347__auto__ = (clojure.browser.event.event_types[goog.typeOf(x__5346__auto__)]);
if((!((m__5347__auto__ == null)))){
return m__5347__auto__.call(null,this$);
} else {
var m__5345__auto__ = (clojure.browser.event.event_types["_"]);
if((!((m__5345__auto__ == null)))){
return m__5345__auto__.call(null,this$);
} else {
throw cljs.core.missing_protocol.call(null,"IEventType.event-types",this$);
}
}
});
clojure.browser.event.event_types = (function clojure$browser$event$event_types(this$){
if((((!((this$ == null)))) && ((!((this$.clojure$browser$event$IEventType$event_types$arity$1 == null)))))){
return this$.clojure$browser$event$IEventType$event_types$arity$1(this$);
} else {
return clojure$browser$event$IEventType$event_types$dyn_530.call(null,this$);
}
});
(goog.events.EventTarget.prototype.clojure$browser$event$IEventType$ = cljs.core.PROTOCOL_SENTINEL);
(goog.events.EventTarget.prototype.clojure$browser$event$IEventType$event_types$arity$1 = (function (this$){
var this$__$1 = this;
return cljs.core.into.call(null,cljs.core.PersistentArrayMap.EMPTY,cljs.core.map.call(null,(function (p__531){
var vec__532 = p__531;
var k = cljs.core.nth.call(null,vec__532,(0),null);
var v = cljs.core.nth.call(null,vec__532,(1),null);
return new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [cljs.core.keyword.call(null,k.toLowerCase()),v], null);
}),cljs.core.merge.call(null,cljs.core.js__GT_clj.call(null,goog.events.EventType))));
}));
if((typeof Element !== 'undefined')){
(Element.prototype.clojure$browser$event$IEventType$ = cljs.core.PROTOCOL_SENTINEL);
(Element.prototype.clojure$browser$event$IEventType$event_types$arity$1 = (function (this$){
var this$__$1 = this;
return cljs.core.into.call(null,cljs.core.PersistentArrayMap.EMPTY,cljs.core.map.call(null,(function (p__535){
var vec__536 = p__535;
var k = cljs.core.nth.call(null,vec__536,(0),null);
var v = cljs.core.nth.call(null,vec__536,(1),null);
return new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [cljs.core.keyword.call(null,k.toLowerCase()),v], null);
}),cljs.core.merge.call(null,cljs.core.js__GT_clj.call(null,goog.events.EventType))));
}));
} else {
}
clojure.browser.event.listen = (function clojure$browser$event$listen(var_args){
var G__540 = arguments.length;
switch (G__540) {
case 3:
return clojure.browser.event.listen.cljs$core$IFn$_invoke$arity$3((arguments[(0)]),(arguments[(1)]),(arguments[(2)]));
break;
case 4:
return clojure.browser.event.listen.cljs$core$IFn$_invoke$arity$4((arguments[(0)]),(arguments[(1)]),(arguments[(2)]),(arguments[(3)]));
break;
default:
throw (new Error(["Invalid arity: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(arguments.length)].join('')));
}
});
(clojure.browser.event.listen.cljs$core$IFn$_invoke$arity$3 = (function (src,type,fn){
return clojure.browser.event.listen.call(null,src,type,fn,false);
}));
(clojure.browser.event.listen.cljs$core$IFn$_invoke$arity$4 = (function (src,type,fn,capture_QMARK_){
return goog.events.listen(src,cljs.core.get.call(null,clojure.browser.event.event_types.call(null,src),type,type),fn,capture_QMARK_);
}));
(clojure.browser.event.listen.cljs$lang$maxFixedArity = 4);
clojure.browser.event.listen_once = (function clojure$browser$event$listen_once(var_args){
var G__543 = arguments.length;
switch (G__543) {
case 3:
return clojure.browser.event.listen_once.cljs$core$IFn$_invoke$arity$3((arguments[(0)]),(arguments[(1)]),(arguments[(2)]));
break;
case 4:
return clojure.browser.event.listen_once.cljs$core$IFn$_invoke$arity$4((arguments[(0)]),(arguments[(1)]),(arguments[(2)]),(arguments[(3)]));
break;
default:
throw (new Error(["Invalid arity: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(arguments.length)].join('')));
}
});
(clojure.browser.event.listen_once.cljs$core$IFn$_invoke$arity$3 = (function (src,type,fn){
return clojure.browser.event.listen_once.call(null,src,type,fn,false);
}));
(clojure.browser.event.listen_once.cljs$core$IFn$_invoke$arity$4 = (function (src,type,fn,capture_QMARK_){
return goog.events.listenOnce(src,cljs.core.get.call(null,clojure.browser.event.event_types.call(null,src),type,type),fn,capture_QMARK_);
}));
(clojure.browser.event.listen_once.cljs$lang$maxFixedArity = 4);
clojure.browser.event.unlisten = (function clojure$browser$event$unlisten(var_args){
var G__546 = arguments.length;
switch (G__546) {
case 3:
return clojure.browser.event.unlisten.cljs$core$IFn$_invoke$arity$3((arguments[(0)]),(arguments[(1)]),(arguments[(2)]));
break;
case 4:
return clojure.browser.event.unlisten.cljs$core$IFn$_invoke$arity$4((arguments[(0)]),(arguments[(1)]),(arguments[(2)]),(arguments[(3)]));
break;
default:
throw (new Error(["Invalid arity: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(arguments.length)].join('')));
}
});
(clojure.browser.event.unlisten.cljs$core$IFn$_invoke$arity$3 = (function (src,type,fn){
return clojure.browser.event.unlisten.call(null,src,type,fn,false);
}));
(clojure.browser.event.unlisten.cljs$core$IFn$_invoke$arity$4 = (function (src,type,fn,capture_QMARK_){
return goog.events.unlisten(src,cljs.core.get.call(null,clojure.browser.event.event_types.call(null,src),type,type),fn,capture_QMARK_);
}));
(clojure.browser.event.unlisten.cljs$lang$maxFixedArity = 4);
clojure.browser.event.unlisten_by_key = (function clojure$browser$event$unlisten_by_key(key){
return goog.events.unlistenByKey(key);
});
clojure.browser.event.dispatch_event = (function clojure$browser$event$dispatch_event(src,event){
return goog.events.dispatchEvent(src,event);
});
clojure.browser.event.expose = (function clojure$browser$event$expose(e){
return goog.events.expose(e);
});
clojure.browser.event.fire_listeners = (function clojure$browser$event$fire_listeners(obj,type,capture,event){
return null;
});
clojure.browser.event.total_listener_count = (function clojure$browser$event$total_listener_count(){
return goog.events.getTotalListenerCount();
});
clojure.browser.event.get_listener = (function clojure$browser$event$get_listener(src,type,listener,opt_capt,opt_handler){
return null;
});
clojure.browser.event.all_listeners = (function clojure$browser$event$all_listeners(obj,type,capture){
return null;
});
clojure.browser.event.unique_event_id = (function clojure$browser$event$unique_event_id(event_type){
return null;
});
clojure.browser.event.has_listener = (function clojure$browser$event$has_listener(obj,opt_type,opt_capture){
return null;
});
clojure.browser.event.remove_all = (function clojure$browser$event$remove_all(opt_obj,opt_type,opt_capt){
return null;
});
//# sourceMappingURL=event.js.map

View File

@ -1 +0,0 @@
{"version":3,"file":"\/Users\/scott\/.cljs\/.aot_cache\/1.11.121\/4A35AE8\/clojure\/browser\/event.js","sources":["event.cljs"],"lineCount":172,"mappings":";AAQA;;;;;AAOA,AAAA;AAAA;;;mCAAA,nCAAaO;;AAAb,IAAAP,uDAAA,WACgBQ;AADhB,AAAA,IAAAP,kBAAA,EAAA,UAAA,OAAA,hBACgBO,qBAAAA;IADhBN,kBAAA,CAAAC,kCAAA,AAAAC,YAAAH;AAAA,AAAA,GAAA,GAAA,CAAAC,mBAAA;AAAA,OAAAA,0BACgBM;;AADhB,IAAAH,kBAAA,CAAAF,kCAAA;AAAA,AAAA,GAAA,GAAA,CAAAE,mBAAA;AAAA,OAAAA,0BACgBG;;AADhB,MAAA,AAAAF,qCAAA,yBACgBE;;;;AADhB,AAAA,oCAAA,pCACGL,gFAAaK;AADhB,AAAA,GAAA,EAAA,GAAA,UAAA,aAAA,GAAA,CAAA,8DAAA,xFACgBA,0BAAAA;AADhB,OACgBA,2DAAAA;;AADhB,OAAAR,+DACgBQ;;;;AADhB,AAGA,AAAA,AAAA,CAAA,AAAA,sEAAAC,tEAEEC;;AAFF,CAAA,AAAA,AAEEA,yFACA,WACGF;AADH,AAAA,gBAAA,ZACGA;AADH,AAEE,gCAAA,zBAACG,4DACK,AAACC,wBACA,WAAAC;AAAA,AAAA,IAAAC,WAAAD;QAAA,AAAAE,wBAAAD,SAAA,IAAA,zCAAME;QAAN,AAAAD,wBAAAD,SAAA,IAAA,zCAAQG;AAAR,AAAA,0FACG,AAACC,4BAAQ,AAAcF,iBACvBC;GACH,AAACE,0BACA,AAACC,+BAAQC;;AAErB,GAAM,QAAAC;AAAN,AACE,AAAA,AAAA,CAAA,AAAA,sDAAAb,tDAEEa;;AAFF,CAAA,AAAA,AAEEA,yEACA,WACGd;AADH,AAAA,gBAAA,ZACGA;AADH,AAEE,gCAAA,zBAACG,4DACK,AAACC,wBACA,WAAAW;AAAA,AAAA,IAAAC,WAAAD;QAAA,AAAAR,wBAAAS,SAAA,IAAA,zCAAMR;QAAN,AAAAD,wBAAAS,SAAA,IAAA,zCAAQP;AAAR,AAAA,0FACG,AAACC,4BAAQ,AAAcF,iBACvBC;GACH,AAACE,0BACA,AAACC,+BAAQC;;;AAZvB;AAcA,AAAA,+BAAA,uCAAAI,tEAAME;AAAN,AAAA,IAAAD,SAAA,AAAA;AAAA,AAAA,QAAAA;KAAA;AAAA,OAAAC,2DAAA,CAAA,UAAA,MAAA,CAAA,UAAA,MAAA,CAAA,UAAA;;;KAAA;AAAA,OAAAA,2DAAA,CAAA,UAAA,MAAA,CAAA,UAAA,MAAA,CAAA,UAAA,MAAA,CAAA,UAAA;;;;AAAA,MAAA,KAAAC,MAAA,CAAA,8DAAA,AAAA;;;;;AAAA,CAAA,6DAAA,7DAAMD,wEACFE,IAAIC,KAAKC;AADb,AAEK,0DAAA,nDAACJ,uCAAOE,IAAIC,KAAKC;;;AAFtB,CAAA,6DAAA,7DAAMJ,wEAGFE,IAAIC,KAAKC,GAAGC;AAHhB,AAIK,OAACC,mBAAcJ,IACA,AAACK,wBAAI,AAAC\/B,4CAAY0B,KAAKC,KAAKA,MAC5BC,GACAC;;;AAPpB,CAAA,uDAAA,vDAAML;;AAAN,AASA,AAAA,oCAAA,4CAAAF,hFAAMW;AAAN,AAAA,IAAAD,SAAA,AAAA;AAAA,AAAA,QAAAA;KAAA;AAAA,OAAAC,gEAAA,CAAA,UAAA,MAAA,CAAA,UAAA,MAAA,CAAA,UAAA;;;KAAA;AAAA,OAAAA,gEAAA,CAAA,UAAA,MAAA,CAAA,UAAA,MAAA,CAAA,UAAA,MAAA,CAAA,UAAA;;;;AAAA,MAAA,KAAAR,MAAA,CAAA,8DAAA,AAAA;;;;;AAAA,CAAA,kEAAA,lEAAMQ,6EACFP,IAAIC,KAAKC;AADb,AAEK,+DAAA,xDAACK,4CAAYP,IAAIC,KAAKC;;;AAF3B,CAAA,kEAAA,lEAAMK,6EAGFP,IAAIC,KAAKC,GAAGC;AAHhB,AAIK,OAACK,uBAAkBR,IACA,AAACK,wBAAI,AAAC\/B,4CAAY0B,KAAKC,KAAKA,MAC5BC,GACAC;;;AAPxB,CAAA,4DAAA,5DAAMI;;AAAN,AASA,AAAA,iCAAA,yCAAAX,1EAAMc;AAAN,AAAA,IAAAD,SAAA,AAAA;AAAA,AAAA,QAAAA;KAAA;AAAA,OAAAC,6DAAA,CAAA,UAAA,MAAA,CAAA,UAAA,MAAA,CAAA,UAAA;;;KAAA;AAAA,OAAAA,6DAAA,CAAA,UAAA,MAAA,CAAA,UAAA,MAAA,CAAA,UAAA,MAAA,CAAA,UAAA;;;;AAAA,MAAA,KAAAX,MAAA,CAAA,8DAAA,AAAA;;;;;AAAA,CAAA,+DAAA,\/DAAMW,0EACFV,IAAIC,KAAKC;AADb,AAEK,4DAAA,rDAACQ,yCAASV,IAAIC,KAAKC;;;AAFxB,CAAA,+DAAA,\/DAAMQ,0EAGFV,IAAIC,KAAKC,GAAGC;AAHhB,AAIK,OAACQ,qBAAgBX,IACA,AAACK,wBAAI,AAAC\/B,4CAAY0B,KAAKC,KAAKA,MAC5BC,GACAC;;;AAPtB,CAAA,yDAAA,zDAAMO;;AAAN,AASA,wCAAA,xCAAME,wFACHC;AADH,AAEE,OAACC,0BAAqBD;;AAExB,uCAAA,vCAAME,sFACHf,IAAIgB;AADP,AAEE,OAACC,0BAAqBjB,IAAIgB;;AAE5B,+BAAA,\/BAAME,sEAAQC;AAAd,AACE,OAACC,mBAAcD;;AAEjB,uCAAA,vCAAME,sFACHC,IAAIrB,KAAKsB,QAAQP;AADpB,AAAA;;AAGA,6CAAA,7CAAMQ;AAAN,AACE,OAACC;;AAGH,qCAAA,rCAAMC,kFAAc1B,IAAIC,KAAK0B,SAASC,SAASC;AAA\/C,AAAA;;AACA,sCAAA,tCAAMC,oFAAeR,IAAIrB,KAAKsB;AAA9B,AAAA;;AAEA,wCAAA,xCAAMQ,wFAAiBC;AAAvB,AAAA;;AAEA,qCAAA,rCAAMC,kFAAcX,IAAIY,SAASC;AAAjC,AAAA;;AAIA,mCAAA,nCAAMC,8EAAYC,QAAQH,SAASN;AAAnC,AAAA","names":["clojure$browser$event$IEventType$event_types$dyn","x__5346__auto__","m__5347__auto__","clojure.browser.event\/event-types","goog\/typeOf","m__5345__auto__","cljs.core\/missing-protocol","clojure.browser.event\/IEventType","this","cljs.core\/PROTOCOL_SENTINEL","goog.events\/EventTarget","cljs.core\/into","cljs.core\/map","p__531","vec__532","cljs.core\/nth","k","v","cljs.core\/keyword","cljs.core\/merge","cljs.core\/js->clj","goog.events\/EventType","js\/Element","p__535","vec__536","var_args","G__540","clojure.browser.event\/listen","js\/Error","src","type","fn","capture?","goog.events\/listen","cljs.core\/get","G__543","clojure.browser.event\/listen-once","goog.events\/listenOnce","G__546","clojure.browser.event\/unlisten","goog.events\/unlisten","clojure.browser.event\/unlisten-by-key","key","goog.events\/unlistenByKey","clojure.browser.event\/dispatch-event","event","goog.events\/dispatchEvent","clojure.browser.event\/expose","e","goog.events\/expose","clojure.browser.event\/fire-listeners","obj","capture","clojure.browser.event\/total-listener-count","goog.events\/getTotalListenerCount","clojure.browser.event\/get-listener","listener","opt_capt","opt_handler","clojure.browser.event\/all-listeners","clojure.browser.event\/unique-event-id","event-type","clojure.browser.event\/has-listener","opt_type","opt_capture","clojure.browser.event\/remove-all","opt_obj"]}

View File

@ -1,181 +0,0 @@
;; Copyright (c) Rich Hickey. All rights reserved.
;; The use and distribution terms for this software are covered by the
;; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)
;; which can be found in the file epl-v10.html at the root of this distribution.
;; By using this software in any fashion, you are agreeing to be bound by
;; the terms of this license.
;; You must not remove this notice, or any other, from this software.
(ns ^{:doc "Network communication library, wrapping goog.net.
Includes a common API over XhrIo, CrossPageChannel, and Websockets."
:author "Bobby Calderwood and Alex Redington"}
clojure.browser.net
(:require [clojure.browser.event :as event]
[goog.json :as gjson]
[goog.object :as gobj])
(:import [goog.net XhrIo EventType WebSocket]
[goog.net.xpc CfgFields CrossPageChannel]
[goog Uri]))
(def *timeout* 10000)
(def event-types
(into {}
(map
(fn [[k v]]
[(keyword (.toLowerCase k))
v])
(merge
(js->clj EventType)))))
(defprotocol IConnection
(connect
[this]
[this opt1]
[this opt1 opt2]
[this opt1 opt2 opt3])
(transmit
[this opt]
[this opt opt2]
[this opt opt2 opt3]
[this opt opt2 opt3 opt4]
[this opt opt2 opt3 opt4 opt5])
(close [this]))
(extend-type XhrIo
IConnection
(transmit
([this uri]
(transmit this uri "GET" nil nil *timeout*))
([this uri method]
(transmit this uri method nil nil *timeout*))
([this uri method content]
(transmit this uri method content nil *timeout*))
([this uri method content headers]
(transmit this uri method content headers *timeout*))
([this uri method content headers timeout]
(.setTimeoutInterval this timeout)
(.send this uri method content headers)))
event/IEventType
(event-types [this]
(into {}
(map
(fn [[k v]]
[(keyword (.toLowerCase k))
v])
(merge
(js->clj EventType))))))
;; TODO jQuery/sinatra/RestClient style API: (get [uri]), (post [uri payload]), (put [uri payload]), (delete [uri])
(def xpc-config-fields
(into {}
(map
(fn [[k v]]
[(keyword (.toLowerCase k))
v])
(js->clj CfgFields))))
(defn xhr-connection
"Returns an XhrIo connection"
[]
(XhrIo.))
(defprotocol ICrossPageChannel
(register-service [this service-name fn] [this service-name fn encode-json?]))
(extend-type CrossPageChannel
ICrossPageChannel
(register-service
([this service-name fn]
(register-service this service-name fn false))
([this service-name fn encode-json?]
(.registerService this (name service-name) fn encode-json?)))
IConnection
(connect
([this]
(connect this nil))
([this on-connect-fn]
(.connect this on-connect-fn))
([this on-connect-fn config-iframe-fn]
(connect this on-connect-fn config-iframe-fn (.-body js/document)))
([this on-connect-fn config-iframe-fn iframe-parent]
(.createPeerIframe this iframe-parent config-iframe-fn)
(.connect this on-connect-fn)))
(transmit [this service-name payload]
(.send this (name service-name) payload))
(close [this]
(.close this)))
(defn xpc-connection
"When passed with a config hash-map, returns a parent
CrossPageChannel object. Keys in the config hash map are downcased
versions of the goog.net.xpc.CfgFields enum keys,
e.g. goog.net.xpc.CfgFields.PEER_URI becomes :peer_uri in the config
hash.
When passed with no args, creates a child CrossPageChannel object,
and the config is automatically taken from the URL param 'xpc', as
per the CrossPageChannel API."
([]
(when-let [config (.getParameterValue
(Uri. (.-href (.-location js/window)))
"xpc")]
(CrossPageChannel. (gjson/parse config))))
([config]
(CrossPageChannel.
(reduce (fn [sum [k v]]
(if-let [field (get xpc-config-fields k)]
(doto sum (gobj/set field v))
sum))
(js-obj)
config))))
;; WebSocket is not supported in the 3/23/11 release of Google
;; Closure, but will be included in the next release.
(defprotocol IWebSocket
(open? [this]))
(extend-type WebSocket
IWebSocket
(open? [this]
(.isOpen this ()))
IConnection
(connect
([this url]
(connect this url nil))
([this url protocol]
(.open this url protocol)))
(transmit [this message]
(.send this message))
(close [this]
(.close this ()))
event/IEventType
(event-types [this]
(into {}
(map
(fn [[k v]]
[(keyword (. k (toLowerCase)))
v])
(merge
(js->clj WebSocket.EventType))))))
(defn websocket-connection
([]
(websocket-connection nil nil))
([auto-reconnect?]
(websocket-connection auto-reconnect? nil))
([auto-reconnect? next-reconnect-fn]
(WebSocket. auto-reconnect? next-reconnect-fn)))

File diff suppressed because one or more lines are too long

View File

@ -1,701 +0,0 @@
// Compiled by ClojureScript 1.11.121 {:optimizations :none}
goog.provide('clojure.browser.net');
goog.require('cljs.core');
goog.require('clojure.browser.event');
goog.require('goog.json');
goog.require('goog.net.XhrIo');
goog.require('goog.net.EventType');
goog.require('goog.net.WebSocket');
goog.require('goog.net.xpc.CfgFields');
goog.require('goog.net.xpc.CrossPageChannel');
goog.require('goog.Uri');
goog.require('goog.object');
goog.scope(function(){
clojure.browser.net.goog$module$goog$object = goog.module.get('goog.object');
});
clojure.browser.net._STAR_timeout_STAR_ = (10000);
clojure.browser.net.event_types = cljs.core.into.call(null,cljs.core.PersistentArrayMap.EMPTY,cljs.core.map.call(null,(function (p__550){
var vec__551 = p__550;
var k = cljs.core.nth.call(null,vec__551,(0),null);
var v = cljs.core.nth.call(null,vec__551,(1),null);
return new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [cljs.core.keyword.call(null,k.toLowerCase()),v], null);
}),cljs.core.merge.call(null,cljs.core.js__GT_clj.call(null,goog.net.EventType))));
/**
* @interface
*/
clojure.browser.net.IConnection = function(){};
var clojure$browser$net$IConnection$connect$dyn_558 = (function() {
var G__559 = null;
var G__559__1 = (function (this$){
var x__5346__auto__ = (((this$ == null))?null:this$);
var m__5347__auto__ = (clojure.browser.net.connect[goog.typeOf(x__5346__auto__)]);
if((!((m__5347__auto__ == null)))){
return m__5347__auto__.call(null,this$);
} else {
var m__5345__auto__ = (clojure.browser.net.connect["_"]);
if((!((m__5345__auto__ == null)))){
return m__5345__auto__.call(null,this$);
} else {
throw cljs.core.missing_protocol.call(null,"IConnection.connect",this$);
}
}
});
var G__559__2 = (function (this$,opt1){
var x__5346__auto__ = (((this$ == null))?null:this$);
var m__5347__auto__ = (clojure.browser.net.connect[goog.typeOf(x__5346__auto__)]);
if((!((m__5347__auto__ == null)))){
return m__5347__auto__.call(null,this$,opt1);
} else {
var m__5345__auto__ = (clojure.browser.net.connect["_"]);
if((!((m__5345__auto__ == null)))){
return m__5345__auto__.call(null,this$,opt1);
} else {
throw cljs.core.missing_protocol.call(null,"IConnection.connect",this$);
}
}
});
var G__559__3 = (function (this$,opt1,opt2){
var x__5346__auto__ = (((this$ == null))?null:this$);
var m__5347__auto__ = (clojure.browser.net.connect[goog.typeOf(x__5346__auto__)]);
if((!((m__5347__auto__ == null)))){
return m__5347__auto__.call(null,this$,opt1,opt2);
} else {
var m__5345__auto__ = (clojure.browser.net.connect["_"]);
if((!((m__5345__auto__ == null)))){
return m__5345__auto__.call(null,this$,opt1,opt2);
} else {
throw cljs.core.missing_protocol.call(null,"IConnection.connect",this$);
}
}
});
var G__559__4 = (function (this$,opt1,opt2,opt3){
var x__5346__auto__ = (((this$ == null))?null:this$);
var m__5347__auto__ = (clojure.browser.net.connect[goog.typeOf(x__5346__auto__)]);
if((!((m__5347__auto__ == null)))){
return m__5347__auto__.call(null,this$,opt1,opt2,opt3);
} else {
var m__5345__auto__ = (clojure.browser.net.connect["_"]);
if((!((m__5345__auto__ == null)))){
return m__5345__auto__.call(null,this$,opt1,opt2,opt3);
} else {
throw cljs.core.missing_protocol.call(null,"IConnection.connect",this$);
}
}
});
G__559 = function(this$,opt1,opt2,opt3){
switch(arguments.length){
case 1:
return G__559__1.call(this,this$);
case 2:
return G__559__2.call(this,this$,opt1);
case 3:
return G__559__3.call(this,this$,opt1,opt2);
case 4:
return G__559__4.call(this,this$,opt1,opt2,opt3);
}
throw(new Error('Invalid arity: ' + arguments.length));
};
G__559.cljs$core$IFn$_invoke$arity$1 = G__559__1;
G__559.cljs$core$IFn$_invoke$arity$2 = G__559__2;
G__559.cljs$core$IFn$_invoke$arity$3 = G__559__3;
G__559.cljs$core$IFn$_invoke$arity$4 = G__559__4;
return G__559;
})()
;
clojure.browser.net.connect = (function clojure$browser$net$connect(var_args){
var G__555 = arguments.length;
switch (G__555) {
case 1:
return clojure.browser.net.connect.cljs$core$IFn$_invoke$arity$1((arguments[(0)]));
break;
case 2:
return clojure.browser.net.connect.cljs$core$IFn$_invoke$arity$2((arguments[(0)]),(arguments[(1)]));
break;
case 3:
return clojure.browser.net.connect.cljs$core$IFn$_invoke$arity$3((arguments[(0)]),(arguments[(1)]),(arguments[(2)]));
break;
case 4:
return clojure.browser.net.connect.cljs$core$IFn$_invoke$arity$4((arguments[(0)]),(arguments[(1)]),(arguments[(2)]),(arguments[(3)]));
break;
default:
throw (new Error(["Invalid arity: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(arguments.length)].join('')));
}
});
(clojure.browser.net.connect.cljs$core$IFn$_invoke$arity$1 = (function (this$){
if((((!((this$ == null)))) && ((!((this$.clojure$browser$net$IConnection$connect$arity$1 == null)))))){
return this$.clojure$browser$net$IConnection$connect$arity$1(this$);
} else {
return clojure$browser$net$IConnection$connect$dyn_558.call(null,this$);
}
}));
(clojure.browser.net.connect.cljs$core$IFn$_invoke$arity$2 = (function (this$,opt1){
if((((!((this$ == null)))) && ((!((this$.clojure$browser$net$IConnection$connect$arity$2 == null)))))){
return this$.clojure$browser$net$IConnection$connect$arity$2(this$,opt1);
} else {
return clojure$browser$net$IConnection$connect$dyn_558.call(null,this$,opt1);
}
}));
(clojure.browser.net.connect.cljs$core$IFn$_invoke$arity$3 = (function (this$,opt1,opt2){
if((((!((this$ == null)))) && ((!((this$.clojure$browser$net$IConnection$connect$arity$3 == null)))))){
return this$.clojure$browser$net$IConnection$connect$arity$3(this$,opt1,opt2);
} else {
return clojure$browser$net$IConnection$connect$dyn_558.call(null,this$,opt1,opt2);
}
}));
(clojure.browser.net.connect.cljs$core$IFn$_invoke$arity$4 = (function (this$,opt1,opt2,opt3){
if((((!((this$ == null)))) && ((!((this$.clojure$browser$net$IConnection$connect$arity$4 == null)))))){
return this$.clojure$browser$net$IConnection$connect$arity$4(this$,opt1,opt2,opt3);
} else {
return clojure$browser$net$IConnection$connect$dyn_558.call(null,this$,opt1,opt2,opt3);
}
}));
(clojure.browser.net.connect.cljs$lang$maxFixedArity = 4);
var clojure$browser$net$IConnection$transmit$dyn_561 = (function() {
var G__562 = null;
var G__562__2 = (function (this$,opt){
var x__5346__auto__ = (((this$ == null))?null:this$);
var m__5347__auto__ = (clojure.browser.net.transmit[goog.typeOf(x__5346__auto__)]);
if((!((m__5347__auto__ == null)))){
return m__5347__auto__.call(null,this$,opt);
} else {
var m__5345__auto__ = (clojure.browser.net.transmit["_"]);
if((!((m__5345__auto__ == null)))){
return m__5345__auto__.call(null,this$,opt);
} else {
throw cljs.core.missing_protocol.call(null,"IConnection.transmit",this$);
}
}
});
var G__562__3 = (function (this$,opt,opt2){
var x__5346__auto__ = (((this$ == null))?null:this$);
var m__5347__auto__ = (clojure.browser.net.transmit[goog.typeOf(x__5346__auto__)]);
if((!((m__5347__auto__ == null)))){
return m__5347__auto__.call(null,this$,opt,opt2);
} else {
var m__5345__auto__ = (clojure.browser.net.transmit["_"]);
if((!((m__5345__auto__ == null)))){
return m__5345__auto__.call(null,this$,opt,opt2);
} else {
throw cljs.core.missing_protocol.call(null,"IConnection.transmit",this$);
}
}
});
var G__562__4 = (function (this$,opt,opt2,opt3){
var x__5346__auto__ = (((this$ == null))?null:this$);
var m__5347__auto__ = (clojure.browser.net.transmit[goog.typeOf(x__5346__auto__)]);
if((!((m__5347__auto__ == null)))){
return m__5347__auto__.call(null,this$,opt,opt2,opt3);
} else {
var m__5345__auto__ = (clojure.browser.net.transmit["_"]);
if((!((m__5345__auto__ == null)))){
return m__5345__auto__.call(null,this$,opt,opt2,opt3);
} else {
throw cljs.core.missing_protocol.call(null,"IConnection.transmit",this$);
}
}
});
var G__562__5 = (function (this$,opt,opt2,opt3,opt4){
var x__5346__auto__ = (((this$ == null))?null:this$);
var m__5347__auto__ = (clojure.browser.net.transmit[goog.typeOf(x__5346__auto__)]);
if((!((m__5347__auto__ == null)))){
return m__5347__auto__.call(null,this$,opt,opt2,opt3,opt4);
} else {
var m__5345__auto__ = (clojure.browser.net.transmit["_"]);
if((!((m__5345__auto__ == null)))){
return m__5345__auto__.call(null,this$,opt,opt2,opt3,opt4);
} else {
throw cljs.core.missing_protocol.call(null,"IConnection.transmit",this$);
}
}
});
var G__562__6 = (function (this$,opt,opt2,opt3,opt4,opt5){
var x__5346__auto__ = (((this$ == null))?null:this$);
var m__5347__auto__ = (clojure.browser.net.transmit[goog.typeOf(x__5346__auto__)]);
if((!((m__5347__auto__ == null)))){
return m__5347__auto__.call(null,this$,opt,opt2,opt3,opt4,opt5);
} else {
var m__5345__auto__ = (clojure.browser.net.transmit["_"]);
if((!((m__5345__auto__ == null)))){
return m__5345__auto__.call(null,this$,opt,opt2,opt3,opt4,opt5);
} else {
throw cljs.core.missing_protocol.call(null,"IConnection.transmit",this$);
}
}
});
G__562 = function(this$,opt,opt2,opt3,opt4,opt5){
switch(arguments.length){
case 2:
return G__562__2.call(this,this$,opt);
case 3:
return G__562__3.call(this,this$,opt,opt2);
case 4:
return G__562__4.call(this,this$,opt,opt2,opt3);
case 5:
return G__562__5.call(this,this$,opt,opt2,opt3,opt4);
case 6:
return G__562__6.call(this,this$,opt,opt2,opt3,opt4,opt5);
}
throw(new Error('Invalid arity: ' + arguments.length));
};
G__562.cljs$core$IFn$_invoke$arity$2 = G__562__2;
G__562.cljs$core$IFn$_invoke$arity$3 = G__562__3;
G__562.cljs$core$IFn$_invoke$arity$4 = G__562__4;
G__562.cljs$core$IFn$_invoke$arity$5 = G__562__5;
G__562.cljs$core$IFn$_invoke$arity$6 = G__562__6;
return G__562;
})()
;
clojure.browser.net.transmit = (function clojure$browser$net$transmit(var_args){
var G__557 = arguments.length;
switch (G__557) {
case 2:
return clojure.browser.net.transmit.cljs$core$IFn$_invoke$arity$2((arguments[(0)]),(arguments[(1)]));
break;
case 3:
return clojure.browser.net.transmit.cljs$core$IFn$_invoke$arity$3((arguments[(0)]),(arguments[(1)]),(arguments[(2)]));
break;
case 4:
return clojure.browser.net.transmit.cljs$core$IFn$_invoke$arity$4((arguments[(0)]),(arguments[(1)]),(arguments[(2)]),(arguments[(3)]));
break;
case 5:
return clojure.browser.net.transmit.cljs$core$IFn$_invoke$arity$5((arguments[(0)]),(arguments[(1)]),(arguments[(2)]),(arguments[(3)]),(arguments[(4)]));
break;
case 6:
return clojure.browser.net.transmit.cljs$core$IFn$_invoke$arity$6((arguments[(0)]),(arguments[(1)]),(arguments[(2)]),(arguments[(3)]),(arguments[(4)]),(arguments[(5)]));
break;
default:
throw (new Error(["Invalid arity: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(arguments.length)].join('')));
}
});
(clojure.browser.net.transmit.cljs$core$IFn$_invoke$arity$2 = (function (this$,opt){
if((((!((this$ == null)))) && ((!((this$.clojure$browser$net$IConnection$transmit$arity$2 == null)))))){
return this$.clojure$browser$net$IConnection$transmit$arity$2(this$,opt);
} else {
return clojure$browser$net$IConnection$transmit$dyn_561.call(null,this$,opt);
}
}));
(clojure.browser.net.transmit.cljs$core$IFn$_invoke$arity$3 = (function (this$,opt,opt2){
if((((!((this$ == null)))) && ((!((this$.clojure$browser$net$IConnection$transmit$arity$3 == null)))))){
return this$.clojure$browser$net$IConnection$transmit$arity$3(this$,opt,opt2);
} else {
return clojure$browser$net$IConnection$transmit$dyn_561.call(null,this$,opt,opt2);
}
}));
(clojure.browser.net.transmit.cljs$core$IFn$_invoke$arity$4 = (function (this$,opt,opt2,opt3){
if((((!((this$ == null)))) && ((!((this$.clojure$browser$net$IConnection$transmit$arity$4 == null)))))){
return this$.clojure$browser$net$IConnection$transmit$arity$4(this$,opt,opt2,opt3);
} else {
return clojure$browser$net$IConnection$transmit$dyn_561.call(null,this$,opt,opt2,opt3);
}
}));
(clojure.browser.net.transmit.cljs$core$IFn$_invoke$arity$5 = (function (this$,opt,opt2,opt3,opt4){
if((((!((this$ == null)))) && ((!((this$.clojure$browser$net$IConnection$transmit$arity$5 == null)))))){
return this$.clojure$browser$net$IConnection$transmit$arity$5(this$,opt,opt2,opt3,opt4);
} else {
return clojure$browser$net$IConnection$transmit$dyn_561.call(null,this$,opt,opt2,opt3,opt4);
}
}));
(clojure.browser.net.transmit.cljs$core$IFn$_invoke$arity$6 = (function (this$,opt,opt2,opt3,opt4,opt5){
if((((!((this$ == null)))) && ((!((this$.clojure$browser$net$IConnection$transmit$arity$6 == null)))))){
return this$.clojure$browser$net$IConnection$transmit$arity$6(this$,opt,opt2,opt3,opt4,opt5);
} else {
return clojure$browser$net$IConnection$transmit$dyn_561.call(null,this$,opt,opt2,opt3,opt4,opt5);
}
}));
(clojure.browser.net.transmit.cljs$lang$maxFixedArity = 6);
var clojure$browser$net$IConnection$close$dyn_564 = (function (this$){
var x__5346__auto__ = (((this$ == null))?null:this$);
var m__5347__auto__ = (clojure.browser.net.close[goog.typeOf(x__5346__auto__)]);
if((!((m__5347__auto__ == null)))){
return m__5347__auto__.call(null,this$);
} else {
var m__5345__auto__ = (clojure.browser.net.close["_"]);
if((!((m__5345__auto__ == null)))){
return m__5345__auto__.call(null,this$);
} else {
throw cljs.core.missing_protocol.call(null,"IConnection.close",this$);
}
}
});
clojure.browser.net.close = (function clojure$browser$net$close(this$){
if((((!((this$ == null)))) && ((!((this$.clojure$browser$net$IConnection$close$arity$1 == null)))))){
return this$.clojure$browser$net$IConnection$close$arity$1(this$);
} else {
return clojure$browser$net$IConnection$close$dyn_564.call(null,this$);
}
});
(goog.net.XhrIo.prototype.clojure$browser$net$IConnection$ = cljs.core.PROTOCOL_SENTINEL);
(goog.net.XhrIo.prototype.clojure$browser$net$IConnection$transmit$arity$2 = (function (this$,uri){
var this$__$1 = this;
return clojure.browser.net.transmit.call(null,this$__$1,uri,"GET",null,null,clojure.browser.net._STAR_timeout_STAR_);
}));
(goog.net.XhrIo.prototype.clojure$browser$net$IConnection$transmit$arity$3 = (function (this$,uri,method){
var this$__$1 = this;
return clojure.browser.net.transmit.call(null,this$__$1,uri,method,null,null,clojure.browser.net._STAR_timeout_STAR_);
}));
(goog.net.XhrIo.prototype.clojure$browser$net$IConnection$transmit$arity$4 = (function (this$,uri,method,content){
var this$__$1 = this;
return clojure.browser.net.transmit.call(null,this$__$1,uri,method,content,null,clojure.browser.net._STAR_timeout_STAR_);
}));
(goog.net.XhrIo.prototype.clojure$browser$net$IConnection$transmit$arity$5 = (function (this$,uri,method,content,headers){
var this$__$1 = this;
return clojure.browser.net.transmit.call(null,this$__$1,uri,method,content,headers,clojure.browser.net._STAR_timeout_STAR_);
}));
(goog.net.XhrIo.prototype.clojure$browser$net$IConnection$transmit$arity$6 = (function (this$,uri,method,content,headers,timeout){
var this$__$1 = this;
this$__$1.setTimeoutInterval(timeout);
return this$__$1.send(uri,method,content,headers);
}));
(goog.net.XhrIo.prototype.clojure$browser$event$IEventType$ = cljs.core.PROTOCOL_SENTINEL);
(goog.net.XhrIo.prototype.clojure$browser$event$IEventType$event_types$arity$1 = (function (this$){
var this$__$1 = this;
return cljs.core.into.call(null,cljs.core.PersistentArrayMap.EMPTY,cljs.core.map.call(null,(function (p__565){
var vec__566 = p__565;
var k = cljs.core.nth.call(null,vec__566,(0),null);
var v = cljs.core.nth.call(null,vec__566,(1),null);
return new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [cljs.core.keyword.call(null,k.toLowerCase()),v], null);
}),cljs.core.merge.call(null,cljs.core.js__GT_clj.call(null,goog.net.EventType))));
}));
clojure.browser.net.xpc_config_fields = cljs.core.into.call(null,cljs.core.PersistentArrayMap.EMPTY,cljs.core.map.call(null,(function (p__569){
var vec__570 = p__569;
var k = cljs.core.nth.call(null,vec__570,(0),null);
var v = cljs.core.nth.call(null,vec__570,(1),null);
return new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [cljs.core.keyword.call(null,k.toLowerCase()),v], null);
}),cljs.core.js__GT_clj.call(null,goog.net.xpc.CfgFields)));
/**
* Returns an XhrIo connection
*/
clojure.browser.net.xhr_connection = (function clojure$browser$net$xhr_connection(){
return (new goog.net.XhrIo());
});
/**
* @interface
*/
clojure.browser.net.ICrossPageChannel = function(){};
var clojure$browser$net$ICrossPageChannel$register_service$dyn_575 = (function() {
var G__576 = null;
var G__576__3 = (function (this$,service_name,fn){
var x__5346__auto__ = (((this$ == null))?null:this$);
var m__5347__auto__ = (clojure.browser.net.register_service[goog.typeOf(x__5346__auto__)]);
if((!((m__5347__auto__ == null)))){
return m__5347__auto__.call(null,this$,service_name,fn);
} else {
var m__5345__auto__ = (clojure.browser.net.register_service["_"]);
if((!((m__5345__auto__ == null)))){
return m__5345__auto__.call(null,this$,service_name,fn);
} else {
throw cljs.core.missing_protocol.call(null,"ICrossPageChannel.register-service",this$);
}
}
});
var G__576__4 = (function (this$,service_name,fn,encode_json_QMARK_){
var x__5346__auto__ = (((this$ == null))?null:this$);
var m__5347__auto__ = (clojure.browser.net.register_service[goog.typeOf(x__5346__auto__)]);
if((!((m__5347__auto__ == null)))){
return m__5347__auto__.call(null,this$,service_name,fn,encode_json_QMARK_);
} else {
var m__5345__auto__ = (clojure.browser.net.register_service["_"]);
if((!((m__5345__auto__ == null)))){
return m__5345__auto__.call(null,this$,service_name,fn,encode_json_QMARK_);
} else {
throw cljs.core.missing_protocol.call(null,"ICrossPageChannel.register-service",this$);
}
}
});
G__576 = function(this$,service_name,fn,encode_json_QMARK_){
switch(arguments.length){
case 3:
return G__576__3.call(this,this$,service_name,fn);
case 4:
return G__576__4.call(this,this$,service_name,fn,encode_json_QMARK_);
}
throw(new Error('Invalid arity: ' + arguments.length));
};
G__576.cljs$core$IFn$_invoke$arity$3 = G__576__3;
G__576.cljs$core$IFn$_invoke$arity$4 = G__576__4;
return G__576;
})()
;
clojure.browser.net.register_service = (function clojure$browser$net$register_service(var_args){
var G__574 = arguments.length;
switch (G__574) {
case 3:
return clojure.browser.net.register_service.cljs$core$IFn$_invoke$arity$3((arguments[(0)]),(arguments[(1)]),(arguments[(2)]));
break;
case 4:
return clojure.browser.net.register_service.cljs$core$IFn$_invoke$arity$4((arguments[(0)]),(arguments[(1)]),(arguments[(2)]),(arguments[(3)]));
break;
default:
throw (new Error(["Invalid arity: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(arguments.length)].join('')));
}
});
(clojure.browser.net.register_service.cljs$core$IFn$_invoke$arity$3 = (function (this$,service_name,fn){
if((((!((this$ == null)))) && ((!((this$.clojure$browser$net$ICrossPageChannel$register_service$arity$3 == null)))))){
return this$.clojure$browser$net$ICrossPageChannel$register_service$arity$3(this$,service_name,fn);
} else {
return clojure$browser$net$ICrossPageChannel$register_service$dyn_575.call(null,this$,service_name,fn);
}
}));
(clojure.browser.net.register_service.cljs$core$IFn$_invoke$arity$4 = (function (this$,service_name,fn,encode_json_QMARK_){
if((((!((this$ == null)))) && ((!((this$.clojure$browser$net$ICrossPageChannel$register_service$arity$4 == null)))))){
return this$.clojure$browser$net$ICrossPageChannel$register_service$arity$4(this$,service_name,fn,encode_json_QMARK_);
} else {
return clojure$browser$net$ICrossPageChannel$register_service$dyn_575.call(null,this$,service_name,fn,encode_json_QMARK_);
}
}));
(clojure.browser.net.register_service.cljs$lang$maxFixedArity = 4);
(goog.net.xpc.CrossPageChannel.prototype.clojure$browser$net$ICrossPageChannel$ = cljs.core.PROTOCOL_SENTINEL);
(goog.net.xpc.CrossPageChannel.prototype.clojure$browser$net$ICrossPageChannel$register_service$arity$3 = (function (this$,service_name,fn){
var this$__$1 = this;
return clojure.browser.net.register_service.call(null,this$__$1,service_name,fn,false);
}));
(goog.net.xpc.CrossPageChannel.prototype.clojure$browser$net$ICrossPageChannel$register_service$arity$4 = (function (this$,service_name,fn,encode_json_QMARK_){
var this$__$1 = this;
return this$__$1.registerService(cljs.core.name.call(null,service_name),fn,encode_json_QMARK_);
}));
(goog.net.xpc.CrossPageChannel.prototype.clojure$browser$net$IConnection$ = cljs.core.PROTOCOL_SENTINEL);
(goog.net.xpc.CrossPageChannel.prototype.clojure$browser$net$IConnection$connect$arity$1 = (function (this$){
var this$__$1 = this;
return clojure.browser.net.connect.call(null,this$__$1,null);
}));
(goog.net.xpc.CrossPageChannel.prototype.clojure$browser$net$IConnection$connect$arity$2 = (function (this$,on_connect_fn){
var this$__$1 = this;
return this$__$1.connect(on_connect_fn);
}));
(goog.net.xpc.CrossPageChannel.prototype.clojure$browser$net$IConnection$connect$arity$3 = (function (this$,on_connect_fn,config_iframe_fn){
var this$__$1 = this;
return clojure.browser.net.connect.call(null,this$__$1,on_connect_fn,config_iframe_fn,document.body);
}));
(goog.net.xpc.CrossPageChannel.prototype.clojure$browser$net$IConnection$connect$arity$4 = (function (this$,on_connect_fn,config_iframe_fn,iframe_parent){
var this$__$1 = this;
this$__$1.createPeerIframe(iframe_parent,config_iframe_fn);
return this$__$1.connect(on_connect_fn);
}));
(goog.net.xpc.CrossPageChannel.prototype.clojure$browser$net$IConnection$transmit$arity$3 = (function (this$,service_name,payload){
var this$__$1 = this;
return this$__$1.send(cljs.core.name.call(null,service_name),payload);
}));
(goog.net.xpc.CrossPageChannel.prototype.clojure$browser$net$IConnection$close$arity$1 = (function (this$){
var this$__$1 = this;
return this$__$1.close();
}));
/**
* When passed with a config hash-map, returns a parent
* CrossPageChannel object. Keys in the config hash map are downcased
* versions of the goog.net.xpc.CfgFields enum keys,
* e.g. goog.net.xpc.CfgFields.PEER_URI becomes :peer_uri in the config
* hash.
*
* When passed with no args, creates a child CrossPageChannel object,
* and the config is automatically taken from the URL param 'xpc', as
* per the CrossPageChannel API.
*/
clojure.browser.net.xpc_connection = (function clojure$browser$net$xpc_connection(var_args){
var G__579 = arguments.length;
switch (G__579) {
case 0:
return clojure.browser.net.xpc_connection.cljs$core$IFn$_invoke$arity$0();
break;
case 1:
return clojure.browser.net.xpc_connection.cljs$core$IFn$_invoke$arity$1((arguments[(0)]));
break;
default:
throw (new Error(["Invalid arity: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(arguments.length)].join('')));
}
});
(clojure.browser.net.xpc_connection.cljs$core$IFn$_invoke$arity$0 = (function (){
var temp__5804__auto__ = (new goog.Uri(window.location.href)).getParameterValue("xpc");
if(cljs.core.truth_(temp__5804__auto__)){
var config = temp__5804__auto__;
return (new goog.net.xpc.CrossPageChannel(goog.json.parse(config)));
} else {
return null;
}
}));
(clojure.browser.net.xpc_connection.cljs$core$IFn$_invoke$arity$1 = (function (config){
return (new goog.net.xpc.CrossPageChannel(cljs.core.reduce.call(null,(function (sum,p__580){
var vec__581 = p__580;
var k = cljs.core.nth.call(null,vec__581,(0),null);
var v = cljs.core.nth.call(null,vec__581,(1),null);
var temp__5802__auto__ = cljs.core.get.call(null,clojure.browser.net.xpc_config_fields,k);
if(cljs.core.truth_(temp__5802__auto__)){
var field = temp__5802__auto__;
var G__584 = sum;
clojure.browser.net.goog$module$goog$object.set.call(null,G__584,field,v);
return G__584;
} else {
return sum;
}
}),({}),config)));
}));
(clojure.browser.net.xpc_connection.cljs$lang$maxFixedArity = 1);
/**
* @interface
*/
clojure.browser.net.IWebSocket = function(){};
var clojure$browser$net$IWebSocket$open_QMARK_$dyn_588 = (function (this$){
var x__5346__auto__ = (((this$ == null))?null:this$);
var m__5347__auto__ = (clojure.browser.net.open_QMARK_[goog.typeOf(x__5346__auto__)]);
if((!((m__5347__auto__ == null)))){
return m__5347__auto__.call(null,this$);
} else {
var m__5345__auto__ = (clojure.browser.net.open_QMARK_["_"]);
if((!((m__5345__auto__ == null)))){
return m__5345__auto__.call(null,this$);
} else {
throw cljs.core.missing_protocol.call(null,"IWebSocket.open?",this$);
}
}
});
clojure.browser.net.open_QMARK_ = (function clojure$browser$net$open_QMARK_(this$){
if((((!((this$ == null)))) && ((!((this$.clojure$browser$net$IWebSocket$open_QMARK_$arity$1 == null)))))){
return this$.clojure$browser$net$IWebSocket$open_QMARK_$arity$1(this$);
} else {
return clojure$browser$net$IWebSocket$open_QMARK_$dyn_588.call(null,this$);
}
});
(goog.net.WebSocket.prototype.clojure$browser$net$IWebSocket$ = cljs.core.PROTOCOL_SENTINEL);
(goog.net.WebSocket.prototype.clojure$browser$net$IWebSocket$open_QMARK_$arity$1 = (function (this$){
var this$__$1 = this;
return this$__$1.isOpen(cljs.core.List.EMPTY);
}));
(goog.net.WebSocket.prototype.clojure$browser$net$IConnection$ = cljs.core.PROTOCOL_SENTINEL);
(goog.net.WebSocket.prototype.clojure$browser$net$IConnection$connect$arity$2 = (function (this$,url){
var this$__$1 = this;
return clojure.browser.net.connect.call(null,this$__$1,url,null);
}));
(goog.net.WebSocket.prototype.clojure$browser$net$IConnection$connect$arity$3 = (function (this$,url,protocol){
var this$__$1 = this;
return this$__$1.open(url,protocol);
}));
(goog.net.WebSocket.prototype.clojure$browser$net$IConnection$transmit$arity$2 = (function (this$,message){
var this$__$1 = this;
return this$__$1.send(message);
}));
(goog.net.WebSocket.prototype.clojure$browser$net$IConnection$close$arity$1 = (function (this$){
var this$__$1 = this;
return this$__$1.close(cljs.core.List.EMPTY);
}));
(goog.net.WebSocket.prototype.clojure$browser$event$IEventType$ = cljs.core.PROTOCOL_SENTINEL);
(goog.net.WebSocket.prototype.clojure$browser$event$IEventType$event_types$arity$1 = (function (this$){
var this$__$1 = this;
return cljs.core.into.call(null,cljs.core.PersistentArrayMap.EMPTY,cljs.core.map.call(null,(function (p__589){
var vec__590 = p__589;
var k = cljs.core.nth.call(null,vec__590,(0),null);
var v = cljs.core.nth.call(null,vec__590,(1),null);
return new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [cljs.core.keyword.call(null,k.toLowerCase()),v], null);
}),cljs.core.merge.call(null,cljs.core.js__GT_clj.call(null,goog.net.WebSocket.EventType))));
}));
clojure.browser.net.websocket_connection = (function clojure$browser$net$websocket_connection(var_args){
var G__594 = arguments.length;
switch (G__594) {
case 0:
return clojure.browser.net.websocket_connection.cljs$core$IFn$_invoke$arity$0();
break;
case 1:
return clojure.browser.net.websocket_connection.cljs$core$IFn$_invoke$arity$1((arguments[(0)]));
break;
case 2:
return clojure.browser.net.websocket_connection.cljs$core$IFn$_invoke$arity$2((arguments[(0)]),(arguments[(1)]));
break;
default:
throw (new Error(["Invalid arity: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(arguments.length)].join('')));
}
});
(clojure.browser.net.websocket_connection.cljs$core$IFn$_invoke$arity$0 = (function (){
return clojure.browser.net.websocket_connection.call(null,null,null);
}));
(clojure.browser.net.websocket_connection.cljs$core$IFn$_invoke$arity$1 = (function (auto_reconnect_QMARK_){
return clojure.browser.net.websocket_connection.call(null,auto_reconnect_QMARK_,null);
}));
(clojure.browser.net.websocket_connection.cljs$core$IFn$_invoke$arity$2 = (function (auto_reconnect_QMARK_,next_reconnect_fn){
return (new goog.net.WebSocket(auto_reconnect_QMARK_,next_reconnect_fn));
}));
(clojure.browser.net.websocket_connection.cljs$lang$maxFixedArity = 2);
//# sourceMappingURL=net.js.map

File diff suppressed because one or more lines are too long

View File

@ -1,278 +0,0 @@
;; Copyright (c) Rich Hickey. All rights reserved.
;; The use and distribution terms for this software are covered by the
;; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)
;; which can be found in the file epl-v10.html at the root of this distribution.
;; By using this software in any fashion, you are agreeing to be bound by
;; the terms of this license.
;; You must not remove this notice, or any other, from this software.
(ns ^{:doc "Receive - Eval - Print - Loop
Receive a block of JS (presumably generated by a ClojureScript compiler)
Evaluate it naively
Print the result of evaluation to a string
Send the resulting string back to the server Loop!"
:author "Bobby Calderwood and Alex Redington"}
clojure.browser.repl
(:require [goog.dom :as gdom]
[goog.object :as gobj]
[goog.array :as garray]
[goog.json :as json]
[goog.userAgent.product :as product]
[clojure.browser.net :as net]
[clojure.browser.event :as event]
;; repl-connection callback will receive goog.require('cljs.repl')
;; and monkey-patched require expects to be able to derive it
;; via goog.basePath, so this namespace should be compiled together
;; with clojure.browser.repl:
[cljs.repl]))
(goog-define HOST "localhost")
(goog-define PORT 9000)
(def ^:dynamic *repl* nil)
;; these two defs are top-level so we can use them for printing
(def xpc-connection (atom nil))
(def parent-connected? (atom false))
;; captures any printing that occurs *before* we actually have a connection
(def print-queue (array))
(defn flush-print-queue! [conn]
(doseq [str print-queue]
(net/transmit conn :print
(json/serialize
#js {"repl" *repl*
"str" str})))
(garray/clear print-queue))
(defn repl-print [data]
(.push print-queue (pr-str data))
(when @parent-connected?
(flush-print-queue! @xpc-connection)))
(set! *print-newline* true)
(set-print-fn! repl-print)
(set-print-err-fn! repl-print)
(defn get-ua-product []
(cond
product/SAFARI :safari
product/CHROME :chrome
product/FIREFOX :firefox
product/IE :ie))
(defn evaluate-javascript
"Process a single block of JavaScript received from the server"
[conn block]
(let [result
(try
{:status :success
:value (str (js* "eval(~{block})"))}
(catch :default e
{:status :exception
:value (cljs.repl/error->str e)}))]
(pr-str result)))
(defn send-result [connection url data]
(net/transmit connection url "POST" data nil 0))
(defn send-print
"Send data to be printed in the REPL. If there is an error, try again
up to 10 times."
([url data]
(send-print url data 0))
([url data n]
(let [conn (net/xhr-connection)]
(event/listen conn :error
(fn [_]
(if (< n 10)
(send-print url data (inc n))
(.log js/console (str "Could not send " data " after " n " attempts.")))))
(net/transmit conn url "POST" data nil 0))))
(def order (atom 0))
(defn wrap-message [repl t data]
(pr-str
{:repl repl
:type t
:content data
:order (swap! order inc)}))
(defn start-evaluator
"Start the REPL server connection process. This process runs inside the
embedded iframe."
[url]
(if-let [repl-connection (net/xpc-connection)]
(let [connection (net/xhr-connection)
repl-connected? (atom false)
try-handshake (fn try-handshake []
(when-not @repl-connected?
(net/transmit repl-connection :start-handshake nil)))]
(net/connect repl-connection try-handshake)
(net/register-service repl-connection
:ack-handshake
(fn [_]
(when-not @repl-connected?
(reset! repl-connected? true)
;; Now that we're connected to the parent, we can start talking to
;; the server.
(send-result connection
url (wrap-message nil :ready "ready")))))
(event/listen connection
:error
(fn [e]
(reset! repl-connected? false)
(net/transmit repl-connection :reconnect nil)
(js/setTimeout try-handshake 1000)))
(event/listen connection
:success
(fn [e]
(net/transmit
repl-connection
:evaluate-javascript
(.getResponseText (.-currentTarget e) ()))))
(net/register-service repl-connection
:send-result
(fn [json]
(let [obj (json/parse json)
repl (gobj/get obj "repl")
result (gobj/get obj "result")]
(send-result connection url
(wrap-message repl :result result)))))
(net/register-service repl-connection
:print
(fn [json]
(let [obj (json/parse json)
repl (gobj/get obj "repl")
str (gobj/get obj "str")]
(send-print url (wrap-message repl :print str))))))
(js/alert "No 'xpc' param provided to child iframe.")))
(def load-queue nil)
(defn bootstrap
"Reusable browser REPL bootstrapping. Patches the essential functions
in goog.base to support re-loading of namespaces after page load."
[]
;; Monkey-patch goog.provide if running under optimizations :none - David
(when-not js/COMPILED
(set! (.-require__ js/goog) js/goog.require)
;; suppress useless Google Closure error about duplicate provides
(set! (.-isProvided_ js/goog) (fn [name] false))
;; provide cljs.user
(goog/constructNamespace_ "cljs.user")
(set! (.-writeScriptTag__ js/goog)
(fn [src opt_sourceText]
;; the page is already loaded, we can no longer leverage document.write
;; instead construct script tag elements and append them to the body
;; of the page, to avoid parallel script loading enforce sequential
;; load with a simple load queue
(let [loaded (atom false)
onload (fn []
(when (and load-queue (false? @loaded))
(swap! loaded not)
(if (zero? (alength load-queue))
(set! load-queue nil)
(.apply js/goog.writeScriptTag__ nil (.shift load-queue)))))]
(.appendChild js/document.body
(as-> (.createElement js/document "script") script
(doto script
(gobj/set "type" "text/javascript")
(gobj/set "onload" onload)
(gobj/set "onreadystatechange" onload)) ;; IE
(if (nil? opt_sourceText)
(doto script (gobj/set "src" src))
(doto script (gdom/setTextContent opt_sourceText))))))))
;; queue or load
(set! (.-writeScriptTag_ js/goog)
(fn [src opt_sourceText]
(if load-queue
(.push load-queue #js [src opt_sourceText])
(do
(set! load-queue #js [])
(js/goog.writeScriptTag__ src opt_sourceText)))))
;; In the latest Closure library implementation, there is no goog.writeScriptTag_,
;; to monkey-patch. The behavior of interest is instead in goog.Dependency.prototype.load,
;; which first checks and uses CLOSURE_IMPORT_SCRIPT if defined. So we hook our desired
;; behavior here.
(when goog/debugLoader_
(set! js/CLOSURE_IMPORT_SCRIPT (.-writeScriptTag_ js/goog)))
;; we must reuse Closure library dev time dependency management, under namespace
;; reload scenarios we simply delete entries from the correct private locations
(set! (.-require js/goog)
(fn [src reload]
(when (= reload "reload-all")
(set! (.-cljsReloadAll_ js/goog) true))
(let [reload? (or reload (.-cljsReloadAll_ js/goog))]
(when reload?
(if (some? goog/debugLoader_)
(let [path (.getPathFromDeps_ goog/debugLoader_ src)]
(gobj/remove (.-written_ goog/debugLoader_) path)
(gobj/remove (.-written_ goog/debugLoader_)
(str js/goog.basePath path)))
(let [path (gobj/get js/goog.dependencies_.nameToPath src)]
(gobj/remove js/goog.dependencies_.visited path)
(gobj/remove js/goog.dependencies_.written path)
(gobj/remove js/goog.dependencies_.written
(str js/goog.basePath path)))))
(let [ret (.require__ js/goog src)]
(when (= reload "reload-all")
(set! (.-cljsReloadAll_ js/goog) false))
;; handle requires from Closure Library goog.modules
(if (js/goog.isInModuleLoader_)
(js/goog.module.getInternal_ src)
ret)))))))
(defn connect
"Connects to a REPL server from an HTML document. After the
connection is made, the REPL will evaluate forms in the context of
the document that called this function."
[repl-server-url]
(let [connected? (atom false)
repl-connection (net/xpc-connection {:peer_uri repl-server-url})]
(swap! xpc-connection (constantly repl-connection))
(net/register-service repl-connection
:start-handshake
(fn [_]
;; Child will keep retrying, but we only want
;; to ack once.
(when-not @connected?
(reset! connected? true)
(reset! parent-connected? true)
(net/transmit repl-connection :ack-handshake nil)
(flush-print-queue! repl-connection))))
(net/register-service repl-connection
:reconnect
(fn [_]
(reset! connected? false)
(reset! parent-connected? false)))
(net/register-service repl-connection
:evaluate-javascript
(fn [json]
(let [obj (json/parse json)
repl (gobj/get obj "repl")
form (gobj/get obj "form")]
(net/transmit
repl-connection
:send-result
(json/serialize
#js {"repl" repl
"result"
(binding [*repl* repl]
(evaluate-javascript repl-connection form))})))))
(net/connect repl-connection
(constantly nil)
(fn [iframe]
(set! (.-display (.-style iframe))
"none")))
(bootstrap)
repl-connection))

File diff suppressed because one or more lines are too long

View File

@ -1,409 +0,0 @@
// Compiled by ClojureScript 1.11.121 {:optimizations :none}
goog.provide('clojure.browser.repl');
goog.require('cljs.core');
goog.require('goog.dom');
goog.require('goog.json');
goog.require('goog.userAgent.product');
goog.require('clojure.browser.net');
goog.require('clojure.browser.event');
goog.require('cljs.repl');
goog.require('goog.object');
goog.scope(function(){
clojure.browser.repl.goog$module$goog$object = goog.module.get('goog.object');
});
goog.require('goog.array');
goog.scope(function(){
clojure.browser.repl.goog$module$goog$array = goog.module.get('goog.array');
});
/**
* @define {string}
*/
clojure.browser.repl.HOST = goog.define("clojure.browser.repl.HOST","localhost");
/**
* @define {number}
*/
clojure.browser.repl.PORT = goog.define("clojure.browser.repl.PORT",(9000));
clojure.browser.repl._STAR_repl_STAR_ = null;
clojure.browser.repl.xpc_connection = cljs.core.atom.call(null,null);
clojure.browser.repl.parent_connected_QMARK_ = cljs.core.atom.call(null,false);
clojure.browser.repl.print_queue = [];
clojure.browser.repl.flush_print_queue_BANG_ = (function clojure$browser$repl$flush_print_queue_BANG_(conn){
var seq__1626_1630 = cljs.core.seq.call(null,clojure.browser.repl.print_queue);
var chunk__1627_1631 = null;
var count__1628_1632 = (0);
var i__1629_1633 = (0);
while(true){
if((i__1629_1633 < count__1628_1632)){
var str_1634 = cljs.core._nth.call(null,chunk__1627_1631,i__1629_1633);
clojure.browser.net.transmit.call(null,conn,new cljs.core.Keyword(null,"print","print",1299562414),goog.json.serialize(({"repl": clojure.browser.repl._STAR_repl_STAR_, "str": str_1634})));
var G__1635 = seq__1626_1630;
var G__1636 = chunk__1627_1631;
var G__1637 = count__1628_1632;
var G__1638 = (i__1629_1633 + (1));
seq__1626_1630 = G__1635;
chunk__1627_1631 = G__1636;
count__1628_1632 = G__1637;
i__1629_1633 = G__1638;
continue;
} else {
var temp__5804__auto___1639 = cljs.core.seq.call(null,seq__1626_1630);
if(temp__5804__auto___1639){
var seq__1626_1640__$1 = temp__5804__auto___1639;
if(cljs.core.chunked_seq_QMARK_.call(null,seq__1626_1640__$1)){
var c__5521__auto___1641 = cljs.core.chunk_first.call(null,seq__1626_1640__$1);
var G__1642 = cljs.core.chunk_rest.call(null,seq__1626_1640__$1);
var G__1643 = c__5521__auto___1641;
var G__1644 = cljs.core.count.call(null,c__5521__auto___1641);
var G__1645 = (0);
seq__1626_1630 = G__1642;
chunk__1627_1631 = G__1643;
count__1628_1632 = G__1644;
i__1629_1633 = G__1645;
continue;
} else {
var str_1646 = cljs.core.first.call(null,seq__1626_1640__$1);
clojure.browser.net.transmit.call(null,conn,new cljs.core.Keyword(null,"print","print",1299562414),goog.json.serialize(({"repl": clojure.browser.repl._STAR_repl_STAR_, "str": str_1646})));
var G__1647 = cljs.core.next.call(null,seq__1626_1640__$1);
var G__1648 = null;
var G__1649 = (0);
var G__1650 = (0);
seq__1626_1630 = G__1647;
chunk__1627_1631 = G__1648;
count__1628_1632 = G__1649;
i__1629_1633 = G__1650;
continue;
}
} else {
}
}
break;
}
return clojure.browser.repl.goog$module$goog$array.clear.call(null,clojure.browser.repl.print_queue);
});
clojure.browser.repl.repl_print = (function clojure$browser$repl$repl_print(data){
clojure.browser.repl.print_queue.push(cljs.core.pr_str.call(null,data));
if(cljs.core.truth_(cljs.core.deref.call(null,clojure.browser.repl.parent_connected_QMARK_))){
return clojure.browser.repl.flush_print_queue_BANG_.call(null,cljs.core.deref.call(null,clojure.browser.repl.xpc_connection));
} else {
return null;
}
});
(cljs.core._STAR_print_newline_STAR_ = true);
cljs.core.set_print_fn_BANG_.call(null,clojure.browser.repl.repl_print);
cljs.core.set_print_err_fn_BANG_.call(null,clojure.browser.repl.repl_print);
clojure.browser.repl.get_ua_product = (function clojure$browser$repl$get_ua_product(){
if(goog.userAgent.product.SAFARI){
return new cljs.core.Keyword(null,"safari","safari",497115653);
} else {
if(goog.userAgent.product.CHROME){
return new cljs.core.Keyword(null,"chrome","chrome",1718738387);
} else {
if(goog.userAgent.product.FIREFOX){
return new cljs.core.Keyword(null,"firefox","firefox",1283768880);
} else {
if(goog.userAgent.product.IE){
return new cljs.core.Keyword(null,"ie","ie",2038473780);
} else {
return null;
}
}
}
}
});
/**
* Process a single block of JavaScript received from the server
*/
clojure.browser.repl.evaluate_javascript = (function clojure$browser$repl$evaluate_javascript(conn,block){
var result = (function (){try{return new cljs.core.PersistentArrayMap(null, 2, [new cljs.core.Keyword(null,"status","status",-1997798413),new cljs.core.Keyword(null,"success","success",1890645906),new cljs.core.Keyword(null,"value","value",305978217),cljs.core.str.cljs$core$IFn$_invoke$arity$1(eval(block))], null);
}catch (e1651){var e = e1651;
return new cljs.core.PersistentArrayMap(null, 2, [new cljs.core.Keyword(null,"status","status",-1997798413),new cljs.core.Keyword(null,"exception","exception",-335277064),new cljs.core.Keyword(null,"value","value",305978217),cljs.repl.error__GT_str.call(null,e)], null);
}})();
return cljs.core.pr_str.call(null,result);
});
clojure.browser.repl.send_result = (function clojure$browser$repl$send_result(connection,url,data){
return clojure.browser.net.transmit.call(null,connection,url,"POST",data,null,(0));
});
/**
* Send data to be printed in the REPL. If there is an error, try again
* up to 10 times.
*/
clojure.browser.repl.send_print = (function clojure$browser$repl$send_print(var_args){
var G__1653 = arguments.length;
switch (G__1653) {
case 2:
return clojure.browser.repl.send_print.cljs$core$IFn$_invoke$arity$2((arguments[(0)]),(arguments[(1)]));
break;
case 3:
return clojure.browser.repl.send_print.cljs$core$IFn$_invoke$arity$3((arguments[(0)]),(arguments[(1)]),(arguments[(2)]));
break;
default:
throw (new Error(["Invalid arity: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(arguments.length)].join('')));
}
});
(clojure.browser.repl.send_print.cljs$core$IFn$_invoke$arity$2 = (function (url,data){
return clojure.browser.repl.send_print.call(null,url,data,(0));
}));
(clojure.browser.repl.send_print.cljs$core$IFn$_invoke$arity$3 = (function (url,data,n){
var conn = clojure.browser.net.xhr_connection.call(null);
clojure.browser.event.listen.call(null,conn,new cljs.core.Keyword(null,"error","error",-978969032),(function (_){
if((n < (10))){
return clojure.browser.repl.send_print.call(null,url,data,(n + (1)));
} else {
return console.log(["Could not send ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(data)," after ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(n)," attempts."].join(''));
}
}));
return clojure.browser.net.transmit.call(null,conn,url,"POST",data,null,(0));
}));
(clojure.browser.repl.send_print.cljs$lang$maxFixedArity = 3);
clojure.browser.repl.order = cljs.core.atom.call(null,(0));
clojure.browser.repl.wrap_message = (function clojure$browser$repl$wrap_message(repl,t,data){
return cljs.core.pr_str.call(null,new cljs.core.PersistentArrayMap(null, 4, [new cljs.core.Keyword(null,"repl","repl",-35398667),repl,new cljs.core.Keyword(null,"type","type",1174270348),t,new cljs.core.Keyword(null,"content","content",15833224),data,new cljs.core.Keyword(null,"order","order",-1254677256),cljs.core.swap_BANG_.call(null,clojure.browser.repl.order,cljs.core.inc)], null));
});
/**
* Start the REPL server connection process. This process runs inside the
* embedded iframe.
*/
clojure.browser.repl.start_evaluator = (function clojure$browser$repl$start_evaluator(url){
var temp__5802__auto__ = clojure.browser.net.xpc_connection.call(null);
if(cljs.core.truth_(temp__5802__auto__)){
var repl_connection = temp__5802__auto__;
var connection = clojure.browser.net.xhr_connection.call(null);
var repl_connected_QMARK_ = cljs.core.atom.call(null,false);
var try_handshake = (function clojure$browser$repl$start_evaluator_$_try_handshake(){
if(cljs.core.truth_(cljs.core.deref.call(null,repl_connected_QMARK_))){
return null;
} else {
return clojure.browser.net.transmit.call(null,repl_connection,new cljs.core.Keyword(null,"start-handshake","start-handshake",359692894),null);
}
});
clojure.browser.net.connect.call(null,repl_connection,try_handshake);
clojure.browser.net.register_service.call(null,repl_connection,new cljs.core.Keyword(null,"ack-handshake","ack-handshake",1651340387),(function (_){
if(cljs.core.truth_(cljs.core.deref.call(null,repl_connected_QMARK_))){
return null;
} else {
cljs.core.reset_BANG_.call(null,repl_connected_QMARK_,true);
return clojure.browser.repl.send_result.call(null,connection,url,clojure.browser.repl.wrap_message.call(null,null,new cljs.core.Keyword(null,"ready","ready",1086465795),"ready"));
}
}));
clojure.browser.event.listen.call(null,connection,new cljs.core.Keyword(null,"error","error",-978969032),(function (e){
cljs.core.reset_BANG_.call(null,repl_connected_QMARK_,false);
clojure.browser.net.transmit.call(null,repl_connection,new cljs.core.Keyword(null,"reconnect","reconnect",596420411),null);
return setTimeout(try_handshake,(1000));
}));
clojure.browser.event.listen.call(null,connection,new cljs.core.Keyword(null,"success","success",1890645906),(function (e){
return clojure.browser.net.transmit.call(null,repl_connection,new cljs.core.Keyword(null,"evaluate-javascript","evaluate-javascript",-315749780),e.currentTarget.getResponseText(cljs.core.List.EMPTY));
}));
clojure.browser.net.register_service.call(null,repl_connection,new cljs.core.Keyword(null,"send-result","send-result",35388249),(function (json){
var obj = goog.json.parse(json);
var repl = clojure.browser.repl.goog$module$goog$object.get.call(null,obj,"repl");
var result = clojure.browser.repl.goog$module$goog$object.get.call(null,obj,"result");
return clojure.browser.repl.send_result.call(null,connection,url,clojure.browser.repl.wrap_message.call(null,repl,new cljs.core.Keyword(null,"result","result",1415092211),result));
}));
return clojure.browser.net.register_service.call(null,repl_connection,new cljs.core.Keyword(null,"print","print",1299562414),(function (json){
var obj = goog.json.parse(json);
var repl = clojure.browser.repl.goog$module$goog$object.get.call(null,obj,"repl");
var str = clojure.browser.repl.goog$module$goog$object.get.call(null,obj,"str");
return clojure.browser.repl.send_print.call(null,url,clojure.browser.repl.wrap_message.call(null,repl,new cljs.core.Keyword(null,"print","print",1299562414),str));
}));
} else {
return alert("No 'xpc' param provided to child iframe.");
}
});
clojure.browser.repl.load_queue = null;
/**
* Reusable browser REPL bootstrapping. Patches the essential functions
* in goog.base to support re-loading of namespaces after page load.
*/
clojure.browser.repl.bootstrap = (function clojure$browser$repl$bootstrap(){
if(cljs.core.truth_(COMPILED)){
return null;
} else {
(goog.require__ = goog.require);
(goog.isProvided_ = (function (name){
return false;
}));
goog.constructNamespace_("cljs.user");
(goog.writeScriptTag__ = (function (src,opt_sourceText){
var loaded = cljs.core.atom.call(null,false);
var onload = (function (){
if(cljs.core.truth_((function (){var and__4996__auto__ = clojure.browser.repl.load_queue;
if(cljs.core.truth_(and__4996__auto__)){
return cljs.core.deref.call(null,loaded) === false;
} else {
return and__4996__auto__;
}
})())){
cljs.core.swap_BANG_.call(null,loaded,cljs.core.not);
if((clojure.browser.repl.load_queue.length === (0))){
return (clojure.browser.repl.load_queue = null);
} else {
return goog.writeScriptTag__.apply(null,clojure.browser.repl.load_queue.shift());
}
} else {
return null;
}
});
return document.body.appendChild((function (){var script = document.createElement("script");
var script__$1 = (function (){var G__1655 = script;
clojure.browser.repl.goog$module$goog$object.set.call(null,G__1655,"type","text/javascript");
clojure.browser.repl.goog$module$goog$object.set.call(null,G__1655,"onload",onload);
clojure.browser.repl.goog$module$goog$object.set.call(null,G__1655,"onreadystatechange",onload);
return G__1655;
})();
if((opt_sourceText == null)){
var G__1656 = script__$1;
clojure.browser.repl.goog$module$goog$object.set.call(null,G__1656,"src",src);
return G__1656;
} else {
var G__1657 = script__$1;
goog.dom.setTextContent(G__1657,opt_sourceText);
return G__1657;
}
})());
}));
(goog.writeScriptTag_ = (function (src,opt_sourceText){
if(cljs.core.truth_(clojure.browser.repl.load_queue)){
return clojure.browser.repl.load_queue.push([src,opt_sourceText]);
} else {
(clojure.browser.repl.load_queue = []);
return goog.writeScriptTag__(src,opt_sourceText);
}
}));
if(cljs.core.truth_(goog.debugLoader_)){
(CLOSURE_IMPORT_SCRIPT = goog.writeScriptTag_);
} else {
}
return (goog.require = (function (src,reload){
if(cljs.core._EQ_.call(null,reload,"reload-all")){
(goog.cljsReloadAll_ = true);
} else {
}
var reload_QMARK_ = (function (){var or__4998__auto__ = reload;
if(cljs.core.truth_(or__4998__auto__)){
return or__4998__auto__;
} else {
return goog.cljsReloadAll_;
}
})();
if(cljs.core.truth_(reload_QMARK_)){
if((!((goog.debugLoader_ == null)))){
var path_1658 = goog.debugLoader_.getPathFromDeps_(src);
clojure.browser.repl.goog$module$goog$object.remove.call(null,goog.debugLoader_.written_,path_1658);
clojure.browser.repl.goog$module$goog$object.remove.call(null,goog.debugLoader_.written_,[cljs.core.str.cljs$core$IFn$_invoke$arity$1(goog.basePath),cljs.core.str.cljs$core$IFn$_invoke$arity$1(path_1658)].join(''));
} else {
var path_1659 = clojure.browser.repl.goog$module$goog$object.get.call(null,goog.dependencies_.nameToPath,src);
clojure.browser.repl.goog$module$goog$object.remove.call(null,goog.dependencies_.visited,path_1659);
clojure.browser.repl.goog$module$goog$object.remove.call(null,goog.dependencies_.written,path_1659);
clojure.browser.repl.goog$module$goog$object.remove.call(null,goog.dependencies_.written,[cljs.core.str.cljs$core$IFn$_invoke$arity$1(goog.basePath),cljs.core.str.cljs$core$IFn$_invoke$arity$1(path_1659)].join(''));
}
} else {
}
var ret = goog.require__(src);
if(cljs.core._EQ_.call(null,reload,"reload-all")){
(goog.cljsReloadAll_ = false);
} else {
}
if(cljs.core.truth_(goog.isInModuleLoader_())){
return goog.module.getInternal_(src);
} else {
return ret;
}
}));
}
});
/**
* Connects to a REPL server from an HTML document. After the
* connection is made, the REPL will evaluate forms in the context of
* the document that called this function.
*/
clojure.browser.repl.connect = (function clojure$browser$repl$connect(repl_server_url){
var connected_QMARK_ = cljs.core.atom.call(null,false);
var repl_connection = clojure.browser.net.xpc_connection.call(null,new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"peer_uri","peer_uri",910305997),repl_server_url], null));
cljs.core.swap_BANG_.call(null,clojure.browser.repl.xpc_connection,cljs.core.constantly.call(null,repl_connection));
clojure.browser.net.register_service.call(null,repl_connection,new cljs.core.Keyword(null,"start-handshake","start-handshake",359692894),(function (_){
if(cljs.core.truth_(cljs.core.deref.call(null,connected_QMARK_))){
return null;
} else {
cljs.core.reset_BANG_.call(null,connected_QMARK_,true);
cljs.core.reset_BANG_.call(null,clojure.browser.repl.parent_connected_QMARK_,true);
clojure.browser.net.transmit.call(null,repl_connection,new cljs.core.Keyword(null,"ack-handshake","ack-handshake",1651340387),null);
return clojure.browser.repl.flush_print_queue_BANG_.call(null,repl_connection);
}
}));
clojure.browser.net.register_service.call(null,repl_connection,new cljs.core.Keyword(null,"reconnect","reconnect",596420411),(function (_){
cljs.core.reset_BANG_.call(null,connected_QMARK_,false);
return cljs.core.reset_BANG_.call(null,clojure.browser.repl.parent_connected_QMARK_,false);
}));
clojure.browser.net.register_service.call(null,repl_connection,new cljs.core.Keyword(null,"evaluate-javascript","evaluate-javascript",-315749780),(function (json){
var obj = goog.json.parse(json);
var repl = clojure.browser.repl.goog$module$goog$object.get.call(null,obj,"repl");
var form = clojure.browser.repl.goog$module$goog$object.get.call(null,obj,"form");
return clojure.browser.net.transmit.call(null,repl_connection,new cljs.core.Keyword(null,"send-result","send-result",35388249),goog.json.serialize(({"repl": repl, "result": (function (){var _STAR_repl_STAR__orig_val__1660 = clojure.browser.repl._STAR_repl_STAR_;
var _STAR_repl_STAR__temp_val__1661 = repl;
(clojure.browser.repl._STAR_repl_STAR_ = _STAR_repl_STAR__temp_val__1661);
try{return clojure.browser.repl.evaluate_javascript.call(null,repl_connection,form);
}finally {(clojure.browser.repl._STAR_repl_STAR_ = _STAR_repl_STAR__orig_val__1660);
}})()})));
}));
clojure.browser.net.connect.call(null,repl_connection,cljs.core.constantly.call(null,null),(function (iframe){
return (iframe.style.display = "none");
}));
clojure.browser.repl.bootstrap.call(null);
return repl_connection;
});
//# sourceMappingURL=repl.js.map

File diff suppressed because one or more lines are too long

View File

@ -1,13 +0,0 @@
;; Copyright (c) Rich Hickey. All rights reserved.
;; The use and distribution terms for this software are covered by the
;; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)
;; which can be found in the file epl-v10.html at the root of this distribution.
;; By using this software in any fashion, you are agreeing to be bound by
;; the terms of this license.
;; You must not remove this notice, or any other, from this software.
(ns clojure.browser.repl.preload
(:require [clojure.browser.repl :as repl]))
(defonce conn
(repl/connect (str "http://" repl/HOST ":" repl/PORT "/repl")))

View File

@ -1 +0,0 @@
["^ ","~:rename-macros",["^ "],"~:renames",["^ "],"~:use-macros",["^ "],"~:excludes",["~#set",[]],"~:name","~$clojure.browser.repl.preload","~:imports",null,"~:requires",["^ ","~$repl","~$clojure.browser.repl","^:","^:"],"~:cljs.spec/speced-vars",[],"~:uses",null,"~:defs",["^ ","~$conn",["^ ","^5","~$clojure.browser.repl.preload/conn","~:file","/Users/scott/.cljs/.aot_cache/1.11.121/1632479/clojure/browser/repl/preload.cljs","~:line",12,"~:column",1,"~:end-line",12,"~:end-column",14,"~:meta",["^ ","^@","/Users/scott/.cljs/.aot_cache/1.11.121/1632479/clojure/browser/repl/preload.cljs","^A",12,"^B",10,"^C",12,"^D",14],"~:tag","~$goog.net.xpc/CrossPageChannel"]],"~:cljs.spec/registry-ref",[],"~:require-macros",null,"~:doc",null,"~:as-aliases",["^ "]]

View File

@ -1,10 +0,0 @@
// Compiled by ClojureScript 1.11.121 {:optimizations :none}
goog.provide('clojure.browser.repl.preload');
goog.require('cljs.core');
goog.require('clojure.browser.repl');
if((typeof clojure !== 'undefined') && (typeof clojure.browser !== 'undefined') && (typeof clojure.browser.repl !== 'undefined') && (typeof clojure.browser.repl.preload !== 'undefined') && (typeof clojure.browser.repl.preload.conn !== 'undefined')){
} else {
clojure.browser.repl.preload.conn = clojure.browser.repl.connect.call(null,["http://",cljs.core.str.cljs$core$IFn$_invoke$arity$1(clojure.browser.repl.HOST),":",cljs.core.str.cljs$core$IFn$_invoke$arity$1(clojure.browser.repl.PORT),"/repl"].join(''));
}
//# sourceMappingURL=preload.js.map

View File

@ -1 +0,0 @@
{"version":3,"file":"\/Users\/scott\/.cljs\/.aot_cache\/1.11.121\/1632479\/clojure\/browser\/repl\/preload.js","sources":["preload.cljs"],"lineCount":10,"mappings":";AAQA;;;AAGA,GAAA,QAAAA,oCAAAC,4CAAAC,iDAAAC,yDAAAC;AAAA;AAAA,AAAA,AAASC,oCACP,AAACC,uCAAa,CAAA,iFAAA,2EAAA,tGAAeC,2EAAcC","names":["js\/clojure","js\/clojure.browser","js\/clojure.browser.repl","js\/clojure.browser.repl.preload","js\/clojure.browser.repl.preload.conn","clojure.browser.repl.preload\/conn","clojure.browser.repl\/connect","clojure.browser.repl\/HOST","clojure.browser.repl\/PORT"]}

View File

@ -1,290 +0,0 @@
; Copyright (c) Rich Hickey. All rights reserved.
; The use and distribution terms for this software are covered by the
; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)
; which can be found in the file epl-v10.html at the root of this distribution.
; By using this software in any fashion, you are agreeing to be bound by
; the terms of this license.
; You must not remove this notice, or any other, from this software.
(ns clojure.string
(:refer-clojure :exclude [replace reverse])
(:require [goog.string :as gstring])
(:import [goog.string StringBuffer]))
(defn- seq-reverse
[coll]
(reduce conj () coll))
(def ^:private re-surrogate-pair
(js/RegExp. "([\\uD800-\\uDBFF])([\\uDC00-\\uDFFF])" "g"))
(defn ^string reverse
"Returns s with its characters reversed."
[s]
(-> (.replace s re-surrogate-pair "$2$1")
(.. (split "") (reverse) (join ""))))
(defn- replace-all
[s re replacement]
(let [r (js/RegExp. (.-source re)
(cond-> "g"
(.-ignoreCase re) (str "i")
(.-multiline re) (str "m")
(.-unicode re) (str "u")))]
(.replace s r replacement)))
(defn- replace-with
[f]
(fn [& args]
(let [matches (drop-last 2 args)]
(if (= (count matches) 1)
(f (first matches))
(f (vec matches))))))
(defn ^string replace
"Replaces all instance of match with replacement in s.
match/replacement can be:
string / string
pattern / (string or function of match).
See also replace-first.
The replacement is literal (i.e. none of its characters are treated
specially) for all cases above except pattern / string.
For pattern / string, $1, $2, etc. in the replacement string are
substituted with the string that matched the corresponding
parenthesized group in the pattern.
Example:
(clojure.string/replace \"Almost Pig Latin\" #\"\\b(\\w)(\\w+)\\b\" \"$2$1ay\")
-> \"lmostAay igPay atinLay\""
[s match replacement]
(cond
(string? match)
(.replace s (js/RegExp. (gstring/regExpEscape match) "g") replacement)
(instance? js/RegExp match)
(if (string? replacement)
(replace-all s match replacement)
(replace-all s match (replace-with replacement)))
:else (throw (str "Invalid match arg: " match))))
(defn ^string replace-first
"Replaces the first instance of match with replacement in s.
match/replacement can be:
string / string
pattern / (string or function of match).
See also replace.
The replacement is literal (i.e. none of its characters are treated
specially) for all cases above except pattern / string.
For pattern / string, $1, $2, etc. in the replacement string are
substituted with the string that matched the corresponding
parenthesized group in the pattern.
Example:
(clojure.string/replace-first \"swap first two words\"
#\"(\\w+)(\\s+)(\\w+)\" \"$3$2$1\")
-> \"first swap two words\""
[s match replacement]
(.replace s match replacement))
(defn join
"Returns a string of all elements in coll, as returned by (seq coll),
separated by an optional separator."
([coll]
(loop [sb (StringBuffer.) coll (seq coll)]
(if-not (nil? coll)
(recur (. sb (append (str (first coll)))) (next coll))
^string (.toString sb))))
([separator coll]
(loop [sb (StringBuffer.) coll (seq coll)]
(if-not (nil? coll)
(do
(. sb (append (str (first coll))))
(let [coll (next coll)]
(when-not (nil? coll)
(. sb (append separator)))
(recur sb coll)))
^string (.toString sb)))))
(defn ^string upper-case
"Converts string to all upper-case."
[s]
(.toUpperCase s))
(defn ^string lower-case
"Converts string to all lower-case."
[s]
(.toLowerCase s))
(defn ^string capitalize
"Converts first character of the string to upper-case, all other
characters to lower-case."
[s]
(gstring/capitalize s))
;; The JavaScript split function takes a limit argument but the return
;; value is not the same as the Java split function.
;;
;; Java: (.split "a-b-c" #"-" 2) => ["a" "b-c"]
;; JavaScript: (.split "a-b-c" #"-" 2) => ["a" "b"]
;;
;; For consistency, the three arg version has been implemented to
;; mimic Java's behavior.
(defn- pop-last-while-empty
[v]
(loop [v v]
(if (identical? "" (peek v))
(recur (pop v))
v)))
(defn- discard-trailing-if-needed
[limit v]
(if (and (== 0 limit) (< 1 (count v)))
(pop-last-while-empty v)
v))
(defn- split-with-empty-regex
[s limit]
(if (or (<= limit 0) (>= limit (+ 2 (count s))))
(conj (vec (cons "" (map str (seq s)))) "")
(condp == limit
1 (vector s)
2 (vector "" s)
(let [c (- limit 2)]
(conj (vec (cons "" (subvec (vec (map str (seq s))) 0 c))) (subs s c))))))
(defn split
"Splits string on a regular expression. Optional argument limit is
the maximum number of parts. Not lazy. Returns vector of the parts.
Trailing empty strings are not returned - pass limit of -1 to return all."
([s re]
(split s re 0))
([s re limit]
(discard-trailing-if-needed limit
(if (identical? "/(?:)/" (str re))
(split-with-empty-regex s limit)
(if (< limit 1)
(vec (.split (str s) re))
(loop [s s
limit limit
parts []]
(if (== 1 limit)
(conj parts s)
(let [m (re-find re s)]
(if-not (nil? m)
(let [index (.indexOf s m)]
(recur (.substring s (+ index (count m)))
(dec limit)
(conj parts (.substring s 0 index))))
(conj parts s))))))))))
(defn split-lines
"Splits s on \\n or \\r\\n. Trailing empty lines are not returned."
[s]
(split s #"\n|\r\n"))
(defn ^string trim
"Removes whitespace from both ends of string."
[s]
(gstring/trim s))
(defn ^string triml
"Removes whitespace from the left side of string."
[s]
(gstring/trimLeft s))
(defn ^string trimr
"Removes whitespace from the right side of string."
[s]
(gstring/trimRight s))
(defn ^string trim-newline
"Removes all trailing newline \\n or return \\r characters from
string. Similar to Perl's chomp."
[s]
(loop [index (.-length s)]
(if (zero? index)
""
(let [ch (get s (dec index))]
(if (or (identical? \newline ch)
(identical? \return ch))
(recur (dec index))
(.substring s 0 index))))))
(defn ^boolean blank?
"True if s is nil, empty, or contains only whitespace."
[s]
(gstring/isEmptyOrWhitespace (gstring/makeSafe s)))
(defn ^string escape
"Return a new string, using cmap to escape each character ch
from s as follows:
If (cmap ch) is nil, append ch to the new string.
If (cmap ch) is non-nil, append (str (cmap ch)) instead."
[s cmap]
(let [buffer (StringBuffer.)
length (.-length s)]
(loop [index 0]
(if (== length index)
(. buffer (toString))
(let [ch (.charAt s index)
replacement (cmap ch)]
(if-not (nil? replacement)
(.append buffer (str replacement))
(.append buffer ch))
(recur (inc index)))))))
(defn index-of
"Return index of value (string or char) in s, optionally searching
forward from from-index or nil if not found."
([s value]
(let [result (.indexOf s value)]
(if (neg? result)
nil
result)))
([s value from-index]
(let [result (.indexOf s value from-index)]
(if (neg? result)
nil
result))))
(defn last-index-of
"Return last index of value (string or char) in s, optionally
searching backward from from-index or nil if not found."
([s value]
(let [result (.lastIndexOf s value)]
(if (neg? result)
nil
result)))
([s value from-index]
(let [result (.lastIndexOf s value from-index)]
(if (neg? result)
nil
result))))
(defn ^boolean starts-with?
"True if s starts with substr."
[s substr]
(gstring/startsWith s substr))
(defn ^boolean ends-with?
"True if s ends with substr."
[s substr]
(gstring/endsWith s substr))
(defn ^boolean includes?
"True if s includes substr."
[s substr]
(gstring/contains s substr))

File diff suppressed because one or more lines are too long

View File

@ -1,478 +0,0 @@
// Compiled by ClojureScript 1.11.121 {:optimizations :none}
goog.provide('clojure.string');
goog.require('cljs.core');
goog.require('goog.string');
goog.require('goog.string.StringBuffer');
clojure.string.seq_reverse = (function clojure$string$seq_reverse(coll){
return cljs.core.reduce.call(null,cljs.core.conj,cljs.core.List.EMPTY,coll);
});
clojure.string.re_surrogate_pair = (new RegExp("([\\uD800-\\uDBFF])([\\uDC00-\\uDFFF])","g"));
/**
* Returns s with its characters reversed.
*/
clojure.string.reverse = (function clojure$string$reverse(s){
return s.replace(clojure.string.re_surrogate_pair,"$2$1").split("").reverse().join("");
});
clojure.string.replace_all = (function clojure$string$replace_all(s,re,replacement){
var r = (new RegExp(re.source,(function (){var G__598 = "g";
var G__598__$1 = (cljs.core.truth_(re.ignoreCase)?[G__598,"i"].join(''):G__598);
var G__598__$2 = (cljs.core.truth_(re.multiline)?[G__598__$1,"m"].join(''):G__598__$1);
if(cljs.core.truth_(re.unicode)){
return [G__598__$2,"u"].join('');
} else {
return G__598__$2;
}
})()));
return s.replace(r,replacement);
});
clojure.string.replace_with = (function clojure$string$replace_with(f){
return (function() {
var G__599__delegate = function (args){
var matches = cljs.core.drop_last.call(null,(2),args);
if(cljs.core._EQ_.call(null,cljs.core.count.call(null,matches),(1))){
return f.call(null,cljs.core.first.call(null,matches));
} else {
return f.call(null,cljs.core.vec.call(null,matches));
}
};
var G__599 = function (var_args){
var args = null;
if (arguments.length > 0) {
var G__600__i = 0, G__600__a = new Array(arguments.length - 0);
while (G__600__i < G__600__a.length) {G__600__a[G__600__i] = arguments[G__600__i + 0]; ++G__600__i;}
args = new cljs.core.IndexedSeq(G__600__a,0,null);
}
return G__599__delegate.call(this,args);};
G__599.cljs$lang$maxFixedArity = 0;
G__599.cljs$lang$applyTo = (function (arglist__601){
var args = cljs.core.seq(arglist__601);
return G__599__delegate(args);
});
G__599.cljs$core$IFn$_invoke$arity$variadic = G__599__delegate;
return G__599;
})()
;
});
/**
* Replaces all instance of match with replacement in s.
*
* match/replacement can be:
*
* string / string
* pattern / (string or function of match).
*
* See also replace-first.
*
* The replacement is literal (i.e. none of its characters are treated
* specially) for all cases above except pattern / string.
*
* For pattern / string, $1, $2, etc. in the replacement string are
* substituted with the string that matched the corresponding
* parenthesized group in the pattern.
*
* Example:
* (clojure.string/replace "Almost Pig Latin" #"\b(\w)(\w+)\b" "$2$1ay")
* -> "lmostAay igPay atinLay"
*/
clojure.string.replace = (function clojure$string$replace(s,match,replacement){
if(typeof match === 'string'){
return s.replace((new RegExp(goog.string.regExpEscape(match),"g")),replacement);
} else {
if((match instanceof RegExp)){
if(typeof replacement === 'string'){
return clojure.string.replace_all.call(null,s,match,replacement);
} else {
return clojure.string.replace_all.call(null,s,match,clojure.string.replace_with.call(null,replacement));
}
} else {
throw ["Invalid match arg: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(match)].join('');
}
}
});
/**
* Replaces the first instance of match with replacement in s.
*
* match/replacement can be:
*
* string / string
* pattern / (string or function of match).
*
* See also replace.
*
* The replacement is literal (i.e. none of its characters are treated
* specially) for all cases above except pattern / string.
*
* For pattern / string, $1, $2, etc. in the replacement string are
* substituted with the string that matched the corresponding
* parenthesized group in the pattern.
*
* Example:
* (clojure.string/replace-first "swap first two words"
* #"(\w+)(\s+)(\w+)" "$3$2$1")
* -> "first swap two words"
*/
clojure.string.replace_first = (function clojure$string$replace_first(s,match,replacement){
return s.replace(match,replacement);
});
/**
* Returns a string of all elements in coll, as returned by (seq coll),
* separated by an optional separator.
*/
clojure.string.join = (function clojure$string$join(var_args){
var G__603 = arguments.length;
switch (G__603) {
case 1:
return clojure.string.join.cljs$core$IFn$_invoke$arity$1((arguments[(0)]));
break;
case 2:
return clojure.string.join.cljs$core$IFn$_invoke$arity$2((arguments[(0)]),(arguments[(1)]));
break;
default:
throw (new Error(["Invalid arity: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(arguments.length)].join('')));
}
});
(clojure.string.join.cljs$core$IFn$_invoke$arity$1 = (function (coll){
var sb = (new goog.string.StringBuffer());
var coll__$1 = cljs.core.seq.call(null,coll);
while(true){
if((!((coll__$1 == null)))){
var G__605 = sb.append(cljs.core.str.cljs$core$IFn$_invoke$arity$1(cljs.core.first.call(null,coll__$1)));
var G__606 = cljs.core.next.call(null,coll__$1);
sb = G__605;
coll__$1 = G__606;
continue;
} else {
return sb.toString();
}
break;
}
}));
(clojure.string.join.cljs$core$IFn$_invoke$arity$2 = (function (separator,coll){
var sb = (new goog.string.StringBuffer());
var coll__$1 = cljs.core.seq.call(null,coll);
while(true){
if((!((coll__$1 == null)))){
sb.append(cljs.core.str.cljs$core$IFn$_invoke$arity$1(cljs.core.first.call(null,coll__$1)));
var coll__$2 = cljs.core.next.call(null,coll__$1);
if((coll__$2 == null)){
} else {
sb.append(separator);
}
var G__607 = sb;
var G__608 = coll__$2;
sb = G__607;
coll__$1 = G__608;
continue;
} else {
return sb.toString();
}
break;
}
}));
(clojure.string.join.cljs$lang$maxFixedArity = 2);
/**
* Converts string to all upper-case.
*/
clojure.string.upper_case = (function clojure$string$upper_case(s){
return s.toUpperCase();
});
/**
* Converts string to all lower-case.
*/
clojure.string.lower_case = (function clojure$string$lower_case(s){
return s.toLowerCase();
});
/**
* Converts first character of the string to upper-case, all other
* characters to lower-case.
*/
clojure.string.capitalize = (function clojure$string$capitalize(s){
return goog.string.capitalize(s);
});
clojure.string.pop_last_while_empty = (function clojure$string$pop_last_while_empty(v){
var v__$1 = v;
while(true){
if(("" === cljs.core.peek.call(null,v__$1))){
var G__609 = cljs.core.pop.call(null,v__$1);
v__$1 = G__609;
continue;
} else {
return v__$1;
}
break;
}
});
clojure.string.discard_trailing_if_needed = (function clojure$string$discard_trailing_if_needed(limit,v){
if(((((0) === limit)) && (((1) < cljs.core.count.call(null,v))))){
return clojure.string.pop_last_while_empty.call(null,v);
} else {
return v;
}
});
clojure.string.split_with_empty_regex = (function clojure$string$split_with_empty_regex(s,limit){
if((((limit <= (0))) || ((limit >= ((2) + cljs.core.count.call(null,s)))))){
return cljs.core.conj.call(null,cljs.core.vec.call(null,cljs.core.cons.call(null,"",cljs.core.map.call(null,cljs.core.str,cljs.core.seq.call(null,s)))),"");
} else {
var pred__610 = cljs.core._EQ__EQ_;
var expr__611 = limit;
if(cljs.core.truth_(pred__610.call(null,(1),expr__611))){
return (new cljs.core.PersistentVector(null,1,(5),cljs.core.PersistentVector.EMPTY_NODE,[s],null));
} else {
if(cljs.core.truth_(pred__610.call(null,(2),expr__611))){
return (new cljs.core.PersistentVector(null,2,(5),cljs.core.PersistentVector.EMPTY_NODE,["",s],null));
} else {
var c = (limit - (2));
return cljs.core.conj.call(null,cljs.core.vec.call(null,cljs.core.cons.call(null,"",cljs.core.subvec.call(null,cljs.core.vec.call(null,cljs.core.map.call(null,cljs.core.str,cljs.core.seq.call(null,s))),(0),c))),cljs.core.subs.call(null,s,c));
}
}
}
});
/**
* Splits string on a regular expression. Optional argument limit is
* the maximum number of parts. Not lazy. Returns vector of the parts.
* Trailing empty strings are not returned - pass limit of -1 to return all.
*/
clojure.string.split = (function clojure$string$split(var_args){
var G__614 = arguments.length;
switch (G__614) {
case 2:
return clojure.string.split.cljs$core$IFn$_invoke$arity$2((arguments[(0)]),(arguments[(1)]));
break;
case 3:
return clojure.string.split.cljs$core$IFn$_invoke$arity$3((arguments[(0)]),(arguments[(1)]),(arguments[(2)]));
break;
default:
throw (new Error(["Invalid arity: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(arguments.length)].join('')));
}
});
(clojure.string.split.cljs$core$IFn$_invoke$arity$2 = (function (s,re){
return clojure.string.split.call(null,s,re,(0));
}));
(clojure.string.split.cljs$core$IFn$_invoke$arity$3 = (function (s,re,limit){
return clojure.string.discard_trailing_if_needed.call(null,limit,((("/(?:)/" === cljs.core.str.cljs$core$IFn$_invoke$arity$1(re)))?clojure.string.split_with_empty_regex.call(null,s,limit):(((limit < (1)))?cljs.core.vec.call(null,cljs.core.str.cljs$core$IFn$_invoke$arity$1(s).split(re)):(function (){var s__$1 = s;
var limit__$1 = limit;
var parts = cljs.core.PersistentVector.EMPTY;
while(true){
if(((1) === limit__$1)){
return cljs.core.conj.call(null,parts,s__$1);
} else {
var m = cljs.core.re_find.call(null,re,s__$1);
if((!((m == null)))){
var index = s__$1.indexOf(m);
var G__616 = s__$1.substring((index + cljs.core.count.call(null,m)));
var G__617 = (limit__$1 - (1));
var G__618 = cljs.core.conj.call(null,parts,s__$1.substring((0),index));
s__$1 = G__616;
limit__$1 = G__617;
parts = G__618;
continue;
} else {
return cljs.core.conj.call(null,parts,s__$1);
}
}
break;
}
})())));
}));
(clojure.string.split.cljs$lang$maxFixedArity = 3);
/**
* Splits s on \n or \r\n. Trailing empty lines are not returned.
*/
clojure.string.split_lines = (function clojure$string$split_lines(s){
return clojure.string.split.call(null,s,/\n|\r\n/);
});
/**
* Removes whitespace from both ends of string.
*/
clojure.string.trim = (function clojure$string$trim(s){
return goog.string.trim(s);
});
/**
* Removes whitespace from the left side of string.
*/
clojure.string.triml = (function clojure$string$triml(s){
return goog.string.trimLeft(s);
});
/**
* Removes whitespace from the right side of string.
*/
clojure.string.trimr = (function clojure$string$trimr(s){
return goog.string.trimRight(s);
});
/**
* Removes all trailing newline \n or return \r characters from
* string. Similar to Perl's chomp.
*/
clojure.string.trim_newline = (function clojure$string$trim_newline(s){
var index = s.length;
while(true){
if((index === (0))){
return "";
} else {
var ch = cljs.core.get.call(null,s,(index - (1)));
if(((("\n" === ch)) || (("\r" === ch)))){
var G__619 = (index - (1));
index = G__619;
continue;
} else {
return s.substring((0),index);
}
}
break;
}
});
/**
* True if s is nil, empty, or contains only whitespace.
*/
clojure.string.blank_QMARK_ = (function clojure$string$blank_QMARK_(s){
return goog.string.isEmptyOrWhitespace(goog.string.makeSafe(s));
});
/**
* Return a new string, using cmap to escape each character ch
* from s as follows:
*
* If (cmap ch) is nil, append ch to the new string.
* If (cmap ch) is non-nil, append (str (cmap ch)) instead.
*/
clojure.string.escape = (function clojure$string$escape(s,cmap){
var buffer = (new goog.string.StringBuffer());
var length = s.length;
var index = (0);
while(true){
if((length === index)){
return buffer.toString();
} else {
var ch = s.charAt(index);
var replacement = cmap.call(null,ch);
if((!((replacement == null)))){
buffer.append(cljs.core.str.cljs$core$IFn$_invoke$arity$1(replacement));
} else {
buffer.append(ch);
}
var G__620 = (index + (1));
index = G__620;
continue;
}
break;
}
});
/**
* Return index of value (string or char) in s, optionally searching
* forward from from-index or nil if not found.
*/
clojure.string.index_of = (function clojure$string$index_of(var_args){
var G__622 = arguments.length;
switch (G__622) {
case 2:
return clojure.string.index_of.cljs$core$IFn$_invoke$arity$2((arguments[(0)]),(arguments[(1)]));
break;
case 3:
return clojure.string.index_of.cljs$core$IFn$_invoke$arity$3((arguments[(0)]),(arguments[(1)]),(arguments[(2)]));
break;
default:
throw (new Error(["Invalid arity: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(arguments.length)].join('')));
}
});
(clojure.string.index_of.cljs$core$IFn$_invoke$arity$2 = (function (s,value){
var result = s.indexOf(value);
if((result < (0))){
return null;
} else {
return result;
}
}));
(clojure.string.index_of.cljs$core$IFn$_invoke$arity$3 = (function (s,value,from_index){
var result = s.indexOf(value,from_index);
if((result < (0))){
return null;
} else {
return result;
}
}));
(clojure.string.index_of.cljs$lang$maxFixedArity = 3);
/**
* Return last index of value (string or char) in s, optionally
* searching backward from from-index or nil if not found.
*/
clojure.string.last_index_of = (function clojure$string$last_index_of(var_args){
var G__625 = arguments.length;
switch (G__625) {
case 2:
return clojure.string.last_index_of.cljs$core$IFn$_invoke$arity$2((arguments[(0)]),(arguments[(1)]));
break;
case 3:
return clojure.string.last_index_of.cljs$core$IFn$_invoke$arity$3((arguments[(0)]),(arguments[(1)]),(arguments[(2)]));
break;
default:
throw (new Error(["Invalid arity: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(arguments.length)].join('')));
}
});
(clojure.string.last_index_of.cljs$core$IFn$_invoke$arity$2 = (function (s,value){
var result = s.lastIndexOf(value);
if((result < (0))){
return null;
} else {
return result;
}
}));
(clojure.string.last_index_of.cljs$core$IFn$_invoke$arity$3 = (function (s,value,from_index){
var result = s.lastIndexOf(value,from_index);
if((result < (0))){
return null;
} else {
return result;
}
}));
(clojure.string.last_index_of.cljs$lang$maxFixedArity = 3);
/**
* True if s starts with substr.
*/
clojure.string.starts_with_QMARK_ = (function clojure$string$starts_with_QMARK_(s,substr){
return goog.string.startsWith(s,substr);
});
/**
* True if s ends with substr.
*/
clojure.string.ends_with_QMARK_ = (function clojure$string$ends_with_QMARK_(s,substr){
return goog.string.endsWith(s,substr);
});
/**
* True if s includes substr.
*/
clojure.string.includes_QMARK_ = (function clojure$string$includes_QMARK_(s,substr){
return goog.string.contains(s,substr);
});
//# sourceMappingURL=string.js.map

File diff suppressed because one or more lines are too long

View File

@ -1,98 +0,0 @@
; Copyright (c) Rich Hickey. All rights reserved.
; The use and distribution terms for this software are covered by the
; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)
; which can be found in the file epl-v10.html at the root of this distribution.
; By using this software in any fashion, you are agreeing to be bound by
; the terms of this license.
; You must not remove this notice, or any other, from this software.
;;; walk.cljs - generic tree walker with replacement
;; by Stuart Sierra
;; Jul5 17, 2011
;; CHANGE LOG:
;;
;; * July 17, 2011: Port to ClojureScript
;;
;; * December 15, 2008: replaced 'walk' with 'prewalk' & 'postwalk'
;;
;; * December 9, 2008: first version
(ns
^{:author "Stuart Sierra",
:doc "This file defines a generic tree walker for Clojure data
structures. It takes any data structure (list, vector, map, set,
seq), calls a function on every element, and uses the return value
of the function in place of the original. This makes it fairly
easy to write recursive search-and-replace functions, as shown in
the examples.
Note: \"walk\" supports all Clojure data structures EXCEPT maps
created with sorted-map-by. There is no (obvious) way to retrieve
the sorting function."}
clojure.walk)
(defn walk
"Traverses form, an arbitrary data structure. inner and outer are
functions. Applies inner to each element of form, building up a
data structure of the same type, then applies outer to the result.
Recognizes all Clojure data structures. Consumes seqs as with doall."
{:added "1.1"}
[inner outer form]
(cond
(list? form) (outer (apply list (map inner form)))
(map-entry? form)
(outer (MapEntry. (inner (key form)) (inner (val form)) nil))
(seq? form) (outer (doall (map inner form)))
(record? form) (outer (reduce (fn [r x] (conj r (inner x))) form form))
(coll? form) (outer (into (empty form) (map inner form)))
:else (outer form)))
(defn postwalk
"Performs a depth-first, post-order traversal of form. Calls f on
each sub-form, uses f's return value in place of the original.
Recognizes all Clojure data structures. Consumes seqs as with doall."
{:added "1.1"}
[f form]
(walk (partial postwalk f) f form))
(defn prewalk
"Like postwalk, but does pre-order traversal."
{:added "1.1"}
[f form]
(walk (partial prewalk f) identity (f form)))
(defn keywordize-keys
"Recursively transforms all map keys from strings to keywords."
{:added "1.1"}
[m]
(let [f (fn [[k v]] (if (string? k) [(keyword k) v] [k v]))]
;; only apply to maps
(postwalk (fn [x] (if (map? x) (into {} (map f x)) x)) m)))
(defn stringify-keys
"Recursively transforms all map keys from keywords to strings."
{:added "1.1"}
[m]
(let [f (fn [[k v]] (if (keyword? k) [(name k) v] [k v]))]
;; only apply to maps
(postwalk (fn [x] (if (map? x) (into {} (map f x)) x)) m)))
(defn prewalk-replace
"Recursively transforms form by replacing keys in smap with their
values. Like clojure/replace but works on any data structure. Does
replacement at the root of the tree first."
{:added "1.1"}
[smap form]
(prewalk (fn [x] (if (contains? smap x) (smap x) x)) form))
(defn postwalk-replace
"Recursively transforms form by replacing keys in smap with their
values. Like clojure/replace but works on any data structure. Does
replacement at the leaves of the tree first."
{:added "1.1"}
[smap form]
(postwalk (fn [x] (if (contains? smap x) (smap x) x)) form))

File diff suppressed because one or more lines are too long

View File

@ -1,123 +0,0 @@
// Compiled by ClojureScript 1.11.121 {:optimizations :none}
goog.provide('clojure.walk');
goog.require('cljs.core');
/**
* Traverses form, an arbitrary data structure. inner and outer are
* functions. Applies inner to each element of form, building up a
* data structure of the same type, then applies outer to the result.
* Recognizes all Clojure data structures. Consumes seqs as with doall.
*/
clojure.walk.walk = (function clojure$walk$walk(inner,outer,form){
if(cljs.core.list_QMARK_.call(null,form)){
return outer.call(null,cljs.core.apply.call(null,cljs.core.list,cljs.core.map.call(null,inner,form)));
} else {
if(cljs.core.map_entry_QMARK_.call(null,form)){
return outer.call(null,(new cljs.core.MapEntry(inner.call(null,cljs.core.key.call(null,form)),inner.call(null,cljs.core.val.call(null,form)),null)));
} else {
if(cljs.core.seq_QMARK_.call(null,form)){
return outer.call(null,cljs.core.doall.call(null,cljs.core.map.call(null,inner,form)));
} else {
if(cljs.core.record_QMARK_.call(null,form)){
return outer.call(null,cljs.core.reduce.call(null,(function (r,x){
return cljs.core.conj.call(null,r,inner.call(null,x));
}),form,form));
} else {
if(cljs.core.coll_QMARK_.call(null,form)){
return outer.call(null,cljs.core.into.call(null,cljs.core.empty.call(null,form),cljs.core.map.call(null,inner,form)));
} else {
return outer.call(null,form);
}
}
}
}
}
});
/**
* Performs a depth-first, post-order traversal of form. Calls f on
* each sub-form, uses f's return value in place of the original.
* Recognizes all Clojure data structures. Consumes seqs as with doall.
*/
clojure.walk.postwalk = (function clojure$walk$postwalk(f,form){
return clojure.walk.walk.call(null,cljs.core.partial.call(null,clojure.walk.postwalk,f),f,form);
});
/**
* Like postwalk, but does pre-order traversal.
*/
clojure.walk.prewalk = (function clojure$walk$prewalk(f,form){
return clojure.walk.walk.call(null,cljs.core.partial.call(null,clojure.walk.prewalk,f),cljs.core.identity,f.call(null,form));
});
/**
* Recursively transforms all map keys from strings to keywords.
*/
clojure.walk.keywordize_keys = (function clojure$walk$keywordize_keys(m){
var f = (function (p__629){
var vec__630 = p__629;
var k = cljs.core.nth.call(null,vec__630,(0),null);
var v = cljs.core.nth.call(null,vec__630,(1),null);
if(typeof k === 'string'){
return new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [cljs.core.keyword.call(null,k),v], null);
} else {
return new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [k,v], null);
}
});
return clojure.walk.postwalk.call(null,(function (x){
if(cljs.core.map_QMARK_.call(null,x)){
return cljs.core.into.call(null,cljs.core.PersistentArrayMap.EMPTY,cljs.core.map.call(null,f,x));
} else {
return x;
}
}),m);
});
/**
* Recursively transforms all map keys from keywords to strings.
*/
clojure.walk.stringify_keys = (function clojure$walk$stringify_keys(m){
var f = (function (p__633){
var vec__634 = p__633;
var k = cljs.core.nth.call(null,vec__634,(0),null);
var v = cljs.core.nth.call(null,vec__634,(1),null);
if((k instanceof cljs.core.Keyword)){
return new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [cljs.core.name.call(null,k),v], null);
} else {
return new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [k,v], null);
}
});
return clojure.walk.postwalk.call(null,(function (x){
if(cljs.core.map_QMARK_.call(null,x)){
return cljs.core.into.call(null,cljs.core.PersistentArrayMap.EMPTY,cljs.core.map.call(null,f,x));
} else {
return x;
}
}),m);
});
/**
* Recursively transforms form by replacing keys in smap with their
* values. Like clojure/replace but works on any data structure. Does
* replacement at the root of the tree first.
*/
clojure.walk.prewalk_replace = (function clojure$walk$prewalk_replace(smap,form){
return clojure.walk.prewalk.call(null,(function (x){
if(cljs.core.contains_QMARK_.call(null,smap,x)){
return smap.call(null,x);
} else {
return x;
}
}),form);
});
/**
* Recursively transforms form by replacing keys in smap with their
* values. Like clojure/replace but works on any data structure. Does
* replacement at the leaves of the tree first.
*/
clojure.walk.postwalk_replace = (function clojure$walk$postwalk_replace(smap,form){
return clojure.walk.postwalk.call(null,(function (x){
if(cljs.core.contains_QMARK_.call(null,smap,x)){
return smap.call(null,x);
} else {
return x;
}
}),form);
});
//# sourceMappingURL=walk.js.map

View File

@ -1 +0,0 @@
{"version":3,"file":"\/Users\/scott\/.cljs\/.aot_cache\/1.11.121\/50C4598\/clojure\/walk.js","sources":["walk.cljs"],"lineCount":123,"mappings":";AAsBA;;AAcA;;;;;;oBAAA,pBAAMA,gDAOHC,MAAMC,MAAMC;AAPf,AAQE,GACE,AAACC,gCAAMD;AAAW,OAACD,gBAAM,AAACG,0BAAMC,eAAK,AAACC,wBAAIN,MAAME;;AADlD,GAEE,AAACK,qCAAWL;AACZ,OAACD,gBAAM,KAAAO,iHAAA,9FAAW,AAACR,gBAAM,AAACS,wBAAIP,OAAO,AAACF,gBAAM,AAACU,wBAAIR;;AAHnD,GAIE,AAACS,+BAAKT;AAAY,OAACD,gBAAM,AAACW,0BAAM,AAACN,wBAAIN,MAAME;;AAJ7C,GAKE,AAACW,kCAAQX;AAAS,OAACD,gBAAM,AAACa,2BAAO,WAAKC,EAAEC;AAAP,AAAU,OAACC,yBAAKF,EAAE,AAACf,gBAAMgB;GAAKd,KAAKA;;AALtE,GAME,AAACgB,gCAAMhB;AAAW,OAACD,gBAAM,AAACkB,yBAAK,AAACC,0BAAMlB,MAAM,AAACI,wBAAIN,MAAME;;AANzD,AAOoB,OAACD,gBAAMC;;;;;;;;AAE7B;;;;;wBAAA,xBAAMmB,wDAKHC,EAAEpB;AALL,AAME,OAACH,4BAAK,AAACwB,4BAAQF,sBAASC,GAAGA,EAAEpB;;AAE\/B;;;uBAAA,vBAAMsB,sDAGHF,EAAEpB;AAHL,AAIE,OAACH,4BAAK,AAACwB,4BAAQC,qBAAQF,GAAGG,mBAAS,AAACH,YAAEpB;;AAExC;;;+BAAA,\/BAAMwB,sEAGHC;AAHH,AAIE,IAAML,IAAE,WAAAM;AAAA,AAAA,IAAAC,WAAAD;QAAA,AAAAE,wBAAAD,SAAA,IAAA,zCAAME;QAAN,AAAAD,wBAAAD,SAAA,IAAA,zCAAQG;AAAR,AAAY,GAAI,OAASD;AAAb,0FAAiB,AAACE,4BAAQF,GAAGC;;AAA7B,0FAAiCD,EAAEC;;;AAAvD,AAEE,OAACX,gCAAS,WAAKL;AAAL,AAAQ,GAAI,AAACkB,+BAAKlB;AAAG,gCAAA,zBAACG,4DAAQ,AAACb,wBAAIgB,EAAEN;;AAAIA;;GAAIW;;AAE3D;;;8BAAA,9BAAMQ,oEAGHR;AAHH,AAIE,IAAML,IAAE,WAAAc;AAAA,AAAA,IAAAC,WAAAD;QAAA,AAAAN,wBAAAO,SAAA,IAAA,zCAAMN;QAAN,AAAAD,wBAAAO,SAAA,IAAA,zCAAQL;AAAR,AAAY,GAAI,cAAAM,bAAUP;AAAd,0FAAkB,AAACQ,yBAAKR,GAAGC;;AAA3B,0FAA+BD,EAAEC;;;AAArD,AAEE,OAACX,gCAAS,WAAKL;AAAL,AAAQ,GAAI,AAACkB,+BAAKlB;AAAG,gCAAA,zBAACG,4DAAQ,AAACb,wBAAIgB,EAAEN;;AAAIA;;GAAIW;;AAE3D;;;;;+BAAA,\/BAAMa,sEAKHC,KAAKvC;AALR,AAME,OAACsB,+BAAQ,WAAKR;AAAL,AAAQ,GAAI,AAAC0B,oCAAUD,KAAKzB;AAAG,OAACyB,eAAKzB;;AAAGA;;GAAId;;AAEvD;;;;;gCAAA,hCAAMyC,wEAKHF,KAAKvC;AALR,AAME,OAACmB,gCAAS,WAAKL;AAAL,AAAQ,GAAI,AAAC0B,oCAAUD,KAAKzB;AAAG,OAACyB,eAAKzB;;AAAGA;;GAAId","names":["clojure.walk\/walk","inner","outer","form","cljs.core\/list?","cljs.core\/apply","cljs.core\/list","cljs.core\/map","cljs.core\/map-entry?","cljs.core\/MapEntry","cljs.core\/key","cljs.core\/val","cljs.core\/seq?","cljs.core\/doall","cljs.core\/record?","cljs.core\/reduce","r","x","cljs.core\/conj","cljs.core\/coll?","cljs.core\/into","cljs.core\/empty","clojure.walk\/postwalk","f","cljs.core\/partial","clojure.walk\/prewalk","cljs.core\/identity","clojure.walk\/keywordize-keys","m","p__629","vec__630","cljs.core\/nth","k","v","cljs.core\/keyword","cljs.core\/map?","clojure.walk\/stringify-keys","p__633","vec__634","cljs.core\/Keyword","cljs.core\/name","clojure.walk\/prewalk-replace","smap","cljs.core\/contains?","clojure.walk\/postwalk-replace"]}

View File

@ -1,659 +0,0 @@
/*TRANSPILED*/goog.loadModule(function(exports) {'use strict';/*
Copyright The Closure Library Authors.
SPDX-License-Identifier: Apache-2.0
*/
'use strict';
goog.module("goog.array");
goog.module.declareLegacyNamespace();
const asserts = goog.require("goog.asserts");
goog.NATIVE_ARRAY_PROTOTYPES = goog.define("goog.NATIVE_ARRAY_PROTOTYPES", goog.TRUSTED_SITE);
const ASSUME_NATIVE_FUNCTIONS = goog.define("goog.array.ASSUME_NATIVE_FUNCTIONS", goog.FEATURESET_YEAR > 2012);
exports.ASSUME_NATIVE_FUNCTIONS = ASSUME_NATIVE_FUNCTIONS;
function peek(array) {
return array[array.length - 1];
}
exports.peek = peek;
exports.last = peek;
const indexOf = goog.NATIVE_ARRAY_PROTOTYPES && (ASSUME_NATIVE_FUNCTIONS || Array.prototype.indexOf) ? function(arr, obj, opt_fromIndex) {
asserts.assert(arr.length != null);
return Array.prototype.indexOf.call(arr, obj, opt_fromIndex);
} : function(arr, obj, opt_fromIndex) {
const fromIndex = opt_fromIndex == null ? 0 : opt_fromIndex < 0 ? Math.max(0, arr.length + opt_fromIndex) : opt_fromIndex;
if (typeof arr === "string") {
if (typeof obj !== "string" || obj.length != 1) {
return -1;
}
return arr.indexOf(obj, fromIndex);
}
for (let i = fromIndex; i < arr.length; i++) {
if (i in arr && arr[i] === obj) {
return i;
}
}
return -1;
};
exports.indexOf = indexOf;
const lastIndexOf = goog.NATIVE_ARRAY_PROTOTYPES && (ASSUME_NATIVE_FUNCTIONS || Array.prototype.lastIndexOf) ? function(arr, obj, opt_fromIndex) {
asserts.assert(arr.length != null);
const fromIndex = opt_fromIndex == null ? arr.length - 1 : opt_fromIndex;
return Array.prototype.lastIndexOf.call(arr, obj, fromIndex);
} : function(arr, obj, opt_fromIndex) {
let fromIndex = opt_fromIndex == null ? arr.length - 1 : opt_fromIndex;
if (fromIndex < 0) {
fromIndex = Math.max(0, arr.length + fromIndex);
}
if (typeof arr === "string") {
if (typeof obj !== "string" || obj.length != 1) {
return -1;
}
return arr.lastIndexOf(obj, fromIndex);
}
for (let i = fromIndex; i >= 0; i--) {
if (i in arr && arr[i] === obj) {
return i;
}
}
return -1;
};
exports.lastIndexOf = lastIndexOf;
const forEach = goog.NATIVE_ARRAY_PROTOTYPES && (ASSUME_NATIVE_FUNCTIONS || Array.prototype.forEach) ? function(arr, f, opt_obj) {
asserts.assert(arr.length != null);
Array.prototype.forEach.call(arr, f, opt_obj);
} : function(arr, f, opt_obj) {
const l = arr.length;
const arr2 = typeof arr === "string" ? arr.split("") : arr;
for (let i = 0; i < l; i++) {
if (i in arr2) {
f.call(opt_obj, arr2[i], i, arr);
}
}
};
exports.forEach = forEach;
function forEachRight(arr, f, opt_obj) {
const l = arr.length;
const arr2 = typeof arr === "string" ? arr.split("") : arr;
for (let i = l - 1; i >= 0; --i) {
if (i in arr2) {
f.call(opt_obj, arr2[i], i, arr);
}
}
}
exports.forEachRight = forEachRight;
const filter = goog.NATIVE_ARRAY_PROTOTYPES && (ASSUME_NATIVE_FUNCTIONS || Array.prototype.filter) ? function(arr, f, opt_obj) {
asserts.assert(arr.length != null);
return Array.prototype.filter.call(arr, f, opt_obj);
} : function(arr, f, opt_obj) {
const l = arr.length;
const res = [];
let resLength = 0;
const arr2 = typeof arr === "string" ? arr.split("") : arr;
for (let i = 0; i < l; i++) {
if (i in arr2) {
const val = arr2[i];
if (f.call(opt_obj, val, i, arr)) {
res[resLength++] = val;
}
}
}
return res;
};
exports.filter = filter;
const map = goog.NATIVE_ARRAY_PROTOTYPES && (ASSUME_NATIVE_FUNCTIONS || Array.prototype.map) ? function(arr, f, opt_obj) {
asserts.assert(arr.length != null);
return Array.prototype.map.call(arr, f, opt_obj);
} : function(arr, f, opt_obj) {
const l = arr.length;
const res = new Array(l);
const arr2 = typeof arr === "string" ? arr.split("") : arr;
for (let i = 0; i < l; i++) {
if (i in arr2) {
res[i] = f.call(opt_obj, arr2[i], i, arr);
}
}
return res;
};
exports.map = map;
const reduce = goog.NATIVE_ARRAY_PROTOTYPES && (ASSUME_NATIVE_FUNCTIONS || Array.prototype.reduce) ? function(arr, f, val, opt_obj) {
asserts.assert(arr.length != null);
if (opt_obj) {
f = goog.bind(f, opt_obj);
}
return Array.prototype.reduce.call(arr, f, val);
} : function(arr, f, val, opt_obj) {
let rval = val;
forEach(arr, function(val, index) {
rval = f.call(opt_obj, rval, val, index, arr);
});
return rval;
};
exports.reduce = reduce;
const reduceRight = goog.NATIVE_ARRAY_PROTOTYPES && (ASSUME_NATIVE_FUNCTIONS || Array.prototype.reduceRight) ? function(arr, f, val, opt_obj) {
asserts.assert(arr.length != null);
asserts.assert(f != null);
if (opt_obj) {
f = goog.bind(f, opt_obj);
}
return Array.prototype.reduceRight.call(arr, f, val);
} : function(arr, f, val, opt_obj) {
let rval = val;
forEachRight(arr, function(val, index) {
rval = f.call(opt_obj, rval, val, index, arr);
});
return rval;
};
exports.reduceRight = reduceRight;
const some = goog.NATIVE_ARRAY_PROTOTYPES && (ASSUME_NATIVE_FUNCTIONS || Array.prototype.some) ? function(arr, f, opt_obj) {
asserts.assert(arr.length != null);
return Array.prototype.some.call(arr, f, opt_obj);
} : function(arr, f, opt_obj) {
const l = arr.length;
const arr2 = typeof arr === "string" ? arr.split("") : arr;
for (let i = 0; i < l; i++) {
if (i in arr2 && f.call(opt_obj, arr2[i], i, arr)) {
return true;
}
}
return false;
};
exports.some = some;
const every = goog.NATIVE_ARRAY_PROTOTYPES && (ASSUME_NATIVE_FUNCTIONS || Array.prototype.every) ? function(arr, f, opt_obj) {
asserts.assert(arr.length != null);
return Array.prototype.every.call(arr, f, opt_obj);
} : function(arr, f, opt_obj) {
const l = arr.length;
const arr2 = typeof arr === "string" ? arr.split("") : arr;
for (let i = 0; i < l; i++) {
if (i in arr2 && !f.call(opt_obj, arr2[i], i, arr)) {
return false;
}
}
return true;
};
exports.every = every;
function count(arr, f, opt_obj) {
let count = 0;
forEach(arr, function(element, index, arr) {
if (f.call(opt_obj, element, index, arr)) {
++count;
}
}, opt_obj);
return count;
}
exports.count = count;
function find(arr, f, opt_obj) {
const i = findIndex(arr, f, opt_obj);
return i < 0 ? null : typeof arr === "string" ? arr.charAt(i) : arr[i];
}
exports.find = find;
function findIndex(arr, f, opt_obj) {
const l = arr.length;
const arr2 = typeof arr === "string" ? arr.split("") : arr;
for (let i = 0; i < l; i++) {
if (i in arr2 && f.call(opt_obj, arr2[i], i, arr)) {
return i;
}
}
return -1;
}
exports.findIndex = findIndex;
function findRight(arr, f, opt_obj) {
const i = findIndexRight(arr, f, opt_obj);
return i < 0 ? null : typeof arr === "string" ? arr.charAt(i) : arr[i];
}
exports.findRight = findRight;
function findIndexRight(arr, f, opt_obj) {
const l = arr.length;
const arr2 = typeof arr === "string" ? arr.split("") : arr;
for (let i = l - 1; i >= 0; i--) {
if (i in arr2 && f.call(opt_obj, arr2[i], i, arr)) {
return i;
}
}
return -1;
}
exports.findIndexRight = findIndexRight;
function contains(arr, obj) {
return indexOf(arr, obj) >= 0;
}
exports.contains = contains;
function isEmpty(arr) {
return arr.length == 0;
}
exports.isEmpty = isEmpty;
function clear(arr) {
if (!Array.isArray(arr)) {
for (let i = arr.length - 1; i >= 0; i--) {
delete arr[i];
}
}
arr.length = 0;
}
exports.clear = clear;
function insert(arr, obj) {
if (!contains(arr, obj)) {
arr.push(obj);
}
}
exports.insert = insert;
function insertAt(arr, obj, opt_i) {
splice(arr, opt_i, 0, obj);
}
exports.insertAt = insertAt;
function insertArrayAt(arr, elementsToAdd, opt_i) {
goog.partial(splice, arr, opt_i, 0).apply(null, elementsToAdd);
}
exports.insertArrayAt = insertArrayAt;
function insertBefore(arr, obj, opt_obj2) {
let i;
if (arguments.length == 2 || (i = indexOf(arr, opt_obj2)) < 0) {
arr.push(obj);
} else {
insertAt(arr, obj, i);
}
}
exports.insertBefore = insertBefore;
function remove(arr, obj) {
const i = indexOf(arr, obj);
let rv;
if (rv = i >= 0) {
removeAt(arr, i);
}
return rv;
}
exports.remove = remove;
function removeLast(arr, obj) {
const i = lastIndexOf(arr, obj);
if (i >= 0) {
removeAt(arr, i);
return true;
}
return false;
}
exports.removeLast = removeLast;
function removeAt(arr, i) {
asserts.assert(arr.length != null);
return Array.prototype.splice.call(arr, i, 1).length == 1;
}
exports.removeAt = removeAt;
function removeIf(arr, f, opt_obj) {
const i = findIndex(arr, f, opt_obj);
if (i >= 0) {
removeAt(arr, i);
return true;
}
return false;
}
exports.removeIf = removeIf;
function removeAllIf(arr, f, opt_obj) {
let removedCount = 0;
forEachRight(arr, function(val, index) {
if (f.call(opt_obj, val, index, arr)) {
if (removeAt(arr, index)) {
removedCount++;
}
}
});
return removedCount;
}
exports.removeAllIf = removeAllIf;
function concat(var_args) {
return Array.prototype.concat.apply([], arguments);
}
exports.concat = concat;
function join(var_args) {
return Array.prototype.concat.apply([], arguments);
}
exports.join = join;
function toArray(object) {
const length = object.length;
if (length > 0) {
const rv = new Array(length);
for (let i = 0; i < length; i++) {
rv[i] = object[i];
}
return rv;
}
return [];
}
exports.toArray = toArray;
const clone = toArray;
exports.clone = clone;
function extend(arr1, var_args) {
for (let i = 1; i < arguments.length; i++) {
const arr2 = arguments[i];
if (goog.isArrayLike(arr2)) {
const len1 = arr1.length || 0;
const len2 = arr2.length || 0;
arr1.length = len1 + len2;
for (let j = 0; j < len2; j++) {
arr1[len1 + j] = arr2[j];
}
} else {
arr1.push(arr2);
}
}
}
exports.extend = extend;
function splice(arr, index, howMany, var_args) {
asserts.assert(arr.length != null);
return Array.prototype.splice.apply(arr, slice(arguments, 1));
}
exports.splice = splice;
function slice(arr, start, opt_end) {
asserts.assert(arr.length != null);
if (arguments.length <= 2) {
return Array.prototype.slice.call(arr, start);
} else {
return Array.prototype.slice.call(arr, start, opt_end);
}
}
exports.slice = slice;
function removeDuplicates(arr, opt_rv, opt_hashFn) {
const returnArray = opt_rv || arr;
const defaultHashFn = function(item) {
return goog.isObject(item) ? "o" + goog.getUid(item) : (typeof item).charAt(0) + item;
};
const hashFn = opt_hashFn || defaultHashFn;
let cursorInsert = 0;
let cursorRead = 0;
const seen = {};
while (cursorRead < arr.length) {
const current = arr[cursorRead++];
const key = hashFn(current);
if (!Object.prototype.hasOwnProperty.call(seen, key)) {
seen[key] = true;
returnArray[cursorInsert++] = current;
}
}
returnArray.length = cursorInsert;
}
exports.removeDuplicates = removeDuplicates;
function binarySearch(arr, target, opt_compareFn) {
return binarySearch_(arr, opt_compareFn || defaultCompare, false, target);
}
exports.binarySearch = binarySearch;
function binarySelect(arr, evaluator, opt_obj) {
return binarySearch_(arr, evaluator, true, undefined, opt_obj);
}
exports.binarySelect = binarySelect;
function binarySearch_(arr, compareFn, isEvaluator, opt_target, opt_selfObj) {
let left = 0;
let right = arr.length;
let found;
while (left < right) {
const middle = left + (right - left >>> 1);
let compareResult;
if (isEvaluator) {
compareResult = compareFn.call(opt_selfObj, arr[middle], middle, arr);
} else {
compareResult = compareFn(opt_target, arr[middle]);
}
if (compareResult > 0) {
left = middle + 1;
} else {
right = middle;
found = !compareResult;
}
}
return found ? left : -left - 1;
}
function sort(arr, opt_compareFn) {
arr.sort(opt_compareFn || defaultCompare);
}
exports.sort = sort;
function stableSort(arr, opt_compareFn) {
const compArr = new Array(arr.length);
for (let i = 0; i < arr.length; i++) {
compArr[i] = {index:i, value:arr[i]};
}
const valueCompareFn = opt_compareFn || defaultCompare;
function stableCompareFn(obj1, obj2) {
return valueCompareFn(obj1.value, obj2.value) || obj1.index - obj2.index;
}
sort(compArr, stableCompareFn);
for (let i = 0; i < arr.length; i++) {
arr[i] = compArr[i].value;
}
}
exports.stableSort = stableSort;
function sortByKey(arr, keyFn, opt_compareFn) {
const keyCompareFn = opt_compareFn || defaultCompare;
sort(arr, function(a, b) {
return keyCompareFn(keyFn(a), keyFn(b));
});
}
exports.sortByKey = sortByKey;
function sortObjectsByKey(arr, key, opt_compareFn) {
sortByKey(arr, function(obj) {
return obj[key];
}, opt_compareFn);
}
exports.sortObjectsByKey = sortObjectsByKey;
function isSorted(arr, opt_compareFn, opt_strict) {
const compare = opt_compareFn || defaultCompare;
for (let i = 1; i < arr.length; i++) {
const compareResult = compare(arr[i - 1], arr[i]);
if (compareResult > 0 || compareResult == 0 && opt_strict) {
return false;
}
}
return true;
}
exports.isSorted = isSorted;
function equals(arr1, arr2, opt_equalsFn) {
if (!goog.isArrayLike(arr1) || !goog.isArrayLike(arr2) || arr1.length != arr2.length) {
return false;
}
const l = arr1.length;
const equalsFn = opt_equalsFn || defaultCompareEquality;
for (let i = 0; i < l; i++) {
if (!equalsFn(arr1[i], arr2[i])) {
return false;
}
}
return true;
}
exports.equals = equals;
function compare3(arr1, arr2, opt_compareFn) {
const compare = opt_compareFn || defaultCompare;
const l = Math.min(arr1.length, arr2.length);
for (let i = 0; i < l; i++) {
const result = compare(arr1[i], arr2[i]);
if (result != 0) {
return result;
}
}
return defaultCompare(arr1.length, arr2.length);
}
exports.compare3 = compare3;
function defaultCompare(a, b) {
return a > b ? 1 : a < b ? -1 : 0;
}
exports.defaultCompare = defaultCompare;
function inverseDefaultCompare(a, b) {
return -defaultCompare(a, b);
}
exports.inverseDefaultCompare = inverseDefaultCompare;
function defaultCompareEquality(a, b) {
return a === b;
}
exports.defaultCompareEquality = defaultCompareEquality;
function binaryInsert(array, value, opt_compareFn) {
const index = binarySearch(array, value, opt_compareFn);
if (index < 0) {
insertAt(array, value, -(index + 1));
return true;
}
return false;
}
exports.binaryInsert = binaryInsert;
function binaryRemove(array, value, opt_compareFn) {
const index = binarySearch(array, value, opt_compareFn);
return index >= 0 ? removeAt(array, index) : false;
}
exports.binaryRemove = binaryRemove;
function bucket(array, sorter, opt_obj) {
const buckets = {};
for (let i = 0; i < array.length; i++) {
const value = array[i];
const key = sorter.call(opt_obj, value, i, array);
if (key !== undefined) {
const bucket = buckets[key] || (buckets[key] = []);
bucket.push(value);
}
}
return buckets;
}
exports.bucket = bucket;
function bucketToMap(array, sorter) {
const buckets = new Map();
for (let i = 0; i < array.length; i++) {
const value = array[i];
const key = sorter(value, i, array);
if (key !== undefined) {
let bucket = buckets.get(key);
if (!bucket) {
bucket = [];
buckets.set(key, bucket);
}
bucket.push(value);
}
}
return buckets;
}
exports.bucketToMap = bucketToMap;
function toObject(arr, keyFunc, opt_obj) {
const ret = {};
forEach(arr, function(element, index) {
ret[keyFunc.call(opt_obj, element, index, arr)] = element;
});
return ret;
}
exports.toObject = toObject;
function toMap(arr, keyFunc) {
const map = new Map();
for (let i = 0; i < arr.length; i++) {
const element = arr[i];
map.set(keyFunc(element, i, arr), element);
}
return map;
}
exports.toMap = toMap;
function range(startOrEnd, opt_end, opt_step) {
const array = [];
let start = 0;
let end = startOrEnd;
const step = opt_step || 1;
if (opt_end !== undefined) {
start = startOrEnd;
end = opt_end;
}
if (step * (end - start) < 0) {
return [];
}
if (step > 0) {
for (let i = start; i < end; i += step) {
array.push(i);
}
} else {
for (let i = start; i > end; i += step) {
array.push(i);
}
}
return array;
}
exports.range = range;
function repeat(value, n) {
const array = [];
for (let i = 0; i < n; i++) {
array[i] = value;
}
return array;
}
exports.repeat = repeat;
function flatten(var_args) {
const CHUNK_SIZE = 8192;
const result = [];
for (let i = 0; i < arguments.length; i++) {
const element = arguments[i];
if (Array.isArray(element)) {
for (let c = 0; c < element.length; c += CHUNK_SIZE) {
const chunk = slice(element, c, c + CHUNK_SIZE);
const recurseResult = flatten.apply(null, chunk);
for (let r = 0; r < recurseResult.length; r++) {
result.push(recurseResult[r]);
}
}
} else {
result.push(element);
}
}
return result;
}
exports.flatten = flatten;
function rotate(array, n) {
asserts.assert(array.length != null);
if (array.length) {
n %= array.length;
if (n > 0) {
Array.prototype.unshift.apply(array, array.splice(-n, n));
} else if (n < 0) {
Array.prototype.push.apply(array, array.splice(0, -n));
}
}
return array;
}
exports.rotate = rotate;
function moveItem(arr, fromIndex, toIndex) {
asserts.assert(fromIndex >= 0 && fromIndex < arr.length);
asserts.assert(toIndex >= 0 && toIndex < arr.length);
const removedItems = Array.prototype.splice.call(arr, fromIndex, 1);
Array.prototype.splice.call(arr, toIndex, 0, removedItems[0]);
}
exports.moveItem = moveItem;
function zip(var_args) {
if (!arguments.length) {
return [];
}
const result = [];
let minLen = arguments[0].length;
for (let i = 1; i < arguments.length; i++) {
if (arguments[i].length < minLen) {
minLen = arguments[i].length;
}
}
for (let i = 0; i < minLen; i++) {
const value = [];
for (let j = 0; j < arguments.length; j++) {
value.push(arguments[j][i]);
}
result.push(value);
}
return result;
}
exports.zip = zip;
function shuffle(arr, opt_randFn) {
const randFn = opt_randFn || Math.random;
for (let i = arr.length - 1; i > 0; i--) {
const j = Math.floor(randFn() * (i + 1));
const tmp = arr[i];
arr[i] = arr[j];
arr[j] = tmp;
}
}
exports.shuffle = shuffle;
function copyByIndex(arr, index_arr) {
const result = [];
forEach(index_arr, function(index) {
result.push(arr[index]);
});
return result;
}
exports.copyByIndex = copyByIndex;
function concatMap(arr, f, opt_obj) {
return concat.apply([], map(arr, f, opt_obj));
}
exports.concatMap = concatMap;
;return exports;});

View File

@ -1,132 +0,0 @@
/*TRANSPILED*/goog.loadModule(function(exports) {'use strict';/*
Copyright The Closure Library Authors.
SPDX-License-Identifier: Apache-2.0
*/
'use strict';
goog.module("goog.asserts");
goog.module.declareLegacyNamespace();
const DebugError = goog.require("goog.debug.Error");
const NodeType = goog.require("goog.dom.NodeType");
exports.ENABLE_ASSERTS = goog.define("goog.asserts.ENABLE_ASSERTS", goog.DEBUG);
function AssertionError(messagePattern, messageArgs) {
DebugError.call(this, subs(messagePattern, messageArgs));
this.messagePattern = messagePattern;
}
goog.inherits(AssertionError, DebugError);
exports.AssertionError = AssertionError;
AssertionError.prototype.name = "AssertionError";
exports.DEFAULT_ERROR_HANDLER = function(e) {
throw e;
};
let errorHandler_ = exports.DEFAULT_ERROR_HANDLER;
function subs(pattern, subs) {
const splitParts = pattern.split("%s");
let returnString = "";
const subLast = splitParts.length - 1;
for (let i = 0; i < subLast; i++) {
const sub = i < subs.length ? subs[i] : "%s";
returnString += splitParts[i] + sub;
}
return returnString + splitParts[subLast];
}
function doAssertFailure(defaultMessage, defaultArgs, givenMessage, givenArgs) {
let message = "Assertion failed";
let args;
if (givenMessage) {
message += ": " + givenMessage;
args = givenArgs;
} else if (defaultMessage) {
message += ": " + defaultMessage;
args = defaultArgs;
}
const e = new AssertionError("" + message, args || []);
errorHandler_(e);
}
exports.setErrorHandler = function(errorHandler) {
if (exports.ENABLE_ASSERTS) {
errorHandler_ = errorHandler;
}
};
exports.assert = function(condition, opt_message, var_args) {
if (exports.ENABLE_ASSERTS && !condition) {
doAssertFailure("", null, opt_message, Array.prototype.slice.call(arguments, 2));
}
return condition;
};
exports.assertExists = function(value, opt_message, var_args) {
if (exports.ENABLE_ASSERTS && value == null) {
doAssertFailure("Expected to exist: %s.", [value], opt_message, Array.prototype.slice.call(arguments, 2));
}
return value;
};
exports.fail = function(opt_message, var_args) {
if (exports.ENABLE_ASSERTS) {
errorHandler_(new AssertionError("Failure" + (opt_message ? ": " + opt_message : ""), Array.prototype.slice.call(arguments, 1)));
}
};
exports.assertNumber = function(value, opt_message, var_args) {
if (exports.ENABLE_ASSERTS && typeof value !== "number") {
doAssertFailure("Expected number but got %s: %s.", [goog.typeOf(value), value], opt_message, Array.prototype.slice.call(arguments, 2));
}
return value;
};
exports.assertString = function(value, opt_message, var_args) {
if (exports.ENABLE_ASSERTS && typeof value !== "string") {
doAssertFailure("Expected string but got %s: %s.", [goog.typeOf(value), value], opt_message, Array.prototype.slice.call(arguments, 2));
}
return value;
};
exports.assertFunction = function(value, opt_message, var_args) {
if (exports.ENABLE_ASSERTS && typeof value !== "function") {
doAssertFailure("Expected function but got %s: %s.", [goog.typeOf(value), value], opt_message, Array.prototype.slice.call(arguments, 2));
}
return value;
};
exports.assertObject = function(value, opt_message, var_args) {
if (exports.ENABLE_ASSERTS && !goog.isObject(value)) {
doAssertFailure("Expected object but got %s: %s.", [goog.typeOf(value), value], opt_message, Array.prototype.slice.call(arguments, 2));
}
return value;
};
exports.assertArray = function(value, opt_message, var_args) {
if (exports.ENABLE_ASSERTS && !Array.isArray(value)) {
doAssertFailure("Expected array but got %s: %s.", [goog.typeOf(value), value], opt_message, Array.prototype.slice.call(arguments, 2));
}
return value;
};
exports.assertBoolean = function(value, opt_message, var_args) {
if (exports.ENABLE_ASSERTS && typeof value !== "boolean") {
doAssertFailure("Expected boolean but got %s: %s.", [goog.typeOf(value), value], opt_message, Array.prototype.slice.call(arguments, 2));
}
return value;
};
exports.assertElement = function(value, opt_message, var_args) {
if (exports.ENABLE_ASSERTS && (!goog.isObject(value) || value.nodeType != NodeType.ELEMENT)) {
doAssertFailure("Expected Element but got %s: %s.", [goog.typeOf(value), value], opt_message, Array.prototype.slice.call(arguments, 2));
}
return value;
};
exports.assertInstanceof = function(value, type, opt_message, var_args) {
if (exports.ENABLE_ASSERTS && !(value instanceof type)) {
doAssertFailure("Expected instanceof %s but got %s.", [getType(type), getType(value)], opt_message, Array.prototype.slice.call(arguments, 3));
}
return value;
};
exports.assertFinite = function(value, opt_message, var_args) {
if (exports.ENABLE_ASSERTS && (typeof value != "number" || !isFinite(value))) {
doAssertFailure("Expected %s to be a finite number but it is not.", [value], opt_message, Array.prototype.slice.call(arguments, 2));
}
return value;
};
function getType(value) {
if (value instanceof Function) {
return value.displayName || value.name || "unknown type name";
} else if (value instanceof Object) {
return value.constructor.displayName || value.constructor.name || Object.prototype.toString.call(value);
} else {
return value === null ? "null" : typeof value;
}
}
;
;return exports;});

View File

@ -1,88 +0,0 @@
/*TRANSPILED*/goog.loadModule(function(exports) {'use strict';/*
Copyright The Closure Library Authors.
SPDX-License-Identifier: Apache-2.0
*/
'use strict';
goog.module("goog.asserts.dom");
goog.module.declareLegacyNamespace();
const TagName = goog.require("goog.dom.TagName");
const asserts = goog.require("goog.asserts");
const element = goog.require("goog.dom.element");
const assertIsElement = value => {
if (asserts.ENABLE_ASSERTS && !element.isElement(value)) {
asserts.fail(`Argument is not an Element; got: ${debugStringForType(value)}`);
}
return value;
};
const assertIsHtmlElement = value => {
if (asserts.ENABLE_ASSERTS && !element.isHtmlElement(value)) {
asserts.fail(`Argument is not an HTML Element; got: ${debugStringForType(value)}`);
}
return value;
};
const assertIsHtmlElementOfType = (value, tagName) => {
if (asserts.ENABLE_ASSERTS && !element.isHtmlElementOfType(value, tagName)) {
asserts.fail(`Argument is not an HTML Element with tag name ` + `${tagName.toString()}; got: ${debugStringForType(value)}`);
}
return value;
};
const assertIsHtmlAnchorElement = value => {
return assertIsHtmlElementOfType(value, TagName.A);
};
const assertIsHtmlButtonElement = value => {
return assertIsHtmlElementOfType(value, TagName.BUTTON);
};
const assertIsHtmlLinkElement = value => {
return assertIsHtmlElementOfType(value, TagName.LINK);
};
const assertIsHtmlImageElement = value => {
return assertIsHtmlElementOfType(value, TagName.IMG);
};
const assertIsHtmlAudioElement = value => {
return assertIsHtmlElementOfType(value, TagName.AUDIO);
};
const assertIsHtmlVideoElement = value => {
return assertIsHtmlElementOfType(value, TagName.VIDEO);
};
const assertIsHtmlInputElement = value => {
return assertIsHtmlElementOfType(value, TagName.INPUT);
};
const assertIsHtmlTextAreaElement = value => {
return assertIsHtmlElementOfType(value, TagName.TEXTAREA);
};
const assertIsHtmlCanvasElement = value => {
return assertIsHtmlElementOfType(value, TagName.CANVAS);
};
const assertIsHtmlEmbedElement = value => {
return assertIsHtmlElementOfType(value, TagName.EMBED);
};
const assertIsHtmlFormElement = value => {
return assertIsHtmlElementOfType(value, TagName.FORM);
};
const assertIsHtmlFrameElement = value => {
return assertIsHtmlElementOfType(value, TagName.FRAME);
};
const assertIsHtmlIFrameElement = value => {
return assertIsHtmlElementOfType(value, TagName.IFRAME);
};
const assertIsHtmlObjectElement = value => {
return assertIsHtmlElementOfType(value, TagName.OBJECT);
};
const assertIsHtmlScriptElement = value => {
return assertIsHtmlElementOfType(value, TagName.SCRIPT);
};
const debugStringForType = value => {
if (goog.isObject(value)) {
try {
return value.constructor.displayName || value.constructor.name || Object.prototype.toString.call(value);
} catch (e) {
return "\x3cobject could not be stringified\x3e";
}
} else {
return value === undefined ? "undefined" : value === null ? "null" : typeof value;
}
};
exports = {assertIsElement, assertIsHtmlElement, assertIsHtmlElementOfType, assertIsHtmlAnchorElement, assertIsHtmlButtonElement, assertIsHtmlLinkElement, assertIsHtmlImageElement, assertIsHtmlAudioElement, assertIsHtmlVideoElement, assertIsHtmlInputElement, assertIsHtmlTextAreaElement, assertIsHtmlCanvasElement, assertIsHtmlEmbedElement, assertIsHtmlFormElement, assertIsHtmlFrameElement, assertIsHtmlIFrameElement, assertIsHtmlObjectElement, assertIsHtmlScriptElement,};
;return exports;});

View File

@ -1,183 +0,0 @@
/**
* @license
* Copyright The Closure Library Authors.
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @fileoverview Defines a class useful for handling functions that must be
* invoked after a delay, especially when that delay is frequently restarted.
* Examples include delaying before displaying a tooltip, menu hysteresis,
* idle timers, etc.
* @see ../demos/timers.html
*/
goog.provide('goog.async.Delay');
goog.require('goog.Disposable');
goog.require('goog.Timer');
/**
* A Delay object invokes the associated function after a specified delay. The
* interval duration can be specified once in the constructor, or can be defined
* each time the delay is started. Calling start on an active delay will reset
* the timer.
*
* @param {function(this:THIS)} listener Function to call when the
* delay completes.
* @param {number=} opt_interval The default length of the invocation delay (in
* milliseconds).
* @param {THIS=} opt_handler The object scope to invoke the function in.
* @template THIS
* @constructor
* @struct
* @extends {goog.Disposable}
* @final
*/
goog.async.Delay = function(listener, opt_interval, opt_handler) {
'use strict';
goog.async.Delay.base(this, 'constructor');
/**
* The function that will be invoked after a delay.
* @private {function(this:THIS)}
*/
this.listener_ = listener;
/**
* The default amount of time to delay before invoking the callback.
* @type {number}
* @private
*/
this.interval_ = opt_interval || 0;
/**
* The object context to invoke the callback in.
* @type {Object|undefined}
* @private
*/
this.handler_ = opt_handler;
/**
* Cached callback function invoked when the delay finishes.
* @type {Function}
* @private
*/
this.callback_ = goog.bind(this.doAction_, this);
};
goog.inherits(goog.async.Delay, goog.Disposable);
/**
* Identifier of the active delay timeout, or 0 when inactive.
* @type {number}
* @private
*/
goog.async.Delay.prototype.id_ = 0;
/**
* Disposes of the object, cancelling the timeout if it is still outstanding and
* removing all object references.
* @override
* @protected
*/
goog.async.Delay.prototype.disposeInternal = function() {
'use strict';
goog.async.Delay.base(this, 'disposeInternal');
this.stop();
delete this.listener_;
delete this.handler_;
};
/**
* Starts the delay timer. The provided listener function will be called after
* the specified interval. Calling start on an active timer will reset the
* delay interval.
* @param {number=} opt_interval If specified, overrides the object's default
* interval with this one (in milliseconds).
*/
goog.async.Delay.prototype.start = function(opt_interval) {
'use strict';
this.stop();
this.id_ = goog.Timer.callOnce(
this.callback_,
opt_interval !== undefined ? opt_interval : this.interval_);
};
/**
* Starts the delay timer if it's not already active.
* @param {number=} opt_interval If specified and the timer is not already
* active, overrides the object's default interval with this one (in
* milliseconds).
*/
goog.async.Delay.prototype.startIfNotActive = function(opt_interval) {
'use strict';
if (!this.isActive()) {
this.start(opt_interval);
}
};
/**
* Stops the delay timer if it is active. No action is taken if the timer is not
* in use.
*/
goog.async.Delay.prototype.stop = function() {
'use strict';
if (this.isActive()) {
goog.Timer.clear(this.id_);
}
this.id_ = 0;
};
/**
* Fires delay's action even if timer has already gone off or has not been
* started yet; guarantees action firing. Stops the delay timer.
*/
goog.async.Delay.prototype.fire = function() {
'use strict';
this.stop();
this.doAction_();
};
/**
* Fires delay's action only if timer is currently active. Stops the delay
* timer.
*/
goog.async.Delay.prototype.fireIfActive = function() {
'use strict';
if (this.isActive()) {
this.fire();
}
};
/**
* @return {boolean} True if the delay is currently active, false otherwise.
*/
goog.async.Delay.prototype.isActive = function() {
'use strict';
return this.id_ != 0;
};
/**
* Invokes the callback function after the delay successfully completes.
* @private
*/
goog.async.Delay.prototype.doAction_ = function() {
'use strict';
this.id_ = 0;
if (this.listener_) {
this.listener_.call(this.handler_);
}
};

View File

@ -1,43 +0,0 @@
/*TRANSPILED*/goog.loadModule(function(exports) {'use strict';/*
Copyright The Closure Library Authors.
SPDX-License-Identifier: Apache-2.0
*/
'use strict';
goog.module("goog.async.FreeList");
goog.module.declareLegacyNamespace();
class FreeList {
constructor(create, reset, limit) {
this.limit_ = limit;
this.create_ = create;
this.reset_ = reset;
this.occupants_ = 0;
this.head_ = null;
}
get() {
let item;
if (this.occupants_ > 0) {
this.occupants_--;
item = this.head_;
this.head_ = item.next;
item.next = null;
} else {
item = this.create_();
}
return item;
}
put(item) {
this.reset_(item);
if (this.occupants_ < this.limit_) {
this.occupants_++;
item.next = this.head_;
this.head_ = item;
}
}
occupants() {
return this.occupants_;
}
}
exports = FreeList;
;return exports;});

View File

@ -1,236 +0,0 @@
/**
* @license
* Copyright The Closure Library Authors.
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @fileoverview Provides a function to schedule running a function as soon
* as possible after the current JS execution stops and yields to the event
* loop.
*/
goog.provide('goog.async.nextTick');
goog.require('goog.debug.entryPointRegistry');
goog.require('goog.dom');
goog.require('goog.dom.TagName');
goog.require('goog.functions');
goog.require('goog.labs.userAgent.browser');
goog.require('goog.labs.userAgent.engine');
/**
* Fires the provided callbacks as soon as possible after the current JS
* execution context. setTimeout(, 0) takes at least 4ms when called from
* within another setTimeout(, 0) for legacy reasons.
*
* This will not schedule the callback as a microtask (i.e. a task that can
* preempt user input or networking callbacks). It is meant to emulate what
* setTimeout(_, 0) would do if it were not throttled. If you desire microtask
* behavior, use {@see goog.Promise} instead.
*
* @param {function(this:SCOPE)} callback Callback function to fire as soon as
* possible.
* @param {SCOPE=} opt_context Object in whose scope to call the listener.
* @param {boolean=} opt_useSetImmediate Avoid the IE workaround that
* ensures correctness at the cost of speed. See comments for details.
* @template SCOPE
*/
goog.async.nextTick = function(callback, opt_context, opt_useSetImmediate) {
'use strict';
var cb = callback;
if (opt_context) {
cb = goog.bind(callback, opt_context);
}
cb = goog.async.nextTick.wrapCallback_(cb);
// Note we do allow callers to also request setImmediate if they are willing
// to accept the possible tradeoffs of incorrectness in exchange for speed.
// The IE fallback of readystate change is much slower. See useSetImmediate_
// for details.
if (typeof goog.global.setImmediate === 'function' &&
(opt_useSetImmediate || goog.async.nextTick.useSetImmediate_())) {
goog.global.setImmediate(cb);
return;
}
// Look for and cache the custom fallback version of setImmediate.
if (!goog.async.nextTick.nextTickImpl) {
goog.async.nextTick.nextTickImpl = goog.async.nextTick.getNextTickImpl_();
}
goog.async.nextTick.nextTickImpl(cb);
};
/**
* Returns whether should use setImmediate implementation currently on window.
*
* window.setImmediate was introduced and currently only supported by IE10+,
* but due to a bug in the implementation it is not guaranteed that
* setImmediate is faster than setTimeout nor that setImmediate N is before
* setImmediate N+1. That is why we do not use the native version if
* available. We do, however, call setImmediate if it is a non-native function
* because that indicates that it has been replaced by goog.testing.MockClock
* which we do want to support.
* See
* http://connect.microsoft.com/IE/feedback/details/801823/setimmediate-and-messagechannel-are-broken-in-ie10
*
* @return {boolean} Whether to use the implementation of setImmediate defined
* on Window.
* @private
* @suppress {missingProperties} For "Window.prototype.setImmediate"
*/
goog.async.nextTick.useSetImmediate_ = function() {
'use strict';
// Not a browser environment.
if (!goog.global.Window || !goog.global.Window.prototype) {
return true;
}
// MS Edge has window.setImmediate natively, but it's not on Window.prototype.
// Also, there's no clean way to detect if the goog.global.setImmediate has
// been replaced by mockClock as its replacement also shows up as "[native
// code]" when using toString. Therefore, just always use
// goog.global.setImmediate for Edge. It's unclear if it suffers the same
// issues as IE10/11, but based on
// https://dev.modern.ie/testdrive/demos/setimmediatesorting/
// it seems they've been working to ensure it's WAI.
if (goog.labs.userAgent.browser.isEdge() ||
goog.global.Window.prototype.setImmediate != goog.global.setImmediate) {
// Something redefined setImmediate in which case we decide to use it (This
// is so that we use the mockClock setImmediate).
return true;
}
return false;
};
/**
* Cache for the nextTick implementation. Exposed so tests can replace it,
* if needed.
* @type {function(function())}
*/
goog.async.nextTick.nextTickImpl;
/**
* Determines the best possible implementation to run a function as soon as
* the JS event loop is idle.
* @return {function(function())} The "setImmediate" implementation.
* @private
*/
goog.async.nextTick.getNextTickImpl_ = function() {
'use strict';
// Create a private message channel and use it to postMessage empty messages
// to ourselves.
/** @type {!Function|undefined} */
var Channel = goog.global['MessageChannel'];
// If MessageChannel is not available and we are in a browser, implement
// an iframe based polyfill in browsers that have postMessage and
// document.addEventListener. The latter excludes IE8 because it has a
// synchronous postMessage implementation.
if (typeof Channel === 'undefined' && typeof window !== 'undefined' &&
window.postMessage && window.addEventListener &&
// Presto (The old pre-blink Opera engine) has problems with iframes
// and contentWindow.
!goog.labs.userAgent.engine.isPresto()) {
/** @constructor */
Channel = function() {
'use strict';
// Make an empty, invisible iframe.
var iframe = goog.dom.createElement(goog.dom.TagName.IFRAME);
iframe.style.display = 'none';
document.documentElement.appendChild(iframe);
var win = iframe.contentWindow;
var doc = win.document;
doc.open();
doc.close();
// Do not post anything sensitive over this channel, as the workaround for
// pages with file: origin could allow that information to be modified or
// intercepted.
var message = 'callImmediate' + Math.random();
// The same origin policy rejects attempts to postMessage from file: urls
// unless the origin is '*'.
var origin = win.location.protocol == 'file:' ?
'*' :
win.location.protocol + '//' + win.location.host;
var onmessage = goog.bind(function(e) {
'use strict';
// Validate origin and message to make sure that this message was
// intended for us. If the origin is set to '*' (see above) only the
// message needs to match since, for example, '*' != 'file://'. Allowing
// the wildcard is ok, as we are not concerned with security here.
if ((origin != '*' && e.origin != origin) || e.data != message) {
return;
}
this['port1'].onmessage();
}, this);
win.addEventListener('message', onmessage, false);
this['port1'] = {};
this['port2'] = {
postMessage: function() {
'use strict';
win.postMessage(message, origin);
}
};
};
}
if (typeof Channel !== 'undefined' && !goog.labs.userAgent.browser.isIE()) {
// Exclude all of IE due to
// http://codeforhire.com/2013/09/21/setimmediate-and-messagechannel-broken-on-internet-explorer-10/
// which allows starving postMessage with a busy setTimeout loop.
// This currently affects IE10 and IE11 which would otherwise be able
// to use the postMessage based fallbacks.
var channel = new Channel();
// Use a fifo linked list to call callbacks in the right order.
var head = {};
var tail = head;
channel['port1'].onmessage = function() {
'use strict';
if (head.next !== undefined) {
head = head.next;
var cb = head.cb;
head.cb = null;
cb();
}
};
return function(cb) {
'use strict';
tail.next = {cb: cb};
tail = tail.next;
channel['port2'].postMessage(0);
};
}
// Fall back to setTimeout with 0. In browsers this creates a delay of 5ms
// or more.
// NOTE(user): This fallback is used for IE.
return function(cb) {
'use strict';
goog.global.setTimeout(/** @type {function()} */ (cb), 0);
};
};
/**
* Helper function that is overrided to protect callbacks with entry point
* monitor if the application monitors entry points.
* @param {function()} callback Callback function to fire as soon as possible.
* @return {function()} The wrapped callback.
* @private
*/
goog.async.nextTick.wrapCallback_ = goog.functions.identity;
// Register the callback function as an entry point, so that it can be
// monitored for exception handling, etc. This has to be done in this file
// since it requires special code to handle all browsers.
goog.debug.entryPointRegistry.register(
/**
* @param {function(!Function): !Function} transformer The transforming
* function.
*/
function(transformer) {
'use strict';
goog.async.nextTick.wrapCallback_ = transformer;
});

View File

@ -1,71 +0,0 @@
/*TRANSPILED*/goog.loadModule(function(exports) {'use strict';/*
Copyright The Closure Library Authors.
SPDX-License-Identifier: Apache-2.0
*/
'use strict';
goog.module("goog.async.run");
goog.module.declareLegacyNamespace();
const WorkQueue = goog.require("goog.async.WorkQueue");
const asyncStackTag = goog.require("goog.debug.asyncStackTag");
const nextTick = goog.require("goog.async.nextTick");
const throwException = goog.require("goog.async.throwException");
goog.ASSUME_NATIVE_PROMISE = goog.define("goog.ASSUME_NATIVE_PROMISE", false);
let schedule;
let workQueueScheduled = false;
let workQueue = new WorkQueue();
let run = (callback, context = undefined) => {
if (!schedule) {
initializeRunner();
}
if (!workQueueScheduled) {
schedule();
workQueueScheduled = true;
}
callback = asyncStackTag.wrap(callback, "goog.async.run");
workQueue.add(callback, context);
};
let initializeRunner = () => {
if (goog.ASSUME_NATIVE_PROMISE || goog.global.Promise && goog.global.Promise.resolve) {
const promise = goog.global.Promise.resolve(undefined);
schedule = () => {
promise.then(run.processWorkQueue);
};
} else {
schedule = () => {
nextTick(run.processWorkQueue);
};
}
};
run.forceNextTick = (realSetTimeout = undefined) => {
schedule = () => {
nextTick(run.processWorkQueue);
if (realSetTimeout) {
realSetTimeout(run.processWorkQueue);
}
};
};
if (goog.DEBUG) {
run.resetQueue = () => {
workQueueScheduled = false;
workQueue = new WorkQueue();
};
run.resetSchedulerForTest = () => {
initializeRunner();
};
}
run.processWorkQueue = () => {
let item = null;
while (item = workQueue.remove()) {
try {
item.fn.call(item.scope);
} catch (e) {
throwException(e);
}
workQueue.returnUnused(item);
}
workQueueScheduled = false;
};
exports = run;
;return exports;});

View File

@ -1,16 +0,0 @@
/*TRANSPILED*/goog.loadModule(function(exports) {'use strict';/*
Copyright The Closure Library Authors.
SPDX-License-Identifier: Apache-2.0
*/
'use strict';
goog.module("goog.async.throwException");
goog.module.declareLegacyNamespace();
function throwException(exception) {
goog.global.setTimeout(() => {
throw exception;
}, 0);
}
exports = throwException;
;return exports;});

View File

@ -1,68 +0,0 @@
/*TRANSPILED*/goog.loadModule(function(exports) {'use strict';/*
Copyright The Closure Library Authors.
SPDX-License-Identifier: Apache-2.0
*/
'use strict';
goog.module("goog.async.WorkQueue");
goog.module.declareLegacyNamespace();
const FreeList = goog.require("goog.async.FreeList");
const {assert} = goog.require("goog.asserts");
class WorkQueue {
constructor() {
this.workHead_ = null;
this.workTail_ = null;
}
add(fn, scope) {
const item = this.getUnusedItem_();
item.set(fn, scope);
if (this.workTail_) {
this.workTail_.next = item;
this.workTail_ = item;
} else {
assert(!this.workHead_);
this.workHead_ = item;
this.workTail_ = item;
}
}
remove() {
let item = null;
if (this.workHead_) {
item = this.workHead_;
this.workHead_ = this.workHead_.next;
if (!this.workHead_) {
this.workTail_ = null;
}
item.next = null;
}
return item;
}
returnUnused(item) {
WorkQueue.freelist_.put(item);
}
getUnusedItem_() {
return WorkQueue.freelist_.get();
}
}
WorkQueue.DEFAULT_MAX_UNUSED = goog.define("goog.async.WorkQueue.DEFAULT_MAX_UNUSED", 100);
WorkQueue.freelist_ = new FreeList(() => new WorkItem(), item => item.reset(), WorkQueue.DEFAULT_MAX_UNUSED);
class WorkItem {
constructor() {
this.fn = null;
this.scope = null;
this.next = null;
}
set(fn, scope) {
this.fn = fn;
this.scope = scope;
this.next = null;
}
reset() {
this.fn = null;
this.scope = null;
this.next = null;
}
}
exports = WorkQueue;
;return exports;});

File diff suppressed because it is too large Load Diff

View File

@ -1,80 +0,0 @@
/*TRANSPILED*/goog.loadModule(function(exports) {'use strict';/*
Copyright The Closure Library Authors.
SPDX-License-Identifier: Apache-2.0
*/
'use strict';
goog.module("goog.collections.maps");
goog.module.declareLegacyNamespace();
class MapLike {
constructor() {
this.size;
}
set(key, val) {
}
get(key) {
}
keys() {
}
values() {
}
has(key) {
}
}
exports.MapLike = MapLike;
function setAll(map, entries) {
if (!entries) {
return;
}
for (const [k, v] of entries) {
map.set(k, v);
}
}
exports.setAll = setAll;
function hasValue(map, val, valueEqualityFn = defaultEqualityFn) {
for (const v of map.values()) {
if (valueEqualityFn(v, val)) {
return true;
}
}
return false;
}
exports.hasValue = hasValue;
const defaultEqualityFn = (a, b) => a === b;
function equals(map, otherMap, valueEqualityFn = defaultEqualityFn) {
if (map === otherMap) {
return true;
}
if (map.size !== otherMap.size) {
return false;
}
for (const key of map.keys()) {
if (!otherMap.has(key)) {
return false;
}
if (!valueEqualityFn(map.get(key), otherMap.get(key))) {
return false;
}
}
return true;
}
exports.equals = equals;
function transpose(map) {
const transposed = new Map();
for (const key of map.keys()) {
const val = map.get(key);
transposed.set(val, key);
}
return transposed;
}
exports.transpose = transpose;
function toObject(map) {
const obj = {};
for (const key of map.keys()) {
obj[key] = map.get(key);
}
return obj;
}
exports.toObject = toObject;
;return exports;});

View File

@ -1,28 +0,0 @@
/*TRANSPILED*/goog.loadModule(function(exports) {'use strict';/*
Copyright The Closure Library Authors.
SPDX-License-Identifier: Apache-2.0
*/
'use strict';
goog.module("goog.debug.asyncStackTag");
goog.module.declareLegacyNamespace();
const {assertExists} = goog.require("goog.asserts");
const createTask = goog.DEBUG && goog.global.console && goog.global.console.createTask ? goog.global.console.createTask.bind(goog.global.console) : undefined;
const CONSOLE_TASK_SYMBOL = createTask ? Symbol("consoleTask") : undefined;
function wrap(fn, name = "anonymous") {
if (!goog.DEBUG || !createTask) {
return fn;
}
if (fn[assertExists(CONSOLE_TASK_SYMBOL)]) {
return fn;
}
const consoleTask = createTask(fn.name || name);
function wrappedFn(...args) {
return consoleTask["run"](() => fn.call(this, ...args));
}
wrappedFn[assertExists(CONSOLE_TASK_SYMBOL)] = consoleTask;
return wrappedFn;
}
exports = {wrap,};
;return exports;});

View File

@ -1,747 +0,0 @@
/**
* @license
* Copyright The Closure Library Authors.
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @fileoverview Logging and debugging utilities.
*
* @see ../demos/debug.html
*/
goog.provide('goog.debug');
goog.require('goog.array');
goog.require('goog.debug.errorcontext');
/** @define {boolean} Whether logging should be enabled. */
goog.debug.LOGGING_ENABLED =
goog.define('goog.debug.LOGGING_ENABLED', goog.DEBUG);
/** @define {boolean} Whether to force "sloppy" stack building. */
goog.debug.FORCE_SLOPPY_STACKS =
goog.define('goog.debug.FORCE_SLOPPY_STACKS', false);
/**
* @define {boolean} TODO(user): Remove this hack once bug is resolved.
*/
goog.debug.CHECK_FOR_THROWN_EVENT =
goog.define('goog.debug.CHECK_FOR_THROWN_EVENT', false);
/**
* Catches onerror events fired by windows and similar objects.
* @param {function(Object)} logFunc The function to call with the error
* information.
* @param {boolean=} opt_cancel Whether to stop the error from reaching the
* browser.
* @param {Object=} opt_target Object that fires onerror events.
* @suppress {strictMissingProperties} onerror is not defined as a property
* on Object.
*/
goog.debug.catchErrors = function(logFunc, opt_cancel, opt_target) {
'use strict';
var target = opt_target || goog.global;
var oldErrorHandler = target.onerror;
var retVal = !!opt_cancel;
/**
* New onerror handler for this target. This onerror handler follows the spec
* according to
* http://www.whatwg.org/specs/web-apps/current-work/#runtime-script-errors
* The spec was changed in August 2013 to support receiving column information
* and an error object for all scripts on the same origin or cross origin
* scripts with the proper headers. See
* https://mikewest.org/2013/08/debugging-runtime-errors-with-window-onerror
*
* @param {string} message The error message. For cross-origin errors, this
* will be scrubbed to just "Script error.". For new browsers that have
* updated to follow the latest spec, errors that come from origins that
* have proper cross origin headers will not be scrubbed.
* @param {string} url The URL of the script that caused the error. The URL
* will be scrubbed to "" for cross origin scripts unless the script has
* proper cross origin headers and the browser has updated to the latest
* spec.
* @param {number} line The line number in the script that the error
* occurred on.
* @param {number=} opt_col The optional column number that the error
* occurred on. Only browsers that have updated to the latest spec will
* include this.
* @param {Error=} opt_error The optional actual error object for this
* error that should include the stack. Only browsers that have updated
* to the latest spec will inlude this parameter.
* @return {boolean} Whether to prevent the error from reaching the browser.
*/
target.onerror = function(message, url, line, opt_col, opt_error) {
'use strict';
if (oldErrorHandler) {
oldErrorHandler(message, url, line, opt_col, opt_error);
}
logFunc({
message: message,
fileName: url,
line: line,
lineNumber: line,
col: opt_col,
error: opt_error
});
return retVal;
};
};
/**
* Creates a string representing an object and all its properties.
* @param {Object|null|undefined} obj Object to expose.
* @param {boolean=} opt_showFn Show the functions as well as the properties,
* default is false.
* @return {string} The string representation of `obj`.
*/
goog.debug.expose = function(obj, opt_showFn) {
'use strict';
if (typeof obj == 'undefined') {
return 'undefined';
}
if (obj == null) {
return 'NULL';
}
var str = [];
for (var x in obj) {
if (!opt_showFn && typeof obj[x] === 'function') {
continue;
}
var s = x + ' = ';
try {
s += obj[x];
} catch (e) {
s += '*** ' + e + ' ***';
}
str.push(s);
}
return str.join('\n');
};
/**
* Creates a string representing a given primitive or object, and for an
* object, all its properties and nested objects. NOTE: The output will include
* Uids on all objects that were exposed. Any added Uids will be removed before
* returning.
* @param {*} obj Object to expose.
* @param {boolean=} opt_showFn Also show properties that are functions (by
* default, functions are omitted).
* @return {string} A string representation of `obj`.
*/
goog.debug.deepExpose = function(obj, opt_showFn) {
'use strict';
var str = [];
// Track any objects where deepExpose added a Uid, so they can be cleaned up
// before return. We do this globally, rather than only on ancestors so that
// if the same object appears in the output, you can see it.
var uidsToCleanup = [];
var ancestorUids = {};
var helper = function(obj, space) {
'use strict';
var nestspace = space + ' ';
var indentMultiline = function(str) {
'use strict';
return str.replace(/\n/g, '\n' + space);
};
try {
if (obj === undefined) {
str.push('undefined');
} else if (obj === null) {
str.push('NULL');
} else if (typeof obj === 'string') {
str.push('"' + indentMultiline(obj) + '"');
} else if (typeof obj === 'function') {
str.push(indentMultiline(String(obj)));
} else if (goog.isObject(obj)) {
// Add a Uid if needed. The struct calls implicitly adds them.
if (!goog.hasUid(obj)) {
uidsToCleanup.push(obj);
}
var uid = goog.getUid(obj);
if (ancestorUids[uid]) {
str.push('*** reference loop detected (id=' + uid + ') ***');
} else {
ancestorUids[uid] = true;
str.push('{');
for (var x in obj) {
if (!opt_showFn && typeof obj[x] === 'function') {
continue;
}
str.push('\n');
str.push(nestspace);
str.push(x + ' = ');
helper(obj[x], nestspace);
}
str.push('\n' + space + '}');
delete ancestorUids[uid];
}
} else {
str.push(obj);
}
} catch (e) {
str.push('*** ' + e + ' ***');
}
};
helper(obj, '');
// Cleanup any Uids that were added by the deepExpose.
for (var i = 0; i < uidsToCleanup.length; i++) {
goog.removeUid(uidsToCleanup[i]);
}
return str.join('');
};
/**
* Recursively outputs a nested array as a string.
* @param {Array<?>} arr The array.
* @return {string} String representing nested array.
*/
goog.debug.exposeArray = function(arr) {
'use strict';
var str = [];
for (var i = 0; i < arr.length; i++) {
if (Array.isArray(arr[i])) {
str.push(goog.debug.exposeArray(arr[i]));
} else {
str.push(arr[i]);
}
}
return '[ ' + str.join(', ') + ' ]';
};
/**
* Normalizes the error/exception object between browsers.
* @param {*} err Raw error object.
* @return {{
* message: (?|undefined),
* name: (?|undefined),
* lineNumber: (?|undefined),
* fileName: (?|undefined),
* stack: (?|undefined)
* }} Representation of err as an Object. It will never return err.
* @suppress {strictMissingProperties} properties not defined on err
*/
goog.debug.normalizeErrorObject = function(err) {
'use strict';
var href = goog.getObjectByName('window.location.href');
if (err == null) {
err = 'Unknown Error of type "null/undefined"';
}
if (typeof err === 'string') {
return {
'message': err,
'name': 'Unknown error',
'lineNumber': 'Not available',
'fileName': href,
'stack': 'Not available'
};
}
var lineNumber, fileName;
var threwError = false;
try {
lineNumber = err.lineNumber || err.line || 'Not available';
} catch (e) {
// Firefox 2 sometimes throws an error when accessing 'lineNumber':
// Message: Permission denied to get property UnnamedClass.lineNumber
lineNumber = 'Not available';
threwError = true;
}
try {
fileName = err.fileName || err.filename || err.sourceURL ||
// $googDebugFname may be set before a call to eval to set the filename
// that the eval is supposed to present.
goog.global['$googDebugFname'] || href;
} catch (e) {
// Firefox 2 may also throw an error when accessing 'filename'.
fileName = 'Not available';
threwError = true;
}
var stack = goog.debug.serializeErrorStack_(err);
// The IE Error object contains only the name and the message.
// The Safari Error object uses the line and sourceURL fields.
if (threwError || !err.lineNumber || !err.fileName || !err.stack ||
!err.message || !err.name) {
var message = err.message;
if (message == null) {
if (err.constructor && err.constructor instanceof Function) {
var ctorName = err.constructor.name ?
err.constructor.name :
goog.debug.getFunctionName(err.constructor);
message = 'Unknown Error of type "' + ctorName + '"';
// TODO(user): Remove this hack once bug is resolved.
if (goog.debug.CHECK_FOR_THROWN_EVENT && ctorName == 'Event') {
try {
message = message + ' with Event.type "' + (err.type || '') + '"';
} catch (e) {
// Just give up on getting more information out of the error object.
}
}
} else {
message = 'Unknown Error of unknown type';
}
// Avoid TypeError since toString could be missing from the instance
// (e.g. if created Object.create(null)).
if (typeof err.toString === 'function' &&
Object.prototype.toString !== err.toString) {
message += ': ' + err.toString();
}
}
return {
'message': message,
'name': err.name || 'UnknownError',
'lineNumber': lineNumber,
'fileName': fileName,
'stack': stack || 'Not available'
};
}
// Standards error object
// Typed !Object. Should be a subtype of the return type, but it's not.
err.stack = stack;
// Return non-standard error to allow for consistent result (eg. enumerable).
return {
'message': err.message,
'name': err.name,
'lineNumber': err.lineNumber,
'fileName': err.fileName,
'stack': err.stack
};
};
/**
* Serialize stack by including the cause chain of the exception if it exists.
*
*
* @param {*} e an exception that may have a cause
* @param {!Object=} seen set of cause that have already been serialized
* @return {string}
* @private
* @suppress {missingProperties} properties not defined on cause and e
*/
goog.debug.serializeErrorStack_ = function(e, seen) {
'use strict';
if (!seen) {
seen = {};
}
seen[goog.debug.serializeErrorAsKey_(e)] = true;
var stack = e['stack'] || '';
// Add cause if exists.
var cause = e.cause;
if (cause && !seen[goog.debug.serializeErrorAsKey_(cause)]) {
stack += '\nCaused by: ';
// Some browsers like Chrome add the error message as the first frame of the
// stack, In this case we don't need to add it. Note: we don't use
// String.startsWith method because it might have to be polyfilled.
if (!cause.stack || cause.stack.indexOf(cause.toString()) != 0) {
stack += (typeof cause === 'string') ? cause : cause.message + '\n';
}
stack += goog.debug.serializeErrorStack_(cause, seen);
}
return stack;
};
/**
* Serialize an error to a string key.
* @param {*} e an exception
* @return {string}
* @private
*/
goog.debug.serializeErrorAsKey_ = function(e) {
'use strict';
var keyPrefix = '';
if (typeof e.toString === 'function') {
keyPrefix = '' + e;
}
return keyPrefix + e['stack'];
};
/**
* Converts an object to an Error using the object's toString if it's not
* already an Error, adds a stacktrace if there isn't one, and optionally adds
* an extra message.
* @param {*} err The original thrown error, object, or string.
* @param {string=} opt_message optional additional message to add to the
* error.
* @return {!Error} If err is an Error, it is enhanced and returned. Otherwise,
* it is converted to an Error which is enhanced and returned.
*/
goog.debug.enhanceError = function(err, opt_message) {
'use strict';
var error;
if (!(err instanceof Error)) {
error = Error(err);
if (Error.captureStackTrace) {
// Trim this function off the call stack, if we can.
Error.captureStackTrace(error, goog.debug.enhanceError);
}
} else {
error = err;
}
if (!error.stack) {
error.stack = goog.debug.getStacktrace(goog.debug.enhanceError);
}
if (opt_message) {
// find the first unoccupied 'messageX' property
var x = 0;
while (error['message' + x]) {
++x;
}
error['message' + x] = String(opt_message);
}
return error;
};
/**
* Converts an object to an Error using the object's toString if it's not
* already an Error, adds a stacktrace if there isn't one, and optionally adds
* context to the Error, which is reported by the closure error reporter.
* @param {*} err The original thrown error, object, or string.
* @param {!Object<string, string>=} opt_context Key-value context to add to the
* Error.
* @return {!Error} If err is an Error, it is enhanced and returned. Otherwise,
* it is converted to an Error which is enhanced and returned.
*/
goog.debug.enhanceErrorWithContext = function(err, opt_context) {
'use strict';
var error = goog.debug.enhanceError(err);
if (opt_context) {
for (var key in opt_context) {
goog.debug.errorcontext.addErrorContext(error, key, opt_context[key]);
}
}
return error;
};
/**
* Gets the current stack trace. Simple and iterative - doesn't worry about
* catching circular references or getting the args.
* @param {number=} opt_depth Optional maximum depth to trace back to.
* @return {string} A string with the function names of all functions in the
* stack, separated by \n.
* @suppress {es5Strict}
*/
goog.debug.getStacktraceSimple = function(opt_depth) {
'use strict';
if (!goog.debug.FORCE_SLOPPY_STACKS) {
var stack = goog.debug.getNativeStackTrace_(goog.debug.getStacktraceSimple);
if (stack) {
return stack;
}
// NOTE: browsers that have strict mode support also have native "stack"
// properties. Fall-through for legacy browser support.
}
var sb = [];
var fn = arguments.callee.caller;
var depth = 0;
while (fn && (!opt_depth || depth < opt_depth)) {
sb.push(goog.debug.getFunctionName(fn));
sb.push('()\n');
try {
fn = fn.caller;
} catch (e) {
sb.push('[exception trying to get caller]\n');
break;
}
depth++;
if (depth >= goog.debug.MAX_STACK_DEPTH) {
sb.push('[...long stack...]');
break;
}
}
if (opt_depth && depth >= opt_depth) {
sb.push('[...reached max depth limit...]');
} else {
sb.push('[end]');
}
return sb.join('');
};
/**
* Max length of stack to try and output
* @type {number}
*/
goog.debug.MAX_STACK_DEPTH = 50;
/**
* @param {Function} fn The function to start getting the trace from.
* @return {?string}
* @private
*/
goog.debug.getNativeStackTrace_ = function(fn) {
'use strict';
var tempErr = new Error();
if (Error.captureStackTrace) {
Error.captureStackTrace(tempErr, fn);
return String(tempErr.stack);
} else {
// IE10, only adds stack traces when an exception is thrown.
try {
throw tempErr;
} catch (e) {
tempErr = e;
}
var stack = tempErr.stack;
if (stack) {
return String(stack);
}
}
return null;
};
/**
* Gets the current stack trace, either starting from the caller or starting
* from a specified function that's currently on the call stack.
* @param {?Function=} fn If provided, when collecting the stack trace all
* frames above the topmost call to this function, including that call,
* will be left out of the stack trace.
* @return {string} Stack trace.
* @suppress {es5Strict}
*/
goog.debug.getStacktrace = function(fn) {
'use strict';
var stack;
if (!goog.debug.FORCE_SLOPPY_STACKS) {
// Try to get the stack trace from the environment if it is available.
var contextFn = fn || goog.debug.getStacktrace;
stack = goog.debug.getNativeStackTrace_(contextFn);
}
if (!stack) {
// NOTE: browsers that have strict mode support also have native "stack"
// properties. This function will throw in strict mode.
stack = goog.debug.getStacktraceHelper_(fn || arguments.callee.caller, []);
}
return stack;
};
/**
* Private helper for getStacktrace().
* @param {?Function} fn If provided, when collecting the stack trace all
* frames above the topmost call to this function, including that call,
* will be left out of the stack trace.
* @param {Array<!Function>} visited List of functions visited so far.
* @return {string} Stack trace starting from function fn.
* @suppress {es5Strict}
* @private
*/
goog.debug.getStacktraceHelper_ = function(fn, visited) {
'use strict';
var sb = [];
// Circular reference, certain functions like bind seem to cause a recursive
// loop so we need to catch circular references
if (goog.array.contains(visited, fn)) {
sb.push('[...circular reference...]');
// Traverse the call stack until function not found or max depth is reached
} else if (fn && visited.length < goog.debug.MAX_STACK_DEPTH) {
sb.push(goog.debug.getFunctionName(fn) + '(');
var args = fn.arguments;
// Args may be null for some special functions such as host objects or eval.
for (var i = 0; args && i < args.length; i++) {
if (i > 0) {
sb.push(', ');
}
var argDesc;
var arg = args[i];
switch (typeof arg) {
case 'object':
argDesc = arg ? 'object' : 'null';
break;
case 'string':
argDesc = arg;
break;
case 'number':
argDesc = String(arg);
break;
case 'boolean':
argDesc = arg ? 'true' : 'false';
break;
case 'function':
argDesc = goog.debug.getFunctionName(arg);
argDesc = argDesc ? argDesc : '[fn]';
break;
case 'undefined':
default:
argDesc = typeof arg;
break;
}
if (argDesc.length > 40) {
argDesc = argDesc.slice(0, 40) + '...';
}
sb.push(argDesc);
}
visited.push(fn);
sb.push(')\n');
try {
sb.push(goog.debug.getStacktraceHelper_(fn.caller, visited));
} catch (e) {
sb.push('[exception trying to get caller]\n');
}
} else if (fn) {
sb.push('[...long stack...]');
} else {
sb.push('[end]');
}
return sb.join('');
};
/**
* Gets a function name
* @param {Function} fn Function to get name of.
* @return {string} Function's name.
*/
goog.debug.getFunctionName = function(fn) {
'use strict';
if (goog.debug.fnNameCache_[fn]) {
return goog.debug.fnNameCache_[fn];
}
// Heuristically determine function name based on code.
var functionSource = String(fn);
if (!goog.debug.fnNameCache_[functionSource]) {
var matches = /function\s+([^\(]+)/m.exec(functionSource);
if (matches) {
var method = matches[1];
goog.debug.fnNameCache_[functionSource] = method;
} else {
goog.debug.fnNameCache_[functionSource] = '[Anonymous]';
}
}
return goog.debug.fnNameCache_[functionSource];
};
/**
* Makes whitespace visible by replacing it with printable characters.
* This is useful in finding diffrences between the expected and the actual
* output strings of a testcase.
* @param {string} string whose whitespace needs to be made visible.
* @return {string} string whose whitespace is made visible.
*/
goog.debug.makeWhitespaceVisible = function(string) {
'use strict';
return string.replace(/ /g, '[_]')
.replace(/\f/g, '[f]')
.replace(/\n/g, '[n]\n')
.replace(/\r/g, '[r]')
.replace(/\t/g, '[t]');
};
/**
* Returns the type of a value. If a constructor is passed, and a suitable
* string cannot be found, 'unknown type name' will be returned.
*
* <p>Forked rather than moved from {@link goog.asserts.getType_}
* to avoid adding a dependency to goog.asserts.
* @param {*} value A constructor, object, or primitive.
* @return {string} The best display name for the value, or 'unknown type name'.
*/
goog.debug.runtimeType = function(value) {
'use strict';
if (value instanceof Function) {
return value.displayName || value.name || 'unknown type name';
} else if (value instanceof Object) {
return /** @type {string} */ (value.constructor.displayName) ||
value.constructor.name || Object.prototype.toString.call(value);
} else {
return value === null ? 'null' : typeof value;
}
};
/**
* Hash map for storing function names that have already been looked up.
* @type {Object}
* @private
*/
goog.debug.fnNameCache_ = {};
/**
* Private internal function to support goog.debug.freeze.
* @param {T} arg
* @return {T}
* @template T
* @private
*/
goog.debug.freezeInternal_ = goog.DEBUG && Object.freeze || function(arg) {
'use strict';
return arg;
};
/**
* Freezes the given object, but only in debug mode (and in browsers that
* support it). Note that this is a shallow freeze, so for deeply nested
* objects it must be called at every level to ensure deep immutability.
* @param {T} arg
* @return {T}
* @template T
*/
goog.debug.freeze = function(arg) {
'use strict';
// NOTE: this compiles to nothing, but hides the possible side effect of
// freezeInternal_ from the compiler so that the entire call can be
// removed if the result is not used.
return {
valueOf: function() {
'use strict';
return goog.debug.freezeInternal_(arg);
}
}.valueOf();
};

View File

@ -1,158 +0,0 @@
/**
* @license
* Copyright The Closure Library Authors.
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @fileoverview A global registry for entry points into a program,
* so that they can be instrumented. Each module should register their
* entry points with this registry. Designed to be compiled out
* if no instrumentation is requested.
*
* Entry points may be registered before or after a call to
* goog.debug.entryPointRegistry.monitorAll. If an entry point is registered
* later, the existing monitor will instrument the new entry point.
*/
goog.provide('goog.debug.EntryPointMonitor');
goog.provide('goog.debug.entryPointRegistry');
goog.require('goog.asserts');
/**
* @interface
*/
goog.debug.entryPointRegistry.EntryPointMonitor = function() {};
/**
* Instruments a function.
*
* @param {!Function} fn A function to instrument.
* @return {!Function} The instrumented function.
*/
goog.debug.entryPointRegistry.EntryPointMonitor.prototype.wrap;
/**
* Try to remove an instrumentation wrapper created by this monitor.
* If the function passed to unwrap is not a wrapper created by this
* monitor, then we will do nothing.
*
* Notice that some wrappers may not be unwrappable. For example, if other
* monitors have applied their own wrappers, then it will be impossible to
* unwrap them because their wrappers will have captured our wrapper.
*
* So it is important that entry points are unwrapped in the reverse
* order that they were wrapped.
*
* @param {!Function} fn A function to unwrap.
* @return {!Function} The unwrapped function, or `fn` if it was not
* a wrapped function created by this monitor.
*/
goog.debug.entryPointRegistry.EntryPointMonitor.prototype.unwrap;
/**
* Alias for goog.debug.entryPointRegistry.EntryPointMonitor, for compatibility
* purposes.
* @const
*/
goog.debug.EntryPointMonitor = goog.debug.entryPointRegistry.EntryPointMonitor;
/**
* An array of entry point callbacks.
* @type {!Array<function(!Function)>}
* @private
*/
goog.debug.entryPointRegistry.refList_ = [];
/**
* Monitors that should wrap all the entry points.
* @type {!Array<!goog.debug.EntryPointMonitor>}
* @private
*/
goog.debug.entryPointRegistry.monitors_ = [];
/**
* Whether goog.debug.entryPointRegistry.monitorAll has ever been called.
* Checking this allows the compiler to optimize out the registrations.
* @type {boolean}
* @private
*/
goog.debug.entryPointRegistry.monitorsMayExist_ = false;
/**
* Register an entry point with this module.
*
* The entry point will be instrumented when a monitor is passed to
* goog.debug.entryPointRegistry.monitorAll. If this has already occurred, the
* entry point is instrumented immediately.
*
* @param {function(!Function)} callback A callback function which is called
* with a transforming function to instrument the entry point. The callback
* is responsible for wrapping the relevant entry point with the
* transforming function.
*/
goog.debug.entryPointRegistry.register = function(callback) {
'use strict';
// Don't use push(), so that this can be compiled out.
goog.debug.entryPointRegistry
.refList_[goog.debug.entryPointRegistry.refList_.length] = callback;
// If no one calls monitorAll, this can be compiled out.
if (goog.debug.entryPointRegistry.monitorsMayExist_) {
var monitors = goog.debug.entryPointRegistry.monitors_;
for (var i = 0; i < monitors.length; i++) {
callback(goog.bind(monitors[i].wrap, monitors[i]));
}
}
};
/**
* Configures a monitor to wrap all entry points.
*
* Entry points that have already been registered are immediately wrapped by
* the monitor. When an entry point is registered in the future, it will also
* be wrapped by the monitor when it is registered.
*
* @param {!goog.debug.EntryPointMonitor} monitor An entry point monitor.
*/
goog.debug.entryPointRegistry.monitorAll = function(monitor) {
'use strict';
goog.debug.entryPointRegistry.monitorsMayExist_ = true;
var transformer = goog.bind(monitor.wrap, monitor);
for (var i = 0; i < goog.debug.entryPointRegistry.refList_.length; i++) {
goog.debug.entryPointRegistry.refList_[i](transformer);
}
goog.debug.entryPointRegistry.monitors_.push(monitor);
};
/**
* Try to unmonitor all the entry points that have already been registered. If
* an entry point is registered in the future, it will not be wrapped by the
* monitor when it is registered. Note that this may fail if the entry points
* have additional wrapping.
*
* @param {!goog.debug.EntryPointMonitor} monitor The last monitor to wrap
* the entry points.
* @throws {Error} If the monitor is not the most recently configured monitor.
*/
goog.debug.entryPointRegistry.unmonitorAllIfPossible = function(monitor) {
'use strict';
var monitors = goog.debug.entryPointRegistry.monitors_;
goog.asserts.assert(
monitor == monitors[monitors.length - 1],
'Only the most recent monitor can be unwrapped.');
var transformer = goog.bind(monitor.unwrap, monitor);
for (var i = 0; i < goog.debug.entryPointRegistry.refList_.length; i++) {
goog.debug.entryPointRegistry.refList_[i](transformer);
}
monitors.length--;
};

View File

@ -1,30 +0,0 @@
/*TRANSPILED*/goog.loadModule(function(exports) {'use strict';/*
Copyright The Closure Library Authors.
SPDX-License-Identifier: Apache-2.0
*/
'use strict';
goog.module("goog.debug.Error");
goog.module.declareLegacyNamespace();
function DebugError(msg = undefined, cause = undefined) {
if (Error.captureStackTrace) {
Error.captureStackTrace(this, DebugError);
} else {
const stack = (new Error()).stack;
if (stack) {
this.stack = stack;
}
}
if (msg) {
this.message = String(msg);
}
if (cause !== undefined) {
this.cause = cause;
}
this.reportErrorToServer = true;
}
goog.inherits(DebugError, Error);
DebugError.prototype.name = "CustomError";
exports = DebugError;
;return exports;});

View File

@ -1,43 +0,0 @@
/**
* @license
* Copyright The Closure Library Authors.
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @fileoverview Provides methods dealing with context on error objects.
*/
goog.provide('goog.debug.errorcontext');
/**
* Adds key-value context to the error.
* @param {!Error} err The error to add context to.
* @param {string} contextKey Key for the context to be added.
* @param {string} contextValue Value for the context to be added.
*/
goog.debug.errorcontext.addErrorContext = function(
err, contextKey, contextValue) {
'use strict';
if (!err[goog.debug.errorcontext.CONTEXT_KEY_]) {
err[goog.debug.errorcontext.CONTEXT_KEY_] = {};
}
err[goog.debug.errorcontext.CONTEXT_KEY_][contextKey] = contextValue;
};
/**
* @param {!Error} err The error to get context from.
* @return {!Object<string, string>} The context of the provided error.
*/
goog.debug.errorcontext.getErrorContext = function(err) {
'use strict';
return err[goog.debug.errorcontext.CONTEXT_KEY_] || {};
};
// TODO(user): convert this to a Symbol once goog.debug.ErrorReporter is
// able to use ES6.
/** @private @const {string} */
goog.debug.errorcontext.CONTEXT_KEY_ = '__closure__error__context__984382';

View File

@ -1,152 +0,0 @@
/*TRANSPILED*//*
Copyright The Closure Library Authors.
SPDX-License-Identifier: Apache-2.0
*/
'use strict';
goog.provide("goog.debug.ErrorHandler");
goog.provide("goog.debug.ErrorHandler.ProtectedFunctionError");
goog.require("goog.Disposable");
goog.require("goog.asserts");
goog.require("goog.debug.EntryPointMonitor");
goog.require("goog.debug.Error");
goog.debug.ErrorHandler = function(handler) {
goog.debug.ErrorHandler.base(this, "constructor");
this.errorHandlerFn_ = handler;
this.wrapErrors_ = true;
this.prefixErrorMessages_ = false;
};
goog.inherits(goog.debug.ErrorHandler, goog.Disposable);
goog.debug.ErrorHandler.prototype.wrap = function(fn) {
return this.protectEntryPoint(goog.asserts.assertFunction(fn));
};
goog.debug.ErrorHandler.prototype.unwrap = function(fn) {
goog.asserts.assertFunction(fn);
return fn[this.getFunctionIndex_(false)] || fn;
};
goog.debug.ErrorHandler.prototype.getFunctionIndex_ = function(wrapper) {
return (wrapper ? "__wrapper_" : "__protected_") + goog.getUid(this) + "__";
};
goog.debug.ErrorHandler.prototype.protectEntryPoint = function(fn) {
var protectedFnName = this.getFunctionIndex_(true);
if (!fn[protectedFnName]) {
var wrapper = fn[protectedFnName] = this.getProtectedFunction(fn);
wrapper[this.getFunctionIndex_(false)] = fn;
}
return fn[protectedFnName];
};
goog.debug.ErrorHandler.prototype.getProtectedFunction = function(fn) {
var that = this;
var googDebugErrorHandlerProtectedFunction = function() {
var self = this;
if (that.isDisposed()) {
return fn.apply(self, arguments);
}
try {
return fn.apply(self, arguments);
} catch (e) {
that.handleError_(e);
}
};
googDebugErrorHandlerProtectedFunction[this.getFunctionIndex_(false)] = fn;
return googDebugErrorHandlerProtectedFunction;
};
goog.debug.ErrorHandler.prototype.handleError_ = function(e) {
var MESSAGE_PREFIX = goog.debug.ErrorHandler.ProtectedFunctionError.MESSAGE_PREFIX;
if (e && typeof e === "object" && typeof e.message === "string" && e.message.indexOf(MESSAGE_PREFIX) == 0 || typeof e === "string" && e.indexOf(MESSAGE_PREFIX) == 0) {
return;
}
this.errorHandlerFn_(e);
if (!this.wrapErrors_) {
if (this.prefixErrorMessages_) {
if (typeof e === "object" && e && typeof e.message === "string") {
e.message = MESSAGE_PREFIX + e.message;
} else {
e = MESSAGE_PREFIX + e;
}
}
if (goog.DEBUG) {
if (e && typeof e.stack === "string" && Error.captureStackTrace && goog.global["console"]) {
goog.global["console"]["error"](e.message, e.stack);
}
}
throw e;
}
throw new goog.debug.ErrorHandler.ProtectedFunctionError(e);
};
goog.debug.ErrorHandler.prototype.protectWindowSetTimeout = function() {
this.protectWindowFunctionsHelper_("setTimeout");
};
goog.debug.ErrorHandler.prototype.protectWindowSetInterval = function() {
this.protectWindowFunctionsHelper_("setInterval");
};
goog.debug.ErrorHandler.prototype.catchUnhandledRejections = function(win) {
win = win || goog.global["window"] || goog.global["globalThis"];
if ("onunhandledrejection" in win) {
win.onunhandledrejection = event => {
const e = event && event.reason ? event.reason : new Error("uncaught error");
this.handleError_(e);
};
}
};
goog.debug.ErrorHandler.prototype.protectWindowRequestAnimationFrame = function() {
const win = goog.global["window"] || goog.global["globalThis"];
var fnNames = ["requestAnimationFrame", "mozRequestAnimationFrame", "webkitAnimationFrame", "msRequestAnimationFrame"];
for (var i = 0; i < fnNames.length; i++) {
var fnName = fnNames[i];
if (fnNames[i] in win) {
this.protectWindowFunctionsHelper_(fnName);
}
}
};
goog.debug.ErrorHandler.prototype.protectWindowFunctionsHelper_ = function(fnName) {
const win = goog.global["window"] || goog.global["globalThis"];
var originalFn = win[fnName];
if (!originalFn) {
throw new Error(fnName + " not on global?");
}
var that = this;
win[fnName] = function(fn, time) {
if (typeof fn === "string") {
fn = goog.partial(goog.globalEval, fn);
}
if (fn) {
arguments[0] = fn = that.protectEntryPoint(fn);
}
if (originalFn.apply) {
return originalFn.apply(this, arguments);
} else {
var callback = fn;
if (arguments.length > 2) {
var args = Array.prototype.slice.call(arguments, 2);
callback = function() {
fn.apply(this, args);
};
}
return originalFn(callback, time);
}
};
win[fnName][this.getFunctionIndex_(false)] = originalFn;
};
goog.debug.ErrorHandler.prototype.setWrapErrors = function(wrapErrors) {
this.wrapErrors_ = wrapErrors;
};
goog.debug.ErrorHandler.prototype.setPrefixErrorMessages = function(prefixErrorMessages) {
this.prefixErrorMessages_ = prefixErrorMessages;
};
goog.debug.ErrorHandler.prototype.disposeInternal = function() {
const win = goog.global["window"] || goog.global["globalThis"];
win.setTimeout = this.unwrap(win.setTimeout);
win.setInterval = this.unwrap(win.setInterval);
goog.debug.ErrorHandler.base(this, "disposeInternal");
};
goog.debug.ErrorHandler.ProtectedFunctionError = function(cause) {
var message = goog.debug.ErrorHandler.ProtectedFunctionError.MESSAGE_PREFIX + (cause && cause.message ? String(cause.message) : String(cause));
goog.debug.ErrorHandler.ProtectedFunctionError.base(this, "constructor", message, cause);
var stack = cause && cause.stack;
if (stack && typeof stack === "string") {
this.stack = stack;
}
};
goog.inherits(goog.debug.ErrorHandler.ProtectedFunctionError, goog.debug.Error);
goog.debug.ErrorHandler.ProtectedFunctionError.MESSAGE_PREFIX = "Error in protected function: ";

File diff suppressed because one or more lines are too long

View File

@ -1,285 +0,0 @@
/**
* @license
* Copyright The Closure Library Authors.
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @fileoverview Implements the disposable interface.
*/
goog.provide('goog.Disposable');
goog.require('goog.disposable.IDisposable');
goog.require('goog.dispose');
/**
* TODO(user): Remove this require.
* @suppress {extraRequire}
*/
goog.require('goog.disposeAll');
/**
* Class that provides the basic implementation for disposable objects. If your
* class holds references or resources that can't be collected by standard GC,
* it should extend this class or implement the disposable interface (defined
* in goog.disposable.IDisposable). See description of
* goog.disposable.IDisposable for examples of cleanup.
* @constructor
* @implements {goog.disposable.IDisposable}
*/
goog.Disposable = function() {
'use strict';
/**
* If monitoring the goog.Disposable instances is enabled, stores the creation
* stack trace of the Disposable instance.
* @type {string|undefined}
*/
this.creationStack;
if (goog.Disposable.MONITORING_MODE != goog.Disposable.MonitoringMode.OFF) {
if (goog.Disposable.INCLUDE_STACK_ON_CREATION) {
this.creationStack = new Error().stack;
}
goog.Disposable.instances_[goog.getUid(this)] = this;
}
// Support sealing
this.disposed_ = this.disposed_;
this.onDisposeCallbacks_ = this.onDisposeCallbacks_;
};
/**
* @enum {number} Different monitoring modes for Disposable.
*/
goog.Disposable.MonitoringMode = {
/**
* No monitoring.
*/
OFF: 0,
/**
* Creating and disposing the goog.Disposable instances is monitored. All
* disposable objects need to call the `goog.Disposable` base
* constructor. The PERMANENT mode must be switched on before creating any
* goog.Disposable instances.
*/
PERMANENT: 1,
/**
* INTERACTIVE mode can be switched on and off on the fly without producing
* errors. It also doesn't warn if the disposable objects don't call the
* `goog.Disposable` base constructor.
*/
INTERACTIVE: 2
};
/**
* @define {number} The monitoring mode of the goog.Disposable
* instances. Default is OFF. Switching on the monitoring is only
* recommended for debugging because it has a significant impact on
* performance and memory usage. If switched off, the monitoring code
* compiles down to 0 bytes.
*/
goog.Disposable.MONITORING_MODE =
goog.define('goog.Disposable.MONITORING_MODE', 0);
/**
* @define {boolean} Whether to attach creation stack to each created disposable
* instance; This is only relevant for when MonitoringMode != OFF.
*/
goog.Disposable.INCLUDE_STACK_ON_CREATION =
goog.define('goog.Disposable.INCLUDE_STACK_ON_CREATION', true);
/**
* Maps the unique ID of every undisposed `goog.Disposable` object to
* the object itself.
* @type {!Object<number, !goog.Disposable>}
* @private
*/
goog.Disposable.instances_ = {};
/**
* @return {!Array<!goog.Disposable>} All `goog.Disposable` objects that
* haven't been disposed of.
*/
goog.Disposable.getUndisposedObjects = function() {
'use strict';
var ret = [];
for (var id in goog.Disposable.instances_) {
if (goog.Disposable.instances_.hasOwnProperty(id)) {
ret.push(goog.Disposable.instances_[Number(id)]);
}
}
return ret;
};
/**
* Clears the registry of undisposed objects but doesn't dispose of them.
*/
goog.Disposable.clearUndisposedObjects = function() {
'use strict';
goog.Disposable.instances_ = {};
};
/**
* Whether the object has been disposed of.
* @type {boolean}
* @private
*/
goog.Disposable.prototype.disposed_ = false;
/**
* Callbacks to invoke when this object is disposed.
* @type {Array<!Function>}
* @private
*/
goog.Disposable.prototype.onDisposeCallbacks_;
/**
* @return {boolean} Whether the object has been disposed of.
* @override
*/
goog.Disposable.prototype.isDisposed = function() {
'use strict';
return this.disposed_;
};
/**
* @return {boolean} Whether the object has been disposed of.
* @deprecated Use {@link #isDisposed} instead.
*/
goog.Disposable.prototype.getDisposed = goog.Disposable.prototype.isDisposed;
/**
* Disposes of the object. If the object hasn't already been disposed of, calls
* {@link #disposeInternal}. Classes that extend `goog.Disposable` should
* override {@link #disposeInternal} in order to cleanup references, resources
* and other disposable objects. Reentrant.
*
* @return {void} Nothing.
* @override
*/
goog.Disposable.prototype.dispose = function() {
'use strict';
if (!this.disposed_) {
// Set disposed_ to true first, in case during the chain of disposal this
// gets disposed recursively.
this.disposed_ = true;
this.disposeInternal();
if (goog.Disposable.MONITORING_MODE != goog.Disposable.MonitoringMode.OFF) {
var uid = goog.getUid(this);
if (goog.Disposable.MONITORING_MODE ==
goog.Disposable.MonitoringMode.PERMANENT &&
!goog.Disposable.instances_.hasOwnProperty(uid)) {
throw new Error(
this + ' did not call the goog.Disposable base ' +
'constructor or was disposed of after a clearUndisposedObjects ' +
'call');
}
if (goog.Disposable.MONITORING_MODE !=
goog.Disposable.MonitoringMode.OFF &&
this.onDisposeCallbacks_ && this.onDisposeCallbacks_.length > 0) {
throw new Error(
this + ' did not empty its onDisposeCallbacks queue. This ' +
'probably means it overrode dispose() or disposeInternal() ' +
'without calling the superclass\' method.');
}
delete goog.Disposable.instances_[uid];
}
}
};
/**
* Associates a disposable object with this object so that they will be disposed
* together.
* @param {goog.disposable.IDisposable} disposable that will be disposed when
* this object is disposed.
*/
goog.Disposable.prototype.registerDisposable = function(disposable) {
'use strict';
this.addOnDisposeCallback(goog.partial(goog.dispose, disposable));
};
/**
* Invokes a callback function when this object is disposed. Callbacks are
* invoked in the order in which they were added. If a callback is added to
* an already disposed Disposable, it will be called immediately.
* @param {function(this:T):?} callback The callback function.
* @param {T=} opt_scope An optional scope to call the callback in.
* @template T
*/
goog.Disposable.prototype.addOnDisposeCallback = function(callback, opt_scope) {
'use strict';
if (this.disposed_) {
opt_scope !== undefined ? callback.call(opt_scope) : callback();
return;
}
if (!this.onDisposeCallbacks_) {
this.onDisposeCallbacks_ = [];
}
this.onDisposeCallbacks_.push(
opt_scope !== undefined ? goog.bind(callback, opt_scope) : callback);
};
/**
* Performs appropriate cleanup. See description of goog.disposable.IDisposable
* for examples. Classes that extend `goog.Disposable` should override this
* method. Not reentrant. To avoid calling it twice, it must only be called from
* the subclass' `disposeInternal` method. Everywhere else the public `dispose`
* method must be used. For example:
*
* <pre>
* mypackage.MyClass = function() {
* mypackage.MyClass.base(this, 'constructor');
* // Constructor logic specific to MyClass.
* ...
* };
* goog.inherits(mypackage.MyClass, goog.Disposable);
*
* mypackage.MyClass.prototype.disposeInternal = function() {
* // Dispose logic specific to MyClass.
* ...
* // Call superclass's disposeInternal at the end of the subclass's, like
* // in C++, to avoid hard-to-catch issues.
* mypackage.MyClass.base(this, 'disposeInternal');
* };
* </pre>
*
* @protected
*/
goog.Disposable.prototype.disposeInternal = function() {
'use strict';
if (this.onDisposeCallbacks_) {
while (this.onDisposeCallbacks_.length) {
this.onDisposeCallbacks_.shift()();
}
}
};
/**
* Returns True if we can verify the object is disposed.
* Calls `isDisposed` on the argument if it supports it. If obj
* is not an object with an isDisposed() method, return false.
* @param {*} obj The object to investigate.
* @return {boolean} True if we can verify the object is disposed.
*/
goog.Disposable.isDisposed = function(obj) {
'use strict';
if (obj && typeof obj.isDisposed == 'function') {
return obj.isDisposed();
}
return false;
};

View File

@ -1,27 +0,0 @@
/*TRANSPILED*/goog.loadModule(function(exports) {'use strict';/**
* @license
* Copyright The Closure Library Authors.
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @fileoverview The dispose method is used to clean up references and
* resources.
*/
goog.module('goog.dispose');
goog.module.declareLegacyNamespace();
/**
* Calls `dispose` on the argument if it supports it. If obj is not an
* object with a dispose() method, this is a no-op.
* @param {*} obj The object to dispose of.
*/
function dispose(obj) {
if (obj && typeof obj.dispose == 'function') {
obj.dispose();
}
}
exports = dispose;
;return exports;});

View File

@ -1,22 +0,0 @@
/*TRANSPILED*/goog.loadModule(function(exports) {'use strict';/*
Copyright The Closure Library Authors.
SPDX-License-Identifier: Apache-2.0
*/
'use strict';
goog.module("goog.disposeAll");
goog.module.declareLegacyNamespace();
const dispose = goog.require("goog.dispose");
function disposeAll(var_args) {
for (let i = 0, len = arguments.length; i < len; ++i) {
const disposable = arguments[i];
if (goog.isArrayLike(disposable)) {
disposeAll.apply(null, disposable);
} else {
dispose(disposable);
}
}
}
exports = disposeAll;
;return exports;});

View File

@ -1,48 +0,0 @@
/**
* @license
* Copyright The Closure Library Authors.
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @fileoverview Definition of the disposable interface. A disposable object
* has a dispose method to to clean up references and resources.
*/
goog.provide('goog.disposable.IDisposable');
/**
* Interface for a disposable object. If a instance requires cleanup, it should
* implement this interface (it may subclass goog.Disposable).
*
* Examples of cleanup that can be done in `dispose` method:
* 1. Remove event listeners.
* 2. Cancel timers (setTimeout, setInterval, goog.Timer).
* 3. Call `dispose` on other disposable objects hold by current object.
* 4. Close connections (e.g. WebSockets).
*
* Note that it's not required to delete properties (e.g. DOM nodes) or set them
* to null as garbage collector will collect them assuming that references to
* current object will be lost after it is disposed.
*
* See also http://go/mdn/JavaScript/Memory_Management.
*
* @record
*/
goog.disposable.IDisposable = function() {};
/**
* Disposes of the object and its resources.
* @return {void} Nothing.
*/
goog.disposable.IDisposable.prototype.dispose = goog.abstractMethod;
/**
* @return {boolean} Whether the object has been disposed of.
*/
goog.disposable.IDisposable.prototype.isDisposed = goog.abstractMethod;

View File

@ -1,117 +0,0 @@
/**
* @license
* Copyright The Closure Library Authors.
* SPDX-License-Identifier: Apache-2.0
*/
goog.provide('goog.dom.asserts');
goog.require('goog.asserts');
/**
* @fileoverview Custom assertions to ensure that an element has the appropriate
* type.
*
* Using a goog.dom.safe wrapper on an object on the incorrect type (via an
* incorrect static type cast) can result in security bugs: For instance,
* g.d.s.setAnchorHref ensures that the URL assigned to the .href attribute
* satisfies the SafeUrl contract, i.e., is safe to dereference as a hyperlink.
* However, the value assigned to a HTMLLinkElement's .href property requires
* the stronger TrustedResourceUrl contract, since it can refer to a stylesheet.
* Thus, using g.d.s.setAnchorHref on an (incorrectly statically typed) object
* of type HTMLLinkElement can result in a security vulnerability.
* Assertions of the correct run-time type help prevent such incorrect use.
*
* In some cases, code using the DOM API is tested using mock objects (e.g., a
* plain object such as {'href': url} instead of an actual Location object).
* To allow such mocking, the assertions permit objects of types that are not
* relevant DOM API objects at all (for instance, not Element or Location).
*
* Note that instanceof checks don't work straightforwardly in older versions of
* IE, or across frames (see,
* http://stackoverflow.com/questions/384286/javascript-isdom-how-do-you-check-if-a-javascript-object-is-a-dom-object,
* http://stackoverflow.com/questions/26248599/instanceof-htmlelement-in-iframe-is-not-element-or-object).
*
* Hence, these assertions may pass vacuously in such scenarios. The resulting
* risk of security bugs is limited by the following factors:
* - A bug can only arise in scenarios involving incorrect static typing (the
* wrapper methods are statically typed to demand objects of the appropriate,
* precise type).
* - Typically, code is tested and exercised in multiple browsers.
*/
/**
* Asserts that a given object is a Location.
*
* To permit this assertion to pass in the context of tests where DOM APIs might
* be mocked, also accepts any other type except for subtypes of {!Element}.
* This is to ensure that, for instance, HTMLLinkElement is not being used in
* place of a Location, since this could result in security bugs due to stronger
* contracts required for assignments to the href property of the latter.
*
* @param {?Object} o The object whose type to assert.
* @return {!Location}
*/
goog.dom.asserts.assertIsLocation = function(o) {
'use strict';
if (goog.asserts.ENABLE_ASSERTS) {
var win = goog.dom.asserts.getWindow_(o);
if (win) {
if (!o || (!(o instanceof win.Location) && o instanceof win.Element)) {
goog.asserts.fail(
'Argument is not a Location (or a non-Element mock); got: %s',
goog.dom.asserts.debugStringForType_(o));
}
}
}
return /** @type {!Location} */ (o);
};
/**
* Returns a string representation of a value's type.
*
* @param {*} value An object, or primitive.
* @return {string} The best display name for the value.
* @private
*/
goog.dom.asserts.debugStringForType_ = function(value) {
'use strict';
if (goog.isObject(value)) {
try {
return /** @type {string|undefined} */ (value.constructor.displayName) ||
value.constructor.name || Object.prototype.toString.call(value);
} catch (e) {
return '<object could not be stringified>';
}
} else {
return value === undefined ? 'undefined' :
value === null ? 'null' : typeof value;
}
};
/**
* Gets window of element.
* @param {?Object} o
* @return {?Window}
* @private
* @suppress {strictMissingProperties} ownerDocument not defined on Object
*/
goog.dom.asserts.getWindow_ = function(o) {
'use strict';
try {
var doc = o && o.ownerDocument;
// This can throw “Blocked a frame with origin "chrome-extension://..." from
// accessing a cross-origin frame” in Chrome extension.
var win =
doc && /** @type {?Window} */ (doc.defaultView || doc.parentWindow);
win = win || /** @type {!Window} */ (goog.global);
// This can throw “Permission denied to access property "Element" on
// cross-origin object”.
if (win.Element && win.Location) {
return win;
}
} catch (ex) {
}
return null;
};

View File

@ -1,94 +0,0 @@
/**
* @license
* Copyright The Closure Library Authors.
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @fileoverview Browser capability checks for the dom package.
*/
goog.provide('goog.dom.BrowserFeature');
goog.require('goog.userAgent');
/**
* @define {boolean} Whether we know at compile time that the browser doesn't
* support OffscreenCanvas.
*/
goog.dom.BrowserFeature.ASSUME_NO_OFFSCREEN_CANVAS =
goog.define('goog.dom.ASSUME_NO_OFFSCREEN_CANVAS', false);
/**
* @define {boolean} Whether we know at compile time that the browser supports
* all OffscreenCanvas contexts.
*/
// TODO(user): Eventually this should default to "FEATURESET_YEAR >= 202X".
goog.dom.BrowserFeature.ASSUME_OFFSCREEN_CANVAS =
goog.define('goog.dom.ASSUME_OFFSCREEN_CANVAS', false);
/**
* Detects if a particular OffscreenCanvas context is supported.
* @param {string} contextName name of the context to test.
* @return {boolean} Whether the browser supports this OffscreenCanvas context.
* @private
*/
goog.dom.BrowserFeature.detectOffscreenCanvas_ = function(contextName) {
'use strict';
// This code only gets removed because we forced @nosideeffects on
// the functions. See: b/138802376
try {
return Boolean(new self.OffscreenCanvas(0, 0).getContext(contextName));
} catch (ex) {
}
return false;
};
/**
* Whether the browser supports OffscreenCanvas 2D context.
* @const {boolean}
*/
goog.dom.BrowserFeature.OFFSCREEN_CANVAS_2D =
!goog.dom.BrowserFeature.ASSUME_NO_OFFSCREEN_CANVAS &&
(goog.dom.BrowserFeature.ASSUME_OFFSCREEN_CANVAS ||
goog.dom.BrowserFeature.detectOffscreenCanvas_('2d'));
/**
* Whether attributes 'name' and 'type' can be added to an element after it's
* created. False in Internet Explorer prior to version 9.
* @const {boolean}
*/
goog.dom.BrowserFeature.CAN_ADD_NAME_OR_TYPE_ATTRIBUTES = true;
/**
* Whether we can use element.children to access an element's Element
* children. Available since Gecko 1.9.1, IE 9. (IE<9 also includes comment
* nodes in the collection.)
* @const {boolean}
*/
goog.dom.BrowserFeature.CAN_USE_CHILDREN_ATTRIBUTE = true;
/**
* Opera, Safari 3, and Internet Explorer 9 all support innerText but they
* include text nodes in script and style tags. Not document-mode-dependent.
* @const {boolean}
*/
goog.dom.BrowserFeature.CAN_USE_INNER_TEXT = false;
/**
* MSIE, Opera, and Safari>=4 support element.parentElement to access an
* element's parent if it is an Element.
* @const {boolean}
*/
goog.dom.BrowserFeature.CAN_USE_PARENT_ELEMENT_PROPERTY =
goog.userAgent.IE || goog.userAgent.WEBKIT;
/**
* Whether NoScope elements need a scoped element written before them in
* innerHTML.
* MSDN: http://msdn.microsoft.com/en-us/library/ms533897(VS.85).aspx#1
* @const {boolean}
*/
goog.dom.BrowserFeature.INNER_HTML_NEEDS_SCOPED_ELEMENT = goog.userAgent.IE;

File diff suppressed because it is too large Load Diff

View File

@ -1,68 +0,0 @@
/*TRANSPILED*/goog.loadModule(function(exports) {'use strict';/*
Copyright The Closure Library Authors.
SPDX-License-Identifier: Apache-2.0
*/
'use strict';
goog.module("goog.dom.element");
goog.module.declareLegacyNamespace();
const NodeType = goog.require("goog.dom.NodeType");
const TagName = goog.require("goog.dom.TagName");
const HTML_NAMESPACE = "http://www.w3.org/1999/xhtml";
const isElement = value => {
return goog.isObject(value) && value.nodeType === NodeType.ELEMENT;
};
const isHtmlElement = value => {
return goog.isObject(value) && isElement(value) && (!value.namespaceURI || value.namespaceURI === HTML_NAMESPACE);
};
const isHtmlElementOfType = (value, tagName) => {
return goog.isObject(value) && isHtmlElement(value) && value.tagName.toUpperCase() === tagName.toString();
};
const isHtmlAnchorElement = value => {
return isHtmlElementOfType(value, TagName.A);
};
const isHtmlButtonElement = value => {
return isHtmlElementOfType(value, TagName.BUTTON);
};
const isHtmlLinkElement = value => {
return isHtmlElementOfType(value, TagName.LINK);
};
const isHtmlImageElement = value => {
return isHtmlElementOfType(value, TagName.IMG);
};
const isHtmlAudioElement = value => {
return isHtmlElementOfType(value, TagName.AUDIO);
};
const isHtmlVideoElement = value => {
return isHtmlElementOfType(value, TagName.VIDEO);
};
const isHtmlInputElement = value => {
return isHtmlElementOfType(value, TagName.INPUT);
};
const isHtmlTextAreaElement = value => {
return isHtmlElementOfType(value, TagName.TEXTAREA);
};
const isHtmlCanvasElement = value => {
return isHtmlElementOfType(value, TagName.CANVAS);
};
const isHtmlEmbedElement = value => {
return isHtmlElementOfType(value, TagName.EMBED);
};
const isHtmlFormElement = value => {
return isHtmlElementOfType(value, TagName.FORM);
};
const isHtmlFrameElement = value => {
return isHtmlElementOfType(value, TagName.FRAME);
};
const isHtmlIFrameElement = value => {
return isHtmlElementOfType(value, TagName.IFRAME);
};
const isHtmlObjectElement = value => {
return isHtmlElementOfType(value, TagName.OBJECT);
};
const isHtmlScriptElement = value => {
return isHtmlElementOfType(value, TagName.SCRIPT);
};
exports = {isElement, isHtmlElement, isHtmlElementOfType, isHtmlAnchorElement, isHtmlButtonElement, isHtmlLinkElement, isHtmlImageElement, isHtmlAudioElement, isHtmlVideoElement, isHtmlInputElement, isHtmlTextAreaElement, isHtmlCanvasElement, isHtmlEmbedElement, isHtmlFormElement, isHtmlFrameElement, isHtmlIFrameElement, isHtmlObjectElement, isHtmlScriptElement,};
;return exports;});

View File

@ -1,21 +0,0 @@
/**
* @license
* Copyright The Closure Library Authors.
* SPDX-License-Identifier: Apache-2.0
*/
goog.provide('goog.dom.HtmlElement');
/**
* This subclass of HTMLElement is used when only a HTMLElement is possible and
* not any of its subclasses. Normally, a type can refer to an instance of
* itself or an instance of any subtype. More concretely, if HTMLElement is used
* then the compiler must assume that it might still be e.g. HTMLScriptElement.
* With this, the type check knows that it couldn't be any special element.
*
* @constructor
* @extends {HTMLElement}
*/
goog.dom.HtmlElement = function() {};

View File

@ -1,40 +0,0 @@
/**
* @license
* Copyright The Closure Library Authors.
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @fileoverview Definition of goog.dom.NodeType.
*/
goog.provide('goog.dom.NodeType');
/**
* Constants for the nodeType attribute in the Node interface.
*
* These constants match those specified in the Node interface. These are
* usually present on the Node object in recent browsers, but not in older
* browsers (specifically, early IEs) and thus are given here.
*
* In some browsers (early IEs), these are not defined on the Node object,
* so they are provided here.
*
* See http://www.w3.org/TR/DOM-Level-2-Core/core.html#ID-1950641247
* @enum {number}
*/
goog.dom.NodeType = {
ELEMENT: 1,
ATTRIBUTE: 2,
TEXT: 3,
CDATA_SECTION: 4,
ENTITY_REFERENCE: 5,
ENTITY: 6,
PROCESSING_INSTRUCTION: 7,
COMMENT: 8,
DOCUMENT: 9,
DOCUMENT_TYPE: 10,
DOCUMENT_FRAGMENT: 11,
NOTATION: 12
};

View File

@ -1,268 +0,0 @@
/*TRANSPILED*//*
Copyright The Closure Library Authors.
SPDX-License-Identifier: Apache-2.0
*/
'use strict';
goog.provide("goog.dom.safe");
goog.provide("goog.dom.safe.InsertAdjacentHtmlPosition");
goog.require("goog.asserts");
goog.require("goog.asserts.dom");
goog.require("goog.dom.asserts");
goog.require("goog.functions");
goog.require("goog.html.SafeHtml");
goog.require("goog.html.SafeScript");
goog.require("goog.html.SafeStyle");
goog.require("goog.html.SafeUrl");
goog.require("goog.html.TrustedResourceUrl");
goog.require("goog.html.uncheckedconversions");
goog.require("goog.string.Const");
goog.require("goog.string.internal");
goog.dom.safe.InsertAdjacentHtmlPosition = {AFTERBEGIN:"afterbegin", AFTEREND:"afterend", BEFOREBEGIN:"beforebegin", BEFOREEND:"beforeend"};
goog.dom.safe.insertAdjacentHtml = function(node, position, html) {
node.insertAdjacentHTML(position, goog.html.SafeHtml.unwrapTrustedHTML(html));
};
goog.dom.safe.SET_INNER_HTML_DISALLOWED_TAGS_ = {"MATH":true, "SCRIPT":true, "STYLE":true, "SVG":true, "TEMPLATE":true};
goog.dom.safe.isInnerHtmlCleanupRecursive_ = goog.functions.cacheReturnValue(function() {
if (goog.DEBUG && typeof document === "undefined") {
return false;
}
var div = document.createElement("div");
var childDiv = document.createElement("div");
childDiv.appendChild(document.createElement("div"));
div.appendChild(childDiv);
if (goog.DEBUG && !div.firstChild) {
return false;
}
var innerChild = div.firstChild.firstChild;
div.innerHTML = goog.html.SafeHtml.unwrapTrustedHTML(goog.html.SafeHtml.EMPTY);
return !innerChild.parentElement;
});
goog.dom.safe.unsafeSetInnerHtmlDoNotUseOrElse = function(elem, html) {
if (goog.dom.safe.isInnerHtmlCleanupRecursive_()) {
while (elem.lastChild) {
elem.removeChild(elem.lastChild);
}
}
elem.innerHTML = goog.html.SafeHtml.unwrapTrustedHTML(html);
};
goog.dom.safe.setInnerHtml = function(elem, html) {
if (goog.asserts.ENABLE_ASSERTS && elem.tagName) {
var tagName = elem.tagName.toUpperCase();
if (goog.dom.safe.SET_INNER_HTML_DISALLOWED_TAGS_[tagName]) {
throw new Error("goog.dom.safe.setInnerHtml cannot be used to set content of " + elem.tagName + ".");
}
}
goog.dom.safe.unsafeSetInnerHtmlDoNotUseOrElse(elem, html);
};
goog.dom.safe.setInnerHtmlFromConstant = function(element, constHtml) {
goog.dom.safe.setInnerHtml(element, goog.html.uncheckedconversions.safeHtmlFromStringKnownToSatisfyTypeContract(goog.string.Const.from("Constant HTML to be immediatelly used."), goog.string.Const.unwrap(constHtml)));
};
goog.dom.safe.setOuterHtml = function(elem, html) {
elem.outerHTML = goog.html.SafeHtml.unwrapTrustedHTML(html);
};
goog.dom.safe.setFormElementAction = function(form, url) {
var safeUrl;
if (url instanceof goog.html.SafeUrl) {
safeUrl = url;
} else {
safeUrl = goog.html.SafeUrl.sanitizeJavascriptUrlAssertUnchanged(url);
}
goog.asserts.dom.assertIsHtmlFormElement(form).action = goog.html.SafeUrl.unwrap(safeUrl);
};
goog.dom.safe.setButtonFormAction = function(button, url) {
var safeUrl;
if (url instanceof goog.html.SafeUrl) {
safeUrl = url;
} else {
safeUrl = goog.html.SafeUrl.sanitizeJavascriptUrlAssertUnchanged(url);
}
goog.asserts.dom.assertIsHtmlButtonElement(button).formAction = goog.html.SafeUrl.unwrap(safeUrl);
};
goog.dom.safe.setInputFormAction = function(input, url) {
var safeUrl;
if (url instanceof goog.html.SafeUrl) {
safeUrl = url;
} else {
safeUrl = goog.html.SafeUrl.sanitizeJavascriptUrlAssertUnchanged(url);
}
goog.asserts.dom.assertIsHtmlInputElement(input).formAction = goog.html.SafeUrl.unwrap(safeUrl);
};
goog.dom.safe.setStyle = function(elem, style) {
elem.style.cssText = goog.html.SafeStyle.unwrap(style);
};
goog.dom.safe.documentWrite = function(doc, html) {
doc.write(goog.html.SafeHtml.unwrapTrustedHTML(html));
};
goog.dom.safe.setAnchorHref = function(anchor, url) {
goog.asserts.dom.assertIsHtmlAnchorElement(anchor);
var safeUrl;
if (url instanceof goog.html.SafeUrl) {
safeUrl = url;
} else {
safeUrl = goog.html.SafeUrl.sanitizeJavascriptUrlAssertUnchanged(url);
}
anchor.href = goog.html.SafeUrl.unwrap(safeUrl);
};
goog.dom.safe.setAudioSrc = function(audioElement, url) {
goog.asserts.dom.assertIsHtmlAudioElement(audioElement);
var safeUrl;
if (url instanceof goog.html.SafeUrl) {
safeUrl = url;
} else {
safeUrl = goog.html.SafeUrl.sanitizeJavascriptUrlAssertUnchanged(url);
}
audioElement.src = goog.html.SafeUrl.unwrap(safeUrl);
};
goog.dom.safe.setVideoSrc = function(videoElement, url) {
goog.asserts.dom.assertIsHtmlVideoElement(videoElement);
var safeUrl;
if (url instanceof goog.html.SafeUrl) {
safeUrl = url;
} else {
safeUrl = goog.html.SafeUrl.sanitizeJavascriptUrlAssertUnchanged(url);
}
videoElement.src = goog.html.SafeUrl.unwrap(safeUrl);
};
goog.dom.safe.setEmbedSrc = function(embed, url) {
goog.asserts.dom.assertIsHtmlEmbedElement(embed);
embed.src = goog.html.TrustedResourceUrl.unwrapTrustedScriptURL(url);
};
goog.dom.safe.setFrameSrc = function(frame, url) {
goog.asserts.dom.assertIsHtmlFrameElement(frame);
frame.src = goog.html.TrustedResourceUrl.unwrap(url);
};
goog.dom.safe.setIframeSrc = function(iframe, url) {
goog.asserts.dom.assertIsHtmlIFrameElement(iframe);
iframe.src = goog.html.TrustedResourceUrl.unwrap(url);
};
goog.dom.safe.setIframeSrcdoc = function(iframe, html) {
goog.asserts.dom.assertIsHtmlIFrameElement(iframe);
iframe.srcdoc = goog.html.SafeHtml.unwrapTrustedHTML(html);
};
goog.dom.safe.setLinkHrefAndRel = function(link, url, rel) {
goog.asserts.dom.assertIsHtmlLinkElement(link);
link.rel = rel;
if (goog.string.internal.caseInsensitiveContains(rel, "stylesheet")) {
goog.asserts.assert(url instanceof goog.html.TrustedResourceUrl, 'URL must be TrustedResourceUrl because "rel" contains "stylesheet"');
link.href = goog.html.TrustedResourceUrl.unwrap(url);
const win = link.ownerDocument && link.ownerDocument.defaultView;
const nonce = goog.dom.safe.getStyleNonce(win);
if (nonce) {
link.setAttribute("nonce", nonce);
}
} else if (url instanceof goog.html.TrustedResourceUrl) {
link.href = goog.html.TrustedResourceUrl.unwrap(url);
} else if (url instanceof goog.html.SafeUrl) {
link.href = goog.html.SafeUrl.unwrap(url);
} else {
link.href = goog.html.SafeUrl.unwrap(goog.html.SafeUrl.sanitizeJavascriptUrlAssertUnchanged(url));
}
};
goog.dom.safe.setObjectData = function(object, url) {
goog.asserts.dom.assertIsHtmlObjectElement(object);
object.data = goog.html.TrustedResourceUrl.unwrapTrustedScriptURL(url);
};
goog.dom.safe.setScriptSrc = function(script, url) {
goog.asserts.dom.assertIsHtmlScriptElement(script);
goog.dom.safe.setNonceForScriptElement_(script);
script.src = goog.html.TrustedResourceUrl.unwrapTrustedScriptURL(url);
};
goog.dom.safe.setScriptContent = function(script, content) {
goog.asserts.dom.assertIsHtmlScriptElement(script);
goog.dom.safe.setNonceForScriptElement_(script);
script.textContent = goog.html.SafeScript.unwrapTrustedScript(content);
};
goog.dom.safe.setNonceForScriptElement_ = function(script) {
var win = script.ownerDocument && script.ownerDocument.defaultView;
const nonce = goog.dom.safe.getScriptNonce(win);
if (nonce) {
script.setAttribute("nonce", nonce);
}
};
goog.dom.safe.setLocationHref = function(loc, url) {
goog.dom.asserts.assertIsLocation(loc);
var safeUrl;
if (url instanceof goog.html.SafeUrl) {
safeUrl = url;
} else {
safeUrl = goog.html.SafeUrl.sanitizeJavascriptUrlAssertUnchanged(url);
}
loc.href = goog.html.SafeUrl.unwrap(safeUrl);
};
goog.dom.safe.assignLocation = function(loc, url) {
goog.dom.asserts.assertIsLocation(loc);
var safeUrl;
if (url instanceof goog.html.SafeUrl) {
safeUrl = url;
} else {
safeUrl = goog.html.SafeUrl.sanitizeJavascriptUrlAssertUnchanged(url);
}
loc.assign(goog.html.SafeUrl.unwrap(safeUrl));
};
goog.dom.safe.replaceLocation = function(loc, url) {
var safeUrl;
if (url instanceof goog.html.SafeUrl) {
safeUrl = url;
} else {
safeUrl = goog.html.SafeUrl.sanitizeJavascriptUrlAssertUnchanged(url);
}
loc.replace(goog.html.SafeUrl.unwrap(safeUrl));
};
goog.dom.safe.openInWindow = function(url, opt_openerWin, opt_name, opt_specs) {
var safeUrl;
if (url instanceof goog.html.SafeUrl) {
safeUrl = url;
} else {
safeUrl = goog.html.SafeUrl.sanitizeJavascriptUrlAssertUnchanged(url);
}
var win = opt_openerWin || goog.global;
var name = opt_name instanceof goog.string.Const ? goog.string.Const.unwrap(opt_name) : opt_name || "";
if (opt_specs !== undefined) {
return win.open(goog.html.SafeUrl.unwrap(safeUrl), name, opt_specs);
} else {
return win.open(goog.html.SafeUrl.unwrap(safeUrl), name);
}
};
goog.dom.safe.parseFromStringHtml = function(parser, html) {
return goog.dom.safe.parseFromString(parser, html, "text/html");
};
goog.dom.safe.parseFromString = function(parser, content, type) {
return parser.parseFromString(goog.html.SafeHtml.unwrapTrustedHTML(content), type);
};
goog.dom.safe.createImageFromBlob = function(blob) {
if (!/^image\/.*/g.test(blob.type)) {
throw new Error("goog.dom.safe.createImageFromBlob only accepts MIME type image/.*.");
}
var objectUrl = goog.global.URL.createObjectURL(blob);
var image = new goog.global.Image();
image.onload = function() {
goog.global.URL.revokeObjectURL(objectUrl);
};
image.src = objectUrl;
return image;
};
goog.dom.safe.createContextualFragment = function(range, html) {
return range.createContextualFragment(goog.html.SafeHtml.unwrapTrustedHTML(html));
};
goog.dom.safe.getScriptNonce = function(opt_window) {
return goog.dom.safe.getNonce_("script[nonce]", opt_window);
};
goog.dom.safe.getStyleNonce = function(opt_window) {
return goog.dom.safe.getNonce_('style[nonce],link[rel\x3d"stylesheet"][nonce]', opt_window);
};
goog.dom.safe.NONCE_PATTERN_ = /^[\w+/_-]+[=]{0,2}$/;
goog.dom.safe.getNonce_ = function(selector, win) {
const doc = (win || goog.global).document;
if (!doc.querySelector) {
return "";
}
let el = doc.querySelector(selector);
if (el) {
const nonce = el["nonce"] || el.getAttribute("nonce");
if (nonce && goog.dom.safe.NONCE_PATTERN_.test(nonce)) {
return nonce;
}
}
return "";
};

View File

@ -1,149 +0,0 @@
/*TRANSPILED*//*
Copyright The Closure Library Authors.
SPDX-License-Identifier: Apache-2.0
*/
'use strict';
goog.provide("goog.dom.TagName");
goog.require("goog.dom.HtmlElement");
goog.dom.TagName = class {
static cast(name, type) {
return name;
}
constructor() {
this.googDomTagName_doNotImplementThisTypeOrElse_;
this.ensureTypeScriptRemembersTypeT_;
}
toString() {
}
};
goog.dom.TagName.A = "A";
goog.dom.TagName.ABBR = "ABBR";
goog.dom.TagName.ACRONYM = "ACRONYM";
goog.dom.TagName.ADDRESS = "ADDRESS";
goog.dom.TagName.APPLET = "APPLET";
goog.dom.TagName.AREA = "AREA";
goog.dom.TagName.ARTICLE = "ARTICLE";
goog.dom.TagName.ASIDE = "ASIDE";
goog.dom.TagName.AUDIO = "AUDIO";
goog.dom.TagName.B = "B";
goog.dom.TagName.BASE = "BASE";
goog.dom.TagName.BASEFONT = "BASEFONT";
goog.dom.TagName.BDI = "BDI";
goog.dom.TagName.BDO = "BDO";
goog.dom.TagName.BIG = "BIG";
goog.dom.TagName.BLOCKQUOTE = "BLOCKQUOTE";
goog.dom.TagName.BODY = "BODY";
goog.dom.TagName.BR = "BR";
goog.dom.TagName.BUTTON = "BUTTON";
goog.dom.TagName.CANVAS = "CANVAS";
goog.dom.TagName.CAPTION = "CAPTION";
goog.dom.TagName.CENTER = "CENTER";
goog.dom.TagName.CITE = "CITE";
goog.dom.TagName.CODE = "CODE";
goog.dom.TagName.COL = "COL";
goog.dom.TagName.COLGROUP = "COLGROUP";
goog.dom.TagName.COMMAND = "COMMAND";
goog.dom.TagName.DATA = "DATA";
goog.dom.TagName.DATALIST = "DATALIST";
goog.dom.TagName.DD = "DD";
goog.dom.TagName.DEL = "DEL";
goog.dom.TagName.DETAILS = "DETAILS";
goog.dom.TagName.DFN = "DFN";
goog.dom.TagName.DIALOG = "DIALOG";
goog.dom.TagName.DIR = "DIR";
goog.dom.TagName.DIV = "DIV";
goog.dom.TagName.DL = "DL";
goog.dom.TagName.DT = "DT";
goog.dom.TagName.EM = "EM";
goog.dom.TagName.EMBED = "EMBED";
goog.dom.TagName.FIELDSET = "FIELDSET";
goog.dom.TagName.FIGCAPTION = "FIGCAPTION";
goog.dom.TagName.FIGURE = "FIGURE";
goog.dom.TagName.FONT = "FONT";
goog.dom.TagName.FOOTER = "FOOTER";
goog.dom.TagName.FORM = "FORM";
goog.dom.TagName.FRAME = "FRAME";
goog.dom.TagName.FRAMESET = "FRAMESET";
goog.dom.TagName.H1 = "H1";
goog.dom.TagName.H2 = "H2";
goog.dom.TagName.H3 = "H3";
goog.dom.TagName.H4 = "H4";
goog.dom.TagName.H5 = "H5";
goog.dom.TagName.H6 = "H6";
goog.dom.TagName.HEAD = "HEAD";
goog.dom.TagName.HEADER = "HEADER";
goog.dom.TagName.HGROUP = "HGROUP";
goog.dom.TagName.HR = "HR";
goog.dom.TagName.HTML = "HTML";
goog.dom.TagName.I = "I";
goog.dom.TagName.IFRAME = "IFRAME";
goog.dom.TagName.IMG = "IMG";
goog.dom.TagName.INPUT = "INPUT";
goog.dom.TagName.INS = "INS";
goog.dom.TagName.ISINDEX = "ISINDEX";
goog.dom.TagName.KBD = "KBD";
goog.dom.TagName.KEYGEN = "KEYGEN";
goog.dom.TagName.LABEL = "LABEL";
goog.dom.TagName.LEGEND = "LEGEND";
goog.dom.TagName.LI = "LI";
goog.dom.TagName.LINK = "LINK";
goog.dom.TagName.MAIN = "MAIN";
goog.dom.TagName.MAP = "MAP";
goog.dom.TagName.MARK = "MARK";
goog.dom.TagName.MATH = "MATH";
goog.dom.TagName.MENU = "MENU";
goog.dom.TagName.MENUITEM = "MENUITEM";
goog.dom.TagName.META = "META";
goog.dom.TagName.METER = "METER";
goog.dom.TagName.NAV = "NAV";
goog.dom.TagName.NOFRAMES = "NOFRAMES";
goog.dom.TagName.NOSCRIPT = "NOSCRIPT";
goog.dom.TagName.OBJECT = "OBJECT";
goog.dom.TagName.OL = "OL";
goog.dom.TagName.OPTGROUP = "OPTGROUP";
goog.dom.TagName.OPTION = "OPTION";
goog.dom.TagName.OUTPUT = "OUTPUT";
goog.dom.TagName.P = "P";
goog.dom.TagName.PARAM = "PARAM";
goog.dom.TagName.PICTURE = "PICTURE";
goog.dom.TagName.PRE = "PRE";
goog.dom.TagName.PROGRESS = "PROGRESS";
goog.dom.TagName.Q = "Q";
goog.dom.TagName.RP = "RP";
goog.dom.TagName.RT = "RT";
goog.dom.TagName.RTC = "RTC";
goog.dom.TagName.RUBY = "RUBY";
goog.dom.TagName.S = "S";
goog.dom.TagName.SAMP = "SAMP";
goog.dom.TagName.SCRIPT = "SCRIPT";
goog.dom.TagName.SECTION = "SECTION";
goog.dom.TagName.SELECT = "SELECT";
goog.dom.TagName.SMALL = "SMALL";
goog.dom.TagName.SOURCE = "SOURCE";
goog.dom.TagName.SPAN = "SPAN";
goog.dom.TagName.STRIKE = "STRIKE";
goog.dom.TagName.STRONG = "STRONG";
goog.dom.TagName.STYLE = "STYLE";
goog.dom.TagName.SUB = "SUB";
goog.dom.TagName.SUMMARY = "SUMMARY";
goog.dom.TagName.SUP = "SUP";
goog.dom.TagName.SVG = "SVG";
goog.dom.TagName.TABLE = "TABLE";
goog.dom.TagName.TBODY = "TBODY";
goog.dom.TagName.TD = "TD";
goog.dom.TagName.TEMPLATE = "TEMPLATE";
goog.dom.TagName.TEXTAREA = "TEXTAREA";
goog.dom.TagName.TFOOT = "TFOOT";
goog.dom.TagName.TH = "TH";
goog.dom.TagName.THEAD = "THEAD";
goog.dom.TagName.TIME = "TIME";
goog.dom.TagName.TITLE = "TITLE";
goog.dom.TagName.TR = "TR";
goog.dom.TagName.TRACK = "TRACK";
goog.dom.TagName.TT = "TT";
goog.dom.TagName.U = "U";
goog.dom.TagName.UL = "UL";
goog.dom.TagName.VAR = "VAR";
goog.dom.TagName.VIDEO = "VIDEO";
goog.dom.TagName.WBR = "WBR";

View File

@ -1,34 +0,0 @@
/**
* @license
* Copyright The Closure Library Authors.
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @fileoverview Utilities for HTML element tag names.
*/
goog.provide('goog.dom.tags');
goog.require('goog.object');
/**
* The void elements specified by
* http://www.w3.org/TR/html-markup/syntax.html#void-elements.
* @const @private {!Object<string, boolean>}
*/
goog.dom.tags.VOID_TAGS_ = goog.object.createSet(
'area', 'base', 'br', 'col', 'command', 'embed', 'hr', 'img', 'input',
'keygen', 'link', 'meta', 'param', 'source', 'track', 'wbr');
/**
* Checks whether the tag is void (with no contents allowed and no legal end
* tag), for example 'br'.
* @param {string} tagName The tag name in lower case.
* @return {boolean}
*/
goog.dom.tags.isVoidTag = function(tagName) {
'use strict';
return goog.dom.tags.VOID_TAGS_[tagName] === true;
};

View File

@ -1,134 +0,0 @@
/*TRANSPILED*//*
Copyright The Closure Library Authors.
SPDX-License-Identifier: Apache-2.0
*/
'use strict';
goog.provide("goog.events.BrowserEvent");
goog.provide("goog.events.BrowserEvent.MouseButton");
goog.provide("goog.events.BrowserEvent.PointerType");
goog.require("goog.debug");
goog.require("goog.events.Event");
goog.require("goog.events.EventType");
goog.require("goog.reflect");
goog.require("goog.userAgent");
goog.events.BrowserEvent = function(opt_e, opt_currentTarget) {
goog.events.BrowserEvent.base(this, "constructor", opt_e ? opt_e.type : "");
this.target = null;
this.currentTarget = null;
this.relatedTarget = null;
this.offsetX = 0;
this.offsetY = 0;
this.clientX = 0;
this.clientY = 0;
this.screenX = 0;
this.screenY = 0;
this.button = 0;
this.key = "";
this.keyCode = 0;
this.charCode = 0;
this.ctrlKey = false;
this.altKey = false;
this.shiftKey = false;
this.metaKey = false;
this.state = null;
this.platformModifierKey = false;
this.pointerId = 0;
this.pointerType = "";
this.event_ = null;
if (opt_e) {
this.init(opt_e, opt_currentTarget);
}
};
goog.inherits(goog.events.BrowserEvent, goog.events.Event);
goog.events.BrowserEvent.USE_LAYER_XY_AS_OFFSET_XY = goog.define("goog.events.BrowserEvent.USE_LAYER_XY_AS_OFFSET_XY", false);
goog.events.BrowserEvent.MouseButton = {LEFT:0, MIDDLE:1, RIGHT:2, BACK:3, FORWARD:4,};
goog.events.BrowserEvent.PointerType = {MOUSE:"mouse", PEN:"pen", TOUCH:"touch"};
goog.events.BrowserEvent.IEButtonMap = goog.debug.freeze([1, 4, 2]);
goog.events.BrowserEvent.IE_BUTTON_MAP = goog.events.BrowserEvent.IEButtonMap;
goog.events.BrowserEvent.IE_POINTER_TYPE_MAP = goog.debug.freeze({2:goog.events.BrowserEvent.PointerType.TOUCH, 3:goog.events.BrowserEvent.PointerType.PEN, 4:goog.events.BrowserEvent.PointerType.MOUSE});
goog.events.BrowserEvent.prototype.init = function(e, opt_currentTarget) {
var type = this.type = e.type;
var relevantTouch = e.changedTouches && e.changedTouches.length ? e.changedTouches[0] : null;
this.target = e.target || e.srcElement;
this.currentTarget = opt_currentTarget;
var relatedTarget = e.relatedTarget;
if (relatedTarget) {
if (goog.userAgent.GECKO) {
if (!goog.reflect.canAccessProperty(relatedTarget, "nodeName")) {
relatedTarget = null;
}
}
} else if (type == goog.events.EventType.MOUSEOVER) {
relatedTarget = e.fromElement;
} else if (type == goog.events.EventType.MOUSEOUT) {
relatedTarget = e.toElement;
}
this.relatedTarget = relatedTarget;
if (relevantTouch) {
this.clientX = relevantTouch.clientX !== undefined ? relevantTouch.clientX : relevantTouch.pageX;
this.clientY = relevantTouch.clientY !== undefined ? relevantTouch.clientY : relevantTouch.pageY;
this.screenX = relevantTouch.screenX || 0;
this.screenY = relevantTouch.screenY || 0;
} else {
if (goog.events.BrowserEvent.USE_LAYER_XY_AS_OFFSET_XY) {
this.offsetX = e.layerX !== undefined ? e.layerX : e.offsetX;
this.offsetY = e.layerY !== undefined ? e.layerY : e.offsetY;
} else {
this.offsetX = goog.userAgent.WEBKIT || e.offsetX !== undefined ? e.offsetX : e.layerX;
this.offsetY = goog.userAgent.WEBKIT || e.offsetY !== undefined ? e.offsetY : e.layerY;
}
this.clientX = e.clientX !== undefined ? e.clientX : e.pageX;
this.clientY = e.clientY !== undefined ? e.clientY : e.pageY;
this.screenX = e.screenX || 0;
this.screenY = e.screenY || 0;
}
this.button = e.button;
this.keyCode = e.keyCode || 0;
this.key = e.key || "";
this.charCode = e.charCode || (type == "keypress" ? e.keyCode : 0);
this.ctrlKey = e.ctrlKey;
this.altKey = e.altKey;
this.shiftKey = e.shiftKey;
this.metaKey = e.metaKey;
this.platformModifierKey = goog.userAgent.MAC ? e.metaKey : e.ctrlKey;
this.pointerId = e.pointerId || 0;
this.pointerType = goog.events.BrowserEvent.getPointerType_(e);
this.state = e.state;
this.event_ = e;
if (e.defaultPrevented) {
goog.events.BrowserEvent.superClass_.preventDefault.call(this);
}
};
goog.events.BrowserEvent.prototype.isButton = function(button) {
return this.event_.button == button;
};
goog.events.BrowserEvent.prototype.isMouseActionButton = function() {
return this.isButton(goog.events.BrowserEvent.MouseButton.LEFT) && !(goog.userAgent.MAC && this.ctrlKey);
};
goog.events.BrowserEvent.prototype.stopPropagation = function() {
goog.events.BrowserEvent.superClass_.stopPropagation.call(this);
if (this.event_.stopPropagation) {
this.event_.stopPropagation();
} else {
this.event_.cancelBubble = true;
}
};
goog.events.BrowserEvent.prototype.preventDefault = function() {
goog.events.BrowserEvent.superClass_.preventDefault.call(this);
var be = this.event_;
if (!be.preventDefault) {
be.returnValue = false;
} else {
be.preventDefault();
}
};
goog.events.BrowserEvent.prototype.getBrowserEvent = function() {
return this.event_;
};
goog.events.BrowserEvent.getPointerType_ = function(e) {
if (typeof e.pointerType === "string") {
return e.pointerType;
}
return goog.events.BrowserEvent.IE_POINTER_TYPE_MAP[e.pointerType] || "";
};

View File

@ -1,30 +0,0 @@
/*TRANSPILED*/goog.loadModule(function(exports) {'use strict';/*
Copyright The Closure Library Authors.
SPDX-License-Identifier: Apache-2.0
*/
'use strict';
goog.module("goog.events.BrowserFeature");
goog.module.declareLegacyNamespace();
const purify = fn => {
return {valueOf:fn}.valueOf();
};
exports = {TOUCH_ENABLED:"ontouchstart" in goog.global || !!(goog.global["document"] && document.documentElement && "ontouchstart" in document.documentElement) || !!(goog.global["navigator"] && (goog.global["navigator"]["maxTouchPoints"] || goog.global["navigator"]["msMaxTouchPoints"])), POINTER_EVENTS:"PointerEvent" in goog.global, MSPOINTER_EVENTS:false, PASSIVE_EVENTS:purify(function() {
if (!goog.global.addEventListener || !Object.defineProperty) {
return false;
}
var passive = false;
var options = Object.defineProperty({}, "passive", {get:function() {
passive = true;
}});
try {
goog.global.addEventListener("test", () => {
}, options);
goog.global.removeEventListener("test", () => {
}, options);
} catch (e) {
}
return passive;
})};
;return exports;});

View File

@ -1,125 +0,0 @@
/**
* @license
* Copyright The Closure Library Authors.
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @fileoverview A base class for event objects.
*/
goog.provide('goog.events.Event');
/**
* goog.events.Event no longer depends on goog.Disposable. Keep requiring
* goog.Disposable here to not break projects which assume this dependency.
* @suppress {extraRequire}
*/
goog.require('goog.Disposable');
goog.require('goog.events.EventId');
/**
* A base class for event objects, so that they can support preventDefault and
* stopPropagation.
*
* @param {string|!goog.events.EventId} type Event Type.
* @param {Object=} opt_target Reference to the object that is the target of
* this event. It has to implement the `EventTarget` interface
* declared at {@link http://developer.mozilla.org/en/DOM/EventTarget}.
* @constructor
*/
goog.events.Event = function(type, opt_target) {
'use strict';
/**
* Event type.
* @type {string}
*/
this.type = type instanceof goog.events.EventId ? String(type) : type;
/**
* TODO(tbreisacher): The type should probably be
* EventTarget|goog.events.EventTarget.
*
* Target of the event.
* @type {Object|undefined}
*/
this.target = opt_target;
/**
* Object that had the listener attached.
* @type {Object|undefined}
*/
this.currentTarget = this.target;
/**
* Whether to cancel the event in internal capture/bubble processing for IE.
* @type {boolean}
* @private
*/
this.propagationStopped_ = false;
/**
* Whether the default action has been prevented.
* This is a property to match the W3C specification at
* {@link http://www.w3.org/TR/DOM-Level-3-Events/
* #events-event-type-defaultPrevented}.
* Must be treated as read-only outside the class.
* @type {boolean}
*/
this.defaultPrevented = false;
};
/**
* @return {boolean} true iff internal propagation has been stopped.
*/
goog.events.Event.prototype.hasPropagationStopped = function() {
'use strict';
return this.propagationStopped_;
};
/**
* Stops event propagation.
* @return {void}
*/
goog.events.Event.prototype.stopPropagation = function() {
'use strict';
this.propagationStopped_ = true;
};
/**
* Prevents the default action, for example a link redirecting to a url.
* @return {void}
*/
goog.events.Event.prototype.preventDefault = function() {
'use strict';
this.defaultPrevented = true;
};
/**
* Stops the propagation of the event. It is equivalent to
* `e.stopPropagation()`, but can be used as the callback argument of
* {@link goog.events.listen} without declaring another function.
* @param {!goog.events.Event} e An event.
* @return {void}
*/
goog.events.Event.stopPropagation = function(e) {
'use strict';
e.stopPropagation();
};
/**
* Prevents the default action. It is equivalent to
* `e.preventDefault()`, but can be used as the callback argument of
* {@link goog.events.listen} without declaring another function.
* @param {!goog.events.Event} e An event.
* @return {void}
*/
goog.events.Event.preventDefault = function(e) {
'use strict';
e.preventDefault();
};

View File

@ -1,490 +0,0 @@
/**
* @license
* Copyright The Closure Library Authors.
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @fileoverview Class to create objects which want to handle multiple events
* and have their listeners easily cleaned up via a dispose method.
*
* Example:
* <pre>
* function Something() {
* Something.base(this);
*
* ... set up object ...
*
* // Add event listeners
* this.listen(this.starEl, goog.events.EventType.CLICK, this.handleStar);
* this.listen(this.headerEl, goog.events.EventType.CLICK, this.expand);
* this.listen(this.collapseEl, goog.events.EventType.CLICK, this.collapse);
* this.listen(this.infoEl, goog.events.EventType.MOUSEOVER, this.showHover);
* this.listen(this.infoEl, goog.events.EventType.MOUSEOUT, this.hideHover);
* }
* goog.inherits(Something, goog.events.EventHandler);
*
* Something.prototype.disposeInternal = function() {
* Something.base(this, 'disposeInternal');
* goog.dom.removeNode(this.container);
* };
*
*
* // Then elsewhere:
*
* var activeSomething = null;
* function openSomething() {
* activeSomething = new Something();
* }
*
* function closeSomething() {
* if (activeSomething) {
* activeSomething.dispose(); // Remove event listeners
* activeSomething = null;
* }
* }
* </pre>
*/
goog.provide('goog.events.EventHandler');
goog.require('goog.Disposable');
goog.require('goog.events');
goog.require('goog.object');
goog.requireType('goog.events.Event');
goog.requireType('goog.events.EventId');
goog.requireType('goog.events.EventTarget');
goog.requireType('goog.events.EventWrapper');
/**
* Super class for objects that want to easily manage a number of event
* listeners. It allows a short cut to listen and also provides a quick way
* to remove all events listeners belonging to this object.
* @param {SCOPE=} opt_scope Object in whose scope to call the listeners.
* @constructor
* @extends {goog.Disposable}
* @template SCOPE
*/
goog.events.EventHandler = function(opt_scope) {
'use strict';
goog.Disposable.call(this);
// TODO(mknichel): Rename this to this.scope_ and fix the classes in google3
// that access this private variable. :(
this.handler_ = opt_scope;
/**
* Keys for events that are being listened to.
* @type {!Object<!goog.events.Key>}
* @private
*/
this.keys_ = {};
};
goog.inherits(goog.events.EventHandler, goog.Disposable);
/**
* Utility array used to unify the cases of listening for an array of types
* and listening for a single event, without using recursion or allocating
* an array each time.
* @type {!Array<string>}
* @const
* @private
*/
goog.events.EventHandler.typeArray_ = [];
/**
* Listen to an event on a Listenable. If the function is omitted then the
* EventHandler's handleEvent method will be used.
* @param {goog.events.ListenableType} src Event source.
* @param {string|Array<string>|
* !goog.events.EventId<EVENTOBJ>|!Array<!goog.events.EventId<EVENTOBJ>>}
* type Event type to listen for or array of event types.
* @param {function(this:SCOPE, EVENTOBJ):?|{handleEvent:function(?):?}|null=}
* opt_fn Optional callback function to be used as the listener or an object
* with handleEvent function.
* @param {(boolean|!AddEventListenerOptions)=} opt_options
* @return {THIS} This object, allowing for chaining of calls.
* @this {THIS}
* @template EVENTOBJ, THIS
*/
goog.events.EventHandler.prototype.listen = function(
src, type, opt_fn, opt_options) {
'use strict';
var self = /** @type {!goog.events.EventHandler} */ (this);
return self.listen_(src, type, opt_fn, opt_options);
};
/**
* Listen to an event on a Listenable. If the function is omitted then the
* EventHandler's handleEvent method will be used.
* @param {goog.events.ListenableType} src Event source.
* @param {string|Array<string>|
* !goog.events.EventId<EVENTOBJ>|!Array<!goog.events.EventId<EVENTOBJ>>}
* type Event type to listen for or array of event types.
* @param {function(this:T, EVENTOBJ):?|{handleEvent:function(this:T, ?):?}|
* null|undefined} fn Optional callback function to be used as the
* listener or an object with handleEvent function.
* @param {boolean|!AddEventListenerOptions|undefined} options
* @param {T} scope Object in whose scope to call the listener.
* @return {THIS} This object, allowing for chaining of calls.
* @this {THIS}
* @template T, EVENTOBJ, THIS
*/
goog.events.EventHandler.prototype.listenWithScope = function(
src, type, fn, options, scope) {
'use strict';
var self = /** @type {!goog.events.EventHandler} */ (this);
// TODO(mknichel): Deprecate this function.
return self.listen_(src, type, fn, options, scope);
};
/**
* Listen to an event on a Listenable. If the function is omitted then the
* EventHandler's handleEvent method will be used.
* @param {goog.events.ListenableType} src Event source.
* @param {string|Array<string>|
* !goog.events.EventId<EVENTOBJ>|!Array<!goog.events.EventId<EVENTOBJ>>}
* type Event type to listen for or array of event types.
* @param {function(EVENTOBJ):?|{handleEvent:function(?):?}|null=} opt_fn
* Optional callback function to be used as the listener or an object with
* handleEvent function.
* @param {(boolean|!AddEventListenerOptions)=} opt_options
* @param {Object=} opt_scope Object in whose scope to call the listener.
* @return {THIS} This object, allowing for chaining of calls.
* @this {THIS}
* @template EVENTOBJ, THIS
* @private
*/
goog.events.EventHandler.prototype.listen_ = function(
src, type, opt_fn, opt_options, opt_scope) {
'use strict';
var self = /** @type {!goog.events.EventHandler} */ (this);
if (!Array.isArray(type)) {
if (type) {
goog.events.EventHandler.typeArray_[0] = type.toString();
}
type = goog.events.EventHandler.typeArray_;
}
for (var i = 0; i < type.length; i++) {
var listenerObj = goog.events.listen(
src, type[i], opt_fn || self.handleEvent, opt_options || false,
opt_scope || self.handler_ || self);
if (!listenerObj) {
// When goog.events.listen run on OFF_AND_FAIL or OFF_AND_SILENT
// (goog.events.CaptureSimulationMode) in IE8-, it will return null
// value.
return self;
}
/** @suppress {strictMissingProperties} Added to tighten compiler checks */
var key = listenerObj.key;
self.keys_[key] = listenerObj;
}
return self;
};
/**
* Listen to an event on a Listenable. If the function is omitted, then the
* EventHandler's handleEvent method will be used. After the event has fired the
* event listener is removed from the target. If an array of event types is
* provided, each event type will be listened to once.
* @param {goog.events.ListenableType} src Event source.
* @param {string|Array<string>|
* !goog.events.EventId<EVENTOBJ>|!Array<!goog.events.EventId<EVENTOBJ>>}
* type Event type to listen for or array of event types.
* @param {function(this:SCOPE, EVENTOBJ):?|{handleEvent:function(?):?}|null=}
* opt_fn
* Optional callback function to be used as the listener or an object with
* handleEvent function.
* @param {(boolean|!AddEventListenerOptions)=} opt_options
* @return {THIS} This object, allowing for chaining of calls.
* @this {THIS}
* @template EVENTOBJ, THIS
*/
goog.events.EventHandler.prototype.listenOnce = function(
src, type, opt_fn, opt_options) {
'use strict';
var self = /** @type {!goog.events.EventHandler} */ (this);
return self.listenOnce_(src, type, opt_fn, opt_options);
};
/**
* Listen to an event on a Listenable. If the function is omitted, then the
* EventHandler's handleEvent method will be used. After the event has fired the
* event listener is removed from the target. If an array of event types is
* provided, each event type will be listened to once.
* @param {goog.events.ListenableType} src Event source.
* @param {string|Array<string>|
* !goog.events.EventId<EVENTOBJ>|!Array<!goog.events.EventId<EVENTOBJ>>}
* type Event type to listen for or array of event types.
* @param {function(this:T, EVENTOBJ):?|{handleEvent:function(this:T, ?):?}|
* null|undefined} fn Optional callback function to be used as the
* listener or an object with handleEvent function.
* @param {boolean|undefined} capture Optional whether to use capture phase.
* @param {T} scope Object in whose scope to call the listener.
* @return {THIS} This object, allowing for chaining of calls.
* @this {THIS}
* @template T, EVENTOBJ, THIS
*/
goog.events.EventHandler.prototype.listenOnceWithScope = function(
src, type, fn, capture, scope) {
'use strict';
var self = /** @type {!goog.events.EventHandler} */ (this);
// TODO(mknichel): Deprecate this function.
return self.listenOnce_(src, type, fn, capture, scope);
};
/**
* Listen to an event on a Listenable. If the function is omitted, then the
* EventHandler's handleEvent method will be used. After the event has fired
* the event listener is removed from the target. If an array of event types is
* provided, each event type will be listened to once.
* @param {goog.events.ListenableType} src Event source.
* @param {string|Array<string>|
* !goog.events.EventId<EVENTOBJ>|!Array<!goog.events.EventId<EVENTOBJ>>}
* type Event type to listen for or array of event types.
* @param {function(EVENTOBJ):?|{handleEvent:function(?):?}|null=} opt_fn
* Optional callback function to be used as the listener or an object with
* handleEvent function.
* @param {(boolean|!AddEventListenerOptions)=} opt_options
* @param {Object=} opt_scope Object in whose scope to call the listener.
* @return {THIS} This object, allowing for chaining of calls.
* @this {THIS}
* @template EVENTOBJ, THIS
* @private
*/
goog.events.EventHandler.prototype.listenOnce_ = function(
src, type, opt_fn, opt_options, opt_scope) {
'use strict';
var self = /** @type {!goog.events.EventHandler} */ (this);
if (Array.isArray(type)) {
for (var i = 0; i < type.length; i++) {
self.listenOnce_(src, type[i], opt_fn, opt_options, opt_scope);
}
} else {
var listenerObj = goog.events.listenOnce(
src, type, opt_fn || self.handleEvent, opt_options,
opt_scope || self.handler_ || self);
if (!listenerObj) {
// When goog.events.listen run on OFF_AND_FAIL or OFF_AND_SILENT
// (goog.events.CaptureSimulationMode) in IE8-, it will return null
// value.
return self;
}
/** @suppress {strictMissingProperties} Added to tighten compiler checks */
var key = listenerObj.key;
self.keys_[key] = listenerObj;
}
return self;
};
/**
* Adds an event listener with a specific event wrapper on a DOM Node or an
* object that has implemented {@link goog.events.EventTarget}. A listener can
* only be added once to an object.
*
* @param {EventTarget|goog.events.EventTarget} src The node to listen to
* events on.
* @param {goog.events.EventWrapper} wrapper Event wrapper to use.
* @param {function(this:SCOPE, ?):?|{handleEvent:function(?):?}|null} listener
* Callback method, or an object with a handleEvent function.
* @param {boolean=} opt_capt Whether to fire in capture phase (defaults to
* false).
* @return {THIS} This object, allowing for chaining of calls.
* @this {THIS}
* @template THIS
*/
goog.events.EventHandler.prototype.listenWithWrapper = function(
src, wrapper, listener, opt_capt) {
'use strict';
var self = /** @type {!goog.events.EventHandler} */ (this);
// TODO(mknichel): Remove the opt_scope from this function and then
// templatize it.
return self.listenWithWrapper_(src, wrapper, listener, opt_capt);
};
/**
* Adds an event listener with a specific event wrapper on a DOM Node or an
* object that has implemented {@link goog.events.EventTarget}. A listener can
* only be added once to an object.
*
* @param {EventTarget|goog.events.EventTarget} src The node to listen to
* events on.
* @param {goog.events.EventWrapper} wrapper Event wrapper to use.
* @param {function(this:T, ?):?|{handleEvent:function(this:T, ?):?}|null}
* listener Optional callback function to be used as the
* listener or an object with handleEvent function.
* @param {boolean|undefined} capture Optional whether to use capture phase.
* @param {T} scope Object in whose scope to call the listener.
* @return {THIS} This object, allowing for chaining of calls.
* @this {THIS}
* @template T, THIS
*/
goog.events.EventHandler.prototype.listenWithWrapperAndScope = function(
src, wrapper, listener, capture, scope) {
'use strict';
var self = /** @type {!goog.events.EventHandler} */ (this);
// TODO(mknichel): Deprecate this function.
return self.listenWithWrapper_(src, wrapper, listener, capture, scope);
};
/**
* Adds an event listener with a specific event wrapper on a DOM Node or an
* object that has implemented {@link goog.events.EventTarget}. A listener can
* only be added once to an object.
*
* @param {EventTarget|goog.events.EventTarget} src The node to listen to
* events on.
* @param {goog.events.EventWrapper} wrapper Event wrapper to use.
* @param {function(?):?|{handleEvent:function(?):?}|null} listener Callback
* method, or an object with a handleEvent function.
* @param {boolean=} opt_capt Whether to fire in capture phase (defaults to
* false).
* @param {Object=} opt_scope Element in whose scope to call the listener.
* @return {THIS} This object, allowing for chaining of calls.
* @this {THIS}
* @template THIS
* @private
*/
goog.events.EventHandler.prototype.listenWithWrapper_ = function(
src, wrapper, listener, opt_capt, opt_scope) {
'use strict';
var self = /** @type {!goog.events.EventHandler} */ (this);
wrapper.listen(
src, listener, opt_capt, opt_scope || self.handler_ || self, self);
return self;
};
/**
* @return {number} Number of listeners registered by this handler.
*/
goog.events.EventHandler.prototype.getListenerCount = function() {
'use strict';
var count = 0;
for (var key in this.keys_) {
if (Object.prototype.hasOwnProperty.call(this.keys_, key)) {
count++;
}
}
return count;
};
/**
* Unlistens on an event.
* @param {goog.events.ListenableType} src Event source.
* @param {string|Array<string>|
* !goog.events.EventId<EVENTOBJ>|!Array<!goog.events.EventId<EVENTOBJ>>}
* type Event type or array of event types to unlisten to.
* @param {function(this:?, EVENTOBJ):?|{handleEvent:function(?):?}|null=}
* opt_fn Optional callback function to be used as the listener or an object
* with handleEvent function.
* @param {(boolean|!EventListenerOptions)=} opt_options
* @param {Object=} opt_scope Object in whose scope to call the listener.
* @return {THIS} This object, allowing for chaining of calls.
* @this {THIS}
* @template EVENTOBJ, THIS
*/
goog.events.EventHandler.prototype.unlisten = function(
src, type, opt_fn, opt_options, opt_scope) {
'use strict';
var self = /** @type {!goog.events.EventHandler} */ (this);
if (Array.isArray(type)) {
for (var i = 0; i < type.length; i++) {
self.unlisten(src, type[i], opt_fn, opt_options, opt_scope);
}
} else {
var capture =
goog.isObject(opt_options) ? !!opt_options.capture : !!opt_options;
var listener = goog.events.getListener(
src, type, opt_fn || self.handleEvent, capture,
opt_scope || self.handler_ || self);
if (listener) {
goog.events.unlistenByKey(listener);
delete self.keys_[listener.key];
}
}
return self;
};
/**
* Removes an event listener which was added with listenWithWrapper().
*
* @param {EventTarget|goog.events.EventTarget} src The target to stop
* listening to events on.
* @param {goog.events.EventWrapper} wrapper Event wrapper to use.
* @param {function(?):?|{handleEvent:function(?):?}|null} listener The
* listener function to remove.
* @param {boolean=} opt_capt In DOM-compliant browsers, this determines
* whether the listener is fired during the capture or bubble phase of the
* event.
* @param {Object=} opt_scope Element in whose scope to call the listener.
* @return {THIS} This object, allowing for chaining of calls.
* @this {THIS}
* @template THIS
*/
goog.events.EventHandler.prototype.unlistenWithWrapper = function(
src, wrapper, listener, opt_capt, opt_scope) {
'use strict';
var self = /** @type {!goog.events.EventHandler} */ (this);
wrapper.unlisten(
src, listener, opt_capt, opt_scope || self.handler_ || self, self);
return self;
};
/**
* Unlistens to all events.
*/
goog.events.EventHandler.prototype.removeAll = function() {
'use strict';
goog.object.forEach(this.keys_, function(listenerObj, key) {
'use strict';
if (this.keys_.hasOwnProperty(key)) {
goog.events.unlistenByKey(listenerObj);
}
}, this);
this.keys_ = {};
};
/**
* Disposes of this EventHandler and removes all listeners that it registered.
* @override
* @protected
*/
goog.events.EventHandler.prototype.disposeInternal = function() {
'use strict';
goog.events.EventHandler.superClass_.disposeInternal.call(this);
this.removeAll();
};
/**
* Default event handler
* @param {goog.events.Event} e Event object.
*/
goog.events.EventHandler.prototype.handleEvent = function(e) {
'use strict';
throw new Error('EventHandler.handleEvent not implemented');
};

View File

@ -1,41 +0,0 @@
/**
* @license
* Copyright The Closure Library Authors.
* SPDX-License-Identifier: Apache-2.0
*/
goog.provide('goog.events.EventId');
/**
* A templated class that is used when registering for events. Typical usage:
*
* /** @type {goog.events.EventId<MyEventObj>} *\
* var myEventId = new goog.events.EventId(
* goog.events.getUniqueId(('someEvent'));
*
* // No need to cast or declare here since the compiler knows the
* // correct type of 'evt' (MyEventObj).
* something.listen(myEventId, function(evt) {});
*
* @param {string} eventId
* @template T
* @constructor
* @struct
* @final
*/
goog.events.EventId = function(eventId) {
'use strict';
/** @const */ this.id = eventId;
};
/**
* @override
* @return {string}
*/
goog.events.EventId.prototype.toString = function() {
'use strict';
return this.id;
};

View File

@ -1,24 +0,0 @@
/**
* @license
* Copyright The Closure Library Authors.
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @fileoverview A typedef for event like objects that are dispatchable via the
* goog.events.dispatchEvent function.
*/
goog.provide('goog.events.EventLike');
goog.requireType('goog.events.Event');
goog.requireType('goog.events.EventId');
/**
* A typedef for event like objects that are dispatchable via the
* goog.events.dispatchEvent function. strings are treated as the type for a
* goog.events.Event. Objects are treated as an extension of a new
* goog.events.Event with the type property of the object being used as the type
* of the Event.
* @typedef {string|Object|goog.events.Event|goog.events.EventId}
*/
goog.events.EventLike;

View File

@ -1,336 +0,0 @@
/*TRANSPILED*//*
Copyright The Closure Library Authors.
SPDX-License-Identifier: Apache-2.0
*/
'use strict';
goog.provide("goog.events");
goog.provide("goog.events.CaptureSimulationMode");
goog.provide("goog.events.Key");
goog.provide("goog.events.ListenableType");
goog.require("goog.asserts");
goog.require("goog.debug.entryPointRegistry");
goog.require("goog.events.BrowserEvent");
goog.require("goog.events.BrowserFeature");
goog.require("goog.events.Listenable");
goog.require("goog.events.ListenerMap");
goog.requireType("goog.debug.ErrorHandler");
goog.requireType("goog.events.EventId");
goog.requireType("goog.events.EventLike");
goog.requireType("goog.events.EventWrapper");
goog.requireType("goog.events.ListenableKey");
goog.requireType("goog.events.Listener");
goog.events.Key;
goog.events.ListenableType;
goog.events.LISTENER_MAP_PROP_ = "closure_lm_" + (Math.random() * 1e6 | 0);
goog.events.onString_ = "on";
goog.events.onStringMap_ = {};
goog.events.CaptureSimulationMode = {OFF_AND_FAIL:0, OFF_AND_SILENT:1, ON:2};
goog.events.CAPTURE_SIMULATION_MODE = goog.define("goog.events.CAPTURE_SIMULATION_MODE", 2);
goog.events.listenerCountEstimate_ = 0;
goog.events.listen = function(src, type, listener, opt_options, opt_handler) {
if (opt_options && opt_options.once) {
return goog.events.listenOnce(src, type, listener, opt_options, opt_handler);
}
if (Array.isArray(type)) {
for (var i = 0; i < type.length; i++) {
goog.events.listen(src, type[i], listener, opt_options, opt_handler);
}
return null;
}
listener = goog.events.wrapListener(listener);
if (goog.events.Listenable.isImplementedBy(src)) {
var capture = goog.isObject(opt_options) ? !!opt_options.capture : !!opt_options;
return src.listen(type, listener, capture, opt_handler);
} else {
return goog.events.listen_(src, type, listener, false, opt_options, opt_handler);
}
};
goog.events.listen_ = function(src, type, listener, callOnce, opt_options, opt_handler) {
if (!type) {
throw new Error("Invalid event type");
}
var capture = goog.isObject(opt_options) ? !!opt_options.capture : !!opt_options;
var listenerMap = goog.events.getListenerMap_(src);
if (!listenerMap) {
src[goog.events.LISTENER_MAP_PROP_] = listenerMap = new goog.events.ListenerMap(src);
}
var listenerObj = listenerMap.add(type, listener, callOnce, capture, opt_handler);
if (listenerObj.proxy) {
return listenerObj;
}
var proxy = goog.events.getProxy();
listenerObj.proxy = proxy;
proxy.src = src;
proxy.listener = listenerObj;
if (src.addEventListener) {
if (!goog.events.BrowserFeature.PASSIVE_EVENTS) {
opt_options = capture;
}
if (opt_options === undefined) {
opt_options = false;
}
src.addEventListener(type.toString(), proxy, opt_options);
} else if (src.attachEvent) {
src.attachEvent(goog.events.getOnString_(type.toString()), proxy);
} else if (src.addListener && src.removeListener) {
goog.asserts.assert(type === "change", "MediaQueryList only has a change event");
src.addListener(proxy);
} else {
throw new Error("addEventListener and attachEvent are unavailable.");
}
goog.events.listenerCountEstimate_++;
return listenerObj;
};
goog.events.getProxy = function() {
const proxyCallbackFunction = goog.events.handleBrowserEvent_;
const f = function(eventObject) {
return proxyCallbackFunction.call(f.src, f.listener, eventObject);
};
return f;
};
goog.events.listenOnce = function(src, type, listener, opt_options, opt_handler) {
if (Array.isArray(type)) {
for (var i = 0; i < type.length; i++) {
goog.events.listenOnce(src, type[i], listener, opt_options, opt_handler);
}
return null;
}
listener = goog.events.wrapListener(listener);
if (goog.events.Listenable.isImplementedBy(src)) {
var capture = goog.isObject(opt_options) ? !!opt_options.capture : !!opt_options;
return src.listenOnce(type, listener, capture, opt_handler);
} else {
return goog.events.listen_(src, type, listener, true, opt_options, opt_handler);
}
};
goog.events.listenWithWrapper = function(src, wrapper, listener, opt_capt, opt_handler) {
wrapper.listen(src, listener, opt_capt, opt_handler);
};
goog.events.unlisten = function(src, type, listener, opt_options, opt_handler) {
if (Array.isArray(type)) {
for (var i = 0; i < type.length; i++) {
goog.events.unlisten(src, type[i], listener, opt_options, opt_handler);
}
return null;
}
var capture = goog.isObject(opt_options) ? !!opt_options.capture : !!opt_options;
listener = goog.events.wrapListener(listener);
if (goog.events.Listenable.isImplementedBy(src)) {
return src.unlisten(type, listener, capture, opt_handler);
}
if (!src) {
return false;
}
var listenerMap = goog.events.getListenerMap_(src);
if (listenerMap) {
var listenerObj = listenerMap.getListener(type, listener, capture, opt_handler);
if (listenerObj) {
return goog.events.unlistenByKey(listenerObj);
}
}
return false;
};
goog.events.unlistenByKey = function(key) {
if (typeof key === "number") {
return false;
}
var listener = key;
if (!listener || listener.removed) {
return false;
}
var src = listener.src;
if (goog.events.Listenable.isImplementedBy(src)) {
return src.unlistenByKey(listener);
}
var type = listener.type;
var proxy = listener.proxy;
if (src.removeEventListener) {
src.removeEventListener(type, proxy, listener.capture);
} else if (src.detachEvent) {
src.detachEvent(goog.events.getOnString_(type), proxy);
} else if (src.addListener && src.removeListener) {
src.removeListener(proxy);
}
goog.events.listenerCountEstimate_--;
var listenerMap = goog.events.getListenerMap_(src);
if (listenerMap) {
listenerMap.removeByKey(listener);
if (listenerMap.getTypeCount() == 0) {
listenerMap.src = null;
src[goog.events.LISTENER_MAP_PROP_] = null;
}
} else {
listener.markAsRemoved();
}
return true;
};
goog.events.unlistenWithWrapper = function(src, wrapper, listener, opt_capt, opt_handler) {
wrapper.unlisten(src, listener, opt_capt, opt_handler);
};
goog.events.removeAll = function(obj, opt_type) {
if (!obj) {
return 0;
}
if (goog.events.Listenable.isImplementedBy(obj)) {
return obj.removeAllListeners(opt_type);
}
var listenerMap = goog.events.getListenerMap_(obj);
if (!listenerMap) {
return 0;
}
var count = 0;
var typeStr = opt_type && opt_type.toString();
for (var type in listenerMap.listeners) {
if (!typeStr || type == typeStr) {
var listeners = listenerMap.listeners[type].concat();
for (var i = 0; i < listeners.length; ++i) {
if (goog.events.unlistenByKey(listeners[i])) {
++count;
}
}
}
}
return count;
};
goog.events.getListeners = function(obj, type, capture) {
if (goog.events.Listenable.isImplementedBy(obj)) {
return obj.getListeners(type, capture);
} else {
if (!obj) {
return [];
}
var listenerMap = goog.events.getListenerMap_(obj);
return listenerMap ? listenerMap.getListeners(type, capture) : [];
}
};
goog.events.getListener = function(src, type, listener, opt_capt, opt_handler) {
type = type;
listener = goog.events.wrapListener(listener);
var capture = !!opt_capt;
if (goog.events.Listenable.isImplementedBy(src)) {
return src.getListener(type, listener, capture, opt_handler);
}
if (!src) {
return null;
}
var listenerMap = goog.events.getListenerMap_(src);
if (listenerMap) {
return listenerMap.getListener(type, listener, capture, opt_handler);
}
return null;
};
goog.events.hasListener = function(obj, opt_type, opt_capture) {
if (goog.events.Listenable.isImplementedBy(obj)) {
return obj.hasListener(opt_type, opt_capture);
}
var listenerMap = goog.events.getListenerMap_(obj);
return !!listenerMap && listenerMap.hasListener(opt_type, opt_capture);
};
goog.events.expose = function(e) {
var str = [];
for (var key in e) {
if (e[key] && e[key].id) {
str.push(key + " \x3d " + e[key] + " (" + e[key].id + ")");
} else {
str.push(key + " \x3d " + e[key]);
}
}
return str.join("\n");
};
goog.events.getOnString_ = function(type) {
if (type in goog.events.onStringMap_) {
return goog.events.onStringMap_[type];
}
return goog.events.onStringMap_[type] = goog.events.onString_ + type;
};
goog.events.fireListeners = function(obj, type, capture, eventObject) {
if (goog.events.Listenable.isImplementedBy(obj)) {
return obj.fireListeners(type, capture, eventObject);
}
return goog.events.fireListeners_(obj, type, capture, eventObject);
};
goog.events.fireListeners_ = function(obj, type, capture, eventObject) {
var retval = true;
var listenerMap = goog.events.getListenerMap_(obj);
if (listenerMap) {
var listenerArray = listenerMap.listeners[type.toString()];
if (listenerArray) {
listenerArray = listenerArray.concat();
for (var i = 0; i < listenerArray.length; i++) {
var listener = listenerArray[i];
if (listener && listener.capture == capture && !listener.removed) {
var result = goog.events.fireListener(listener, eventObject);
retval = retval && result !== false;
}
}
}
}
return retval;
};
goog.events.fireListener = function(listener, eventObject) {
var listenerFn = listener.listener;
var listenerHandler = listener.handler || listener.src;
if (listener.callOnce) {
goog.events.unlistenByKey(listener);
}
return listenerFn.call(listenerHandler, eventObject);
};
goog.events.getTotalListenerCount = function() {
return goog.events.listenerCountEstimate_;
};
goog.events.dispatchEvent = function(src, e) {
goog.asserts.assert(goog.events.Listenable.isImplementedBy(src), "Can not use goog.events.dispatchEvent with " + "non-goog.events.Listenable instance.");
return src.dispatchEvent(e);
};
goog.events.protectBrowserEventEntryPoint = function(errorHandler) {
goog.events.handleBrowserEvent_ = errorHandler.protectEntryPoint(goog.events.handleBrowserEvent_);
};
goog.events.handleBrowserEvent_ = function(listener, opt_evt) {
if (listener.removed) {
return true;
}
return goog.events.fireListener(listener, new goog.events.BrowserEvent(opt_evt, this));
};
goog.events.markIeEvent_ = function(e) {
var useReturnValue = false;
if (e.keyCode == 0) {
try {
e.keyCode = -1;
return;
} catch (ex) {
useReturnValue = true;
}
}
if (useReturnValue || e.returnValue == undefined) {
e.returnValue = true;
}
};
goog.events.isMarkedIeEvent_ = function(e) {
return e.keyCode < 0 || e.returnValue != undefined;
};
goog.events.uniqueIdCounter_ = 0;
goog.events.getUniqueId = function(identifier) {
return identifier + "_" + goog.events.uniqueIdCounter_++;
};
goog.events.getListenerMap_ = function(src) {
var listenerMap = src[goog.events.LISTENER_MAP_PROP_];
return listenerMap instanceof goog.events.ListenerMap ? listenerMap : null;
};
goog.events.LISTENER_WRAPPER_PROP_ = "__closure_events_fn_" + (Math.random() * 1e9 >>> 0);
goog.events.wrapListener = function(listener) {
goog.asserts.assert(listener, "Listener can not be null.");
if (typeof listener === "function") {
return listener;
}
goog.asserts.assert(listener.handleEvent, "An object listener must have handleEvent method.");
if (!listener[goog.events.LISTENER_WRAPPER_PROP_]) {
listener[goog.events.LISTENER_WRAPPER_PROP_] = function(e) {
return listener.handleEvent(e);
};
}
return listener[goog.events.LISTENER_WRAPPER_PROP_];
};
goog.debug.entryPointRegistry.register(function(transformer) {
goog.events.handleBrowserEvent_ = transformer(goog.events.handleBrowserEvent_);
});

View File

@ -1,495 +0,0 @@
/**
* @license
* Copyright The Closure Library Authors.
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @fileoverview A disposable implementation of a custom
* listenable/event target. See also: documentation for
* `goog.events.Listenable`.
*
* @see ../demos/eventtarget.html
* @see goog.events.Listenable
*/
goog.provide('goog.events.EventTarget');
goog.require('goog.Disposable');
goog.require('goog.asserts');
goog.require('goog.events');
goog.require('goog.events.Event');
goog.require('goog.events.Listenable');
goog.require('goog.events.ListenerMap');
goog.require('goog.object');
goog.requireType('goog.events.EventId');
goog.requireType('goog.events.EventLike');
goog.requireType('goog.events.ListenableKey');
/**
* An implementation of `goog.events.Listenable` with full W3C
* EventTarget-like support (capture/bubble mechanism, stopping event
* propagation, preventing default actions).
*
* You may subclass this class to turn your class into a Listenable.
*
* Unless propagation is stopped, an event dispatched by an
* EventTarget will bubble to the parent returned by
* `getParentEventTarget`. To set the parent, call
* `setParentEventTarget`. Subclasses that don't support
* changing the parent can override the setter to throw an error.
*
* Example usage:
* <pre>
* var source = new goog.events.EventTarget();
* function handleEvent(e) {
* alert('Type: ' + e.type + '; Target: ' + e.target);
* }
* source.listen('foo', handleEvent);
* // Or: goog.events.listen(source, 'foo', handleEvent);
* ...
* source.dispatchEvent('foo'); // will call handleEvent
* ...
* source.unlisten('foo', handleEvent);
* // Or: goog.events.unlisten(source, 'foo', handleEvent);
* </pre>
*
* @constructor
* @extends {goog.Disposable}
* @implements {goog.events.Listenable}
*/
goog.events.EventTarget = function() {
'use strict';
goog.Disposable.call(this);
/**
* Maps of event type to an array of listeners.
* @private {!goog.events.ListenerMap}
*/
this.eventTargetListeners_ = new goog.events.ListenerMap(this);
/**
* The object to use for event.target. Useful when mixing in an
* EventTarget to another object.
* @private {!Object}
*/
this.actualEventTarget_ = this;
/**
* Parent event target, used during event bubbling.
*
* TODO(chrishenry): Change this to goog.events.Listenable. This
* currently breaks people who expect getParentEventTarget to return
* goog.events.EventTarget.
*
* @private {?goog.events.EventTarget}
*/
this.parentEventTarget_ = null;
};
goog.inherits(goog.events.EventTarget, goog.Disposable);
goog.events.Listenable.addImplementation(goog.events.EventTarget);
/**
* An artificial cap on the number of ancestors you can have. This is mainly
* for loop detection.
* @const {number}
* @private
*/
goog.events.EventTarget.MAX_ANCESTORS_ = 1000;
/**
* Returns the parent of this event target to use for bubbling.
*
* @return {goog.events.EventTarget} The parent EventTarget or null if
* there is no parent.
* @override
*/
goog.events.EventTarget.prototype.getParentEventTarget = function() {
'use strict';
return this.parentEventTarget_;
};
/**
* Sets the parent of this event target to use for capture/bubble
* mechanism.
* @param {goog.events.EventTarget} parent Parent listenable (null if none).
*/
goog.events.EventTarget.prototype.setParentEventTarget = function(parent) {
'use strict';
this.parentEventTarget_ = parent;
};
/**
* Adds an event listener to the event target. The same handler can only be
* added once per the type. Even if you add the same handler multiple times
* using the same type then it will only be called once when the event is
* dispatched.
*
* @param {string|!goog.events.EventId} type The type of the event to listen for
* @param {function(?):?|{handleEvent:function(?):?}|null} handler The function
* to handle the event. The handler can also be an object that implements
* the handleEvent method which takes the event object as argument.
* @param {boolean=} opt_capture In DOM-compliant browsers, this determines
* whether the listener is fired during the capture or bubble phase
* of the event.
* @param {Object=} opt_handlerScope Object in whose scope to call
* the listener.
* @deprecated Use `#listen` instead, when possible. Otherwise, use
* `goog.events.listen` if you are passing Object
* (instead of Function) as handler.
*/
goog.events.EventTarget.prototype.addEventListener = function(
type, handler, opt_capture, opt_handlerScope) {
'use strict';
goog.events.listen(this, type, handler, opt_capture, opt_handlerScope);
};
/**
* Removes an event listener from the event target. The handler must be the
* same object as the one added. If the handler has not been added then
* nothing is done.
*
* @param {string|!goog.events.EventId} type The type of the event to listen for
* @param {function(?):?|{handleEvent:function(?):?}|null} handler The function
* to handle the event. The handler can also be an object that implements
* the handleEvent method which takes the event object as argument.
* @param {boolean=} opt_capture In DOM-compliant browsers, this determines
* whether the listener is fired during the capture or bubble phase
* of the event.
* @param {Object=} opt_handlerScope Object in whose scope to call
* the listener.
* @deprecated Use `#unlisten` instead, when possible. Otherwise, use
* `goog.events.unlisten` if you are passing Object
* (instead of Function) as handler.
*/
goog.events.EventTarget.prototype.removeEventListener = function(
type, handler, opt_capture, opt_handlerScope) {
'use strict';
goog.events.unlisten(this, type, handler, opt_capture, opt_handlerScope);
};
/**
* @param {?goog.events.EventLike} e Event object.
* @return {boolean} If anyone called preventDefault on the event object (or
* if any of the listeners returns false) this will also return false.
* @override
*/
goog.events.EventTarget.prototype.dispatchEvent = function(e) {
'use strict';
this.assertInitialized_();
var ancestorsTree, ancestor = this.getParentEventTarget();
if (ancestor) {
ancestorsTree = [];
var ancestorCount = 1;
for (; ancestor; ancestor = ancestor.getParentEventTarget()) {
ancestorsTree.push(ancestor);
goog.asserts.assert(
(++ancestorCount < goog.events.EventTarget.MAX_ANCESTORS_),
'infinite loop');
}
}
return goog.events.EventTarget.dispatchEventInternal_(
this.actualEventTarget_, e, ancestorsTree);
};
/**
* Removes listeners from this object. Classes that extend EventTarget may
* need to override this method in order to remove references to DOM Elements
* and additional listeners.
* @override
* @protected
*/
goog.events.EventTarget.prototype.disposeInternal = function() {
'use strict';
goog.events.EventTarget.superClass_.disposeInternal.call(this);
this.removeAllListeners();
this.parentEventTarget_ = null;
};
/**
* @param {string|!goog.events.EventId<EVENTOBJ>} type The event type id.
* @param {function(this:SCOPE, EVENTOBJ):(boolean|undefined)} listener Callback
* method.
* @param {boolean=} opt_useCapture Whether to fire in capture phase
* (defaults to false).
* @param {SCOPE=} opt_listenerScope Object in whose scope to call the
* listener.
* @return {!goog.events.ListenableKey} Unique key for the listener.
* @template SCOPE,EVENTOBJ
* @override
*/
goog.events.EventTarget.prototype.listen = function(
type, listener, opt_useCapture, opt_listenerScope) {
'use strict';
this.assertInitialized_();
return this.eventTargetListeners_.add(
String(type), listener, false /* callOnce */, opt_useCapture,
opt_listenerScope);
};
/**
* @param {string|!goog.events.EventId<EVENTOBJ>} type The event type id.
* @param {function(this:SCOPE, EVENTOBJ):(boolean|undefined)} listener Callback
* method.
* @param {boolean=} opt_useCapture Whether to fire in capture phase
* (defaults to false).
* @param {SCOPE=} opt_listenerScope Object in whose scope to call the
* listener.
* @return {!goog.events.ListenableKey} Unique key for the listener.
* @template SCOPE,EVENTOBJ
* @override
*/
goog.events.EventTarget.prototype.listenOnce = function(
type, listener, opt_useCapture, opt_listenerScope) {
'use strict';
return this.eventTargetListeners_.add(
String(type), listener, true /* callOnce */, opt_useCapture,
opt_listenerScope);
};
/**
* @param {string|!goog.events.EventId<EVENTOBJ>} type The event type id.
* @param {function(this:SCOPE, EVENTOBJ):(boolean|undefined)} listener Callback
* method.
* @param {boolean=} opt_useCapture Whether to fire in capture phase
* (defaults to false).
* @param {SCOPE=} opt_listenerScope Object in whose scope to call
* the listener.
* @return {boolean} Whether any listener was removed.
* @template SCOPE,EVENTOBJ
* @override
*/
goog.events.EventTarget.prototype.unlisten = function(
type, listener, opt_useCapture, opt_listenerScope) {
'use strict';
return this.eventTargetListeners_.remove(
String(type), listener, opt_useCapture, opt_listenerScope);
};
/**
* @param {!goog.events.ListenableKey} key The key returned by
* listen() or listenOnce().
* @return {boolean} Whether any listener was removed.
* @override
*/
goog.events.EventTarget.prototype.unlistenByKey = function(key) {
'use strict';
return this.eventTargetListeners_.removeByKey(key);
};
/**
* @param {string|!goog.events.EventId=} opt_type Type of event to remove,
* default is to remove all types.
* @return {number} Number of listeners removed.
* @override
*/
goog.events.EventTarget.prototype.removeAllListeners = function(opt_type) {
'use strict';
// TODO(chrishenry): Previously, removeAllListeners can be called on
// uninitialized EventTarget, so we preserve that behavior. We
// should remove this when usages that rely on that fact are purged.
if (!this.eventTargetListeners_) {
return 0;
}
return this.eventTargetListeners_.removeAll(opt_type);
};
/**
* @param {string|!goog.events.EventId<EVENTOBJ>} type The type of the
* listeners to fire.
* @param {boolean} capture The capture mode of the listeners to fire.
* @param {EVENTOBJ} eventObject The event object to fire.
* @return {boolean} Whether all listeners succeeded without
* attempting to prevent default behavior. If any listener returns
* false or called goog.events.Event#preventDefault, this returns
* false.
* @template EVENTOBJ
* @override
*/
goog.events.EventTarget.prototype.fireListeners = function(
type, capture, eventObject) {
'use strict';
// TODO(chrishenry): Original code avoids array creation when there
// is no listener, so we do the same. If this optimization turns
// out to be not required, we can replace this with
// getListeners(type, capture) instead, which is simpler.
var listenerArray = this.eventTargetListeners_.listeners[String(type)];
if (!listenerArray) {
return true;
}
listenerArray = listenerArray.concat();
var rv = true;
for (var i = 0; i < listenerArray.length; ++i) {
var listener = listenerArray[i];
// We might not have a listener if the listener was removed.
if (listener && !listener.removed && listener.capture == capture) {
var listenerFn = listener.listener;
var listenerHandler = listener.handler || listener.src;
if (listener.callOnce) {
this.unlistenByKey(listener);
}
rv = listenerFn.call(listenerHandler, eventObject) !== false && rv;
}
}
return rv && !eventObject.defaultPrevented;
};
/**
* @param {string|!goog.events.EventId} type The type of the listeners to fire.
* @param {boolean} capture The capture mode of the listeners to fire.
* @return {!Array<!goog.events.ListenableKey>} An array of registered
* listeners.
* @template EVENTOBJ
* @override
*/
goog.events.EventTarget.prototype.getListeners = function(type, capture) {
'use strict';
return this.eventTargetListeners_.getListeners(String(type), capture);
};
/**
* @param {string|!goog.events.EventId<EVENTOBJ>} type The name of the event
* without the 'on' prefix.
* @param {function(this:SCOPE, EVENTOBJ):(boolean|undefined)} listener The
* listener function to get.
* @param {boolean} capture Whether the listener is a capturing listener.
* @param {SCOPE=} opt_listenerScope Object in whose scope to call the
* listener.
* @return {?goog.events.ListenableKey} the found listener or null if not found.
* @template SCOPE,EVENTOBJ
* @override
*/
goog.events.EventTarget.prototype.getListener = function(
type, listener, capture, opt_listenerScope) {
'use strict';
return this.eventTargetListeners_.getListener(
String(type), listener, capture, opt_listenerScope);
};
/**
* @param {string|!goog.events.EventId<EVENTOBJ>=} opt_type Event type.
* @param {boolean=} opt_capture Whether to check for capture or bubble
* listeners.
* @return {boolean} Whether there is any active listeners matching
* the requested type and/or capture phase.
* @template EVENTOBJ
* @override
*/
goog.events.EventTarget.prototype.hasListener = function(
opt_type, opt_capture) {
'use strict';
var id = (opt_type !== undefined) ? String(opt_type) : undefined;
return this.eventTargetListeners_.hasListener(id, opt_capture);
};
/**
* Sets the target to be used for `event.target` when firing
* event. Mainly used for testing. For example, see
* `goog.testing.events.mixinListenable`.
* @param {!Object} target The target.
*/
goog.events.EventTarget.prototype.setTargetForTesting = function(target) {
'use strict';
this.actualEventTarget_ = target;
};
/**
* Asserts that the event target instance is initialized properly.
* @private
*/
goog.events.EventTarget.prototype.assertInitialized_ = function() {
'use strict';
goog.asserts.assert(
this.eventTargetListeners_,
'Event target is not initialized. Did you call the superclass ' +
'(goog.events.EventTarget) constructor?');
};
/**
* Dispatches the given event on the ancestorsTree.
*
* @param {!Object} target The target to dispatch on.
* @param {goog.events.Event|Object|string} e The event object.
* @param {Array<goog.events.Listenable>=} opt_ancestorsTree The ancestors
* tree of the target, in reverse order from the closest ancestor
* to the root event target. May be null if the target has no ancestor.
* @return {boolean} If anyone called preventDefault on the event object (or
* if any of the listeners returns false) this will also return false.
* @private
*/
goog.events.EventTarget.dispatchEventInternal_ = function(
target, e, opt_ancestorsTree) {
'use strict';
/** @suppress {missingProperties} */
var type = e.type || /** @type {string} */ (e);
// If accepting a string or object, create a custom event object so that
// preventDefault and stopPropagation work with the event.
if (typeof e === 'string') {
e = new goog.events.Event(e, target);
} else if (!(e instanceof goog.events.Event)) {
var oldEvent = e;
e = new goog.events.Event(type, target);
goog.object.extend(e, oldEvent);
} else {
e.target = e.target || target;
}
var rv = true, currentTarget;
// Executes all capture listeners on the ancestors, if any.
if (opt_ancestorsTree) {
for (var i = opt_ancestorsTree.length - 1;
!e.hasPropagationStopped() && i >= 0; i--) {
currentTarget = e.currentTarget = opt_ancestorsTree[i];
rv = currentTarget.fireListeners(type, true, e) && rv;
}
}
// Executes capture and bubble listeners on the target.
if (!e.hasPropagationStopped()) {
currentTarget = /** @type {?} */ (e.currentTarget = target);
rv = currentTarget.fireListeners(type, true, e) && rv;
if (!e.hasPropagationStopped()) {
rv = currentTarget.fireListeners(type, false, e) && rv;
}
}
// Executes all bubble listeners on the ancestors, if any.
if (opt_ancestorsTree) {
for (i = 0; !e.hasPropagationStopped() && i < opt_ancestorsTree.length;
i++) {
currentTarget = e.currentTarget = opt_ancestorsTree[i];
rv = currentTarget.fireListeners(type, false, e) && rv;
}
}
return rv;
};

View File

@ -1,282 +0,0 @@
/**
* @license
* Copyright The Closure Library Authors.
* SPDX-License-Identifier: Apache-2.0
*/
goog.provide('goog.events.EventType');
goog.require('goog.events.eventTypeHelpers');
goog.require('goog.userAgent');
/**
* Constants for event names.
* @enum {string}
*/
goog.events.EventType = {
// Mouse events
CLICK: 'click',
RIGHTCLICK: 'rightclick',
DBLCLICK: 'dblclick',
AUXCLICK: 'auxclick',
MOUSEDOWN: 'mousedown',
MOUSEUP: 'mouseup',
MOUSEOVER: 'mouseover',
MOUSEOUT: 'mouseout',
MOUSEMOVE: 'mousemove',
MOUSEENTER: 'mouseenter',
MOUSELEAVE: 'mouseleave',
// Non-existent event; will never fire. This exists as a mouse counterpart to
// POINTERCANCEL.
MOUSECANCEL: 'mousecancel',
// Selection events.
// https://www.w3.org/TR/selection-api/
SELECTIONCHANGE: 'selectionchange',
SELECTSTART: 'selectstart', // IE, Safari, Chrome
// Wheel events
// http://www.w3.org/TR/DOM-Level-3-Events/#events-wheelevents
WHEEL: 'wheel',
// Key events
KEYPRESS: 'keypress',
KEYDOWN: 'keydown',
KEYUP: 'keyup',
// Focus
BLUR: 'blur',
FOCUS: 'focus',
DEACTIVATE: 'deactivate', // IE only
FOCUSIN: 'focusin',
FOCUSOUT: 'focusout',
// Forms
CHANGE: 'change',
RESET: 'reset',
SELECT: 'select',
SUBMIT: 'submit',
INPUT: 'input',
PROPERTYCHANGE: 'propertychange', // IE only
// Drag and drop
DRAGSTART: 'dragstart',
DRAG: 'drag',
DRAGENTER: 'dragenter',
DRAGOVER: 'dragover',
DRAGLEAVE: 'dragleave',
DROP: 'drop',
DRAGEND: 'dragend',
// Touch events
// Note that other touch events exist, but we should follow the W3C list here.
// http://www.w3.org/TR/touch-events/#list-of-touchevent-types
TOUCHSTART: 'touchstart',
TOUCHMOVE: 'touchmove',
TOUCHEND: 'touchend',
TOUCHCANCEL: 'touchcancel',
// Misc
BEFOREUNLOAD: 'beforeunload',
CONSOLEMESSAGE: 'consolemessage',
CONTEXTMENU: 'contextmenu',
DEVICECHANGE: 'devicechange',
DEVICEMOTION: 'devicemotion',
DEVICEORIENTATION: 'deviceorientation',
DOMCONTENTLOADED: 'DOMContentLoaded',
ERROR: 'error',
HELP: 'help',
LOAD: 'load',
LOSECAPTURE: 'losecapture',
ORIENTATIONCHANGE: 'orientationchange',
READYSTATECHANGE: 'readystatechange',
RESIZE: 'resize',
SCROLL: 'scroll',
UNLOAD: 'unload',
// Media events
CANPLAY: 'canplay',
CANPLAYTHROUGH: 'canplaythrough',
DURATIONCHANGE: 'durationchange',
EMPTIED: 'emptied',
ENDED: 'ended',
LOADEDDATA: 'loadeddata',
LOADEDMETADATA: 'loadedmetadata',
PAUSE: 'pause',
PLAY: 'play',
PLAYING: 'playing',
PROGRESS: 'progress',
RATECHANGE: 'ratechange',
SEEKED: 'seeked',
SEEKING: 'seeking',
STALLED: 'stalled',
SUSPEND: 'suspend',
TIMEUPDATE: 'timeupdate',
VOLUMECHANGE: 'volumechange',
WAITING: 'waiting',
// Media Source Extensions events
// https://www.w3.org/TR/media-source/#mediasource-events
SOURCEOPEN: 'sourceopen',
SOURCEENDED: 'sourceended',
SOURCECLOSED: 'sourceclosed',
// https://www.w3.org/TR/media-source/#sourcebuffer-events
ABORT: 'abort',
UPDATE: 'update',
UPDATESTART: 'updatestart',
UPDATEEND: 'updateend',
// HTML 5 History events
// See http://www.w3.org/TR/html5/browsers.html#event-definitions-0
HASHCHANGE: 'hashchange',
PAGEHIDE: 'pagehide',
PAGESHOW: 'pageshow',
POPSTATE: 'popstate',
// Copy and Paste
// Support is limited. Make sure it works on your favorite browser
// before using.
// http://www.quirksmode.org/dom/events/cutcopypaste.html
COPY: 'copy',
PASTE: 'paste',
CUT: 'cut',
BEFORECOPY: 'beforecopy',
BEFORECUT: 'beforecut',
BEFOREPASTE: 'beforepaste',
// HTML5 online/offline events.
// http://www.w3.org/TR/offline-webapps/#related
ONLINE: 'online',
OFFLINE: 'offline',
// HTML 5 worker events
MESSAGE: 'message',
CONNECT: 'connect',
// Service Worker Events - ServiceWorkerGlobalScope context
// See https://w3c.github.io/ServiceWorker/#execution-context-events
// Note: message event defined in worker events section
INSTALL: 'install',
ACTIVATE: 'activate',
FETCH: 'fetch',
FOREIGNFETCH: 'foreignfetch',
MESSAGEERROR: 'messageerror',
// Service Worker Events - Document context
// See https://w3c.github.io/ServiceWorker/#document-context-events
STATECHANGE: 'statechange',
UPDATEFOUND: 'updatefound',
CONTROLLERCHANGE: 'controllerchange',
// CSS animation events.
ANIMATIONSTART:
goog.events.eventTypeHelpers.getVendorPrefixedName('AnimationStart'),
ANIMATIONEND:
goog.events.eventTypeHelpers.getVendorPrefixedName('AnimationEnd'),
ANIMATIONITERATION:
goog.events.eventTypeHelpers.getVendorPrefixedName('AnimationIteration'),
// CSS transition events. Based on the browser support described at:
// https://developer.mozilla.org/en/css/css_transitions#Browser_compatibility
TRANSITIONEND:
goog.events.eventTypeHelpers.getVendorPrefixedName('TransitionEnd'),
// W3C Pointer Events
// http://www.w3.org/TR/pointerevents/
POINTERDOWN: 'pointerdown',
POINTERUP: 'pointerup',
POINTERCANCEL: 'pointercancel',
POINTERMOVE: 'pointermove',
POINTEROVER: 'pointerover',
POINTEROUT: 'pointerout',
POINTERENTER: 'pointerenter',
POINTERLEAVE: 'pointerleave',
GOTPOINTERCAPTURE: 'gotpointercapture',
LOSTPOINTERCAPTURE: 'lostpointercapture',
// IE specific events.
// See http://msdn.microsoft.com/en-us/library/ie/hh772103(v=vs.85).aspx
// Note: these events will be supplanted in IE11.
MSGESTURECHANGE: 'MSGestureChange',
MSGESTUREEND: 'MSGestureEnd',
MSGESTUREHOLD: 'MSGestureHold',
MSGESTURESTART: 'MSGestureStart',
MSGESTURETAP: 'MSGestureTap',
MSGOTPOINTERCAPTURE: 'MSGotPointerCapture',
MSINERTIASTART: 'MSInertiaStart',
MSLOSTPOINTERCAPTURE: 'MSLostPointerCapture',
MSPOINTERCANCEL: 'MSPointerCancel',
MSPOINTERDOWN: 'MSPointerDown',
MSPOINTERENTER: 'MSPointerEnter',
MSPOINTERHOVER: 'MSPointerHover',
MSPOINTERLEAVE: 'MSPointerLeave',
MSPOINTERMOVE: 'MSPointerMove',
MSPOINTEROUT: 'MSPointerOut',
MSPOINTEROVER: 'MSPointerOver',
MSPOINTERUP: 'MSPointerUp',
// Native IMEs/input tools events.
TEXT: 'text',
// The textInput event is supported in IE9+, but only in lower case. All other
// browsers use the camel-case event name.
TEXTINPUT: goog.userAgent.IE ? 'textinput' : 'textInput',
COMPOSITIONSTART: 'compositionstart',
COMPOSITIONUPDATE: 'compositionupdate',
COMPOSITIONEND: 'compositionend',
// The beforeinput event is initially only supported in Safari. See
// https://bugs.chromium.org/p/chromium/issues/detail?id=342670 for Chrome
// implementation tracking.
BEFOREINPUT: 'beforeinput',
// Fullscreen API events. See https://fullscreen.spec.whatwg.org/.
FULLSCREENCHANGE: 'fullscreenchange',
// iOS-only fullscreen events. See
// https://developer.apple.com/library/archive/documentation/AudioVideo/Conceptual/Using_HTML5_Audio_Video/ControllingMediaWithJavaScript/ControllingMediaWithJavaScript.html
WEBKITBEGINFULLSCREEN: 'webkitbeginfullscreen',
WEBKITENDFULLSCREEN: 'webkitendfullscreen',
// Webview tag events
// See https://developer.chrome.com/apps/tags/webview
EXIT: 'exit',
LOADABORT: 'loadabort',
LOADCOMMIT: 'loadcommit',
LOADREDIRECT: 'loadredirect',
LOADSTART: 'loadstart',
LOADSTOP: 'loadstop',
RESPONSIVE: 'responsive',
SIZECHANGED: 'sizechanged',
UNRESPONSIVE: 'unresponsive',
// HTML5 Page Visibility API. See details at
// `goog.labs.dom.PageVisibilityMonitor`.
VISIBILITYCHANGE: 'visibilitychange',
// LocalStorage event.
STORAGE: 'storage',
// DOM Level 2 mutation events (deprecated).
DOMSUBTREEMODIFIED: 'DOMSubtreeModified',
DOMNODEINSERTED: 'DOMNodeInserted',
DOMNODEREMOVED: 'DOMNodeRemoved',
DOMNODEREMOVEDFROMDOCUMENT: 'DOMNodeRemovedFromDocument',
DOMNODEINSERTEDINTODOCUMENT: 'DOMNodeInsertedIntoDocument',
DOMATTRMODIFIED: 'DOMAttrModified',
DOMCHARACTERDATAMODIFIED: 'DOMCharacterDataModified',
// Print events.
BEFOREPRINT: 'beforeprint',
AFTERPRINT: 'afterprint',
// Web app manifest events.
BEFOREINSTALLPROMPT: 'beforeinstallprompt',
APPINSTALLED: 'appinstalled',
// Web Animation API (WAAPI) playback events
// https://www.w3.org/TR/web-animations-1/#animation-playback-event-types
CANCEL: 'cancel',
FINISH: 'finish',
REMOVE: 'remove'
};

View File

@ -1,52 +0,0 @@
/**
* @license
* Copyright The Closure Library Authors.
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @fileoverview Helpers for defining EventTypes.
*/
goog.provide('goog.events.eventTypeHelpers');
goog.require('goog.events.BrowserFeature');
goog.require('goog.userAgent');
/**
* Returns a prefixed event name for the current browser.
* @param {string} eventName The name of the event.
* @return {string} The prefixed event name.
* @package
*/
goog.events.eventTypeHelpers.getVendorPrefixedName = function(eventName) {
'use strict';
return goog.userAgent.WEBKIT ? 'webkit' + eventName : eventName.toLowerCase();
};
/**
* Returns one of the given pointer fallback event names in order of preference:
* 1. pointerEventName
* 2. msPointerEventName
* 3. fallbackEventName
* @param {string} pointerEventName
* @param {string} msPointerEventName
* @param {string} fallbackEventName
* @return {string} The supported pointer or fallback (mouse or touch) event
* name.
* @package
*/
goog.events.eventTypeHelpers.getPointerFallbackEventName = function(
pointerEventName, msPointerEventName, fallbackEventName) {
'use strict';
if (goog.events.BrowserFeature.POINTER_EVENTS) {
return pointerEventName;
}
if (goog.events.BrowserFeature.MSPOINTER_EVENTS) {
return msPointerEventName;
}
return fallbackEventName;
};

View File

@ -1,56 +0,0 @@
/**
* @license
* Copyright The Closure Library Authors.
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @fileoverview Definition of the goog.events.EventWrapper interface.
*/
goog.provide('goog.events.EventWrapper');
goog.requireType('goog.events.EventHandler');
goog.requireType('goog.events.ListenableType');
/**
* Interface for event wrappers.
* @interface
*/
goog.events.EventWrapper = function() {};
/**
* Adds an event listener using the wrapper on a DOM Node or an object that has
* implemented {@link goog.events.EventTarget}. A listener can only be added
* once to an object.
*
* @param {goog.events.ListenableType} src The node to listen to events on.
* @param {function(?):?|{handleEvent:function(?):?}|null} listener Callback
* method, or an object with a handleEvent function.
* @param {boolean=} opt_capt Whether to fire in capture phase (defaults to
* false).
* @param {Object=} opt_scope Element in whose scope to call the listener.
* @param {goog.events.EventHandler=} opt_eventHandler Event handler to add
* listener to.
*/
goog.events.EventWrapper.prototype.listen = function(
src, listener, opt_capt, opt_scope, opt_eventHandler) {};
/**
* Removes an event listener added using goog.events.EventWrapper.listen.
*
* @param {goog.events.ListenableType} src The node to remove listener from.
* @param {function(?):?|{handleEvent:function(?):?}|null} listener Callback
* method, or an object with a handleEvent function.
* @param {boolean=} opt_capt Whether to fire in capture phase (defaults to
* false).
* @param {Object=} opt_scope Element in whose scope to call the listener.
* @param {goog.events.EventHandler=} opt_eventHandler Event handler to remove
* listener from.
*/
goog.events.EventWrapper.prototype.unlisten = function(
src, listener, opt_capt, opt_scope, opt_eventHandler) {};

View File

@ -1,265 +0,0 @@
/**
* @license
* Copyright The Closure Library Authors.
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @fileoverview An interface for a listenable JavaScript object.
*/
goog.provide('goog.events.Listenable');
goog.requireType('goog.events.EventId');
goog.requireType('goog.events.EventLike');
goog.requireType('goog.events.ListenableKey');
/**
* A listenable interface. A listenable is an object with the ability
* to dispatch/broadcast events to "event listeners" registered via
* listen/listenOnce.
*
* The interface allows for an event propagation mechanism similar
* to one offered by native browser event targets, such as
* capture/bubble mechanism, stopping propagation, and preventing
* default actions. Capture/bubble mechanism depends on the ancestor
* tree constructed via `#getParentEventTarget`; this tree
* must be directed acyclic graph. The meaning of default action(s)
* in preventDefault is specific to a particular use case.
*
* Implementations that do not support capture/bubble or can not have
* a parent listenable can simply not implement any ability to set the
* parent listenable (and have `#getParentEventTarget` return
* null).
*
* Implementation of this class can be used with or independently from
* goog.events.
*
* Implementation must call `#addImplementation(implClass)`.
*
* @interface
* @see goog.events
* @see http://www.w3.org/TR/DOM-Level-2-Events/events.html
*/
goog.events.Listenable = function() {};
/**
* An expando property to indicate that an object implements
* goog.events.Listenable.
*
* See addImplementation/isImplementedBy.
*
* @type {string}
* @const
*/
goog.events.Listenable.IMPLEMENTED_BY_PROP =
'closure_listenable_' + ((Math.random() * 1e6) | 0);
/**
* Marks a given class (constructor) as an implementation of
* Listenable, so that we can query that fact at runtime. The class
* must have already implemented the interface.
* @param {function(new:goog.events.Listenable,...)} cls The class constructor.
* The corresponding class must have already implemented the interface.
*/
goog.events.Listenable.addImplementation = function(cls) {
'use strict';
cls.prototype[goog.events.Listenable.IMPLEMENTED_BY_PROP] = true;
};
/**
* @param {?Object} obj The object to check.
* @return {boolean} Whether a given instance implements Listenable. The
* class/superclass of the instance must call addImplementation.
*/
goog.events.Listenable.isImplementedBy = function(obj) {
'use strict';
return !!(obj && obj[goog.events.Listenable.IMPLEMENTED_BY_PROP]);
};
/**
* Adds an event listener. A listener can only be added once to an
* object and if it is added again the key for the listener is
* returned. Note that if the existing listener is a one-off listener
* (registered via listenOnce), it will no longer be a one-off
* listener after a call to listen().
*
* @param {string|!goog.events.EventId<EVENTOBJ>} type The event type id.
* @param {function(this:SCOPE, EVENTOBJ):(boolean|undefined)} listener Callback
* method.
* @param {boolean=} opt_useCapture Whether to fire in capture phase
* (defaults to false).
* @param {SCOPE=} opt_listenerScope Object in whose scope to call the
* listener.
* @return {!goog.events.ListenableKey} Unique key for the listener.
* @template SCOPE,EVENTOBJ
*/
goog.events.Listenable.prototype.listen = function(
type, listener, opt_useCapture, opt_listenerScope) {};
/**
* Adds an event listener that is removed automatically after the
* listener fired once.
*
* If an existing listener already exists, listenOnce will do
* nothing. In particular, if the listener was previously registered
* via listen(), listenOnce() will not turn the listener into a
* one-off listener. Similarly, if there is already an existing
* one-off listener, listenOnce does not modify the listeners (it is
* still a once listener).
*
* @param {string|!goog.events.EventId<EVENTOBJ>} type The event type id.
* @param {function(this:SCOPE, EVENTOBJ):(boolean|undefined)} listener Callback
* method.
* @param {boolean=} opt_useCapture Whether to fire in capture phase
* (defaults to false).
* @param {SCOPE=} opt_listenerScope Object in whose scope to call the
* listener.
* @return {!goog.events.ListenableKey} Unique key for the listener.
* @template SCOPE,EVENTOBJ
*/
goog.events.Listenable.prototype.listenOnce = function(
type, listener, opt_useCapture, opt_listenerScope) {};
/**
* Removes an event listener which was added with listen() or listenOnce().
*
* @param {string|!goog.events.EventId<EVENTOBJ>} type The event type id.
* @param {function(this:SCOPE, EVENTOBJ):(boolean|undefined)} listener Callback
* method.
* @param {boolean=} opt_useCapture Whether to fire in capture phase
* (defaults to false).
* @param {SCOPE=} opt_listenerScope Object in whose scope to call
* the listener.
* @return {boolean} Whether any listener was removed.
* @template SCOPE,EVENTOBJ
*/
goog.events.Listenable.prototype.unlisten = function(
type, listener, opt_useCapture, opt_listenerScope) {};
/**
* Removes an event listener which was added with listen() by the key
* returned by listen().
*
* @param {!goog.events.ListenableKey} key The key returned by
* listen() or listenOnce().
* @return {boolean} Whether any listener was removed.
*/
goog.events.Listenable.prototype.unlistenByKey = function(key) {};
/**
* Dispatches an event (or event like object) and calls all listeners
* listening for events of this type. The type of the event is decided by the
* type property on the event object.
*
* If any of the listeners returns false OR calls preventDefault then this
* function will return false. If one of the capture listeners calls
* stopPropagation, then the bubble listeners won't fire.
*
* @param {?goog.events.EventLike} e Event object.
* @return {boolean} If anyone called preventDefault on the event object (or
* if any of the listeners returns false) this will also return false.
*/
goog.events.Listenable.prototype.dispatchEvent = function(e) {};
/**
* Removes all listeners from this listenable. If type is specified,
* it will only remove listeners of the particular type. otherwise all
* registered listeners will be removed.
*
* @param {string|!goog.events.EventId=} opt_type Type of event to remove,
* default is to remove all types.
* @return {number} Number of listeners removed.
*/
goog.events.Listenable.prototype.removeAllListeners = function(opt_type) {};
/**
* Returns the parent of this event target to use for capture/bubble
* mechanism.
*
* NOTE(chrishenry): The name reflects the original implementation of
* custom event target (`goog.events.EventTarget`). We decided
* that changing the name is not worth it.
*
* @return {?goog.events.Listenable} The parent EventTarget or null if
* there is no parent.
*/
goog.events.Listenable.prototype.getParentEventTarget = function() {};
/**
* Fires all registered listeners in this listenable for the given
* type and capture mode, passing them the given eventObject. This
* does not perform actual capture/bubble. Only implementors of the
* interface should be using this.
*
* @param {string|!goog.events.EventId<EVENTOBJ>} type The type of the
* listeners to fire.
* @param {boolean} capture The capture mode of the listeners to fire.
* @param {EVENTOBJ} eventObject The event object to fire.
* @return {boolean} Whether all listeners succeeded without
* attempting to prevent default behavior. If any listener returns
* false or called goog.events.Event#preventDefault, this returns
* false.
* @template EVENTOBJ
*/
goog.events.Listenable.prototype.fireListeners = function(
type, capture, eventObject) {};
/**
* Gets all listeners in this listenable for the given type and
* capture mode.
*
* @param {string|!goog.events.EventId} type The type of the listeners to fire.
* @param {boolean} capture The capture mode of the listeners to fire.
* @return {!Array<!goog.events.ListenableKey>} An array of registered
* listeners.
* @template EVENTOBJ
*/
goog.events.Listenable.prototype.getListeners = function(type, capture) {};
/**
* Gets the goog.events.ListenableKey for the event or null if no such
* listener is in use.
*
* @param {string|!goog.events.EventId<EVENTOBJ>} type The name of the event
* without the 'on' prefix.
* @param {function(this:SCOPE, EVENTOBJ):(boolean|undefined)} listener The
* listener function to get.
* @param {boolean} capture Whether the listener is a capturing listener.
* @param {SCOPE=} opt_listenerScope Object in whose scope to call the
* listener.
* @return {?goog.events.ListenableKey} the found listener or null if not found.
* @template SCOPE,EVENTOBJ
*/
goog.events.Listenable.prototype.getListener = function(
type, listener, capture, opt_listenerScope) {};
/**
* Whether there is any active listeners matching the specified
* signature. If either the type or capture parameters are
* unspecified, the function will match on the remaining criteria.
*
* @param {string|!goog.events.EventId<EVENTOBJ>=} opt_type Event type.
* @param {boolean=} opt_capture Whether to check for capture or bubble
* listeners.
* @return {boolean} Whether there is any active listeners matching
* the requested type and/or capture phase.
* @template EVENTOBJ
*/
goog.events.Listenable.prototype.hasListener = function(
opt_type, opt_capture) {};

View File

@ -1,80 +0,0 @@
/**
* @license
* Copyright The Closure Library Authors.
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @fileoverview An interface that describes a single registered listener.
*/
goog.provide('goog.events.ListenableKey');
goog.requireType('goog.events.Listenable');
/**
* An interface that describes a single registered listener.
* @interface
*/
goog.events.ListenableKey = function() {};
/**
* Counter used to create a unique key
* @type {number}
* @private
*/
goog.events.ListenableKey.counter_ = 0;
/**
* Reserves a key to be used for ListenableKey#key field.
* @return {number} A number to be used to fill ListenableKey#key
* field.
*/
goog.events.ListenableKey.reserveKey = function() {
'use strict';
return ++goog.events.ListenableKey.counter_;
};
/**
* The source event target.
* @type {?Object|?goog.events.Listenable}
*/
goog.events.ListenableKey.prototype.src;
/**
* The event type the listener is listening to.
* @type {string}
*/
goog.events.ListenableKey.prototype.type;
/**
* The listener function.
* @type {function(?):?|{handleEvent:function(?):?}|null}
*/
goog.events.ListenableKey.prototype.listener;
/**
* Whether the listener works on capture phase.
* @type {boolean}
*/
goog.events.ListenableKey.prototype.capture;
/**
* The 'this' object for the listener function's scope.
* @type {?Object|undefined}
*/
goog.events.ListenableKey.prototype.handler;
/**
* A globally unique number to identify the key.
* @type {number}
*/
goog.events.ListenableKey.prototype.key;

View File

@ -1,124 +0,0 @@
/**
* @license
* Copyright The Closure Library Authors.
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @fileoverview Listener object.
* @see ../demos/events.html
*/
goog.provide('goog.events.Listener');
goog.require('goog.events.ListenableKey');
goog.requireType('goog.events.Listenable');
/**
* Simple class that stores information about a listener
* @param {function(?):?} listener Callback function.
* @param {Function} proxy Wrapper for the listener that patches the event.
* @param {EventTarget|goog.events.Listenable} src Source object for
* the event.
* @param {string} type Event type.
* @param {boolean} capture Whether in capture or bubble phase.
* @param {Object=} opt_handler Object in whose context to execute the callback.
* @implements {goog.events.ListenableKey}
* @constructor
*/
goog.events.Listener = function(
listener, proxy, src, type, capture, opt_handler) {
'use strict';
if (goog.events.Listener.ENABLE_MONITORING) {
this.creationStack = new Error().stack;
}
/** @override */
this.listener = listener;
/**
* A wrapper over the original listener. This is used solely to
* handle native browser events (it is used to simulate the capture
* phase and to patch the event object).
* @type {Function}
*/
this.proxy = proxy;
/**
* Object or node that callback is listening to
* @type {EventTarget|goog.events.Listenable}
*/
this.src = src;
/**
* The event type.
* @const {string}
*/
this.type = type;
/**
* Whether the listener is being called in the capture or bubble phase
* @const {boolean}
*/
this.capture = !!capture;
/**
* Optional object whose context to execute the listener in
* @type {Object|undefined}
*/
this.handler = opt_handler;
/**
* The key of the listener.
* @const {number}
* @override
*/
this.key = goog.events.ListenableKey.reserveKey();
/**
* Whether to remove the listener after it has been called.
* @type {boolean}
*/
this.callOnce = false;
/**
* Whether the listener has been removed.
* @type {boolean}
*/
this.removed = false;
};
/**
* @define {boolean} Whether to enable the monitoring of the
* goog.events.Listener instances. Switching on the monitoring is only
* recommended for debugging because it has a significant impact on
* performance and memory usage. If switched off, the monitoring code
* compiles down to 0 bytes.
*/
goog.events.Listener.ENABLE_MONITORING =
goog.define('goog.events.Listener.ENABLE_MONITORING', false);
/**
* If monitoring the goog.events.Listener instances is enabled, stores the
* creation stack trace of the Disposable instance.
* @type {string}
*/
goog.events.Listener.prototype.creationStack;
/**
* Marks this listener as removed. This also remove references held by
* this listener object (such as listener and event source).
*/
goog.events.Listener.prototype.markAsRemoved = function() {
'use strict';
this.removed = true;
this.listener = null;
this.proxy = null;
this.src = null;
this.handler = null;
};

View File

@ -1,310 +0,0 @@
/**
* @license
* Copyright The Closure Library Authors.
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @fileoverview A map of listeners that provides utility functions to
* deal with listeners on an event target. Used by
* `goog.events.EventTarget`.
*
* WARNING: Do not use this class from outside goog.events package.
*
*/
goog.provide('goog.events.ListenerMap');
goog.require('goog.array');
goog.require('goog.events.Listener');
goog.require('goog.object');
goog.requireType('goog.events.EventId');
goog.requireType('goog.events.Listenable');
goog.requireType('goog.events.ListenableKey');
/**
* Creates a new listener map.
* @param {EventTarget|goog.events.Listenable} src The src object.
* @constructor
* @final
*/
goog.events.ListenerMap = function(src) {
'use strict';
/** @type {EventTarget|goog.events.Listenable} */
this.src = src;
/**
* Maps of event type to an array of listeners.
* @type {!Object<string, !Array<!goog.events.Listener>>}
*/
this.listeners = {};
/**
* The count of types in this map that have registered listeners.
* @private {number}
*/
this.typeCount_ = 0;
};
/**
* @return {number} The count of event types in this map that actually
* have registered listeners.
*/
goog.events.ListenerMap.prototype.getTypeCount = function() {
'use strict';
return this.typeCount_;
};
/**
* @return {number} Total number of registered listeners.
*/
goog.events.ListenerMap.prototype.getListenerCount = function() {
'use strict';
var count = 0;
for (var type in this.listeners) {
count += this.listeners[type].length;
}
return count;
};
/**
* Adds an event listener. A listener can only be added once to an
* object and if it is added again the key for the listener is
* returned.
*
* Note that a one-off listener will not change an existing listener,
* if any. On the other hand a normal listener will change existing
* one-off listener to become a normal listener.
*
* @param {string|!goog.events.EventId} type The listener event type.
* @param {!Function} listener This listener callback method.
* @param {boolean} callOnce Whether the listener is a one-off
* listener.
* @param {boolean=} opt_useCapture The capture mode of the listener.
* @param {Object=} opt_listenerScope Object in whose scope to call the
* listener.
* @return {!goog.events.ListenableKey} Unique key for the listener.
*/
goog.events.ListenerMap.prototype.add = function(
type, listener, callOnce, opt_useCapture, opt_listenerScope) {
'use strict';
var typeStr = type.toString();
var listenerArray = this.listeners[typeStr];
if (!listenerArray) {
listenerArray = this.listeners[typeStr] = [];
this.typeCount_++;
}
var listenerObj;
var index = goog.events.ListenerMap.findListenerIndex_(
listenerArray, listener, opt_useCapture, opt_listenerScope);
if (index > -1) {
listenerObj = listenerArray[index];
if (!callOnce) {
// Ensure that, if there is an existing callOnce listener, it is no
// longer a callOnce listener.
listenerObj.callOnce = false;
}
} else {
listenerObj = new goog.events.Listener(
listener, null, this.src, typeStr, !!opt_useCapture, opt_listenerScope);
listenerObj.callOnce = callOnce;
listenerArray.push(listenerObj);
}
return listenerObj;
};
/**
* Removes a matching listener.
* @param {string|!goog.events.EventId} type The listener event type.
* @param {!Function} listener This listener callback method.
* @param {boolean=} opt_useCapture The capture mode of the listener.
* @param {Object=} opt_listenerScope Object in whose scope to call the
* listener.
* @return {boolean} Whether any listener was removed.
*/
goog.events.ListenerMap.prototype.remove = function(
type, listener, opt_useCapture, opt_listenerScope) {
'use strict';
var typeStr = type.toString();
if (!(typeStr in this.listeners)) {
return false;
}
var listenerArray = this.listeners[typeStr];
var index = goog.events.ListenerMap.findListenerIndex_(
listenerArray, listener, opt_useCapture, opt_listenerScope);
if (index > -1) {
var listenerObj = listenerArray[index];
listenerObj.markAsRemoved();
goog.array.removeAt(listenerArray, index);
if (listenerArray.length == 0) {
delete this.listeners[typeStr];
this.typeCount_--;
}
return true;
}
return false;
};
/**
* Removes the given listener object.
* @param {!goog.events.ListenableKey} listener The listener to remove.
* @return {boolean} Whether the listener is removed.
*/
goog.events.ListenerMap.prototype.removeByKey = function(listener) {
'use strict';
var type = listener.type;
if (!(type in this.listeners)) {
return false;
}
var removed = goog.array.remove(this.listeners[type], listener);
if (removed) {
/** @type {!goog.events.Listener} */ (listener).markAsRemoved();
if (this.listeners[type].length == 0) {
delete this.listeners[type];
this.typeCount_--;
}
}
return removed;
};
/**
* Removes all listeners from this map. If opt_type is provided, only
* listeners that match the given type are removed.
* @param {string|!goog.events.EventId=} opt_type Type of event to remove.
* @return {number} Number of listeners removed.
*/
goog.events.ListenerMap.prototype.removeAll = function(opt_type) {
'use strict';
var typeStr = opt_type && opt_type.toString();
var count = 0;
for (var type in this.listeners) {
if (!typeStr || type == typeStr) {
var listenerArray = this.listeners[type];
for (var i = 0; i < listenerArray.length; i++) {
++count;
listenerArray[i].markAsRemoved();
}
delete this.listeners[type];
this.typeCount_--;
}
}
return count;
};
/**
* Gets all listeners that match the given type and capture mode. The
* returned array is a copy (but the listener objects are not).
* @param {string|!goog.events.EventId} type The type of the listeners
* to retrieve.
* @param {boolean} capture The capture mode of the listeners to retrieve.
* @return {!Array<!goog.events.ListenableKey>} An array of matching
* listeners.
*/
goog.events.ListenerMap.prototype.getListeners = function(type, capture) {
'use strict';
var listenerArray = this.listeners[type.toString()];
var rv = [];
if (listenerArray) {
for (var i = 0; i < listenerArray.length; ++i) {
var listenerObj = listenerArray[i];
if (listenerObj.capture == capture) {
rv.push(listenerObj);
}
}
}
return rv;
};
/**
* Gets the goog.events.ListenableKey for the event or null if no such
* listener is in use.
*
* @param {string|!goog.events.EventId} type The type of the listener
* to retrieve.
* @param {!Function} listener The listener function to get.
* @param {boolean} capture Whether the listener is a capturing listener.
* @param {Object=} opt_listenerScope Object in whose scope to call the
* listener.
* @return {goog.events.ListenableKey} the found listener or null if not found.
*/
goog.events.ListenerMap.prototype.getListener = function(
type, listener, capture, opt_listenerScope) {
'use strict';
var listenerArray = this.listeners[type.toString()];
var i = -1;
if (listenerArray) {
i = goog.events.ListenerMap.findListenerIndex_(
listenerArray, listener, capture, opt_listenerScope);
}
return i > -1 ? listenerArray[i] : null;
};
/**
* Whether there is a matching listener. If either the type or capture
* parameters are unspecified, the function will match on the
* remaining criteria.
*
* @param {string|!goog.events.EventId=} opt_type The type of the listener.
* @param {boolean=} opt_capture The capture mode of the listener.
* @return {boolean} Whether there is an active listener matching
* the requested type and/or capture phase.
*/
goog.events.ListenerMap.prototype.hasListener = function(
opt_type, opt_capture) {
'use strict';
var hasType = (opt_type !== undefined);
var typeStr = hasType ? opt_type.toString() : '';
var hasCapture = (opt_capture !== undefined);
return goog.object.some(this.listeners, function(listenerArray, type) {
'use strict';
for (var i = 0; i < listenerArray.length; ++i) {
if ((!hasType || listenerArray[i].type == typeStr) &&
(!hasCapture || listenerArray[i].capture == opt_capture)) {
return true;
}
}
return false;
});
};
/**
* Finds the index of a matching goog.events.Listener in the given
* listenerArray.
* @param {!Array<!goog.events.Listener>} listenerArray Array of listener.
* @param {!Function} listener The listener function.
* @param {boolean=} opt_useCapture The capture flag for the listener.
* @param {Object=} opt_listenerScope The listener scope.
* @return {number} The index of the matching listener within the
* listenerArray.
* @private
*/
goog.events.ListenerMap.findListenerIndex_ = function(
listenerArray, listener, opt_useCapture, opt_listenerScope) {
'use strict';
for (var i = 0; i < listenerArray.length; ++i) {
var listenerObj = listenerArray[i];
if (!listenerObj.removed && listenerObj.listener == listener &&
listenerObj.capture == !!opt_useCapture &&
listenerObj.handler == opt_listenerScope) {
return i;
}
}
return -1;
};

View File

@ -1,13 +0,0 @@
/*TRANSPILED*/goog.loadModule(function(exports) {'use strict';/**
* @license
* Copyright The Closure Library Authors.
* SPDX-License-Identifier: Apache-2.0
*/
goog.module('goog.flags');
goog.module.declareLegacyNamespace();
exports.USE_USER_AGENT_CLIENT_HINTS = false;
exports.ASYNC_THROW_ON_UNICODE_TO_BYTE = false;
;return exports;});

View File

@ -1,40 +0,0 @@
/*TRANSPILED*//*
Copyright The Closure Library Authors.
SPDX-License-Identifier: Apache-2.0
*/
'use strict';
goog.provide("goog.fs.blob");
goog.fs.blob.getBlob = function(var_args) {
const BlobBuilder = goog.global.BlobBuilder || goog.global.WebKitBlobBuilder;
if (BlobBuilder !== undefined) {
const bb = new BlobBuilder();
for (let i = 0; i < arguments.length; i++) {
bb.append(arguments[i]);
}
return bb.getBlob();
} else {
return goog.fs.blob.getBlobWithProperties(Array.prototype.slice.call(arguments));
}
};
goog.fs.blob.getBlobWithProperties = function(parts, opt_type, opt_endings) {
const BlobBuilder = goog.global.BlobBuilder || goog.global.WebKitBlobBuilder;
if (BlobBuilder !== undefined) {
const bb = new BlobBuilder();
for (let i = 0; i < parts.length; i++) {
bb.append(parts[i], opt_endings);
}
return bb.getBlob(opt_type);
} else if (goog.global.Blob !== undefined) {
const properties = {};
if (opt_type) {
properties["type"] = opt_type;
}
if (opt_endings) {
properties["endings"] = opt_endings;
}
return new Blob(parts, properties);
} else {
throw new Error("This browser doesn't seem to support creating Blobs");
}
};

View File

@ -1,39 +0,0 @@
/*TRANSPILED*//*
Copyright The Closure Library Authors.
SPDX-License-Identifier: Apache-2.0
*/
'use strict';
goog.provide("goog.fs.url");
goog.fs.url.createObjectUrl = function(obj) {
return goog.fs.url.getUrlObject_().createObjectURL(obj);
};
goog.fs.url.revokeObjectUrl = function(url) {
goog.fs.url.getUrlObject_().revokeObjectURL(url);
};
goog.fs.url.UrlObject_ = function() {
};
goog.fs.url.UrlObject_.prototype.createObjectURL = function(arg) {
};
goog.fs.url.UrlObject_.prototype.revokeObjectURL = function(s) {
};
goog.fs.url.getUrlObject_ = function() {
const urlObject = goog.fs.url.findUrlObject_();
if (urlObject != null) {
return urlObject;
} else {
throw new Error("This browser doesn't seem to support blob URLs");
}
};
goog.fs.url.findUrlObject_ = function() {
if (goog.global.URL !== undefined && goog.global.URL.createObjectURL !== undefined) {
return goog.global.URL;
} else if (goog.global.createObjectURL !== undefined) {
return goog.global;
} else {
return null;
}
};
goog.fs.url.browserSupportsObjectUrls = function() {
return goog.fs.url.findUrlObject_() != null;
};

View File

@ -1,213 +0,0 @@
/*TRANSPILED*//*
Copyright The Closure Library Authors.
SPDX-License-Identifier: Apache-2.0
*/
'use strict';
goog.provide("goog.functions");
goog.functions.constant = function(retValue) {
return function() {
return retValue;
};
};
goog.functions.FALSE = function() {
return false;
};
goog.functions.TRUE = function() {
return true;
};
goog.functions.NULL = function() {
return null;
};
goog.functions.UNDEFINED = function() {
return undefined;
};
goog.functions.EMPTY = goog.functions.UNDEFINED;
goog.functions.identity = function(opt_returnValue, var_args) {
return opt_returnValue;
};
goog.functions.error = function(message) {
return function() {
throw new Error(message);
};
};
goog.functions.fail = function(err) {
return function() {
throw err;
};
};
goog.functions.lock = function(f, opt_numArgs) {
opt_numArgs = opt_numArgs || 0;
return function() {
const self = this;
return f.apply(self, Array.prototype.slice.call(arguments, 0, opt_numArgs));
};
};
goog.functions.nth = function(n) {
return function() {
return arguments[n];
};
};
goog.functions.partialRight = function(fn, var_args) {
const rightArgs = Array.prototype.slice.call(arguments, 1);
return function() {
let self = this;
if (self === goog.global) {
self = undefined;
}
const newArgs = Array.prototype.slice.call(arguments);
newArgs.push.apply(newArgs, rightArgs);
return fn.apply(self, newArgs);
};
};
goog.functions.withReturnValue = function(f, retValue) {
return goog.functions.sequence(f, goog.functions.constant(retValue));
};
goog.functions.equalTo = function(value, opt_useLooseComparison) {
return function(other) {
return opt_useLooseComparison ? value == other : value === other;
};
};
goog.functions.compose = function(fn, var_args) {
const functions = arguments;
const length = functions.length;
return function() {
const self = this;
let result;
if (length) {
result = functions[length - 1].apply(self, arguments);
}
for (let i = length - 2; i >= 0; i--) {
result = functions[i].call(self, result);
}
return result;
};
};
goog.functions.sequence = function(var_args) {
const functions = arguments;
const length = functions.length;
return function() {
const self = this;
let result;
for (let i = 0; i < length; i++) {
result = functions[i].apply(self, arguments);
}
return result;
};
};
goog.functions.and = function(var_args) {
const functions = arguments;
const length = functions.length;
return function() {
const self = this;
for (let i = 0; i < length; i++) {
if (!functions[i].apply(self, arguments)) {
return false;
}
}
return true;
};
};
goog.functions.or = function(var_args) {
const functions = arguments;
const length = functions.length;
return function() {
const self = this;
for (let i = 0; i < length; i++) {
if (functions[i].apply(self, arguments)) {
return true;
}
}
return false;
};
};
goog.functions.not = function(f) {
return function() {
const self = this;
return !f.apply(self, arguments);
};
};
goog.functions.create = function(constructor, var_args) {
const temp = function() {
};
temp.prototype = constructor.prototype;
const obj = new temp();
constructor.apply(obj, Array.prototype.slice.call(arguments, 1));
return obj;
};
goog.functions.CACHE_RETURN_VALUE = goog.define("goog.functions.CACHE_RETURN_VALUE", true);
goog.functions.cacheReturnValue = function(fn) {
let called = false;
let value;
return function() {
if (!goog.functions.CACHE_RETURN_VALUE) {
return fn();
}
if (!called) {
value = fn();
called = true;
}
return value;
};
};
goog.functions.once = function(f) {
let inner = f;
return function() {
if (inner) {
const tmp = inner;
inner = null;
tmp();
}
};
};
goog.functions.debounce = function(f, interval, opt_scope) {
let timeout = 0;
return function(var_args) {
goog.global.clearTimeout(timeout);
const args = arguments;
timeout = goog.global.setTimeout(function() {
f.apply(opt_scope, args);
}, interval);
};
};
goog.functions.throttle = function(f, interval, opt_scope) {
let timeout = 0;
let shouldFire = false;
let storedArgs = [];
const handleTimeout = function() {
timeout = 0;
if (shouldFire) {
shouldFire = false;
fire();
}
};
const fire = function() {
timeout = goog.global.setTimeout(handleTimeout, interval);
let args = storedArgs;
storedArgs = [];
f.apply(opt_scope, args);
};
return function(var_args) {
storedArgs = arguments;
if (!timeout) {
fire();
} else {
shouldFire = true;
}
};
};
goog.functions.rateLimit = function(f, interval, opt_scope) {
let timeout = 0;
const handleTimeout = function() {
timeout = 0;
};
return function(var_args) {
if (!timeout) {
timeout = goog.global.setTimeout(handleTimeout, interval);
f.apply(opt_scope, arguments);
}
};
};
goog.functions.isFunction = val => {
return typeof val === "function";
};

View File

@ -1,190 +0,0 @@
/**
* @license
* Copyright The Closure Library Authors.
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @fileoverview Transitional utilities to unsafely trust random strings as
* goog.html types. Intended for temporary use when upgrading a library that
* used to accept plain strings to use safe types, but where it's not
* practical to transitively update callers.
*
* IMPORTANT: No new code should use the conversion functions in this file,
* they are intended for refactoring old code to use goog.html types. New code
* should construct goog.html types via their APIs, template systems or
* sanitizers. If thats not possible it should use
* goog.html.uncheckedconversions and undergo security review.
*
* The semantics of the conversions in goog.html.legacyconversions are very
* different from the ones provided by goog.html.uncheckedconversions. The
* latter are for use in code where it has been established through manual
* security review that the value produced by a piece of code will always
* satisfy the SafeHtml contract (e.g., the output of a secure HTML sanitizer).
* In uses of goog.html.legacyconversions, this guarantee is not given -- the
* value in question originates in unreviewed legacy code and there is no
* guarantee that it satisfies the SafeHtml contract.
*
* There are only three valid uses of legacyconversions:
*
* 1. Introducing a goog.html version of a function which currently consumes
* string and passes that string to a DOM API which can execute script - and
* hence cause XSS - like innerHTML. For example, Dialog might expose a
* setContent method which takes a string and sets the innerHTML property of
* an element with it. In this case a setSafeHtmlContent function could be
* added, consuming goog.html.SafeHtml instead of string, and using
* goog.dom.safe.setInnerHtml instead of directly setting innerHTML.
* setContent could then internally use legacyconversions to create a SafeHtml
* from string and pass the SafeHtml to setSafeHtmlContent. In this scenario
* remember to document the use of legacyconversions in the modified setContent
* and consider deprecating it as well.
*
* 2. Automated refactoring of application code which handles HTML as string
* but needs to call a function which only takes goog.html types. For example,
* in the Dialog scenario from (1) an alternative option would be to refactor
* setContent to accept goog.html.SafeHtml instead of string and then refactor
* all current callers to use legacyconversions to pass SafeHtml. This is
* generally preferable to (1) because it keeps the library clean of
* legacyconversions, and makes code sites in application code that are
* potentially vulnerable to XSS more apparent.
*
* 3. Old code which needs to call APIs which consume goog.html types and for
* which it is prohibitively expensive to refactor to use goog.html types.
* Generally, this is code where safety from XSS is either hopeless or
* unimportant.
*/
goog.provide('goog.html.legacyconversions');
goog.require('goog.html.SafeHtml');
goog.require('goog.html.SafeScript');
goog.require('goog.html.SafeStyle');
goog.require('goog.html.SafeStyleSheet');
goog.require('goog.html.SafeUrl');
goog.require('goog.html.TrustedResourceUrl');
/**
* Performs an "unchecked conversion" from string to SafeHtml for legacy API
* purposes.
*
* Please read fileoverview documentation before using.
*
* @param {string} html A string to be converted to SafeHtml.
* @return {!goog.html.SafeHtml} The value of html, wrapped in a SafeHtml
* object.
*/
goog.html.legacyconversions.safeHtmlFromString = function(html) {
'use strict';
goog.html.legacyconversions.reportCallback_();
return goog.html.SafeHtml.createSafeHtmlSecurityPrivateDoNotAccessOrElse(
html);
};
/**
* Performs an "unchecked conversion" from string to SafeScript for legacy API
* purposes.
*
* Please read fileoverview documentation before using.
*
* @param {string} script A string to be converted to SafeScript.
* @return {!goog.html.SafeScript} The value of script, wrapped in a SafeScript
* object.
*/
goog.html.legacyconversions.safeScriptFromString = function(script) {
'use strict';
goog.html.legacyconversions.reportCallback_();
return goog.html.SafeScript.createSafeScriptSecurityPrivateDoNotAccessOrElse(
script);
};
/**
* Performs an "unchecked conversion" from string to SafeStyle for legacy API
* purposes.
*
* Please read fileoverview documentation before using.
*
* @param {string} style A string to be converted to SafeStyle.
* @return {!goog.html.SafeStyle} The value of style, wrapped in a SafeStyle
* object.
*/
goog.html.legacyconversions.safeStyleFromString = function(style) {
'use strict';
goog.html.legacyconversions.reportCallback_();
return goog.html.SafeStyle.createSafeStyleSecurityPrivateDoNotAccessOrElse(
style);
};
/**
* Performs an "unchecked conversion" from string to SafeStyleSheet for legacy
* API purposes.
*
* Please read fileoverview documentation before using.
*
* @param {string} styleSheet A string to be converted to SafeStyleSheet.
* @return {!goog.html.SafeStyleSheet} The value of style sheet, wrapped in
* a SafeStyleSheet object.
*/
goog.html.legacyconversions.safeStyleSheetFromString = function(styleSheet) {
'use strict';
goog.html.legacyconversions.reportCallback_();
return goog.html.SafeStyleSheet
.createSafeStyleSheetSecurityPrivateDoNotAccessOrElse(styleSheet);
};
/**
* Performs an "unchecked conversion" from string to SafeUrl for legacy API
* purposes.
*
* Please read fileoverview documentation before using.
*
* @param {string} url A string to be converted to SafeUrl.
* @return {!goog.html.SafeUrl} The value of url, wrapped in a SafeUrl
* object.
*/
goog.html.legacyconversions.safeUrlFromString = function(url) {
'use strict';
goog.html.legacyconversions.reportCallback_();
return goog.html.SafeUrl.createSafeUrlSecurityPrivateDoNotAccessOrElse(url);
};
/**
* Performs an "unchecked conversion" from string to TrustedResourceUrl for
* legacy API purposes.
*
* Please read fileoverview documentation before using.
*
* @param {string} url A string to be converted to TrustedResourceUrl.
* @return {!goog.html.TrustedResourceUrl} The value of url, wrapped in a
* TrustedResourceUrl object.
*/
goog.html.legacyconversions.trustedResourceUrlFromString = function(url) {
'use strict';
goog.html.legacyconversions.reportCallback_();
return goog.html.TrustedResourceUrl
.createTrustedResourceUrlSecurityPrivateDoNotAccessOrElse(url);
};
/**
* @private {function(): undefined}
*/
goog.html.legacyconversions.reportCallback_ = function() {};
/**
* Sets a function that will be called every time a legacy conversion is
* performed. The function is called with no parameters but it can use
* goog.debug.getStacktrace to get a stacktrace.
*
* @param {function(): undefined} callback Error callback as defined above.
*/
goog.html.legacyconversions.setReportCallback = function(callback) {
'use strict';
goog.html.legacyconversions.reportCallback_ = callback;
};

View File

@ -1,307 +0,0 @@
/*TRANSPILED*/goog.loadModule(function(exports) {'use strict';/*
Copyright The Closure Library Authors.
SPDX-License-Identifier: Apache-2.0
*/
'use strict';
goog.module("goog.html.SafeHtml");
goog.module.declareLegacyNamespace();
const Const = goog.require("goog.string.Const");
const SafeScript = goog.require("goog.html.SafeScript");
const SafeStyle = goog.require("goog.html.SafeStyle");
const SafeStyleSheet = goog.require("goog.html.SafeStyleSheet");
const SafeUrl = goog.require("goog.html.SafeUrl");
const TagName = goog.require("goog.dom.TagName");
const TrustedResourceUrl = goog.require("goog.html.TrustedResourceUrl");
const TypedString = goog.require("goog.string.TypedString");
const asserts = goog.require("goog.asserts");
const browser = goog.require("goog.labs.userAgent.browser");
const googArray = goog.require("goog.array");
const googObject = goog.require("goog.object");
const internal = goog.require("goog.string.internal");
const tags = goog.require("goog.dom.tags");
const trustedtypes = goog.require("goog.html.trustedtypes");
const CONSTRUCTOR_TOKEN_PRIVATE = {};
class SafeHtml {
constructor(value, token) {
this.privateDoNotAccessOrElseSafeHtmlWrappedValue_ = token === CONSTRUCTOR_TOKEN_PRIVATE ? value : "";
this.implementsGoogStringTypedString = true;
}
getTypedStringValue() {
return this.privateDoNotAccessOrElseSafeHtmlWrappedValue_.toString();
}
toString() {
return this.privateDoNotAccessOrElseSafeHtmlWrappedValue_.toString();
}
static unwrap(safeHtml) {
return SafeHtml.unwrapTrustedHTML(safeHtml).toString();
}
static unwrapTrustedHTML(safeHtml) {
if (safeHtml instanceof SafeHtml && safeHtml.constructor === SafeHtml) {
return safeHtml.privateDoNotAccessOrElseSafeHtmlWrappedValue_;
} else {
asserts.fail(`expected object of type SafeHtml, got '${safeHtml}' of type ` + goog.typeOf(safeHtml));
return "type_error:SafeHtml";
}
}
static htmlEscape(textOrHtml) {
if (textOrHtml instanceof SafeHtml) {
return textOrHtml;
}
const textIsObject = typeof textOrHtml == "object";
let textAsString;
if (textIsObject && textOrHtml.implementsGoogStringTypedString) {
textAsString = textOrHtml.getTypedStringValue();
} else {
textAsString = String(textOrHtml);
}
return SafeHtml.createSafeHtmlSecurityPrivateDoNotAccessOrElse(internal.htmlEscape(textAsString));
}
static htmlEscapePreservingNewlines(textOrHtml) {
if (textOrHtml instanceof SafeHtml) {
return textOrHtml;
}
const html = SafeHtml.htmlEscape(textOrHtml);
return SafeHtml.createSafeHtmlSecurityPrivateDoNotAccessOrElse(internal.newLineToBr(SafeHtml.unwrap(html)));
}
static htmlEscapePreservingNewlinesAndSpaces(textOrHtml) {
if (textOrHtml instanceof SafeHtml) {
return textOrHtml;
}
const html = SafeHtml.htmlEscape(textOrHtml);
return SafeHtml.createSafeHtmlSecurityPrivateDoNotAccessOrElse(internal.whitespaceEscape(SafeHtml.unwrap(html)));
}
static comment(text) {
return SafeHtml.createSafeHtmlSecurityPrivateDoNotAccessOrElse("\x3c!--" + internal.htmlEscape(text) + "--\x3e");
}
static create(tagName, attributes = undefined, content = undefined) {
SafeHtml.verifyTagName(String(tagName));
return SafeHtml.createSafeHtmlTagSecurityPrivateDoNotAccessOrElse(String(tagName), attributes, content);
}
static verifyTagName(tagName) {
if (!VALID_NAMES_IN_TAG.test(tagName)) {
throw new Error(SafeHtml.ENABLE_ERROR_MESSAGES ? `Invalid tag name <${tagName}>.` : "");
}
if (tagName.toUpperCase() in NOT_ALLOWED_TAG_NAMES) {
throw new Error(SafeHtml.ENABLE_ERROR_MESSAGES ? `Tag name <${tagName}> is not allowed for SafeHtml.` : "");
}
}
static createIframe(src = undefined, srcdoc = undefined, attributes = undefined, content = undefined) {
if (src) {
TrustedResourceUrl.unwrap(src);
}
const fixedAttributes = {};
fixedAttributes["src"] = src || null;
fixedAttributes["srcdoc"] = srcdoc && SafeHtml.unwrap(srcdoc);
const defaultAttributes = {"sandbox":""};
const combinedAttrs = SafeHtml.combineAttributes(fixedAttributes, defaultAttributes, attributes);
return SafeHtml.createSafeHtmlTagSecurityPrivateDoNotAccessOrElse("iframe", combinedAttrs, content);
}
static createSandboxIframe(src = undefined, srcdoc = undefined, attributes = undefined, content = undefined) {
if (!SafeHtml.canUseSandboxIframe()) {
throw new Error(SafeHtml.ENABLE_ERROR_MESSAGES ? "The browser does not support sandboxed iframes." : "");
}
const fixedAttributes = {};
if (src) {
fixedAttributes["src"] = SafeUrl.unwrap(SafeUrl.sanitize(src));
} else {
fixedAttributes["src"] = null;
}
fixedAttributes["srcdoc"] = srcdoc || null;
fixedAttributes["sandbox"] = "";
const combinedAttrs = SafeHtml.combineAttributes(fixedAttributes, {}, attributes);
return SafeHtml.createSafeHtmlTagSecurityPrivateDoNotAccessOrElse("iframe", combinedAttrs, content);
}
static canUseSandboxIframe() {
return goog.global["HTMLIFrameElement"] && "sandbox" in goog.global["HTMLIFrameElement"].prototype;
}
static createScriptSrc(src, attributes = undefined) {
TrustedResourceUrl.unwrap(src);
const fixedAttributes = {"src":src};
const defaultAttributes = {};
const combinedAttrs = SafeHtml.combineAttributes(fixedAttributes, defaultAttributes, attributes);
return SafeHtml.createSafeHtmlTagSecurityPrivateDoNotAccessOrElse("script", combinedAttrs);
}
static createScript(script, attributes = undefined) {
for (let attr in attributes) {
if (Object.prototype.hasOwnProperty.call(attributes, attr)) {
const attrLower = attr.toLowerCase();
if (attrLower == "language" || attrLower == "src" || attrLower == "text") {
throw new Error(SafeHtml.ENABLE_ERROR_MESSAGES ? `Cannot set "${attrLower}" attribute` : "");
}
}
}
let content = "";
script = googArray.concat(script);
for (let i = 0; i < script.length; i++) {
content += SafeScript.unwrap(script[i]);
}
const htmlContent = SafeHtml.createSafeHtmlSecurityPrivateDoNotAccessOrElse(content);
return SafeHtml.createSafeHtmlTagSecurityPrivateDoNotAccessOrElse("script", attributes, htmlContent);
}
static createStyle(styleSheet, attributes = undefined) {
const fixedAttributes = {"type":"text/css"};
const defaultAttributes = {};
const combinedAttrs = SafeHtml.combineAttributes(fixedAttributes, defaultAttributes, attributes);
let content = "";
styleSheet = googArray.concat(styleSheet);
for (let i = 0; i < styleSheet.length; i++) {
content += SafeStyleSheet.unwrap(styleSheet[i]);
}
const htmlContent = SafeHtml.createSafeHtmlSecurityPrivateDoNotAccessOrElse(content);
return SafeHtml.createSafeHtmlTagSecurityPrivateDoNotAccessOrElse("style", combinedAttrs, htmlContent);
}
static createMetaRefresh(url, secs = undefined) {
let unwrappedUrl = SafeUrl.unwrap(SafeUrl.sanitize(url));
if (browser.isIE() || browser.isEdge()) {
if (internal.contains(unwrappedUrl, ";")) {
unwrappedUrl = "'" + unwrappedUrl.replace(/'/g, "%27") + "'";
}
}
const attributes = {"http-equiv":"refresh", "content":(secs || 0) + "; url\x3d" + unwrappedUrl,};
return SafeHtml.createSafeHtmlTagSecurityPrivateDoNotAccessOrElse("meta", attributes);
}
static join(separator, parts) {
const separatorHtml = SafeHtml.htmlEscape(separator);
const content = [];
const addArgument = argument => {
if (Array.isArray(argument)) {
argument.forEach(addArgument);
} else {
const html = SafeHtml.htmlEscape(argument);
content.push(SafeHtml.unwrap(html));
}
};
parts.forEach(addArgument);
return SafeHtml.createSafeHtmlSecurityPrivateDoNotAccessOrElse(content.join(SafeHtml.unwrap(separatorHtml)));
}
static concat(var_args) {
return SafeHtml.join(SafeHtml.EMPTY, Array.prototype.slice.call(arguments));
}
static createSafeHtmlSecurityPrivateDoNotAccessOrElse(html) {
const noinlineHtml = html;
const policy = trustedtypes.getPolicyPrivateDoNotAccessOrElse();
const trustedHtml = policy ? policy.createHTML(noinlineHtml) : noinlineHtml;
return new SafeHtml(trustedHtml, CONSTRUCTOR_TOKEN_PRIVATE);
}
static createSafeHtmlTagSecurityPrivateDoNotAccessOrElse(tagName, attributes = undefined, content = undefined) {
let result = `<${tagName}`;
result += SafeHtml.stringifyAttributes(tagName, attributes);
if (content == null) {
content = [];
} else if (!Array.isArray(content)) {
content = [content];
}
if (tags.isVoidTag(tagName.toLowerCase())) {
asserts.assert(!content.length, `Void tag <${tagName}> does not allow content.`);
result += "\x3e";
} else {
const html = SafeHtml.concat(content);
result += "\x3e" + SafeHtml.unwrap(html) + "\x3c/" + tagName + "\x3e";
}
return SafeHtml.createSafeHtmlSecurityPrivateDoNotAccessOrElse(result);
}
static stringifyAttributes(tagName, attributes = undefined) {
let result = "";
if (attributes) {
for (let name in attributes) {
if (Object.prototype.hasOwnProperty.call(attributes, name)) {
if (!VALID_NAMES_IN_TAG.test(name)) {
throw new Error(SafeHtml.ENABLE_ERROR_MESSAGES ? `Invalid attribute name "${name}".` : "");
}
const value = attributes[name];
if (value == null) {
continue;
}
result += " " + getAttrNameAndValue(tagName, name, value);
}
}
}
return result;
}
static combineAttributes(fixedAttributes, defaultAttributes, attributes = undefined) {
const combinedAttributes = {};
for (const name in fixedAttributes) {
if (Object.prototype.hasOwnProperty.call(fixedAttributes, name)) {
asserts.assert(name.toLowerCase() == name, "Must be lower case");
combinedAttributes[name] = fixedAttributes[name];
}
}
for (const name in defaultAttributes) {
if (Object.prototype.hasOwnProperty.call(defaultAttributes, name)) {
asserts.assert(name.toLowerCase() == name, "Must be lower case");
combinedAttributes[name] = defaultAttributes[name];
}
}
if (attributes) {
for (const name in attributes) {
if (Object.prototype.hasOwnProperty.call(attributes, name)) {
const nameLower = name.toLowerCase();
if (nameLower in fixedAttributes) {
throw new Error(SafeHtml.ENABLE_ERROR_MESSAGES ? `Cannot override "${nameLower}" attribute, got "` + name + '" with value "' + attributes[name] + '"' : "");
}
if (nameLower in defaultAttributes) {
delete combinedAttributes[nameLower];
}
combinedAttributes[name] = attributes[name];
}
}
}
return combinedAttributes;
}
}
SafeHtml.ENABLE_ERROR_MESSAGES = goog.define("goog.html.SafeHtml.ENABLE_ERROR_MESSAGES", goog.DEBUG);
SafeHtml.SUPPORT_STYLE_ATTRIBUTE = goog.define("goog.html.SafeHtml.SUPPORT_STYLE_ATTRIBUTE", true);
SafeHtml.TextOrHtml_;
SafeHtml.from = SafeHtml.htmlEscape;
const VALID_NAMES_IN_TAG = /^[a-zA-Z0-9-]+$/;
const URL_ATTRIBUTES = googObject.createSet("action", "cite", "data", "formaction", "href", "manifest", "poster", "src");
const NOT_ALLOWED_TAG_NAMES = googObject.createSet(TagName.APPLET, TagName.BASE, TagName.EMBED, TagName.IFRAME, TagName.LINK, TagName.MATH, TagName.META, TagName.OBJECT, TagName.SCRIPT, TagName.STYLE, TagName.SVG, TagName.TEMPLATE);
SafeHtml.AttributeValue;
function getAttrNameAndValue(tagName, name, value) {
if (value instanceof Const) {
value = Const.unwrap(value);
} else if (name.toLowerCase() == "style") {
if (SafeHtml.SUPPORT_STYLE_ATTRIBUTE) {
value = getStyleValue(value);
} else {
throw new Error(SafeHtml.ENABLE_ERROR_MESSAGES ? 'Attribute "style" not supported.' : "");
}
} else if (/^on/i.test(name)) {
throw new Error(SafeHtml.ENABLE_ERROR_MESSAGES ? `Attribute "${name}` + '" requires goog.string.Const value, "' + value + '" given.' : "");
} else if (name.toLowerCase() in URL_ATTRIBUTES) {
if (value instanceof TrustedResourceUrl) {
value = TrustedResourceUrl.unwrap(value);
} else if (value instanceof SafeUrl) {
value = SafeUrl.unwrap(value);
} else if (typeof value === "string") {
value = SafeUrl.sanitize(value).getTypedStringValue();
} else {
throw new Error(SafeHtml.ENABLE_ERROR_MESSAGES ? `Attribute "${name}" on tag "${tagName}` + '" requires goog.html.SafeUrl, goog.string.Const, or' + ' string, value "' + value + '" given.' : "");
}
}
if (value.implementsGoogStringTypedString) {
value = value.getTypedStringValue();
}
asserts.assert(typeof value === "string" || typeof value === "number", "String or number value expected, got " + typeof value + " with value: " + value);
return `${name}="` + internal.htmlEscape(String(value)) + '"';
}
function getStyleValue(value) {
if (!goog.isObject(value)) {
throw new Error(SafeHtml.ENABLE_ERROR_MESSAGES ? 'The "style" attribute requires goog.html.SafeStyle or map ' + "of style properties, " + typeof value + " given: " + value : "");
}
if (!(value instanceof SafeStyle)) {
value = SafeStyle.create(value);
}
return SafeStyle.unwrap(value);
}
SafeHtml.DOCTYPE_HTML = {valueOf:function() {
return SafeHtml.createSafeHtmlSecurityPrivateDoNotAccessOrElse("\x3c!DOCTYPE html\x3e");
},}.valueOf();
SafeHtml.EMPTY = new SafeHtml(goog.global.trustedTypes && goog.global.trustedTypes.emptyHTML || "", CONSTRUCTOR_TOKEN_PRIVATE);
SafeHtml.BR = {valueOf:function() {
return SafeHtml.createSafeHtmlSecurityPrivateDoNotAccessOrElse("\x3cbr\x3e");
},}.valueOf();
exports = SafeHtml;
;return exports;});

View File

@ -1,62 +0,0 @@
/*TRANSPILED*/goog.loadModule(function(exports) {'use strict';/*
Copyright The Closure Library Authors.
SPDX-License-Identifier: Apache-2.0
*/
'use strict';
goog.module("goog.html.SafeScript");
goog.module.declareLegacyNamespace();
const Const = goog.require("goog.string.Const");
const TypedString = goog.require("goog.string.TypedString");
const trustedtypes = goog.require("goog.html.trustedtypes");
const {fail} = goog.require("goog.asserts");
const CONSTRUCTOR_TOKEN_PRIVATE = {};
class SafeScript {
constructor(value, token) {
this.privateDoNotAccessOrElseSafeScriptWrappedValue_ = token === CONSTRUCTOR_TOKEN_PRIVATE ? value : "";
this.implementsGoogStringTypedString = true;
}
toString() {
return this.privateDoNotAccessOrElseSafeScriptWrappedValue_.toString();
}
static fromConstant(script) {
const scriptString = Const.unwrap(script);
if (scriptString.length === 0) {
return SafeScript.EMPTY;
}
return SafeScript.createSafeScriptSecurityPrivateDoNotAccessOrElse(scriptString);
}
static fromJson(val) {
return SafeScript.createSafeScriptSecurityPrivateDoNotAccessOrElse(SafeScript.stringify_(val));
}
getTypedStringValue() {
return this.privateDoNotAccessOrElseSafeScriptWrappedValue_.toString();
}
static unwrap(safeScript) {
return SafeScript.unwrapTrustedScript(safeScript).toString();
}
static unwrapTrustedScript(safeScript) {
if (safeScript instanceof SafeScript && safeScript.constructor === SafeScript) {
return safeScript.privateDoNotAccessOrElseSafeScriptWrappedValue_;
} else {
fail("expected object of type SafeScript, got '" + safeScript + "' of type " + goog.typeOf(safeScript));
return "type_error:SafeScript";
}
}
static stringify_(val) {
const json = JSON.stringify(val);
return json.replace(/</g, "\\x3c");
}
static createSafeScriptSecurityPrivateDoNotAccessOrElse(script) {
const noinlineScript = script;
const policy = trustedtypes.getPolicyPrivateDoNotAccessOrElse();
const trustedScript = policy ? policy.createScript(noinlineScript) : noinlineScript;
return new SafeScript(trustedScript, CONSTRUCTOR_TOKEN_PRIVATE);
}
}
SafeScript.EMPTY = {valueOf:function() {
return SafeScript.createSafeScriptSecurityPrivateDoNotAccessOrElse("");
},}.valueOf();
exports = SafeScript;
;return exports;});

View File

@ -1,171 +0,0 @@
/*TRANSPILED*/goog.loadModule(function(exports) {'use strict';/*
Copyright The Closure Library Authors.
SPDX-License-Identifier: Apache-2.0
*/
'use strict';
goog.module("goog.html.SafeStyle");
goog.module.declareLegacyNamespace();
const Const = goog.require("goog.string.Const");
const SafeUrl = goog.require("goog.html.SafeUrl");
const TypedString = goog.require("goog.string.TypedString");
const {AssertionError, assert, fail} = goog.require("goog.asserts");
const {contains, endsWith} = goog.require("goog.string.internal");
const CONSTRUCTOR_TOKEN_PRIVATE = {};
class SafeStyle {
constructor(value, token) {
this.privateDoNotAccessOrElseSafeStyleWrappedValue_ = token === CONSTRUCTOR_TOKEN_PRIVATE ? value : "";
this.implementsGoogStringTypedString = true;
}
static fromConstant(style) {
const styleString = Const.unwrap(style);
if (styleString.length === 0) {
return SafeStyle.EMPTY;
}
assert(endsWith(styleString, ";"), `Last character of style string is not ';': ${styleString}`);
assert(contains(styleString, ":"), "Style string must contain at least one ':', to " + 'specify a "name: value" pair: ' + styleString);
return SafeStyle.createSafeStyleSecurityPrivateDoNotAccessOrElse(styleString);
}
getTypedStringValue() {
return this.privateDoNotAccessOrElseSafeStyleWrappedValue_;
}
toString() {
return this.privateDoNotAccessOrElseSafeStyleWrappedValue_.toString();
}
static unwrap(safeStyle) {
if (safeStyle instanceof SafeStyle && safeStyle.constructor === SafeStyle) {
return safeStyle.privateDoNotAccessOrElseSafeStyleWrappedValue_;
} else {
fail(`expected object of type SafeStyle, got '${safeStyle}` + "' of type " + goog.typeOf(safeStyle));
return "type_error:SafeStyle";
}
}
static createSafeStyleSecurityPrivateDoNotAccessOrElse(style) {
return new SafeStyle(style, CONSTRUCTOR_TOKEN_PRIVATE);
}
static create(map) {
let style = "";
for (let name in map) {
if (Object.prototype.hasOwnProperty.call(map, name)) {
if (!/^[-_a-zA-Z0-9]+$/.test(name)) {
throw new Error(`Name allows only [-_a-zA-Z0-9], got: ${name}`);
}
let value = map[name];
if (value == null) {
continue;
}
if (Array.isArray(value)) {
value = value.map(sanitizePropertyValue).join(" ");
} else {
value = sanitizePropertyValue(value);
}
style += `${name}:${value};`;
}
}
if (!style) {
return SafeStyle.EMPTY;
}
return SafeStyle.createSafeStyleSecurityPrivateDoNotAccessOrElse(style);
}
static concat(var_args) {
let style = "";
const addArgument = argument => {
if (Array.isArray(argument)) {
argument.forEach(addArgument);
} else {
style += SafeStyle.unwrap(argument);
}
};
Array.prototype.forEach.call(arguments, addArgument);
if (!style) {
return SafeStyle.EMPTY;
}
return SafeStyle.createSafeStyleSecurityPrivateDoNotAccessOrElse(style);
}
}
SafeStyle.EMPTY = SafeStyle.createSafeStyleSecurityPrivateDoNotAccessOrElse("");
SafeStyle.INNOCUOUS_STRING = "zClosurez";
SafeStyle.PropertyValue;
SafeStyle.PropertyMap;
function sanitizePropertyValue(value) {
if (value instanceof SafeUrl) {
const url = SafeUrl.unwrap(value);
return 'url("' + url.replace(/</g, "%3c").replace(/[\\"]/g, "\\$\x26") + '")';
}
const result = value instanceof Const ? Const.unwrap(value) : sanitizePropertyValueString(String(value));
if (/[{;}]/.test(result)) {
throw new AssertionError("Value does not allow [{;}], got: %s.", [result]);
}
return result;
}
function sanitizePropertyValueString(value) {
const valueWithoutFunctions = value.replace(FUNCTIONS_RE, "$1").replace(FUNCTIONS_RE, "$1").replace(URL_RE, "url");
if (!VALUE_RE.test(valueWithoutFunctions)) {
fail(`String value allows only ${VALUE_ALLOWED_CHARS}` + " and simple functions, got: " + value);
return SafeStyle.INNOCUOUS_STRING;
} else if (COMMENT_RE.test(value)) {
fail(`String value disallows comments, got: ${value}`);
return SafeStyle.INNOCUOUS_STRING;
} else if (!hasBalancedQuotes(value)) {
fail(`String value requires balanced quotes, got: ${value}`);
return SafeStyle.INNOCUOUS_STRING;
} else if (!hasBalancedSquareBrackets(value)) {
fail("String value requires balanced square brackets and one" + " identifier per pair of brackets, got: " + value);
return SafeStyle.INNOCUOUS_STRING;
}
return sanitizeUrl(value);
}
function hasBalancedQuotes(value) {
let outsideSingle = true;
let outsideDouble = true;
for (let i = 0; i < value.length; i++) {
const c = value.charAt(i);
if (c == "'" && outsideDouble) {
outsideSingle = !outsideSingle;
} else if (c == '"' && outsideSingle) {
outsideDouble = !outsideDouble;
}
}
return outsideSingle && outsideDouble;
}
function hasBalancedSquareBrackets(value) {
let outside = true;
const tokenRe = /^[-_a-zA-Z0-9]$/;
for (let i = 0; i < value.length; i++) {
const c = value.charAt(i);
if (c == "]") {
if (outside) {
return false;
}
outside = true;
} else if (c == "[") {
if (!outside) {
return false;
}
outside = false;
} else if (!outside && !tokenRe.test(c)) {
return false;
}
}
return outside;
}
const VALUE_ALLOWED_CHARS = "[-+,.\"'%_!#/ a-zA-Z0-9\\[\\]]";
const VALUE_RE = new RegExp(`^${VALUE_ALLOWED_CHARS}+\$`);
const URL_RE = new RegExp("\\b(url\\([ \t\n]*)(" + "'[ -\x26(-\\[\\]-~]*'" + '|"[ !#-\\[\\]-~]*"' + "|[!#-\x26*-\\[\\]-~]*" + ")([ \t\n]*\\))", "g");
const ALLOWED_FUNCTIONS = ["calc", "cubic-bezier", "fit-content", "hsl", "hsla", "linear-gradient", "matrix", "minmax", "radial-gradient", "repeat", "rgb", "rgba", "(rotate|scale|translate)(X|Y|Z|3d)?", "steps", "var",];
const FUNCTIONS_RE = new RegExp("\\b(" + ALLOWED_FUNCTIONS.join("|") + ")" + "\\([-+*/0-9a-zA-Z.%#\\[\\], ]+\\)", "g");
const COMMENT_RE = /\/\*/;
function sanitizeUrl(value) {
return value.replace(URL_RE, (match, before, url, after) => {
let quote = "";
url = url.replace(/^(['"])(.*)\1$/, (match, start, inside) => {
quote = start;
return inside;
});
const sanitized = SafeUrl.sanitize(url).getTypedStringValue();
return before + quote + sanitized + quote + after;
});
}
exports = SafeStyle;
;return exports;});

Some files were not shown because too many files have changed in this diff Show More