Skip to content

Commit

Permalink
Merge branch 'release/2.6.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
ku1ik committed Feb 21, 2018
2 parents 9e8f949 + c3f66fb commit 816b986
Show file tree
Hide file tree
Showing 11 changed files with 40 additions and 46 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# asciinema player changelog

## 2.6.1 (2018-02-21)

* Fixed support for idle_time_limit embedded in the v2 recording
* Add support for italic text style

## 2.6.0 (2017-11-10)

* Added support for [asciicast v2](https://github.com/asciinema/asciinema/blob/develop/doc/asciicast-v2.md) recording format
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ terminal session files called
Asciicast is a capture of terminal's raw output, which has to be interpreted
during the playback, so the player comes with its own interpreter based on [Paul
Williams' parser for ANSI-compatible video
terminals](http://vt100.net/emu/dec_ansi_parser). Its output is fully compatible
terminals](https://vt100.net/emu/dec_ansi_parser). Its output is fully compatible
with most widely used terminal emulators like xterm, Gnome Terminal, iTerm etc.

You can see the player in action on [asciinema.org](https://asciinema.org).
Expand Down Expand Up @@ -398,6 +398,6 @@ source [contributors](https://github.com/asciinema/asciinema-player/contributors
## License
Copyright © 2011-2017 Marcin Kulik.
Copyright © 2011-2018 Marcin Kulik.
All code is licensed under the Apache License, Version 2.0. See LICENSE file for details.
3 changes: 0 additions & 3 deletions dev/clj/user.clj
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
(ns user
(:require [schema.core :as s])
(:use [figwheel-sidecar.repl-api :as ra]))

(s/set-fn-validation! true)

(defn start [] (ra/start-figwheel!))

(defn stop [] (ra/stop-figwheel!))
Expand Down
3 changes: 0 additions & 3 deletions dev/cljs/asciinema/player/dev.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,10 @@
[asciinema.player.asciicast.v1 :as v1]
[clojure.walk :as walk]
[cljs.core.async :refer [chan >! <! put!]]
[schema.core :as s]
[goog.net.XhrIo :as xhr]
[clojure.string :as str])
(:require-macros [cljs.core.async.macros :refer [go]]))

;; (s/set-fn-validation! true)

(defonce poster-js [[["File Edit Options Buffers Tools C++ YASnippet Help " {"inverse" true}]] [["/" {"fg" 1, "inverse" true}] ["* Copyright (c) 2014 Vinícius dos San" {"fg" 1}] ["$" {}] ["|" {"inverse" true}] ["/* Copyright (c) 2014 Vinícius dos Sant" {"fg" 1}] ["$" {}]] [[" " {"fg" 1}] ["|" {"inverse" true}] [" " {"fg" 1}]] [[" Distributed under the Boost Softwar" {"fg" 1}] ["$" {}] ["|" {"inverse" true}] [" Distributed under the Boost Software" {"fg" 1}] ["$" {}]] [[" file LICENSE_1_0.txt or copy at htt" {"fg" 1}] ["$" {}] ["|" {"inverse" true}] [" file LICENSE_1_0.txt or copy at http" {"fg" 1}] ["$" {}]] [[" " {}] ["|" {"inverse" true}] [" " {}]] [["#ifndef" {"fg" 4, "bold" true}] [" BOOST_HTTP_EMBEDDED_SERVER_SOC$" {}] ["|" {"inverse" true}] ["#ifndef" {"fg" 4, "bold" true}] [" BOOST_HTTP_EMBEDDED_SERVER_SOCK$" {}]] [["#define" {"fg" 4, "bold" true}] [" " {}] ["BOOST_HTTP_EMBEDDED_SERVER_SOC" {"fg" 3}] ["$" {}] ["|" {"inverse" true}] ["#define" {"fg" 4, "bold" true}] [" " {}] ["BOOST_HTTP_EMBEDDED_SERVER_SOCK" {"fg" 3}] ["$" {}]] [[" " {}] ["|" {"inverse" true}] [" " {}]] [["#include" {"fg" 4, "bold" true}] [" " {}] ["<cstdint>" {"fg" 2}] [" " {}] ["|" {"inverse" true}] ["#include" {"fg" 4, "bold" true}] [" " {}] ["<cstdint>" {"fg" 2}] [" " {}]] [["#include" {"fg" 4, "bold" true}] [" " {}] ["<algorithm>" {"fg" 2}] [" " {}] ["|" {"inverse" true}] ["#include" {"fg" 4, "bold" true}] [" " {}] ["<algorithm>" {"fg" 2}] [" " {}]] [[" " {}] ["|" {"inverse" true}] [" " {}]] [["#include" {"fg" 4, "bold" true}] [" " {}] ["<boost/asio/ip/tcp.hpp>" {"fg" 2}] [" " {}] ["|" {"inverse" true}] ["#include" {"fg" 4, "bold" true}] [" " {}] ["<boost/asio/ip/tcp.hpp>" {"fg" 2}] [" " {}]] [[" " {}] ["|" {"inverse" true}] [" " {}]] [["#include" {"fg" 4, "bold" true}] [" " {}] ["<boost/http/outgoing_state.hp" {"fg" 2}] ["$" {}] ["|" {"inverse" true}] ["#include" {"fg" 4, "bold" true}] [" " {}] ["<boost/http/outgoing_state.hpp" {"fg" 2}] ["$" {}]] [["#include" {"fg" 4, "bold" true}] [" " {}] ["<boost/http/message.hpp>" {"fg" 2}] [" " {}] ["|" {"inverse" true}] ["#include" {"fg" 4, "bold" true}] [" " {}] ["<boost/http/message.hpp>" {"fg" 2}] [" " {}]] [["#include" {"fg" 4, "bold" true}] [" " {}] ["<boost/http/http_errc.hpp>" {"fg" 2}] [" " {}] ["|" {"inverse" true}] ["#include" {"fg" 4, "bold" true}] [" " {}] ["<boost/http/http_errc.hpp>" {"fg" 2}] [" " {}]] [[" " {}] ["|" {"inverse" true}] [" " {}]] [["// TODO: remove me " {"fg" 1}] ["|" {"inverse" true}] ["// TODO: remove me " {"fg" 1}]] [["#include" {"fg" 4, "bold" true}] [" " {}] ["<iostream>" {"fg" 2}] [" " {}] ["|" {"inverse" true}] ["#include" {"fg" 4, "bold" true}] [" " {}] ["<iostream>" {"fg" 2}] [" " {}]] [["#include" {"fg" 4, "bold" true}] [" " {}] ["<string>" {"fg" 2}] [" " {}] ["|" {"inverse" true}] ["#include" {"fg" 4, "bold" true}] [" " {}] ["<string>" {"fg" 2}] [" " {}]] [[" " {}] ["|" {"inverse" true}] [" " {}]] [["-UUU:----F1 " {"inverse" true}] ["embedded_server_socket.hpp" {"bold" true, "inverse" true}] ["|-UUU:----F1 " {"inverse" true}] ["embedded_server_socket.hpp" {"bold" true, "inverse" true}] [" " {"inverse" true}]] [[" " {}]]])

(defonce poster-json (walk/keywordize-keys poster-js))
Expand Down
29 changes: 14 additions & 15 deletions project.clj
Original file line number Diff line number Diff line change
@@ -1,35 +1,34 @@
(defproject player "2.6.0"
(defproject player "2.6.1"
:description "asciinema player"
:url "https://github.com/asciinema/asciinema-player"
:license {:name "Apache 2.0"
:url "http://www.apache.org/licenses/LICENSE-2.0"}

:dependencies [[org.clojure/clojure "1.8.0"]
[org.clojure/clojurescript "1.9.671"]
[org.clojure/core.async "0.2.374"]
:dependencies [[org.clojure/clojure "1.9.0"]
[org.clojure/clojurescript "1.9.946"]
[org.clojure/core.async "0.4.474"]
[reagent "0.7.0"]
[devcards "0.2.2" :exclusions [cljsjs/react cljsjs/create-react-class cljsjs/react-dom-server cljsjs/react-dom]]
[org.clojure/test.check "0.9.0"]
[org.clojure/core.match "0.3.0-alpha4"]
[prismatic/schema "1.1.6"]]

:plugins [[lein-cljsbuild "1.1.5"]
:plugins [[lein-cljsbuild "1.1.7"]
[lein-figwheel "0.5.14"]
[lein-less "1.7.5"]
[lein-doo "0.1.7"]
[lein-doo "0.1.8"]
[lein-kibit "0.1.3"]]

:min-lein-version "2.5.3"

:clean-targets ^{:protect false} ["resources/public/js" "target" "out"]

:source-paths ["src" "vt/src"]
:resource-paths ["resources" "vt/resources"]

:profiles {:dev {:dependencies [[com.cemerick/piggieback "0.2.1"]
[org.clojure/tools.nrepl "0.2.10"]
[environ "1.0.1"]
[figwheel-sidecar "0.5.0-1"]]
[figwheel-sidecar "0.5.14"]]
:plugins [[refactor-nrepl "1.1.0"]]
:source-paths ["dev/clj" "dev/cljs"]}
:repl {:plugins [[cider/cider-nrepl "0.10.0"]]}}
Expand All @@ -43,9 +42,9 @@
:output-to "resources/public/js/dev.js"
:output-dir "resources/public/js/dev"
:source-map true
:foreign-libs [{:file "public/element.js"
:foreign-libs [{:file "resources/public/element.js"
:provides ["asciinema.player.element"]}
{:file "codepoint-polyfill.js"
{:file "vt/resources/codepoint-polyfill.js"
:provides ["asciinema.vt.codepoint-polyfill"]}]
:optimizations :none
:pretty-print true}}
Expand All @@ -56,15 +55,15 @@
:output-to "resources/public/js/devcards.js"
:output-dir "resources/public/js/devcards"
:source-map-timestamp true
:foreign-libs [{:file "public/element.js"
:foreign-libs [{:file "resources/public/element.js"
:provides ["asciinema.player.element"]}]
:optimizations :none}}
:test {:source-paths ["src" "test"]
:compiler {:output-to "resources/public/js/test.js"
:source-map true
:foreign-libs [{:file "public/element.js"
:foreign-libs [{:file "resources/public/element.js"
:provides ["asciinema.player.element"]}
{:file "codepoint-polyfill.js"
{:file "vt/resources/codepoint-polyfill.js"
:provides ["asciinema.vt.codepoint-polyfill"]}]
:optimizations :none
:pretty-print false
Expand All @@ -74,9 +73,9 @@
:output-dir "resources/public/js/release"
:closure-defines {goog.DEBUG false}
:preamble ["license.js" "public/CustomEvent.js" "public/CustomElements.min.js"]
:foreign-libs [{:file "public/element.js"
:foreign-libs [{:file "resources/public/element.js"
:provides ["asciinema.player.element"]}
{:file "codepoint-polyfill.js"
{:file "vt/resources/codepoint-polyfill.js"
:provides ["asciinema.vt.codepoint-polyfill"]}]
:optimizations :advanced
:elide-asserts true
Expand Down
4 changes: 2 additions & 2 deletions resources/license.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* asciinema-player v2.6.0
* asciinema-player v2.6.1
*
* Copyright 2011-2017, Marcin Kulik
* Copyright 2011-2018, Marcin Kulik
*
*/
2 changes: 1 addition & 1 deletion src/asciinema/player/asciicast/v2.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
events (rest asciicast)
width (or vt-width (:width header))
height (or vt-height (:height header))
idle-time-limit (or idle-time-limit (:idle_time_limit asciicast))]
idle-time-limit (or idle-time-limit (:idle_time_limit header))]
{:version 2
:width width
:height height
Expand Down
9 changes: 2 additions & 7 deletions src/asciinema/player/core.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
[asciinema.player.messages :as m]
[asciinema.player.processing]
[asciinema.player.source :as source :refer [make-source]]
[schema.core :as s]
[clojure.string :as str]))

(defn parse-npt [t]
Expand All @@ -15,19 +14,15 @@
components (map * (reverse numbers) (iterate #(* 60 %) 1))]
(apply + components))))

(s/defn parse-json-poster :- (s/protocol screen/Screen)
[json :- s/Str]
(defn parse-json-poster [json]
(let [lines (-> json
(.replace (js/RegExp. "\\s" "g") "")
js/atob
js/JSON.parse
(js->clj :keywordize-keys true))]
{:lines lines}))

(s/defn parse-text-poster :- (s/protocol screen/Screen)
[text :- s/Str
width :- s/Num
height :- s/Num]
(defn parse-text-poster [text width height]
(-> (vt/make-vt (or width 80) (or height 24))
(vt/feed-str text)))

Expand Down
15 changes: 4 additions & 11 deletions src/asciinema/player/source.cljs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
(ns asciinema.player.source
(:refer-clojure :exclude [js->clj])
(:require [cljs.core.async :refer [chan >! <! put! close! timeout poll!]]
(:require [cljs.core.async :refer [chan >! <! put! close! timeout poll! promise-chan]]
[goog.net.XhrIo :as xhr]
[asciinema.player.asciicast :as asciicast]
[asciinema.player.frames :as f]
Expand Down Expand Up @@ -43,24 +43,17 @@
(defn lazy-promise-chan
"Returns a function returning a promise channel. The calculation of the
promise value is triggered by calling returned function with truthy value."
;; TODO simplify it with async/promise-chan when it gets fixed (http://dev.clojure.org/jira/browse/ASYNC-159)
[f]
(let [force-ch (chan)
ready-chan (chan)
value (atom nil)]
value-ch (promise-chan)]
(go
(<! force-ch)
(f (fn [v]
(reset! value v)
(close! ready-chan))))
(put! value-ch v))))
(fn [force?]
(when force?
(close! force-ch))
(let [value-ch (chan)]
(go
(<! ready-chan)
(>! value-ch @value))
value-ch))))
value-ch)))

(defn make-recording-ch-fn [thing vt-width vt-height idle-time-limit]
(lazy-promise-chan
Expand Down
5 changes: 3 additions & 2 deletions src/asciinema/player/view.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,16 @@
color)]
(str prefix color))))

(defn part-class-name [{:keys [fg bg bold blink underline inverse cursor]}]
(defn part-class-name [{:keys [fg bg bold blink underline inverse italic cursor]}]
(let [fg-final (if inverse (or bg "bg") fg)
bg-final (if inverse (or fg "fg") bg)
fg-class (color-class-name fg-final bold "fg-")
bg-class (color-class-name bg-final blink "bg-")
bold-class (when bold "bright")
italic-class (when italic "italic")
underline-class (when underline "underline")
cursor-class (when cursor "cursor")
classes (remove nil? [fg-class bg-class bold-class underline-class cursor-class])]
classes (remove nil? [fg-class bg-class bold-class italic-class underline-class cursor-class])]
(when (seq classes)
(string/join " " classes))))

Expand Down
7 changes: 7 additions & 0 deletions test/asciinema/player/asciicast_test.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,13 @@
(is (= (select-keys (a/load asciicast nil 30 2.5) [:width :height :duration])
{:width 80 :height 30 :duration 6.0}))))

(testing "v2 format, vec, with idle_time_limit"
(let [asciicast [{:version 2 :width 80 :height 24 :idle_time_limit 2.5}
[1.0 "o" "foo"]
[4.0 "i" "iii"]
[10.0 "o" "bar"]]]
(is (= (:duration (a/load asciicast)) 6.0))))

(testing "v2 format, string"
(let [asciicast "[{\"version\":2,\"width\":80,\"height\":24},[1,\"o\",\"foo\"],[2,\"i\",\"iii\"],[3,\"o\",\"bar\"]]"
asciicast (a/load asciicast nil 30)]
Expand Down

0 comments on commit 816b986

Please sign in to comment.