From ab8b790ac1a6e98c7c8d407506a91374ad919d3a Mon Sep 17 00:00:00 2001 From: jiyinyiyong Date: Fri, 18 Jun 2021 16:31:31 +0800 Subject: [PATCH] refine timestamp resolution of each leaf; bump 0.5.29 --- calcit.cirru | 125 ++++++++++++++++++++++++++++++---------- package.json | 2 +- src/app/comp/leaf.cljs | 5 +- src/app/updater/ir.cljs | 9 ++- yarn.lock | 41 ++++--------- 5 files changed, 118 insertions(+), 64 deletions(-) diff --git a/calcit.cirru b/calcit.cirru index dc878fa..9f12459 100644 --- a/calcit.cirru +++ b/calcit.cirru @@ -24517,31 +24517,50 @@ :data $ {} |T $ {} (:type :leaf) (:text |e) (:by |root) (:at 1504777353661) |j $ {} (:type :leaf) (:text |d!) (:by |root) (:at 1504777353661) - |r $ {} (:type :expr) (:by nil) (:at 1504777353661) + |v $ {} (:type :expr) (:by |S1lNv50FW) (:at 1624004726164) :data $ {} - |T $ {} (:type :leaf) (:text |d!) (:by |root) (:at 1504777353661) - |j $ {} (:type :leaf) (:text |:ir/update-leaf) (:by |root) (:at 1504777353661) - |r $ {} (:type :expr) (:by nil) (:at 1504777353661) + |T $ {} (:type :expr) (:by nil) (:at 1504777353661) :data $ {} - |T $ {} (:type :leaf) (:text |:value) (:by |root) (:at 1504777353661) - |j $ {} (:type :leaf) (:text |e) (:by |root) (:at 1504777353661) - |v $ {} (:type :expr) (:by nil) (:at 1504777353661) - :data $ {} - |T $ {} (:type :leaf) (:text |d!) (:by |S1lNv50FW) (:at 1584896641404) - |j $ {} (:type :expr) (:by nil) (:at 1504777353661) + |T $ {} (:type :leaf) (:text |d!) (:by |S1lNv50FW) (:at 1584896641404) + |j $ {} (:type :expr) (:by nil) (:at 1504777353661) + :data $ {} + |T $ {} (:type :leaf) (:text |assoc) (:by |root) (:at 1504777353661) + |j $ {} (:type :leaf) (:text |state) (:by |root) (:at 1504777353661) + |r $ {} (:type :leaf) (:text |:text) (:by |root) (:at 1504777353661) + |v $ {} (:type :expr) (:by nil) (:at 1504777353661) + :data $ {} + |T $ {} (:type :leaf) (:text |:value) (:by |root) (:at 1504777353661) + |j $ {} (:type :leaf) (:text |e) (:by |root) (:at 1504777353661) + |x $ {} (:type :leaf) (:text |:at) (:by |root) (:at 1516274353888) + |y $ {} (:type :leaf) (:by |S1lNv50FW) (:at 1624004748663) (:text |now) + |b $ {} (:type :leaf) (:by |S1lNv50FW) (:at 1584896642318) (:text |cursor) + |D $ {} (:type :leaf) (:by |S1lNv50FW) (:at 1624004727185) (:text |let) + |P $ {} (:type :expr) (:by |S1lNv50FW) (:at 1624004727622) :data $ {} - |T $ {} (:type :leaf) (:text |assoc) (:by |root) (:at 1504777353661) - |j $ {} (:type :leaf) (:text |state) (:by |root) (:at 1504777353661) - |r $ {} (:type :leaf) (:text |:text) (:by |root) (:at 1504777353661) - |v $ {} (:type :expr) (:by nil) (:at 1504777353661) + |T $ {} (:type :expr) (:by |S1lNv50FW) (:at 1624004728069) :data $ {} - |T $ {} (:type :leaf) (:text |:value) (:by |root) (:at 1504777353661) - |j $ {} (:type :leaf) (:text |e) (:by |root) (:at 1504777353661) - |x $ {} (:type :leaf) (:text |:at) (:by |root) (:at 1516274353888) - |y $ {} (:type :expr) (:by nil) (:at 1504777353661) + |T $ {} (:type :leaf) (:by |S1lNv50FW) (:at 1624004728975) (:text |now) + |j $ {} (:type :expr) (:by |S1lNv50FW) (:at 1624004733620) + :data $ {} + |T $ {} (:type :leaf) (:by |S1lNv50FW) (:at 1624004733620) (:text |util/now!) + |R $ {} (:type :expr) (:by |S1lNv50FW) (:at 1624004738424) + :data $ {} + |T $ {} (:type :leaf) (:by |S1lNv50FW) (:at 1624004738424) (:text |d!) + |j $ {} (:type :leaf) (:by |S1lNv50FW) (:at 1624004738424) (:text |:ir/update-leaf) + |r $ {} (:type :expr) (:by |S1lNv50FW) (:at 1624004739776) :data $ {} - |T $ {} (:type :leaf) (:text |util/now!) (:by |root) (:at 1504777353661) - |b $ {} (:type :leaf) (:by |S1lNv50FW) (:at 1584896642318) (:text |cursor) + |T $ {} (:type :expr) (:by |S1lNv50FW) (:at 1624004742074) + :data $ {} + |T $ {} (:type :expr) (:by |S1lNv50FW) (:at 1624004738424) + :data $ {} + |T $ {} (:type :leaf) (:by |S1lNv50FW) (:at 1624004738424) (:text |:value) + |j $ {} (:type :leaf) (:by |S1lNv50FW) (:at 1624004738424) (:text |e) + |D $ {} (:type :leaf) (:by |S1lNv50FW) (:at 1624004743277) (:text |:text) + |D $ {} (:type :leaf) (:by |S1lNv50FW) (:at 1624004740308) (:text |{}) + |j $ {} (:type :expr) (:by |S1lNv50FW) (:at 1624004743887) + :data $ {} + |T $ {} (:type :leaf) (:by |S1lNv50FW) (:at 1624004750031) (:text |:at) + |j $ {} (:type :leaf) (:by |S1lNv50FW) (:at 1624004746358) (:text |now) |on-keydown $ {} (:type :expr) (:by nil) (:at 1504777353661) :data $ {} |T $ {} (:type :leaf) (:text |defn) (:by |root) (:at 1504777353661) @@ -27585,16 +27604,62 @@ |j $ {} (:type :expr) (:at 1504777570689) :data $ {} |T $ {} (:type :leaf) (:by |root) (:at 1504777570689) (:text |leaf) - |v $ {} (:type :expr) (:by |root) (:at 1506759625754) - :data $ {} - |T $ {} (:type :leaf) (:by |root) (:at 1506759655721) (:text |assoc) - |j $ {} (:type :leaf) (:by |root) (:at 1506759629780) (:text |leaf) - |r $ {} (:type :leaf) (:by |root) (:at 1506759630743) (:text |:text) - |v $ {} (:type :leaf) (:by |root) (:at 1506759631684) (:text |op-data) - |x $ {} (:type :leaf) (:by |root) (:at 1514298110406) (:text |:at) - |y $ {} (:type :leaf) (:by |root) (:at 1506759634005) (:text |op-time) - |yT $ {} (:type :leaf) (:by |root) (:at 1514298107771) (:text |:by) - |yj $ {} (:type :leaf) (:by |root) (:at 1506759647443) (:text |user-id) + |v $ {} (:type :expr) (:by |S1lNv50FW) (:at 1624004763772) + :data $ {} + |T $ {} (:type :expr) (:by |root) (:at 1506759625754) + :data $ {} + |T $ {} (:type :leaf) (:by |root) (:at 1506759655721) (:text |assoc) + |j $ {} (:type :leaf) (:by |root) (:at 1506759629780) (:text |leaf) + |r $ {} (:type :leaf) (:by |root) (:at 1506759630743) (:text |:text) + |v $ {} (:type :expr) (:by |S1lNv50FW) (:at 1624004805177) + :data $ {} + |T $ {} (:type :leaf) (:by |S1lNv50FW) (:at 1624004807296) (:text |:text) + |j $ {} (:type :leaf) (:by |S1lNv50FW) (:at 1624004809108) (:text |op-data) + |x $ {} (:type :leaf) (:by |root) (:at 1514298110406) (:text |:at) + |y $ {} (:type :expr) (:by |S1lNv50FW) (:at 1624004796593) + :data $ {} + |T $ {} (:type :leaf) (:by |S1lNv50FW) (:at 1624004798323) (:text |:at) + |j $ {} (:type :leaf) (:by |S1lNv50FW) (:at 1624004799702) (:text |op-data) + |yT $ {} (:type :leaf) (:by |root) (:at 1514298107771) (:text |:by) + |yj $ {} (:type :leaf) (:by |root) (:at 1506759647443) (:text |user-id) + |D $ {} (:type :leaf) (:by |S1lNv50FW) (:at 1624004764910) (:text |if) + |L $ {} (:type :expr) (:by |S1lNv50FW) (:at 1624004775080) + :data $ {} + |T $ {} (:type :expr) (:by |S1lNv50FW) (:at 1624004765101) + :data $ {} + |T $ {} (:type :leaf) (:by |S1lNv50FW) (:at 1624004765785) (:text |some?) + |j $ {} (:type :expr) (:by |S1lNv50FW) (:at 1624004766107) + :data $ {} + |T $ {} (:type :leaf) (:by |S1lNv50FW) (:at 1624004769959) (:text |:at) + |j $ {} (:type :leaf) (:by |S1lNv50FW) (:at 1624004773345) (:text |op-data) + |D $ {} (:type :leaf) (:by |S1lNv50FW) (:at 1624004775654) (:text |and) + |j $ {} (:type :expr) (:by |S1lNv50FW) (:at 1624004765101) + :data $ {} + |T $ {} (:type :leaf) (:by |S1lNv50FW) (:at 1624004765785) (:text |some?) + |j $ {} (:type :expr) (:by |S1lNv50FW) (:at 1624004766107) + :data $ {} + |T $ {} (:type :leaf) (:by |S1lNv50FW) (:at 1624004781354) (:text |:text) + |j $ {} (:type :leaf) (:by |S1lNv50FW) (:at 1624004773345) (:text |op-data) + |r $ {} (:type :expr) (:by |S1lNv50FW) (:at 1624004782693) + :data $ {} + |T $ {} (:type :leaf) (:by |S1lNv50FW) (:at 1624004784725) (:text |>) + |j $ {} (:type :expr) (:by |S1lNv50FW) (:at 1624004786650) + :data $ {} + |T $ {} (:type :leaf) (:by |S1lNv50FW) (:at 1624004786650) (:text |:at) + |j $ {} (:type :leaf) (:by |S1lNv50FW) (:at 1624004786650) (:text |op-data) + |r $ {} (:type :expr) (:by |S1lNv50FW) (:at 1624004787836) + :data $ {} + |T $ {} (:type :leaf) (:by |S1lNv50FW) (:at 1624004788876) (:text |:at) + |j $ {} (:type :leaf) (:by |S1lNv50FW) (:at 1624004791988) (:text |leaf) + |j $ {} (:type :expr) (:by |S1lNv50FW) (:at 1624004820660) + :data $ {} + |T $ {} (:type :leaf) (:by |S1lNv50FW) (:at 1624004812270) (:text |leaf) + |D $ {} (:type :leaf) (:by |S1lNv50FW) (:at 1624004821583) (:text |do) + |L $ {} (:type :expr) (:by |S1lNv50FW) (:at 1624004822579) + :data $ {} + |T $ {} (:type :leaf) (:by |S1lNv50FW) (:at 1624004824066) (:text |println) + |j $ {} (:type :leaf) (:by |S1lNv50FW) (:at 1624004831279) (:text "|\"invalid updata op:") + |r $ {} (:type :leaf) (:by |S1lNv50FW) (:at 1624004834085) (:text |op-data) |unindent $ {} (:type :expr) (:at 1504777570689) :data $ {} |T $ {} (:type :leaf) (:by |root) (:at 1504777570689) (:text |defn) diff --git a/package.json b/package.json index b7385d8..82db4b7 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "calcit-editor", - "version": "0.5.28", + "version": "0.5.29", "description": "Cirru Calcit Editor", "bin": { "calcit-editor": "dist/server.js", diff --git a/src/app/comp/leaf.cljs b/src/app/comp/leaf.cljs index 853de9c..7456c56 100644 --- a/src/app/comp/leaf.cljs +++ b/src/app/comp/leaf.cljs @@ -23,8 +23,9 @@ (defn on-input [state coord cursor] (fn [e d!] - (d! :ir/update-leaf (:value e)) - (d! cursor (assoc state :text (:value e) :at (util/now!))))) + (let [now (util/now!)] + (d! :ir/update-leaf {:text (:value e), :at now}) + (d! cursor (assoc state :text (:value e) :at now))))) (defn on-keydown [state leaf coord picker-mode?] (fn [e d!] diff --git a/src/app/updater/ir.cljs b/src/app/updater/ir.cljs index ffd890a..11ad907 100644 --- a/src/app/updater/ir.cljs +++ b/src/app/updater/ir.cljs @@ -465,4 +465,11 @@ data-path (bookmark->path bookmark) user-id (get-in db [:sessions session-id :user-id])] (-> db - (update-in data-path (fn [leaf] (assoc leaf :text op-data :at op-time :by user-id)))))) + (update-in + data-path + (fn [leaf] + (if (and (some? (:at op-data)) + (some? (:text op-data)) + (> (:at op-data) (:at leaf))) + (assoc leaf :text (:text op-data) :at (:at op-data) :by user-id) + (do (println "invalid updata op:" op-data) leaf))))))) diff --git a/yarn.lock b/yarn.lock index cf23d6a..74d9c7e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -52,11 +52,6 @@ assert@^1.1.1: object-assign "^4.1.1" util "0.10.3" -async-limiter@~1.0.0: - version "1.0.1" - resolved "https://registry.npmjs.org/async-limiter/-/async-limiter-1.0.1.tgz#dd379e94f0db8310b08291f9d64c3209766617fd" - integrity sha512-csOlWGAcRFJaI6m+F2WKdnMKr4HhdhFVBk0H/QbJFMCr+uO2kwohwXQPxw/9OCxp05r5ghVBFSyioixx3gfkNQ== - balanced-match@^1.0.0: version "1.0.2" resolved "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz#e83e3a7e3f300b34cb9d87f615fa0cbf357690ee" @@ -367,9 +362,9 @@ crypto-browserify@^3.11.0: randomfill "^1.0.3" dayjs@^1.10.4: - version "1.10.4" - resolved "https://registry.npmjs.org/dayjs/-/dayjs-1.10.4.tgz#8e544a9b8683f61783f570980a8a80eaf54ab1e2" - integrity sha512-RI/Hh4kqRc1UKLOAf/T5zdMMX5DQIlDxwUe3wSyMMnEbGunnpENCdbUgM+dW7kXidZqCttBrmw7BhN4TMddkCw== + version "1.10.5" + resolved "https://registry.npmjs.org/dayjs/-/dayjs-1.10.5.tgz#5600df4548fc2453b3f163ebb2abbe965ccfb986" + integrity sha512-BUFis41ikLz+65iH6LHQCDm4YPMj5r1YFLdupPIyM4SGcXMmtiLQ7U37i+hGS8urIuqe7I/ou3IS1jVc4nbN4g== debug@2.6.9: version "2.6.9" @@ -1324,16 +1319,16 @@ shadow-cljs-jar@1.3.2: integrity sha512-XmeffAZHv8z7451kzeq9oKh8fh278Ak+UIOGGrapyqrFBB773xN8vMQ3O7J7TYLnb9BUwcqadKkmgaq7q6fhZg== shadow-cljs@^2.13.0: - version "2.13.0" - resolved "https://registry.npmjs.org/shadow-cljs/-/shadow-cljs-2.13.0.tgz#cbe25cca876d4643b066fc0d73785128ff1d8cce" - integrity sha512-ha+w4kx2E3TJy8OHVPaZpwDiHvsCzl46TGasyt/cHQOKw6QmxBKHe0wP8/6Ajw5pQPh6b9gfIcWhCGNTV2hZMQ== + version "2.14.5" + resolved "https://registry.npmjs.org/shadow-cljs/-/shadow-cljs-2.14.5.tgz#f71d9bf1e292d452ecc76ec0a061fdc895af36b5" + integrity sha512-+tn4f8bSD2P006bsuVAmQeBRSzNM55o2oPT2SfDYDcUYVuqevxnxuDc2xza+c2UsA55bnYezP71CSkFDC56Osw== dependencies: node-libs-browser "^2.2.1" readline-sync "^1.4.7" shadow-cljs-jar "1.3.2" source-map-support "^0.4.15" which "^1.3.1" - ws "^3.0.0" + ws "^7.4.6" shellwords@^0.1.1: version "0.1.1" @@ -1462,11 +1457,6 @@ type-is@~1.6.17, type-is@~1.6.18: media-typer "0.3.0" mime-types "~2.1.24" -ultron@~1.1.0: - version "1.1.1" - resolved "https://registry.npmjs.org/ultron/-/ultron-1.1.1.tgz#9fe1536a10a664a65266a1e3ccf85fd36302bc9c" - integrity sha512-UIEXBNeYmKptWH6z8ZnqTeS8fV74zG0/eRU9VGkpzz+LIJNs8W/zM/L+7ctCkRrgbNnnR0xxw4bKOr0cW0N0Og== - unpipe@1.0.0, unpipe@~1.0.0: version "1.0.0" resolved "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz#b2bf4ee8514aae6165b4817829d21b2ef49904ec" @@ -1553,19 +1543,10 @@ wrappy@1: resolved "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f" integrity sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8= -ws@^3.0.0: - version "3.3.3" - resolved "https://registry.npmjs.org/ws/-/ws-3.3.3.tgz#f1cf84fe2d5e901ebce94efaece785f187a228f2" - integrity sha512-nnWLa/NwZSt4KQJu51MYlCcSQ5g7INpOrOMt4XV8j4dqTXdmlUmSHQ8/oLC069ckre0fRsgfvsKwbTdtKLCDkA== - dependencies: - async-limiter "~1.0.0" - safe-buffer "~5.1.0" - ultron "~1.1.0" - -ws@^7.4.5: - version "7.4.6" - resolved "https://registry.yarnpkg.com/ws/-/ws-7.4.6.tgz#5654ca8ecdeee47c33a9a4bf6d28e2be2980377c" - integrity sha512-YmhHDO4MzaDLB+M9ym/mDA5z0naX8j7SIlT8f8z+I0VtzsRbekxEutHSme7NPS2qE8StCYQNUnfWdXta/Yu85A== +ws@^7.4.5, ws@^7.4.6: + version "7.5.0" + resolved "https://registry.npmjs.org/ws/-/ws-7.5.0.tgz#0033bafea031fb9df041b2026fc72a571ca44691" + integrity sha512-6ezXvzOZupqKj4jUqbQ9tXuJNo+BR2gU8fFRk3XCP3e0G6WT414u5ELe6Y0vtp7kmSJ3F7YWObSNr1ESsgi4vw== xtend@^4.0.0: version "4.0.2"