@barefootjs/erb 0.20.0 → 0.21.0
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"erb-adapter.d.ts","sourceRoot":"","sources":["../../src/adapter/erb-adapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AAEH,OAAO,KAAK,EACV,WAAW,EAEX,MAAM,EACN,SAAS,EACT,MAAM,EACN,YAAY,EACZ,aAAa,EACb,MAAM,EACN,WAAW,EACX,UAAU,EACV,MAAM,EACN,aAAa,EACb,UAAU,EACV,OAAO,EAMP,yBAAyB,EAC1B,MAAM,iBAAiB,CAAA;AACxB,OAAO,EACL,WAAW,EACX,KAAK,aAAa,EAClB,KAAK,sBAAsB,EAE3B,KAAK,aAAa,EAClB,KAAK,UAAU,EA8BhB,MAAM,iBAAiB,CAAA;AAKxB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAoClD,YAAY,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAA;AACvD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAA;AAoBvD,qBAAa,UAAW,SAAQ,WAAY,YAAW,aAAa,CAAC,YAAY,CAAC;IAChF,IAAI,SAAQ;IACZ,SAAS,SAAS;IAClB,qBAAqB,UAAO;IAI5B,kBAAkB,EAAG,cAAc,CAAS;IAE5C;;;;;;OAMG;IACH,kBAAkB,EAAE,yBAAyB,CAAyB;IAEtE,OAAO,CAAC,aAAa,CAAa;IAClC;;;;oDAIgD;IAChD,OAAO,CAAC,cAAc,CAAyB;IAC/C,OAAO,CAAC,OAAO,CAA6B;IAC5C,OAAO,CAAC,MAAM,CAAsB;IACpC,OAAO,CAAC,MAAM,CAAiB;IAC/B;;;;;;OAMG;IACH,OAAO,CAAC,mBAAmB,CAAI;IAC/B;;;;;OAKG;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lC;IAED;;;OAGG;IACH,OAAO,CAAC,kBAAkB,CAAI;IAE9B;;;;;;OAMG;IACH,OAAO,CAAC,mBAAmB;IA0B3B,8EAA8E;IAC9E,OAAO,CAAC,cAAc;IAStB,OAAO,CAAC,gBAAgB;IAyCxB,iBAAiB,CAAC,eAAe,EAAE,MAAM,GAAG,MAAM,CAMjD;IAED,gBAAgB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAEvC;IAED,gBAAgB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAEvC;IAMD;;;;;OAKG;IACH,OAAO,CAAC,oBAAoB;IA8B5B,OAAO,CAAC,iCAAiC;IAkCzC;;;;;;;OAOG;IACH,OAAO,CAAC,gCAAgC;IAmBxC;;;;;;;;;;;;;;;OAeG;IACH,OAAO,CAAC,+BAA+B;IAuBvC;;;;;;;OAOG;IACH,OAAO,KAAK,OAAO,GAWlB;IAED;;;;OAIG;IACH,OAAO,KAAK,SAAS,GAQpB;IAED,sEAAsE;IACtE,OAAO,KAAK,OAAO,GAElB;IAED,OAAO,CAAC,uBAAuB;IA+E/B;;;;OAIG;IACH,OAAO,CAAC,sBAAsB;IAI9B;uEACmE;IACnE,OAAO,CAAC,kBAAkB;IAI1B,OAAO,CAAC,gBAAgB;IAcxB,iFAAiF;IACjF,OAAO,CAAC,2BAA2B;CAGpC;AAED,eAAO,MAAM,UAAU,YAAmB,CAAA"}
|
package/dist/adapter/index.js
CHANGED
|
@@ -188964,7 +188964,7 @@ ${alternate}
|
|
|
188964
188964
|
renderFragment(fragment) {
|
|
188965
188965
|
const children = this.renderChildren(fragment.children);
|
|
188966
188966
|
if (fragment.needsScopeComment) {
|
|
188967
|
-
return `<%= bf.scope_comment %>${children}
|
|
188967
|
+
return `<%= bf.scope_comment %>${children}<%= bf.scope_comment_end %>`;
|
|
188968
188968
|
}
|
|
188969
188969
|
return children;
|
|
188970
188970
|
}
|
package/dist/build.js
CHANGED
|
@@ -188964,7 +188964,7 @@ ${alternate}
|
|
|
188964
188964
|
renderFragment(fragment) {
|
|
188965
188965
|
const children = this.renderChildren(fragment.children);
|
|
188966
188966
|
if (fragment.needsScopeComment) {
|
|
188967
|
-
return `<%= bf.scope_comment %>${children}
|
|
188967
|
+
return `<%= bf.scope_comment %>${children}<%= bf.scope_comment_end %>`;
|
|
188968
188968
|
}
|
|
188969
188969
|
return children;
|
|
188970
188970
|
}
|
package/dist/index.js
CHANGED
|
@@ -188964,7 +188964,7 @@ ${alternate}
|
|
|
188964
188964
|
renderFragment(fragment) {
|
|
188965
188965
|
const children = this.renderChildren(fragment.children);
|
|
188966
188966
|
if (fragment.needsScopeComment) {
|
|
188967
|
-
return `<%= bf.scope_comment %>${children}
|
|
188967
|
+
return `<%= bf.scope_comment %>${children}<%= bf.scope_comment_end %>`;
|
|
188968
188968
|
}
|
|
188969
188969
|
return children;
|
|
188970
188970
|
}
|
package/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
|
# -----------------------------------------------------------------
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@barefootjs/erb",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.21.0",
|
|
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.21.0"
|
|
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.21.0",
|
|
65
65
|
"typescript": "^5.0.0"
|
|
66
66
|
}
|
|
67
67
|
}
|
|
@@ -130,6 +130,66 @@ export function ThemeLabel() { const theme = useContext(ThemeContext); return <s
|
|
|
130
130
|
})
|
|
131
131
|
})
|
|
132
132
|
|
|
133
|
+
describe('ErbAdapter - fragment-root scope comment end marker (#2289)', () => {
|
|
134
|
+
// A fragment-rooted component (multiple top-level nodes) uses a
|
|
135
|
+
// comment-based scope marker instead of a real DOM element, so it needs a
|
|
136
|
+
// paired end marker after the last top-level node -- otherwise
|
|
137
|
+
// client-side queries from this scope leak onto later siblings owned by
|
|
138
|
+
// the parent. See `scope_comment_end` in `lib/barefoot_js.rb`.
|
|
139
|
+
test('template emits both bf.scope_comment and bf.scope_comment_end, in order', () => {
|
|
140
|
+
const { template } = compileAndGenerate(`
|
|
141
|
+
export function Wrapper({ children }: { children?: any }) {
|
|
142
|
+
return (
|
|
143
|
+
<>
|
|
144
|
+
<div>Header</div>
|
|
145
|
+
{children}
|
|
146
|
+
</>
|
|
147
|
+
)
|
|
148
|
+
}
|
|
149
|
+
`)
|
|
150
|
+
expect(template).toContain('<%= bf.scope_comment %>')
|
|
151
|
+
expect(template).toContain('<%= bf.scope_comment_end %>')
|
|
152
|
+
expect(template.indexOf('<%= bf.scope_comment %>')).toBeLessThan(
|
|
153
|
+
template.indexOf('<%= bf.scope_comment_end %>'),
|
|
154
|
+
)
|
|
155
|
+
})
|
|
156
|
+
|
|
157
|
+
// Renders through real Ruby (`bf.scope_comment` / `bf.scope_comment_end`
|
|
158
|
+
// both read `_scope_id` at render time) to confirm the two markers carry
|
|
159
|
+
// the SAME scope id -- a template-level check can only see that both
|
|
160
|
+
// calls are present, not that they agree at render time.
|
|
161
|
+
test('rendered HTML pairs bf-scope and bf-/scope with the same scope id', async () => {
|
|
162
|
+
let html: string
|
|
163
|
+
try {
|
|
164
|
+
html = await renderErbComponent({
|
|
165
|
+
source: `
|
|
166
|
+
export function Wrapper({ children }: { children?: any }) {
|
|
167
|
+
return (
|
|
168
|
+
<>
|
|
169
|
+
<div>Header</div>
|
|
170
|
+
{children}
|
|
171
|
+
</>
|
|
172
|
+
)
|
|
173
|
+
}
|
|
174
|
+
`,
|
|
175
|
+
adapter: new ErbAdapter(),
|
|
176
|
+
})
|
|
177
|
+
} catch (err) {
|
|
178
|
+
if (err instanceof ErbNotAvailableError) {
|
|
179
|
+
console.log(`Skipping [scope-comment-end]: ${err.message}`)
|
|
180
|
+
return
|
|
181
|
+
}
|
|
182
|
+
throw err
|
|
183
|
+
}
|
|
184
|
+
const begin = html.match(/<!--bf-scope:([^|]*?)(?:\||-->)/)
|
|
185
|
+
const end = html.match(/<!--bf-\/scope:([^>]*)-->/)
|
|
186
|
+
expect(begin).not.toBeNull()
|
|
187
|
+
expect(end).not.toBeNull()
|
|
188
|
+
expect(end![1]).toBe(begin![1])
|
|
189
|
+
expect(html.indexOf(begin![0])).toBeLessThan(html.indexOf(end![0]))
|
|
190
|
+
})
|
|
191
|
+
})
|
|
192
|
+
|
|
133
193
|
describe('ErbAdapter - prop-derived memo SSR seeding (#1297)', () => {
|
|
134
194
|
test('seeds a prop-derived memo from the prop var', () => {
|
|
135
195
|
const { template } = compileAndGenerate(`
|
|
@@ -1323,7 +1323,10 @@ export class ErbAdapter extends BaseAdapter implements IRNodeEmitter<ErbRenderCt
|
|
|
1323
1323
|
private renderFragment(fragment: IRFragment): string {
|
|
1324
1324
|
const children = this.renderChildren(fragment.children)
|
|
1325
1325
|
if (fragment.needsScopeComment) {
|
|
1326
|
-
|
|
1326
|
+
// End marker bounds the scope's sibling range -- without it, queries
|
|
1327
|
+
// from the fragment scope leak onto later siblings owned by the
|
|
1328
|
+
// parent (#2289). See `scope_comment_end` in barefoot_js.rb.
|
|
1329
|
+
return `<%= bf.scope_comment %>${children}<%= bf.scope_comment_end %>`
|
|
1327
1330
|
}
|
|
1328
1331
|
return children
|
|
1329
1332
|
}
|