barefoot_js 0.20.0 → 0.21.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/barefoot_js.rb +48 -0
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: fb12117ca703a69d2a7355a5e390e5dc44ae3d13511b73e8690c1da326e85270
|
|
4
|
+
data.tar.gz: 53478b4d38635c877a8e290e17016826761a3bb9417314a087d48c578486e7d9
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 7b03e25211173b9a0f9f3a9ff089c5888b4ee39658635116308b7bf5ddb9b8885bb766c12521e984d150c72f806c9b583e8c48c212ef286ed3b5105f0d250076
|
|
7
|
+
data.tar.gz: a6acfd23d5ecf6ee75ad039dd654a45065d2d91f0e1152448e94deac32bd8da5331beee01dd50cde95f61e088283cd681474c73b4ea8e8372f5ca1d6621ab0a2
|
data/lib/barefoot_js.rb
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
require 'set'
|
|
4
|
+
require 'time'
|
|
4
5
|
require 'barefoot_js/evaluator'
|
|
5
6
|
require 'barefoot_js/search_params'
|
|
6
7
|
|
|
@@ -197,6 +198,14 @@ module BarefootJS
|
|
|
197
198
|
"<!--bf-scope:#{scope_id}#{host_segment}#{props_json}-->"
|
|
198
199
|
end
|
|
199
200
|
|
|
201
|
+
# Paired end marker for `scope_comment`, emitted after the fragment's
|
|
202
|
+
# last top-level node. No host/props segments -- the client only needs
|
|
203
|
+
# the scope id to close the boundary (#2289).
|
|
204
|
+
def scope_comment_end
|
|
205
|
+
scope_id = _scope_id || ''
|
|
206
|
+
"<!--bf-/scope:#{scope_id}-->"
|
|
207
|
+
end
|
|
208
|
+
|
|
200
209
|
# -----------------------------------------------------------------
|
|
201
210
|
# Script Registration
|
|
202
211
|
# -----------------------------------------------------------------
|
|
@@ -481,6 +490,45 @@ module BarefootJS
|
|
|
481
490
|
nan_number?(n) ? n : n.abs
|
|
482
491
|
end
|
|
483
492
|
|
|
493
|
+
# `date(recv, op)` -- zero-arg `Date.prototype` method lowering (#2274,
|
|
494
|
+
# spec entry "date"). `recv` arrives as either this runtime's own `Time`
|
|
495
|
+
# or an ISO-8601 String (a template prop may carry either depending on
|
|
496
|
+
# how the host populated it), so both normalize through `Time.iso8601`
|
|
497
|
+
# / `#utc` to the same instant before dispatch. `#mon` is 1-based in
|
|
498
|
+
# Ruby; only `getUTCMonth` subtracts 1 to match JS's 0-based month.
|
|
499
|
+
# `getTime` sums whole milliseconds from `tv_sec`/`tv_nsec` rather than
|
|
500
|
+
# rounding a Float ms value -- `tv_nsec` is always the non-negative
|
|
501
|
+
# sub-second remainder (Ruby normalizes `Time`'s internal rational),
|
|
502
|
+
# even for a pre-epoch instant, so integer division here stays exact.
|
|
503
|
+
def date(recv, op)
|
|
504
|
+
# A nil or unparseable receiver degrades to the zero value the
|
|
505
|
+
# Go / Rust / Perl helpers document (empty string for toISOString,
|
|
506
|
+
# 0 otherwise), rather than raising mid-render.
|
|
507
|
+
t =
|
|
508
|
+
if recv.is_a?(Time)
|
|
509
|
+
recv
|
|
510
|
+
else
|
|
511
|
+
begin
|
|
512
|
+
Time.iso8601(recv.to_s)
|
|
513
|
+
rescue ArgumentError
|
|
514
|
+
nil
|
|
515
|
+
end
|
|
516
|
+
end
|
|
517
|
+
return (op == 'toISOString' ? '' : 0) if t.nil?
|
|
518
|
+
t = t.utc
|
|
519
|
+
case op
|
|
520
|
+
when 'getUTCFullYear' then t.year
|
|
521
|
+
when 'getUTCMonth' then t.mon - 1
|
|
522
|
+
when 'getUTCDate' then t.day
|
|
523
|
+
when 'getUTCHours' then t.hour
|
|
524
|
+
when 'getUTCMinutes' then t.min
|
|
525
|
+
when 'getUTCSeconds' then t.sec
|
|
526
|
+
when 'getTime' then (t.tv_sec * 1000) + (t.tv_nsec / 1_000_000)
|
|
527
|
+
when 'toISOString' then t.strftime('%Y-%m-%dT%H:%M:%S.%LZ')
|
|
528
|
+
else 0
|
|
529
|
+
end
|
|
530
|
+
end
|
|
531
|
+
|
|
484
532
|
# -----------------------------------------------------------------
|
|
485
533
|
# Array / String method helpers
|
|
486
534
|
# -----------------------------------------------------------------
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: barefoot_js
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.21.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- kobaken
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-07-
|
|
11
|
+
date: 2026-07-17 00:00:00.000000000 Z
|
|
12
12
|
dependencies: []
|
|
13
13
|
description: Engine-agnostic BarefootJS server runtime targeting ERB, ported from
|
|
14
14
|
packages/adapter-perl/lib/BarefootJS.pm.
|