@barefootjs/erb 0.21.4 → 0.24.1
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.
- package/dist/index.js +4 -4
- package/lib/barefoot_js.rb +99 -0
- package/package.json +3 -3
- package/src/conformance-pins.ts +7 -7
package/dist/index.js
CHANGED
|
@@ -189261,15 +189261,15 @@ var erbAdapter = new ErbAdapter;
|
|
|
189261
189261
|
// src/conformance-pins.ts
|
|
189262
189262
|
var conformancePins = {
|
|
189263
189263
|
"static-array-from-props": [
|
|
189264
|
-
{ code: "BF101", severity: "error", issue: "https://github.com/piconic-ai/barefootjs/issues/
|
|
189264
|
+
{ code: "BF101", severity: "error", issue: "https://github.com/piconic-ai/barefootjs/issues/2321" }
|
|
189265
189265
|
],
|
|
189266
189266
|
"static-array-from-props-with-component": [
|
|
189267
|
-
{ code: "BF101", severity: "error", issue: "https://github.com/piconic-ai/barefootjs/issues/
|
|
189267
|
+
{ code: "BF101", severity: "error", issue: "https://github.com/piconic-ai/barefootjs/issues/2321" }
|
|
189268
189268
|
],
|
|
189269
189269
|
"filter-nested-find-predicate": [
|
|
189270
|
-
{ code: "BF101", severity: "error", issue: "https://github.com/piconic-ai/barefootjs/issues/
|
|
189270
|
+
{ code: "BF101", severity: "error", issue: "https://github.com/piconic-ai/barefootjs/issues/2320" }
|
|
189271
189271
|
],
|
|
189272
|
-
"dangerous-inner-html-dynamic": [{ code: "BF101", severity: "error", issue: "https://github.com/piconic-ai/barefootjs/issues/
|
|
189272
|
+
"dangerous-inner-html-dynamic": [{ code: "BF101", severity: "error", issue: "https://github.com/piconic-ai/barefootjs/issues/2319" }],
|
|
189273
189273
|
"date-method-uncatalogued": [{ code: "BF021", severity: "error", issue: "https://github.com/piconic-ai/barefootjs/issues/2274" }]
|
|
189274
189274
|
};
|
|
189275
189275
|
// src/render-divergences.ts
|
package/lib/barefoot_js.rb
CHANGED
|
@@ -529,6 +529,105 @@ module BarefootJS
|
|
|
529
529
|
end
|
|
530
530
|
end
|
|
531
531
|
|
|
532
|
+
# `tz` shapes FORMAT_DATE_OFFSET_RE matches: a fixed UTC offset `±HH:MM`
|
|
533
|
+
# (`'+09:00'`, `'-05:30'`) -- the ONLY non-UTC shape `format_date`
|
|
534
|
+
# recognizes (mirrors OFFSET_RE in packages/client/src/format-date.ts).
|
|
535
|
+
FORMAT_DATE_OFFSET_RE = /\A([+-])(\d{2}):(\d{2})\z/
|
|
536
|
+
|
|
537
|
+
# Longest-match pattern-token alternation (mirrors TOKEN_RE in
|
|
538
|
+
# packages/client/src/format-date.ts). Order matters: Onigmo, like JS's
|
|
539
|
+
# regex engine, resolves alternation leftmost-first (not POSIX
|
|
540
|
+
# leftmost-longest), so every multi-char token must be listed before any
|
|
541
|
+
# shorter alternative it prefixes -- YYYY before (nothing shorter
|
|
542
|
+
# shares its prefix), MMMM before MMM before MM before M, DD before D,
|
|
543
|
+
# dddd before ddd. (#2334)
|
|
544
|
+
FORMAT_DATE_TOKEN_RE = /YYYY|MMMM|MMM|MM|DD|dddd|ddd|M|D/
|
|
545
|
+
|
|
546
|
+
# `names`-table section offsets (spec/template-helpers.md "format_date",
|
|
547
|
+
# #2334) -- mirrors MONTHS_WIDE/MONTHS_ABBR/WEEKDAYS_WIDE/WEEKDAYS_ABBR in
|
|
548
|
+
# packages/client/src/format-date.ts.
|
|
549
|
+
FORMAT_DATE_MONTHS_WIDE = 0
|
|
550
|
+
FORMAT_DATE_MONTHS_ABBR = 12
|
|
551
|
+
FORMAT_DATE_WEEKDAYS_WIDE = 24
|
|
552
|
+
FORMAT_DATE_WEEKDAYS_ABBR = 31
|
|
553
|
+
|
|
554
|
+
# `format_date(recv, pattern, tz, names)` (#2324/#2334, spec entry
|
|
555
|
+
# "format_date" in spec/template-helpers.md) -- the lowering target for
|
|
556
|
+
# `formatDate(date, pattern, timeZone, names)`
|
|
557
|
+
# (packages/client/src/format-date.ts, the JS-normative reference this
|
|
558
|
+
# must match byte-for-byte). Total and deterministic: no locale, no host
|
|
559
|
+
# timezone, no `Time.now`.
|
|
560
|
+
#
|
|
561
|
+
# recv: the same receiver contract as `date` above -- a native `Time` or
|
|
562
|
+
# an ISO-8601 string, normalized identically. A nil / unparseable
|
|
563
|
+
# receiver renders '' (never raises mid-render).
|
|
564
|
+
#
|
|
565
|
+
# tz: a fixed UTC offset `±HH:MM` shifts the instant by
|
|
566
|
+
# sign*(HH*60+MM) minutes; ANY other value -- 'UTC', an IANA zone name
|
|
567
|
+
# ('Asia/Tokyo'), or a malformed offset ('+9:00') -- normalizes to a
|
|
568
|
+
# zero-minute shift (UTC), so every backend degrades identically instead
|
|
569
|
+
# of dragging in host tzdata. The shifted instant's UTC calendar fields
|
|
570
|
+
# (not the original instant's) are what pattern tokens read -- the
|
|
571
|
+
# shifted UTC clock face IS the local clock face at that offset. `Time`
|
|
572
|
+
# arithmetic here is exact (Ruby represents the instant as a Rational,
|
|
573
|
+
# not a floor-divided epoch-millis integer), so there's no pre-1970
|
|
574
|
+
# negative-epoch floor-division trap to dodge the way a naive
|
|
575
|
+
# epoch-millis-div-86400000 implementation would hit; the shifted
|
|
576
|
+
# `Time#wday` (0 = Sunday) is likewise exact across the epoch boundary,
|
|
577
|
+
# so it doubles directly as the weekday-name table index.
|
|
578
|
+
#
|
|
579
|
+
# names: the flat table (#2334) -- `[0..11]` wide months, `[12..23]`
|
|
580
|
+
# abbreviated months, `[24..30]` wide weekdays (Sunday-first, matching
|
|
581
|
+
# the shifted `Time#wday`), `[31..37]` abbreviated weekdays. The caller
|
|
582
|
+
# owns the values (locale selection is never this method's job). An
|
|
583
|
+
# index past a missing/short table renders '' rather than raising.
|
|
584
|
+
#
|
|
585
|
+
# pattern: longest-match token substitution
|
|
586
|
+
# (`YYYY|MMMM|MMM|MM|DD|dddd|ddd|M|D`); every other character --
|
|
587
|
+
# including multi-byte ones like 年/月/日 -- passes through literally.
|
|
588
|
+
# `YYYY` is `abs(year)` zero-padded to 4 digits, `-`-prefixed for a
|
|
589
|
+
# negative year; `MM`/`DD` zero-pad to 2; `M`/`D` are bare; `MMMM`/`MMM`
|
|
590
|
+
# read the month's wide/abbreviated name; `dddd`/`ddd` read the shifted
|
|
591
|
+
# weekday's wide/abbreviated name.
|
|
592
|
+
def format_date(recv, pattern, tz, names = [])
|
|
593
|
+
t =
|
|
594
|
+
if recv.is_a?(Time)
|
|
595
|
+
recv
|
|
596
|
+
else
|
|
597
|
+
begin
|
|
598
|
+
Time.iso8601(recv.to_s)
|
|
599
|
+
rescue ArgumentError
|
|
600
|
+
nil
|
|
601
|
+
end
|
|
602
|
+
end
|
|
603
|
+
return '' if t.nil?
|
|
604
|
+
|
|
605
|
+
m = FORMAT_DATE_OFFSET_RE.match(tz.to_s)
|
|
606
|
+
offset_minutes = m ? (m[1] == '-' ? -1 : 1) * ((m[2].to_i * 60) + m[3].to_i) : 0
|
|
607
|
+
|
|
608
|
+
shifted = (t.utc + (offset_minutes * 60)).utc
|
|
609
|
+
year = shifted.year
|
|
610
|
+
month = shifted.mon
|
|
611
|
+
day = shifted.mday
|
|
612
|
+
weekday = shifted.wday # 0 = Sunday, matching the table's Sunday-first layout
|
|
613
|
+
yyyy = (year.negative? ? '-' : '') + year.abs.to_s.rjust(4, '0')
|
|
614
|
+
name_at = ->(index) { (names[index] || '').to_s }
|
|
615
|
+
|
|
616
|
+
pattern.gsub(FORMAT_DATE_TOKEN_RE) do |token|
|
|
617
|
+
case token
|
|
618
|
+
when 'YYYY' then yyyy
|
|
619
|
+
when 'MMMM' then name_at.call(FORMAT_DATE_MONTHS_WIDE + month - 1)
|
|
620
|
+
when 'MMM' then name_at.call(FORMAT_DATE_MONTHS_ABBR + month - 1)
|
|
621
|
+
when 'MM' then format('%02d', month)
|
|
622
|
+
when 'M' then month.to_s
|
|
623
|
+
when 'DD' then format('%02d', day)
|
|
624
|
+
when 'D' then day.to_s
|
|
625
|
+
when 'dddd' then name_at.call(FORMAT_DATE_WEEKDAYS_WIDE + weekday)
|
|
626
|
+
when 'ddd' then name_at.call(FORMAT_DATE_WEEKDAYS_ABBR + weekday)
|
|
627
|
+
end
|
|
628
|
+
end
|
|
629
|
+
end
|
|
630
|
+
|
|
532
631
|
# -----------------------------------------------------------------
|
|
533
632
|
# Array / String method helpers
|
|
534
633
|
# -----------------------------------------------------------------
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@barefootjs/erb",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.24.1",
|
|
4
4
|
"description": "ERB (Embedded Ruby) adapter for BarefootJS — compiles IR to .erb templates and ships the Ruby rendering backend; runs under any Rack app (Sinatra, Rails)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -54,14 +54,14 @@
|
|
|
54
54
|
"directory": "packages/adapter-erb"
|
|
55
55
|
},
|
|
56
56
|
"dependencies": {
|
|
57
|
-
"@barefootjs/shared": "0.
|
|
57
|
+
"@barefootjs/shared": "0.24.1"
|
|
58
58
|
},
|
|
59
59
|
"peerDependencies": {
|
|
60
60
|
"@barefootjs/jsx": ">=0.2.0"
|
|
61
61
|
},
|
|
62
62
|
"devDependencies": {
|
|
63
63
|
"@barefootjs/adapter-tests": "0.1.0",
|
|
64
|
-
"@barefootjs/jsx": "0.
|
|
64
|
+
"@barefootjs/jsx": "0.24.1",
|
|
65
65
|
"typescript": "^5.0.0"
|
|
66
66
|
}
|
|
67
67
|
}
|
package/src/conformance-pins.ts
CHANGED
|
@@ -39,17 +39,17 @@ export const conformancePins: ConformancePins = {
|
|
|
39
39
|
// destructure gate merely exposes — it reproduces identically with a
|
|
40
40
|
// non-destructured param (verified) — not a destructure-lowering
|
|
41
41
|
// limitation, so it is NOT part of #2087's scope. Tracked as its own
|
|
42
|
-
// gap under https://github.com/piconic-ai/barefootjs/issues/
|
|
42
|
+
// gap under https://github.com/piconic-ai/barefootjs/issues/2321;
|
|
43
43
|
// pinned honestly as BF101 (the adapter's own check, see `renderLoop`'s
|
|
44
44
|
// "Loop array is a bare identifier..." comment) rather than faked as
|
|
45
45
|
// BF104 or silently producing broken Ruby.
|
|
46
46
|
'static-array-from-props': [
|
|
47
|
-
{ code: 'BF101', severity: 'error', issue: 'https://github.com/piconic-ai/barefootjs/issues/
|
|
47
|
+
{ code: 'BF101', severity: 'error', issue: 'https://github.com/piconic-ai/barefootjs/issues/2321' },
|
|
48
48
|
],
|
|
49
49
|
// BF103 (imported child in the loop body) no longer fires now that the
|
|
50
50
|
// conformance harness passes `siblingTemplatesRegistered: true` (#2205).
|
|
51
51
|
'static-array-from-props-with-component': [
|
|
52
|
-
{ code: 'BF101', severity: 'error', issue: 'https://github.com/piconic-ai/barefootjs/issues/
|
|
52
|
+
{ code: 'BF101', severity: 'error', issue: 'https://github.com/piconic-ai/barefootjs/issues/2321' },
|
|
53
53
|
],
|
|
54
54
|
// #2087 Phase B: `isLowerableLoopDestructure` now admits every fixed-
|
|
55
55
|
// binding shape (any field/index depth — `destructure-array-index-in-map`,
|
|
@@ -69,9 +69,9 @@ export const conformancePins: ConformancePins = {
|
|
|
69
69
|
// (`filter-nested-callback-predicate`) is NOT pinned: like mojo, ERB
|
|
70
70
|
// lowers it to a real inline Ruby block predicate and must render to
|
|
71
71
|
// Hono parity instead.
|
|
72
|
-
// https://github.com/piconic-ai/barefootjs/issues/2038
|
|
72
|
+
// Faithful lowering tracked: https://github.com/piconic-ai/barefootjs/issues/2320 (successor to #2038)
|
|
73
73
|
'filter-nested-find-predicate': [
|
|
74
|
-
{ code: 'BF101', severity: 'error', issue: 'https://github.com/piconic-ai/barefootjs/issues/
|
|
74
|
+
{ code: 'BF101', severity: 'error', issue: 'https://github.com/piconic-ai/barefootjs/issues/2320' },
|
|
75
75
|
],
|
|
76
76
|
// #1467 demo-corpus context providers (`radio-group`, `accordion`,
|
|
77
77
|
// `dialog`, `popover`, `select`, `dropdown-menu`, `combobox`,
|
|
@@ -101,8 +101,8 @@ export const conformancePins: ConformancePins = {
|
|
|
101
101
|
// `dangerouslySetInnerHTML={{ __html: '...' }}` is spliced directly into
|
|
102
102
|
// the template as trusted raw text (`resolveDangerousInnerHtml`, #2207).
|
|
103
103
|
// A dynamic/signal-derived value still refuses with BF101 — see the
|
|
104
|
-
// `dangerous-inner-html-dynamic` fixture/pin below (tracked: #2215).
|
|
105
|
-
'dangerous-inner-html-dynamic': [{ code: 'BF101', severity: 'error', issue: 'https://github.com/piconic-ai/barefootjs/issues/
|
|
104
|
+
// `dangerous-inner-html-dynamic` fixture/pin below (tracked: #2319, successor to #2215).
|
|
105
|
+
'dangerous-inner-html-dynamic': [{ code: 'BF101', severity: 'error', issue: 'https://github.com/piconic-ai/barefootjs/issues/2319' }],
|
|
106
106
|
// #2273: a method call on a prop typed as a built-in host rich type
|
|
107
107
|
// (Date, Map, …) has no catalogued lowering in any adapter — this is a
|
|
108
108
|
// compiler-level refusal (`checkRichTypeMethodCalls`, wired ahead of
|