@barefootjs/mojolicious 0.9.5 → 0.10.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.
- package/dist/adapter/index.js +9 -4
- package/dist/adapter/mojo-adapter.d.ts.map +1 -1
- package/dist/build.js +9 -4
- package/dist/index.js +9 -4
- package/lib/BarefootJS/Backend/Mojo.pm +1 -1
- package/lib/Mojolicious/Plugin/BarefootJS/DevReload.pm +1 -1
- package/lib/Mojolicious/Plugin/BarefootJS.pm +1 -1
- package/package.json +3 -3
- package/src/__tests__/mojo-adapter.test.ts +28 -11
- package/src/__tests__/scaffold.test.ts +17 -17
- package/src/adapter/mojo-adapter.ts +14 -10
package/dist/adapter/index.js
CHANGED
|
@@ -1404,10 +1404,6 @@ class MojoTopLevelEmitter {
|
|
|
1404
1404
|
return `(${l} // ${r})`;
|
|
1405
1405
|
}
|
|
1406
1406
|
higherOrder(method, object, param, predicate, emit) {
|
|
1407
|
-
if (method === "find" || method === "findIndex" || method === "findLast" || method === "findLastIndex") {
|
|
1408
|
-
this.adapter._recordExprBF101(`Mojo adapter has not lowered Array.prototype.${method} yet`);
|
|
1409
|
-
return "''";
|
|
1410
|
-
}
|
|
1411
1407
|
const arrayExpr = emit(object);
|
|
1412
1408
|
const predBody = this.adapter._renderPerlFilterExprPublic(predicate, param);
|
|
1413
1409
|
const grepBody = predBody.replace(new RegExp(`\\$${param}\\b`, "g"), "$_");
|
|
@@ -1417,6 +1413,15 @@ class MojoTopLevelEmitter {
|
|
|
1417
1413
|
return `!(grep { !(${grepBody}) } @{${arrayExpr}})`;
|
|
1418
1414
|
if (method === "some")
|
|
1419
1415
|
return `!!(grep { ${grepBody} } @{${arrayExpr}})`;
|
|
1416
|
+
const findHelper = {
|
|
1417
|
+
find: "find",
|
|
1418
|
+
findIndex: "find_index",
|
|
1419
|
+
findLast: "find_last",
|
|
1420
|
+
findLastIndex: "find_last_index"
|
|
1421
|
+
};
|
|
1422
|
+
if (findHelper[method]) {
|
|
1423
|
+
return `bf->${findHelper[method]}(${arrayExpr}, sub { my $${param} = $_[0]; ${predBody} })`;
|
|
1424
|
+
}
|
|
1420
1425
|
return arrayExpr;
|
|
1421
1426
|
}
|
|
1422
1427
|
arrayLiteral(elements, emit) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mojo-adapter.d.ts","sourceRoot":"","sources":["../../src/adapter/mojo-adapter.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,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,EAM3B,KAAK,aAAa,EAClB,KAAK,UAAU,EAiBhB,MAAM,iBAAiB,CAAA;AAGxB;;;;;;GAMG;AACH,KAAK,aAAa,GAAG,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAA;AAC1C,OAAO,KAAK,EAAE,UAAU,EAAiF,MAAM,iBAAiB,CAAA;AAqDhI,MAAM,WAAW,kBAAkB;IACjC,qEAAqE;IACrE,gBAAgB,CAAC,EAAE,MAAM,CAAA;IAEzB,8EAA8E;IAC9E,cAAc,CAAC,EAAE,MAAM,CAAA;CACxB;AAkFD,qBAAa,WAAY,SAAQ,WAAY,YAAW,aAAa,CAAC,aAAa,CAAC;IAClF,IAAI,SAAgB;IACpB,SAAS,SAAa;IACtB,qBAAqB,UAAO;IAG5B,kBAAkB,EAAG,cAAc,CAAS;IAE5C;;;;;;;;;;;OAWG;IACH,kBAAkB,EAAE,yBAAyB,CAA0B;IAEvE,OAAO,CAAC,aAAa,CAAa;IAClC;;;;wCAIoC;IACpC,OAAO,CAAC,cAAc,CAAyB;IAC/C,OAAO,CAAC,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OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAYvD;IAED,iFAAiF;IACjF,2BAA2B,CAAC,IAAI,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAEnE;CACF;AA0wBD,eAAO,MAAM,WAAW,aAAoB,CAAA"}
|
package/dist/build.js
CHANGED
|
@@ -1404,10 +1404,6 @@ class MojoTopLevelEmitter {
|
|
|
1404
1404
|
return `(${l} // ${r})`;
|
|
1405
1405
|
}
|
|
1406
1406
|
higherOrder(method, object, param, predicate, emit) {
|
|
1407
|
-
if (method === "find" || method === "findIndex" || method === "findLast" || method === "findLastIndex") {
|
|
1408
|
-
this.adapter._recordExprBF101(`Mojo adapter has not lowered Array.prototype.${method} yet`);
|
|
1409
|
-
return "''";
|
|
1410
|
-
}
|
|
1411
1407
|
const arrayExpr = emit(object);
|
|
1412
1408
|
const predBody = this.adapter._renderPerlFilterExprPublic(predicate, param);
|
|
1413
1409
|
const grepBody = predBody.replace(new RegExp(`\\$${param}\\b`, "g"), "$_");
|
|
@@ -1417,6 +1413,15 @@ class MojoTopLevelEmitter {
|
|
|
1417
1413
|
return `!(grep { !(${grepBody}) } @{${arrayExpr}})`;
|
|
1418
1414
|
if (method === "some")
|
|
1419
1415
|
return `!!(grep { ${grepBody} } @{${arrayExpr}})`;
|
|
1416
|
+
const findHelper = {
|
|
1417
|
+
find: "find",
|
|
1418
|
+
findIndex: "find_index",
|
|
1419
|
+
findLast: "find_last",
|
|
1420
|
+
findLastIndex: "find_last_index"
|
|
1421
|
+
};
|
|
1422
|
+
if (findHelper[method]) {
|
|
1423
|
+
return `bf->${findHelper[method]}(${arrayExpr}, sub { my $${param} = $_[0]; ${predBody} })`;
|
|
1424
|
+
}
|
|
1420
1425
|
return arrayExpr;
|
|
1421
1426
|
}
|
|
1422
1427
|
arrayLiteral(elements, emit) {
|
package/dist/index.js
CHANGED
|
@@ -1404,10 +1404,6 @@ class MojoTopLevelEmitter {
|
|
|
1404
1404
|
return `(${l} // ${r})`;
|
|
1405
1405
|
}
|
|
1406
1406
|
higherOrder(method, object, param, predicate, emit) {
|
|
1407
|
-
if (method === "find" || method === "findIndex" || method === "findLast" || method === "findLastIndex") {
|
|
1408
|
-
this.adapter._recordExprBF101(`Mojo adapter has not lowered Array.prototype.${method} yet`);
|
|
1409
|
-
return "''";
|
|
1410
|
-
}
|
|
1411
1407
|
const arrayExpr = emit(object);
|
|
1412
1408
|
const predBody = this.adapter._renderPerlFilterExprPublic(predicate, param);
|
|
1413
1409
|
const grepBody = predBody.replace(new RegExp(`\\$${param}\\b`, "g"), "$_");
|
|
@@ -1417,6 +1413,15 @@ class MojoTopLevelEmitter {
|
|
|
1417
1413
|
return `!(grep { !(${grepBody}) } @{${arrayExpr}})`;
|
|
1418
1414
|
if (method === "some")
|
|
1419
1415
|
return `!!(grep { ${grepBody} } @{${arrayExpr}})`;
|
|
1416
|
+
const findHelper = {
|
|
1417
|
+
find: "find",
|
|
1418
|
+
findIndex: "find_index",
|
|
1419
|
+
findLast: "find_last",
|
|
1420
|
+
findLastIndex: "find_last_index"
|
|
1421
|
+
};
|
|
1422
|
+
if (findHelper[method]) {
|
|
1423
|
+
return `bf->${findHelper[method]}(${arrayExpr}, sub { my $${param} = $_[0]; ${predBody} })`;
|
|
1424
|
+
}
|
|
1420
1425
|
return arrayExpr;
|
|
1421
1426
|
}
|
|
1422
1427
|
arrayLiteral(elements, emit) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@barefootjs/mojolicious",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.0",
|
|
4
4
|
"description": "Mojolicious EP template adapter for BarefootJS - generates .html.ep files from IR",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
"directory": "packages/adapter-mojolicious"
|
|
53
53
|
},
|
|
54
54
|
"dependencies": {
|
|
55
|
-
"@barefootjs/shared": "0.
|
|
55
|
+
"@barefootjs/shared": "0.10.0"
|
|
56
56
|
},
|
|
57
57
|
"peerDependencies": {
|
|
58
58
|
"@barefootjs/jsx": ">=0.2.0",
|
|
@@ -60,6 +60,6 @@
|
|
|
60
60
|
},
|
|
61
61
|
"devDependencies": {
|
|
62
62
|
"@barefootjs/adapter-tests": "0.1.0",
|
|
63
|
-
"@barefootjs/jsx": "0.
|
|
63
|
+
"@barefootjs/jsx": "0.10.0"
|
|
64
64
|
}
|
|
65
65
|
}
|
|
@@ -109,17 +109,11 @@ runAdapterConformanceTests({
|
|
|
109
109
|
// `string-trim` no longer pinned — pre-existing `bf_trim`
|
|
110
110
|
// (Go) and new `bf->trim` helper (Mojo) handle the strip
|
|
111
111
|
// (#1448 Tier A ninth PR, closing out Tier A).
|
|
112
|
-
//
|
|
113
|
-
//
|
|
114
|
-
//
|
|
115
|
-
//
|
|
116
|
-
//
|
|
117
|
-
// `case 'join'` emits `join(sep, @{arr})` correctly; the
|
|
118
|
-
// text-expression form is routed through the same AST path.
|
|
119
|
-
'array-find': [{ code: 'BF101', severity: 'error' }],
|
|
120
|
-
'array-findIndex': [{ code: 'BF101', severity: 'error' }],
|
|
121
|
-
'array-findLast': [{ code: 'BF101', severity: 'error' }],
|
|
122
|
-
'array-findLastIndex': [{ code: 'BF101', severity: 'error' }],
|
|
112
|
+
// `.find` / `.findIndex` / `.findLast` / `.findLastIndex` are no longer
|
|
113
|
+
// pinned — the Mojo `higherOrder` emitter now lowers them to the runtime
|
|
114
|
+
// `bf->find` / `find_index` / `find_last` / `find_last_index` helpers
|
|
115
|
+
// (per-element coderef predicate), matching Xslate. `.join` was never
|
|
116
|
+
// pinned (handled by `renderArrayMethod`'s `case 'join'`).
|
|
123
117
|
},
|
|
124
118
|
// `JSON_STRINGIFY_VIA_CONST` and `MATH_FLOOR_VIA_CONST` now pass
|
|
125
119
|
// via `MojoAdapter.templatePrimitives` (#1189). The two remaining
|
|
@@ -940,6 +934,29 @@ export { A }`, 'A.tsx', { adapter })
|
|
|
940
934
|
expect(template).not.toContain('$bf->trim')
|
|
941
935
|
})
|
|
942
936
|
|
|
937
|
+
test('lowers .find / .findIndex / .findLast / .findLastIndex via runtime helpers', () => {
|
|
938
|
+
// The runtime `bf->find` / `find_index` / `find_last` / `find_last_index`
|
|
939
|
+
// call the predicate as a per-element coderef; the camelCase JS names map
|
|
940
|
+
// to the snake_case helpers (matching Xslate's Kolon-lambda lowering).
|
|
941
|
+
const cases: Array<[string, string]> = [
|
|
942
|
+
['find', 'find'],
|
|
943
|
+
['findIndex', 'find_index'],
|
|
944
|
+
['findLast', 'find_last'],
|
|
945
|
+
['findLastIndex', 'find_last_index'],
|
|
946
|
+
]
|
|
947
|
+
for (const [js, helper] of cases) {
|
|
948
|
+
const adapter = new MojoAdapter()
|
|
949
|
+
const result = compileJSX(`function A({ items }: { items: string[] }) {
|
|
950
|
+
return <div>{items.${js}(x => x === 'b')}</div>
|
|
951
|
+
}
|
|
952
|
+
export { A }`, 'A.tsx', { adapter })
|
|
953
|
+
expect(result.errors?.filter(e => e.code === 'BF101') ?? []).toEqual([])
|
|
954
|
+
const template = result.files.find(f => f.path.endsWith('.html.ep'))?.content ?? ''
|
|
955
|
+
expect(template).toContain(`bf->${helper}($items, sub { my $x = $_[0]; $x eq 'b' })`)
|
|
956
|
+
expect(template).not.toContain(`$bf->${helper}`)
|
|
957
|
+
}
|
|
958
|
+
})
|
|
959
|
+
|
|
943
960
|
test('lowers .reverse().join(\' \') via bf->reverse + join (#1448 Tier A)', () => {
|
|
944
961
|
// SSR templates render a snapshot, so `.reverse` and
|
|
945
962
|
// `.toReversed` share a Mojo lowering — both return a new
|
|
@@ -10,8 +10,8 @@
|
|
|
10
10
|
// (Mojolicious's built-in dispatcher does not honour URL prefixes,
|
|
11
11
|
// so the explicit routes are load-bearing — without them every
|
|
12
12
|
// stylesheet and client bundle 404s in the browser).
|
|
13
|
-
// - `
|
|
14
|
-
//
|
|
13
|
+
// - the `cpanfile` declares the BarefootJS Perl deps + Mojolicious
|
|
14
|
+
// (installed from CPAN, not vendored under `lib/`), and the plugin's
|
|
15
15
|
// manifest-driven child rendering works without per-component wire-up.
|
|
16
16
|
//
|
|
17
17
|
// BAREFOOT_CREATE_INTEGRATION=1 bun test src/__tests__/scaffold.test.ts
|
|
@@ -143,24 +143,24 @@ describe.skipIf(!INTEGRATION)(
|
|
|
143
143
|
// -------------------------------------------------------------------------
|
|
144
144
|
|
|
145
145
|
describe('mojo wiring', () => {
|
|
146
|
-
test('
|
|
147
|
-
|
|
146
|
+
test('does not vendor BarefootJS .pm copies under lib/', () => {
|
|
147
|
+
// The Perl modules ship on CPAN now, so the scaffold pulls them
|
|
148
|
+
// via `cpanm --installdeps .` instead of vendoring copies. A
|
|
149
|
+
// stray lib/ would shadow the installed dist (app.pl no longer
|
|
150
|
+
// adds it to @INC anyway).
|
|
151
|
+
expect(existsSync(path.join(projectDir, 'lib', 'BarefootJS.pm'))).toBe(false)
|
|
148
152
|
})
|
|
149
153
|
|
|
150
|
-
test('
|
|
151
|
-
//
|
|
152
|
-
//
|
|
153
|
-
//
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
path.join(projectDir, 'lib', 'Mojolicious', 'Plugin', 'BarefootJS', 'DevReload.pm'),
|
|
157
|
-
),
|
|
158
|
-
).toBe(true)
|
|
159
|
-
})
|
|
160
|
-
|
|
161
|
-
test('cpanfile lists Mojolicious', () => {
|
|
154
|
+
test('cpanfile declares the BarefootJS Perl deps + Mojolicious', () => {
|
|
155
|
+
// `Mojolicious::Plugin::BarefootJS` (the plugin + dev-reload
|
|
156
|
+
// plugin + BarefootJS::Backend::Mojo) and `BarefootJS` (core)
|
|
157
|
+
// are declared so `cpanm --installdeps .` installs everything
|
|
158
|
+
// `plugin 'BarefootJS'` / `plugin 'BarefootJS::DevReload'` need
|
|
159
|
+
// at boot.
|
|
162
160
|
const cp = readFileSync(path.join(projectDir, 'cpanfile'), 'utf-8')
|
|
163
|
-
expect(cp).toMatch(/
|
|
161
|
+
expect(cp).toMatch(/^requires 'BarefootJS'/m)
|
|
162
|
+
expect(cp).toMatch(/^requires 'Mojolicious::Plugin::BarefootJS'/m)
|
|
163
|
+
expect(cp).toMatch(/^requires 'Mojolicious'/m)
|
|
164
164
|
})
|
|
165
165
|
|
|
166
166
|
test('plugin auto-loads manifest — no per-route register_components_from_manifest call', () => {
|
|
@@ -2474,22 +2474,26 @@ class MojoTopLevelEmitter implements ParsedExprEmitter {
|
|
|
2474
2474
|
predicate: ParsedExpr,
|
|
2475
2475
|
emit: (e: ParsedExpr) => string,
|
|
2476
2476
|
): string {
|
|
2477
|
-
// Mojo-specific gap: `.find` / `.findIndex` / `.findLast` /
|
|
2478
|
-
// `.findLastIndex` have no Embedded-Perl lowering yet. `isSupported`
|
|
2479
|
-
// accepts them (it's adapter-agnostic), so the refusal lands here
|
|
2480
|
-
// rather than at the support gate. BF101 until a lowering lands.
|
|
2481
|
-
if (method === 'find' || method === 'findIndex' || method === 'findLast' || method === 'findLastIndex') {
|
|
2482
|
-
this.adapter._recordExprBF101(
|
|
2483
|
-
`Mojo adapter has not lowered Array.prototype.${method} yet`,
|
|
2484
|
-
)
|
|
2485
|
-
return "''"
|
|
2486
|
-
}
|
|
2487
2477
|
const arrayExpr = emit(object)
|
|
2488
2478
|
const predBody = this.adapter._renderPerlFilterExprPublic(predicate, param)
|
|
2489
2479
|
const grepBody = predBody.replace(new RegExp(`\\$${param}\\b`, 'g'), '$_')
|
|
2490
2480
|
if (method === 'filter') return `[grep { ${grepBody} } @{${arrayExpr}}]`
|
|
2491
2481
|
if (method === 'every') return `!(grep { !(${grepBody}) } @{${arrayExpr}})`
|
|
2492
2482
|
if (method === 'some') return `!!(grep { ${grepBody} } @{${arrayExpr}})`
|
|
2483
|
+
// `.find` / `.findIndex` / `.findLast` / `.findLastIndex` → the runtime
|
|
2484
|
+
// helpers (`bf->find` / `find_index` / `find_last` / `find_last_index`),
|
|
2485
|
+
// which call the predicate as a per-element coderef — same shape Xslate
|
|
2486
|
+
// emits via a Kolon lambda. The JS camelCase names map to the snake_case
|
|
2487
|
+
// helpers (like index_of / last_index_of).
|
|
2488
|
+
const findHelper: Record<string, string> = {
|
|
2489
|
+
find: 'find',
|
|
2490
|
+
findIndex: 'find_index',
|
|
2491
|
+
findLast: 'find_last',
|
|
2492
|
+
findLastIndex: 'find_last_index',
|
|
2493
|
+
}
|
|
2494
|
+
if (findHelper[method]) {
|
|
2495
|
+
return `bf->${findHelper[method]}(${arrayExpr}, sub { my $${param} = $_[0]; ${predBody} })`
|
|
2496
|
+
}
|
|
2493
2497
|
return arrayExpr
|
|
2494
2498
|
}
|
|
2495
2499
|
|