@barefootjs/client 0.30.5 → 0.31.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/csr-adapter.d.ts +2 -1
- package/dist/csr-adapter.d.ts.map +1 -1
- package/dist/csr-adapter.js +170676 -0
- package/dist/runtime/component.d.ts.map +1 -1
- package/dist/runtime/hydrate.d.ts.map +1 -1
- package/dist/runtime/index.js +4 -3
- package/dist/runtime/standalone.js +4 -3
- package/package.json +6 -6
- package/src/csr-adapter.ts +18 -17
- package/src/runtime/component.ts +13 -2
- package/src/runtime/hydrate.ts +9 -1
- package/dist/build.d.ts +0 -79
- package/dist/build.d.ts.map +0 -1
- package/dist/build.js +0 -78
- package/src/build.ts +0 -115
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"component.d.ts","sourceRoot":"","sources":["../../src/runtime/component.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AASH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AAS9C,wBAAgB,gBAAgB,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI,CAExD;AAED;;;;;;GAMG;AACH,MAAM,MAAM,aAAa,GAAG;IAAE,SAAS,EAAE,IAAI,CAAC;IAAC,MAAM,EAAE,IAAI,GAAG,IAAI,CAAC;IAAC,OAAO,CAAC,EAAE,OAAO,GAAG,IAAI,CAAA;CAAE,CAAA;AAsB9F,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,aAAa,GAAG,IAAI,GAAG,aAAa,GAAG,IAAI,CAI9E;AAQD;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,YAAY,CAAC,EAAE,EAAE,OAAO,GAAG,OAAO,CAQjD;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH;;;GAGG;AACH;;;;;GAKG;AACH,MAAM,WAAW,uBAAuB;IACtC,iDAAiD;IACjD,MAAM,EAAE,MAAM,CAAA;IACd,uDA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AE,YAAY,GAAG,IAAI,
|
|
1
|
+
{"version":3,"file":"hydrate.d.ts","sourceRoot":"","sources":["../../src/runtime/hydrate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AASH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AAS9C;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,YAAY,GAAG,SAAS,CAEvE;AA8CD;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,YAAY,GAAG,IAAI,CAwB7D;AAED;;;;;;;;;GASG;AACH,wBAAgB,YAAY,IAAI,IAAI,CAEnC;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,cAAc,IAAI,IAAI,CAKrC;AAED;;;;;;;;;GASG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,CAalD;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,CAiBhD"}
|
package/dist/runtime/index.js
CHANGED
|
@@ -1179,7 +1179,7 @@ function scheduleWalk() {
|
|
|
1179
1179
|
}
|
|
1180
1180
|
}
|
|
1181
1181
|
function hydrate(name, def) {
|
|
1182
|
-
def.name
|
|
1182
|
+
def.name ??= name;
|
|
1183
1183
|
registeredDefs.set(name, def);
|
|
1184
1184
|
registerComponent(name, def.init);
|
|
1185
1185
|
if (def.template) {
|
|
@@ -1413,7 +1413,7 @@ function materializeComponent(nameOrDef, props = {}, key, slot, mountAt) {
|
|
|
1413
1413
|
const def = getRegisteredDef(name);
|
|
1414
1414
|
const isCommentWrapper = def?.comment === true;
|
|
1415
1415
|
const derivedScopeId = slot?.parent && slot.mount ? `${slot.parent}_${slot.mount}` : null;
|
|
1416
|
-
const scopeId = isCommentWrapper ? null : derivedScopeId ?? `${name}_${generateId()}`;
|
|
1416
|
+
const scopeId = isCommentWrapper ? null : derivedScopeId ?? `${def?.name ?? name}_${generateId()}`;
|
|
1417
1417
|
const prevParentScopeId = _parentScopeId;
|
|
1418
1418
|
if (scopeId) {
|
|
1419
1419
|
_parentScopeId = scopeId;
|
|
@@ -1479,7 +1479,8 @@ function materializeComponent(nameOrDef, props = {}, key, slot, mountAt) {
|
|
|
1479
1479
|
function renderChild(name, props, key, slotSuffix) {
|
|
1480
1480
|
const templateFn = getTemplate(name);
|
|
1481
1481
|
const suffix = slotSuffix ? `_${slotSuffix}` : "";
|
|
1482
|
-
const
|
|
1482
|
+
const displayName = getRegisteredDef(name)?.name ?? name;
|
|
1483
|
+
const scopePrefix = _parentScopeId && slotSuffix ? _parentScopeId : `${displayName}_${generateId()}`;
|
|
1483
1484
|
const keyAttr = key !== undefined ? ` ${BF_KEY}="${key}"` : "";
|
|
1484
1485
|
const slotAttrs = _parentScopeId && slotSuffix ? ` ${BF_HOST}="${_parentScopeId}" ${BF_AT}="${slotSuffix}"` : "";
|
|
1485
1486
|
const bfsAttr = `${BF_SCOPE}="${scopePrefix}${suffix}"`;
|
|
@@ -1586,7 +1586,7 @@ function scheduleWalk() {
|
|
|
1586
1586
|
}
|
|
1587
1587
|
}
|
|
1588
1588
|
function hydrate(name, def) {
|
|
1589
|
-
def.name
|
|
1589
|
+
def.name ??= name;
|
|
1590
1590
|
registeredDefs.set(name, def);
|
|
1591
1591
|
registerComponent(name, def.init);
|
|
1592
1592
|
if (def.template) {
|
|
@@ -1819,7 +1819,7 @@ function materializeComponent(nameOrDef, props = {}, key, slot, mountAt) {
|
|
|
1819
1819
|
const def = getRegisteredDef(name);
|
|
1820
1820
|
const isCommentWrapper = def?.comment === true;
|
|
1821
1821
|
const derivedScopeId = slot?.parent && slot.mount ? `${slot.parent}_${slot.mount}` : null;
|
|
1822
|
-
const scopeId = isCommentWrapper ? null : derivedScopeId ?? `${name}_${generateId()}`;
|
|
1822
|
+
const scopeId = isCommentWrapper ? null : derivedScopeId ?? `${def?.name ?? name}_${generateId()}`;
|
|
1823
1823
|
const prevParentScopeId = _parentScopeId;
|
|
1824
1824
|
if (scopeId) {
|
|
1825
1825
|
_parentScopeId = scopeId;
|
|
@@ -1885,7 +1885,8 @@ function materializeComponent(nameOrDef, props = {}, key, slot, mountAt) {
|
|
|
1885
1885
|
function renderChild(name, props, key, slotSuffix) {
|
|
1886
1886
|
const templateFn = getTemplate(name);
|
|
1887
1887
|
const suffix = slotSuffix ? `_${slotSuffix}` : "";
|
|
1888
|
-
const
|
|
1888
|
+
const displayName = getRegisteredDef(name)?.name ?? name;
|
|
1889
|
+
const scopePrefix = _parentScopeId && slotSuffix ? _parentScopeId : `${displayName}_${generateId()}`;
|
|
1889
1890
|
const keyAttr = key !== undefined ? ` ${BF_KEY}="${key}"` : "";
|
|
1890
1891
|
const slotAttrs = _parentScopeId && slotSuffix ? ` ${BF_HOST}="${_parentScopeId}" ${BF_AT}="${slotSuffix}"` : "";
|
|
1891
1892
|
const bfsAttr = `${BF_SCOPE}="${scopePrefix}${suffix}"`;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@barefootjs/client",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.31.0",
|
|
4
4
|
"description": "BarefootJS client package: reactive primitives (SSR-safe) plus browser runtime under the `/runtime` subpath (compiler target)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -22,9 +22,9 @@
|
|
|
22
22
|
"types": "./dist/runtime/index.d.ts",
|
|
23
23
|
"import": "./dist/runtime/standalone.js"
|
|
24
24
|
},
|
|
25
|
-
"./
|
|
26
|
-
"types": "./dist/
|
|
27
|
-
"import": "./dist/
|
|
25
|
+
"./csr-adapter": {
|
|
26
|
+
"types": "./dist/csr-adapter.d.ts",
|
|
27
|
+
"import": "./dist/csr-adapter.js"
|
|
28
28
|
}
|
|
29
29
|
},
|
|
30
30
|
"files": [
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
],
|
|
34
34
|
"scripts": {
|
|
35
35
|
"build": "bun run build:js && bun run build:types",
|
|
36
|
-
"build:js": "bun build ./src/reactive.ts --outdir ./dist --format esm && bun build ./src/index.ts --outdir ./dist --format esm --external '@barefootjs/client/reactive' && bun build ./src/runtime/index.ts --outdir ./dist/runtime --format esm --external '@barefootjs/client/reactive' && bun build ./src/runtime/index.ts --outfile ./dist/runtime/standalone.js --format esm && bun build ./src/
|
|
36
|
+
"build:js": "bun build ./src/reactive.ts --outdir ./dist --format esm && bun build ./src/index.ts --outdir ./dist --format esm --external '@barefootjs/client/reactive' && bun build ./src/runtime/index.ts --outdir ./dist/runtime --format esm --external '@barefootjs/client/reactive' && bun build ./src/runtime/index.ts --outfile ./dist/runtime/standalone.js --format esm && bun build ./src/csr-adapter.ts --outdir ./dist --format esm --target node",
|
|
37
37
|
"build:types": "tsgo --emitDeclarationOnly --outDir ./dist",
|
|
38
38
|
"test": "bun test",
|
|
39
39
|
"clean": "rm -rf dist",
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
"directory": "packages/client"
|
|
56
56
|
},
|
|
57
57
|
"dependencies": {
|
|
58
|
-
"@barefootjs/shared": "0.
|
|
58
|
+
"@barefootjs/shared": "0.31.0"
|
|
59
59
|
},
|
|
60
60
|
"peerDependencies": {
|
|
61
61
|
"@barefootjs/jsx": ">=0.2.0"
|
package/src/csr-adapter.ts
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
// Minimal `TemplateAdapter`
|
|
2
|
-
// `
|
|
1
|
+
// Minimal `TemplateAdapter` passed as `adapter` to `@barefootjs/vite`'s
|
|
2
|
+
// `barefoot()` plugin for CSR projects (see `@barefootjs/client/csr-adapter`).
|
|
3
3
|
//
|
|
4
|
-
// CSR builds emit client JS only —
|
|
5
|
-
// `
|
|
6
|
-
//
|
|
7
|
-
//
|
|
8
|
-
//
|
|
9
|
-
// pass-2 loop can
|
|
4
|
+
// CSR builds emit client JS only — a CSR project's `vite.config.ts` leaves
|
|
5
|
+
// `templates` unset (see `BarefootViteOptions`), and the plugin's own
|
|
6
|
+
// `assertNoRealTemplateOutput` (`packages/vite/src/plugin.ts`) refuses
|
|
7
|
+
// loudly if any adapter emits real, non-empty template output without a
|
|
8
|
+
// `templates` dir configured to hold it. All this adapter has to do is
|
|
9
|
+
// satisfy the `TemplateAdapter` interface so the compiler's pass-2 loop can
|
|
10
|
+
// call `adapter.generate()` without crashing.
|
|
10
11
|
//
|
|
11
|
-
//
|
|
12
|
-
// `@barefootjs/hono/adapter`
|
|
13
|
-
//
|
|
14
|
-
//
|
|
15
|
-
//
|
|
16
|
-
//
|
|
17
|
-
//
|
|
18
|
-
// behaviour identical (`acceptsTemplateCall: () => true`).
|
|
12
|
+
// This adapter deliberately does not reuse `HonoAdapter` from
|
|
13
|
+
// `@barefootjs/hono/adapter` as a "broad-acceptance JS template runtime" —
|
|
14
|
+
// that would pull the entire Hono package into a CSR app's `node_modules`
|
|
15
|
+
// for an adapter whose every output is thrown away, confusing for users
|
|
16
|
+
// who picked CSR specifically to avoid an SSR framework dependency. This
|
|
17
|
+
// in-package adapter carries no such transitive dependency, and keeps the
|
|
18
|
+
// analyzer-side behaviour identical (`acceptsTemplateCall: () => true`).
|
|
19
19
|
//
|
|
20
20
|
// What we still need from a "template adapter" in CSR mode:
|
|
21
21
|
//
|
|
@@ -53,7 +53,8 @@ import { BaseAdapter } from '@barefootjs/jsx'
|
|
|
53
53
|
export interface CSRAdapterOptions {
|
|
54
54
|
/**
|
|
55
55
|
* Display name surfaced through `TemplateAdapter.name` — read by
|
|
56
|
-
* `
|
|
56
|
+
* `@barefootjs/vite`'s `assertNoRealTemplateOutput` when naming the
|
|
57
|
+
* offending adapter in its error message. Defaults to `'csr'`.
|
|
57
58
|
*/
|
|
58
59
|
name?: string
|
|
59
60
|
}
|
package/src/runtime/component.ts
CHANGED
|
@@ -246,7 +246,10 @@ function materializeComponent(
|
|
|
246
246
|
const def = getRegisteredDef(name)
|
|
247
247
|
const isCommentWrapper = def?.comment === true
|
|
248
248
|
const derivedScopeId = slot?.parent && slot.mount ? `${slot.parent}_${slot.mount}` : null
|
|
249
|
-
|
|
249
|
+
// Same as in `renderChild`: `name` is the registry key, which is
|
|
250
|
+
// file-scoped (`Name__<8hex>`) for a non-exported component. The scope ID
|
|
251
|
+
// must carry the plain name — see `ComponentDef.name` (#2518).
|
|
252
|
+
const scopeId = isCommentWrapper ? null : (derivedScopeId ?? `${def?.name ?? name}_${generateId()}`)
|
|
250
253
|
|
|
251
254
|
// 5. Generate HTML from props.
|
|
252
255
|
//
|
|
@@ -415,9 +418,17 @@ export function renderChild(
|
|
|
415
418
|
// use the parent scope ID so child scope IDs match the SSR convention
|
|
416
419
|
// (e.g., ~ParentName_parentHash_s5 instead of ~Button_randomHash_s5).
|
|
417
420
|
// This enables $cSingle's getDualScopeIds verification to pass.
|
|
421
|
+
// `name` here is the REGISTRY KEY, which for a non-exported component is
|
|
422
|
+
// file-scoped (`Name__<8hex>`) to stop two private same-named components
|
|
423
|
+
// colliding. That disambiguator must not reach `bf-s`: the scope ID is a
|
|
424
|
+
// documented contract (`Name_abc123`) that the SSR adapters emit and
|
|
425
|
+
// `integrations/shared/e2e/toggle.spec.ts` asserts. The def carries the
|
|
426
|
+
// plain name for exactly this — see `ComponentDef.name`, "Used for scope
|
|
427
|
+
// ID generation" (#2518).
|
|
428
|
+
const displayName = getRegisteredDef(name)?.name ?? name
|
|
418
429
|
const scopePrefix = (_parentScopeId && slotSuffix)
|
|
419
430
|
? _parentScopeId
|
|
420
|
-
: `${
|
|
431
|
+
: `${displayName}_${generateId()}`
|
|
421
432
|
const keyAttr = key !== undefined ? ` ${BF_KEY}="${key}"` : ''
|
|
422
433
|
// Slot-relationship markers — only emitted when both host and slot are
|
|
423
434
|
// known; top-level renders without parent context omit them.
|
package/src/runtime/hydrate.ts
CHANGED
|
@@ -135,7 +135,15 @@ function scheduleWalk(): void {
|
|
|
135
135
|
export function hydrate(name: string, def: ComponentDef): void {
|
|
136
136
|
// Ensure name is always set on the def so createComponentFromDef()
|
|
137
137
|
// doesn't rely on def.init.name (which may be lost under minification).
|
|
138
|
-
|
|
138
|
+
//
|
|
139
|
+
// Defaulted, NOT overwritten: `name` is the registry KEY, which for a
|
|
140
|
+
// non-exported component is file-scoped (`Name__<8hex>`) to keep two
|
|
141
|
+
// private same-named components apart. The compiler puts the plain name
|
|
142
|
+
// on the def precisely so scope IDs can stay the documented
|
|
143
|
+
// `Name_abc123`; clobbering it here leaked the disambiguator into every
|
|
144
|
+
// CSR `bf-s` (#2518). This line predates file-scoping, when the key and
|
|
145
|
+
// the display name were always the same string.
|
|
146
|
+
def.name ??= name
|
|
139
147
|
|
|
140
148
|
registeredDefs.set(name, def)
|
|
141
149
|
|
package/dist/build.d.ts
DELETED
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
import type { BarefootPaths, BundleEntry, ExternalSpec, OutputLayout, PostBuildContext, TemplateAdapter } from '@barefootjs/jsx';
|
|
2
|
-
import { CSRAdapter } from './csr-adapter.ts';
|
|
3
|
-
import type { CSRAdapterOptions } from './csr-adapter.ts';
|
|
4
|
-
export interface CSRBuildOptions {
|
|
5
|
-
/** Project layout paths consumed by registry tooling. */
|
|
6
|
-
paths?: BarefootPaths;
|
|
7
|
-
/** Source component directories relative to the config file. */
|
|
8
|
-
components?: string[];
|
|
9
|
-
/** Output directory relative to the config file. */
|
|
10
|
-
outDir?: string;
|
|
11
|
-
/** Minify client JS output. */
|
|
12
|
-
minify?: boolean;
|
|
13
|
-
/** Add content hash to client JS filenames. */
|
|
14
|
-
contentHash?: boolean;
|
|
15
|
-
/** Custom output directory layout. */
|
|
16
|
-
outputLayout?: OutputLayout;
|
|
17
|
-
/** Post-build hook called after minification, before manifest write. */
|
|
18
|
-
postBuild?: (ctx: PostBuildContext) => Promise<void> | void;
|
|
19
|
-
/** Vendor packages to split out as separately-cached browser chunks. */
|
|
20
|
-
externals?: Record<string, ExternalSpec>;
|
|
21
|
-
/** URL base path for vendor chunks in the emitted importmap. */
|
|
22
|
-
externalsBasePath?: string;
|
|
23
|
-
/** Additional entry points to bundle with esbuild directly. */
|
|
24
|
-
bundleEntries?: BundleEntry[];
|
|
25
|
-
/**
|
|
26
|
-
* Override the compiler adapter. The marked templates this adapter
|
|
27
|
-
* generates are discarded in CSR mode — set this only if you need
|
|
28
|
-
* a different `TemplateAdapter` (e.g. a custom test adapter).
|
|
29
|
-
*/
|
|
30
|
-
adapter?: TemplateAdapter;
|
|
31
|
-
/** Options forwarded to the default `CSRAdapter`. Ignored when `adapter` is set. */
|
|
32
|
-
adapterOptions?: CSRAdapterOptions;
|
|
33
|
-
/**
|
|
34
|
-
* How the CLI produces `barefoot.js`. Defaults to `'treeshake'`, which
|
|
35
|
-
* bundles only the runtime exports this project's compiled client JS
|
|
36
|
-
* actually imports (plus the always-kept public mount API). Set to
|
|
37
|
-
* `'treeshake-exact'` to drop the always-kept set too — smaller output,
|
|
38
|
-
* but any hand-written page script the CLI never compiles (an inline
|
|
39
|
-
* `<script type="module">` calling `render`/`hydrate`/etc. directly) must
|
|
40
|
-
* list those names in `runtimeKeep` or they're silently dropped. Set to
|
|
41
|
-
* `'full'` to copy the entire prebuilt runtime bundle verbatim, matching
|
|
42
|
-
* pre-tree-shaking behavior.
|
|
43
|
-
*/
|
|
44
|
-
runtimeBundle?: 'treeshake' | 'treeshake-exact' | 'full';
|
|
45
|
-
/**
|
|
46
|
-
* Extra `@barefootjs/client*` export names to force-keep in `barefoot.js`
|
|
47
|
-
* under `runtimeBundle: 'treeshake'` or `'treeshake-exact'` — for names
|
|
48
|
-
* only ever referenced from hand-written page scripts the CLI never
|
|
49
|
-
* compiles. Required (not just useful) under `'treeshake-exact'`, which
|
|
50
|
-
* drops the always-kept public mount API those scripts would otherwise
|
|
51
|
-
* fall back on.
|
|
52
|
-
*/
|
|
53
|
-
runtimeKeep?: string[];
|
|
54
|
-
}
|
|
55
|
-
/**
|
|
56
|
-
* Create a BarefootBuildConfig for CSR projects.
|
|
57
|
-
*
|
|
58
|
-
* Uses structural typing — does not import `BarefootBuildConfig` to avoid
|
|
59
|
-
* a circular dependency between `@barefootjs/client` and `@barefootjs/cli`.
|
|
60
|
-
*/
|
|
61
|
-
export declare function createConfig(options?: CSRBuildOptions): {
|
|
62
|
-
adapter: CSRAdapter | TemplateAdapter;
|
|
63
|
-
paths: BarefootPaths | undefined;
|
|
64
|
-
components: string[] | undefined;
|
|
65
|
-
outDir: string | undefined;
|
|
66
|
-
minify: boolean | undefined;
|
|
67
|
-
contentHash: boolean | undefined;
|
|
68
|
-
clientOnly: boolean;
|
|
69
|
-
externals: Record<string, ExternalSpec> | undefined;
|
|
70
|
-
externalsBasePath: string | undefined;
|
|
71
|
-
bundleEntries: BundleEntry[] | undefined;
|
|
72
|
-
outputLayout: OutputLayout | undefined;
|
|
73
|
-
postBuild: ((ctx: PostBuildContext) => Promise<void> | void) | undefined;
|
|
74
|
-
runtimeBundle: "full" | "treeshake" | "treeshake-exact" | undefined;
|
|
75
|
-
runtimeKeep: string[] | undefined;
|
|
76
|
-
};
|
|
77
|
-
export { CSRAdapter } from './csr-adapter.ts';
|
|
78
|
-
export type { CSRAdapterOptions } from './csr-adapter.ts';
|
|
79
|
-
//# sourceMappingURL=build.d.ts.map
|
package/dist/build.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../src/build.ts"],"names":[],"mappings":"AAoBA,OAAO,KAAK,EACV,aAAa,EACb,WAAW,EACX,YAAY,EACZ,YAAY,EACZ,gBAAgB,EAChB,eAAe,EAChB,MAAM,iBAAiB,CAAA;AACxB,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAC7C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAA;AAEzD,MAAM,WAAW,eAAe;IAC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
|
|
3
|
-
var EMPTY_SECTIONS = Object.freeze({
|
|
4
|
-
imports: "",
|
|
5
|
-
types: "",
|
|
6
|
-
component: "",
|
|
7
|
-
defaultExport: ""
|
|
8
|
-
});
|
|
9
|
-
var EMPTY_OUTPUT = Object.freeze({
|
|
10
|
-
template: "",
|
|
11
|
-
sections: EMPTY_SECTIONS,
|
|
12
|
-
extension: ".tsx"
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
class CSRAdapter extends BaseAdapter {
|
|
16
|
-
name;
|
|
17
|
-
extension = ".tsx";
|
|
18
|
-
acceptsTemplateCall = () => true;
|
|
19
|
-
constructor(options = {}) {
|
|
20
|
-
super();
|
|
21
|
-
this.name = options.name ?? "csr";
|
|
22
|
-
}
|
|
23
|
-
generate() {
|
|
24
|
-
return EMPTY_OUTPUT;
|
|
25
|
-
}
|
|
26
|
-
renderNode() {
|
|
27
|
-
return "";
|
|
28
|
-
}
|
|
29
|
-
renderElement() {
|
|
30
|
-
return "";
|
|
31
|
-
}
|
|
32
|
-
renderExpression() {
|
|
33
|
-
return "";
|
|
34
|
-
}
|
|
35
|
-
renderConditional() {
|
|
36
|
-
return "";
|
|
37
|
-
}
|
|
38
|
-
renderLoop() {
|
|
39
|
-
return "";
|
|
40
|
-
}
|
|
41
|
-
renderComponent() {
|
|
42
|
-
return "";
|
|
43
|
-
}
|
|
44
|
-
renderScopeMarker() {
|
|
45
|
-
return "";
|
|
46
|
-
}
|
|
47
|
-
renderSlotMarker() {
|
|
48
|
-
return "";
|
|
49
|
-
}
|
|
50
|
-
renderCondMarker() {
|
|
51
|
-
return "";
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
// src/build.ts
|
|
56
|
-
function createConfig(options = {}) {
|
|
57
|
-
const adapter = options.adapter ?? new CSRAdapter(options.adapterOptions);
|
|
58
|
-
return {
|
|
59
|
-
adapter,
|
|
60
|
-
paths: options.paths,
|
|
61
|
-
components: options.components,
|
|
62
|
-
outDir: options.outDir,
|
|
63
|
-
minify: options.minify,
|
|
64
|
-
contentHash: options.contentHash,
|
|
65
|
-
clientOnly: true,
|
|
66
|
-
externals: options.externals,
|
|
67
|
-
externalsBasePath: options.externalsBasePath,
|
|
68
|
-
bundleEntries: options.bundleEntries,
|
|
69
|
-
outputLayout: options.outputLayout,
|
|
70
|
-
postBuild: options.postBuild,
|
|
71
|
-
runtimeBundle: options.runtimeBundle,
|
|
72
|
-
runtimeKeep: options.runtimeKeep
|
|
73
|
-
};
|
|
74
|
-
}
|
|
75
|
-
export {
|
|
76
|
-
createConfig,
|
|
77
|
-
CSRAdapter
|
|
78
|
-
};
|
package/src/build.ts
DELETED
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
// CSR build config factory for `barefoot.config.ts`.
|
|
2
|
-
//
|
|
3
|
-
// CSR (client-side rendering) projects emit client JS only — no marked
|
|
4
|
-
// templates, no SSR. Pair this config with `render()` from
|
|
5
|
-
// `@barefootjs/client/runtime` on the page.
|
|
6
|
-
//
|
|
7
|
-
// The compiler still needs a `TemplateAdapter` to drive IR→client-JS
|
|
8
|
-
// codegen (the analyzer consults `acceptsTemplateCall` when deciding
|
|
9
|
-
// template-scope vs init-scope placement). The marked templates the
|
|
10
|
-
// adapter would produce are simply not written to disk. The default
|
|
11
|
-
// `CSRAdapter` is the minimum that satisfies the interface — its
|
|
12
|
-
// `generate()` returns an empty `AdapterOutput` and the build
|
|
13
|
-
// pipeline drops the empty marked-template file at the
|
|
14
|
-
// `clientOnly` gate.
|
|
15
|
-
//
|
|
16
|
-
// (Pre-1.0 this was `HonoAdapter` from `@barefootjs/hono/adapter`,
|
|
17
|
-
// which pulled the entire Hono package into a CSR app's
|
|
18
|
-
// `node_modules` for output that was always thrown away. See
|
|
19
|
-
// `csr-adapter.ts` for the rationale on the new in-package adapter.)
|
|
20
|
-
|
|
21
|
-
import type {
|
|
22
|
-
BarefootPaths,
|
|
23
|
-
BundleEntry,
|
|
24
|
-
ExternalSpec,
|
|
25
|
-
OutputLayout,
|
|
26
|
-
PostBuildContext,
|
|
27
|
-
TemplateAdapter,
|
|
28
|
-
} from '@barefootjs/jsx'
|
|
29
|
-
import { CSRAdapter } from './csr-adapter.ts'
|
|
30
|
-
import type { CSRAdapterOptions } from './csr-adapter.ts'
|
|
31
|
-
|
|
32
|
-
export interface CSRBuildOptions {
|
|
33
|
-
/** Project layout paths consumed by registry tooling. */
|
|
34
|
-
paths?: BarefootPaths
|
|
35
|
-
/** Source component directories relative to the config file. */
|
|
36
|
-
components?: string[]
|
|
37
|
-
/** Output directory relative to the config file. */
|
|
38
|
-
outDir?: string
|
|
39
|
-
/** Minify client JS output. */
|
|
40
|
-
minify?: boolean
|
|
41
|
-
/** Add content hash to client JS filenames. */
|
|
42
|
-
contentHash?: boolean
|
|
43
|
-
/** Custom output directory layout. */
|
|
44
|
-
outputLayout?: OutputLayout
|
|
45
|
-
/** Post-build hook called after minification, before manifest write. */
|
|
46
|
-
postBuild?: (ctx: PostBuildContext) => Promise<void> | void
|
|
47
|
-
/** Vendor packages to split out as separately-cached browser chunks. */
|
|
48
|
-
externals?: Record<string, ExternalSpec>
|
|
49
|
-
/** URL base path for vendor chunks in the emitted importmap. */
|
|
50
|
-
externalsBasePath?: string
|
|
51
|
-
/** Additional entry points to bundle with esbuild directly. */
|
|
52
|
-
bundleEntries?: BundleEntry[]
|
|
53
|
-
/**
|
|
54
|
-
* Override the compiler adapter. The marked templates this adapter
|
|
55
|
-
* generates are discarded in CSR mode — set this only if you need
|
|
56
|
-
* a different `TemplateAdapter` (e.g. a custom test adapter).
|
|
57
|
-
*/
|
|
58
|
-
adapter?: TemplateAdapter
|
|
59
|
-
/** Options forwarded to the default `CSRAdapter`. Ignored when `adapter` is set. */
|
|
60
|
-
adapterOptions?: CSRAdapterOptions
|
|
61
|
-
/**
|
|
62
|
-
* How the CLI produces `barefoot.js`. Defaults to `'treeshake'`, which
|
|
63
|
-
* bundles only the runtime exports this project's compiled client JS
|
|
64
|
-
* actually imports (plus the always-kept public mount API). Set to
|
|
65
|
-
* `'treeshake-exact'` to drop the always-kept set too — smaller output,
|
|
66
|
-
* but any hand-written page script the CLI never compiles (an inline
|
|
67
|
-
* `<script type="module">` calling `render`/`hydrate`/etc. directly) must
|
|
68
|
-
* list those names in `runtimeKeep` or they're silently dropped. Set to
|
|
69
|
-
* `'full'` to copy the entire prebuilt runtime bundle verbatim, matching
|
|
70
|
-
* pre-tree-shaking behavior.
|
|
71
|
-
*/
|
|
72
|
-
runtimeBundle?: 'treeshake' | 'treeshake-exact' | 'full'
|
|
73
|
-
/**
|
|
74
|
-
* Extra `@barefootjs/client*` export names to force-keep in `barefoot.js`
|
|
75
|
-
* under `runtimeBundle: 'treeshake'` or `'treeshake-exact'` — for names
|
|
76
|
-
* only ever referenced from hand-written page scripts the CLI never
|
|
77
|
-
* compiles. Required (not just useful) under `'treeshake-exact'`, which
|
|
78
|
-
* drops the always-kept public mount API those scripts would otherwise
|
|
79
|
-
* fall back on.
|
|
80
|
-
*/
|
|
81
|
-
runtimeKeep?: string[]
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
/**
|
|
85
|
-
* Create a BarefootBuildConfig for CSR projects.
|
|
86
|
-
*
|
|
87
|
-
* Uses structural typing — does not import `BarefootBuildConfig` to avoid
|
|
88
|
-
* a circular dependency between `@barefootjs/client` and `@barefootjs/cli`.
|
|
89
|
-
*/
|
|
90
|
-
export function createConfig(options: CSRBuildOptions = {}) {
|
|
91
|
-
// `name` defaults to `'csr'` inside `CSRAdapter`; a caller-supplied
|
|
92
|
-
// `adapterOptions.name` (or a fully-custom `adapter`) wins, matching
|
|
93
|
-
// the pre-decoupling behaviour where `bf build`'s `Adapter: …`
|
|
94
|
-
// banner reflected the option override.
|
|
95
|
-
const adapter = options.adapter ?? new CSRAdapter(options.adapterOptions)
|
|
96
|
-
return {
|
|
97
|
-
adapter,
|
|
98
|
-
paths: options.paths,
|
|
99
|
-
components: options.components,
|
|
100
|
-
outDir: options.outDir,
|
|
101
|
-
minify: options.minify,
|
|
102
|
-
contentHash: options.contentHash,
|
|
103
|
-
clientOnly: true,
|
|
104
|
-
externals: options.externals,
|
|
105
|
-
externalsBasePath: options.externalsBasePath,
|
|
106
|
-
bundleEntries: options.bundleEntries,
|
|
107
|
-
outputLayout: options.outputLayout,
|
|
108
|
-
postBuild: options.postBuild,
|
|
109
|
-
runtimeBundle: options.runtimeBundle,
|
|
110
|
-
runtimeKeep: options.runtimeKeep,
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
export { CSRAdapter } from './csr-adapter.ts'
|
|
115
|
-
export type { CSRAdapterOptions } from './csr-adapter.ts'
|