@barefootjs/hono 0.1.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.
Files changed (81) hide show
  1. package/dist/adapter/hono-adapter.d.ts +141 -0
  2. package/dist/adapter/hono-adapter.d.ts.map +1 -0
  3. package/dist/adapter/index.d.ts +6 -0
  4. package/dist/adapter/index.d.ts.map +1 -0
  5. package/dist/adapter/index.js +632 -0
  6. package/dist/app.d.ts +131 -0
  7. package/dist/app.d.ts.map +1 -0
  8. package/dist/app.js +139 -0
  9. package/dist/async.d.ts +15 -0
  10. package/dist/async.d.ts.map +1 -0
  11. package/dist/async.js +12 -0
  12. package/dist/build.d.ts +65 -0
  13. package/dist/build.d.ts.map +1 -0
  14. package/dist/build.js +785 -0
  15. package/dist/client-shim.d.ts +59 -0
  16. package/dist/client-shim.d.ts.map +1 -0
  17. package/dist/client-shim.js +90 -0
  18. package/dist/dev-worker.d.ts +25 -0
  19. package/dist/dev-worker.d.ts.map +1 -0
  20. package/dist/dev-worker.js +65 -0
  21. package/dist/dev.d.ts +36 -0
  22. package/dist/dev.d.ts.map +1 -0
  23. package/dist/dev.js +418 -0
  24. package/dist/dialog-context.d.ts +13 -0
  25. package/dist/dialog-context.d.ts.map +1 -0
  26. package/dist/dialog-context.js +10 -0
  27. package/dist/index.d.ts +13 -0
  28. package/dist/index.d.ts.map +1 -0
  29. package/dist/index.js +632 -0
  30. package/dist/jsx/jsx-dev-runtime/index.d.ts +9 -0
  31. package/dist/jsx/jsx-dev-runtime/index.d.ts.map +1 -0
  32. package/dist/jsx/jsx-dev-runtime/index.js +6 -0
  33. package/dist/jsx/jsx-runtime/index.d.ts +32 -0
  34. package/dist/jsx/jsx-runtime/index.d.ts.map +1 -0
  35. package/dist/jsx/jsx-runtime/index.js +10 -0
  36. package/dist/portal-ssr.d.ts +22 -0
  37. package/dist/portal-ssr.d.ts.map +1 -0
  38. package/dist/portal-ssr.js +73 -0
  39. package/dist/portals.d.ts +26 -0
  40. package/dist/portals.d.ts.map +1 -0
  41. package/dist/portals.js +41 -0
  42. package/dist/preload.d.ts +56 -0
  43. package/dist/preload.d.ts.map +1 -0
  44. package/dist/preload.js +51 -0
  45. package/dist/scripts.d.ts +80 -0
  46. package/dist/scripts.d.ts.map +1 -0
  47. package/dist/scripts.js +198 -0
  48. package/dist/test-render.d.ts +28 -0
  49. package/dist/test-render.d.ts.map +1 -0
  50. package/dist/utils.d.ts +16 -0
  51. package/dist/utils.d.ts.map +1 -0
  52. package/dist/utils.js +16 -0
  53. package/package.json +116 -0
  54. package/src/__tests__/async.test.tsx +106 -0
  55. package/src/__tests__/bfscripts-entry-roots.test.tsx +135 -0
  56. package/src/__tests__/build.test.ts +299 -0
  57. package/src/__tests__/dev.test.tsx +123 -0
  58. package/src/__tests__/hydration-props-type.test.ts +141 -0
  59. package/src/__tests__/manifest-scripts.test.ts +87 -0
  60. package/src/__tests__/scaffold.test.ts +209 -0
  61. package/src/__tests__/ssr-context-bridge.test.ts +110 -0
  62. package/src/__tests__/string-literal-css-var-prop.test.ts +84 -0
  63. package/src/__tests__/stub-deps-scripts.test.ts +183 -0
  64. package/src/adapter/hono-adapter.ts +1114 -0
  65. package/src/adapter/index.ts +6 -0
  66. package/src/app.ts +220 -0
  67. package/src/async.tsx +55 -0
  68. package/src/build.ts +230 -0
  69. package/src/client-shim.ts +164 -0
  70. package/src/dev-worker.ts +93 -0
  71. package/src/dev.tsx +146 -0
  72. package/src/dialog-context.tsx +44 -0
  73. package/src/index.ts +26 -0
  74. package/src/jsx/jsx-dev-runtime/index.ts +9 -0
  75. package/src/jsx/jsx-runtime/index.ts +40 -0
  76. package/src/portal-ssr.tsx +92 -0
  77. package/src/portals.tsx +98 -0
  78. package/src/preload.tsx +166 -0
  79. package/src/scripts.tsx +220 -0
  80. package/src/test-render.ts +143 -0
  81. package/src/utils.ts +26 -0
package/dist/app.d.ts ADDED
@@ -0,0 +1,131 @@
1
+ /**
2
+ * BarefootJS Hono integration
3
+ *
4
+ * Runtime-agnostic by design — no `node:fs`, no `process.env`, no
5
+ * implicit conventions about URL paths or the dev-reload gate. The
6
+ * caller hands every component / middleware its configuration
7
+ * explicitly so the same module works under Node, Bun, Workers, and
8
+ * Deno without surprises.
9
+ *
10
+ * Two pieces:
11
+ *
12
+ * - **JSX components** (`<BfImportMap />`, `<BfScripts />`,
13
+ * `<BfDevReload />`) — return raw HTML the caller composes inside
14
+ * the Layout passed to Hono's `jsxRenderer`. All URL/data inputs
15
+ * are required props.
16
+ *
17
+ * - **Middleware** (`barefootDevReload`) — registers the SSE endpoint
18
+ * paired with `<BfDevReload />`. Both `endpoint` and `enabled` are
19
+ * required so the runtime gate happens in the caller's code, not
20
+ * here.
21
+ *
22
+ * Components are defined as plain functions returning
23
+ * `HtmlEscapedString` (via `html`/`raw` from `hono/html`) so this file
24
+ * stays `.ts` — `tsx`'s per-file `@jsxImportSource` pragma doesn't
25
+ * always propagate when transpiling `.tsx` from `node_modules` and
26
+ * would otherwise crash with `ReferenceError: React is not defined`.
27
+ */
28
+ import type { MiddlewareHandler } from 'hono';
29
+ import type { HtmlEscapedString } from 'hono/utils/html';
30
+ /**
31
+ * Build manifest shape produced by `bf build`. Each compiled
32
+ * component is keyed by its manifest name; `__barefoot__` is the
33
+ * runtime entry. `clientJs` is a path under `dist/`, e.g.
34
+ * `"components/Counter.client.js"`.
35
+ *
36
+ * `stubDeps` lists the manifest keys of every `'use client'` sibling
37
+ * this bundle reaches via a stub rewrite (i.e. via an imperative
38
+ * `createComponent(name, ...)` call rather than a JSX render). The
39
+ * per-page script collector follows these edges so pages that only
40
+ * touch a child through a stub still ship its `.client.js`. See
41
+ * issue #1243.
42
+ *
43
+ * Note: the entries are manifest keys (e.g. `"ui/button/index"` for
44
+ * `ui/button/index.tsx`), not the runtime registry name passed to
45
+ * `createComponent(...)` (e.g. `"Button"`). For top-level
46
+ * single-component files the two coincide; for nested layouts they
47
+ * differ. `build.ts` does the path → manifest-key conversion before
48
+ * writing this field.
49
+ */
50
+ export interface BarefootBuildManifest {
51
+ __barefoot__?: {
52
+ clientJs?: string;
53
+ };
54
+ [componentName: string]: {
55
+ clientJs?: string;
56
+ stubDeps?: string[];
57
+ } | undefined;
58
+ }
59
+ /**
60
+ * Turn a build manifest into the ordered list of script URLs the page
61
+ * should load — runtime first, then each component. Pure: same input
62
+ * gives same output, no I/O.
63
+ */
64
+ export declare function manifestToScriptUrls(manifest: BarefootBuildManifest, base: string): string[];
65
+ export declare function relPathFromComponentsBase(p: string): string;
66
+ export interface BfImportMapProps {
67
+ /** Base URL where the runtime + component bundles are served. */
68
+ base: string;
69
+ }
70
+ /**
71
+ * Emits the `<script type="importmap">` that maps the bare
72
+ * `@barefootjs/client` / `@barefootjs/client/runtime` specifiers to
73
+ * the runtime bundle. Place in `<head>`.
74
+ */
75
+ export declare function BfImportMap(props: BfImportMapProps): HtmlEscapedString | Promise<HtmlEscapedString>;
76
+ export interface BfScriptsProps {
77
+ /** Base URL where the runtime + component bundles are served. */
78
+ base: string;
79
+ /** Build manifest (from `dist/components/manifest.json`). */
80
+ manifest: BarefootBuildManifest;
81
+ }
82
+ /**
83
+ * Emits one `<script type="module" src=...>` per entry in the build
84
+ * manifest, runtime first. Place at the end of `<body>`.
85
+ *
86
+ * Logs a one-time warning when the manifest is empty — a strong
87
+ * signal the user is running the server before `bf build` has
88
+ * produced anything, which would otherwise present as a silent
89
+ * "page renders but nothing is interactive."
90
+ */
91
+ export declare function BfScripts(props: BfScriptsProps): HtmlEscapedString | Promise<HtmlEscapedString>;
92
+ export interface BfDevReloadProps {
93
+ /**
94
+ * Override the SSE endpoint published by `barefootDevReload`. Almost
95
+ * always omitted: the middleware sets the endpoint on the request
96
+ * context and `<BfDevReload />` reads it. Setting this prop forces
97
+ * the snippet to point at the given endpoint regardless of whether
98
+ * the middleware is mounted.
99
+ */
100
+ endpoint?: string;
101
+ }
102
+ /**
103
+ * Emits the inline EventSource snippet that connects to the SSE
104
+ * endpoint served by `barefootDevReload`. Renders nothing when the
105
+ * middleware isn't mounted (or is mounted with `enabled: false`),
106
+ * so the dev-reload script never lands on production pages — no
107
+ * "two gates to keep in sync" problem in the renderer.
108
+ */
109
+ export declare function BfDevReload(props?: BfDevReloadProps): HtmlEscapedString | null;
110
+ export interface BarefootDevReloadOptions {
111
+ /** SSE endpoint path. */
112
+ endpoint: string;
113
+ /**
114
+ * Whether to wire the endpoint up. When `false` the middleware is a
115
+ * complete no-op — no SSE handler, no context publishing — and
116
+ * `<BfDevReload />` (which reads the endpoint off the context) also
117
+ * renders nothing. The runtime gate (e.g. `NODE_ENV !== 'production'`)
118
+ * lives in the caller.
119
+ */
120
+ enabled: boolean;
121
+ }
122
+ /**
123
+ * Hono middleware that serves the dev-reload SSE stream and publishes
124
+ * its endpoint on the request context so `<BfDevReload />` knows
125
+ * whether and where to wire up. Mount at the root; place
126
+ * `<BfDevReload />` somewhere in `<body>`. There's no separate
127
+ * "render the snippet?" gate to keep in sync — toggling `enabled`
128
+ * controls both.
129
+ */
130
+ export declare function barefootDevReload(opts: BarefootDevReloadOptions): MiddlewareHandler;
131
+ //# sourceMappingURL=app.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"app.d.ts","sourceRoot":"","sources":["../src/app.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,MAAM,CAAA;AAE7C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAA;AAQxD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,WAAW,qBAAqB;IACpC,YAAY,CAAC,EAAE;QAAE,QAAQ,CAAC,EAAE,MAAM,CAAA;KAAE,CAAA;IACpC,CAAC,aAAa,EAAE,MAAM,GAAG;QAAE,QAAQ,CAAC,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAA;KAAE,GAAG,SAAS,CAAA;CAChF;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAClC,QAAQ,EAAE,qBAAqB,EAC/B,IAAI,EAAE,MAAM,GACX,MAAM,EAAE,CAWV;AAED,wBAAgB,yBAAyB,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAE3D;AAID,MAAM,WAAW,gBAAgB;IAC/B,iEAAiE;IACjE,IAAI,EAAE,MAAM,CAAA;CACb;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,gBAAgB,GAAG,iBAAiB,GAAG,OAAO,CAAC,iBAAiB,CAAC,CASnG;AAED,MAAM,WAAW,cAAc;IAC7B,iEAAiE;IACjE,IAAI,EAAE,MAAM,CAAA;IACZ,6DAA6D;IAC7D,QAAQ,EAAE,qBAAqB,CAAA;CAChC;AAQD;;;;;;;;GAQG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,cAAc,GAAG,iBAAiB,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAa/F;AAED,MAAM,WAAW,gBAAgB;IAC/B;;;;;;OAMG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAA;CAClB;AAED;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,KAAK,GAAE,gBAAqB,GAAG,iBAAiB,GAAG,IAAI,CAelF;AAID,MAAM,WAAW,wBAAwB;IACvC,yBAAyB;IACzB,QAAQ,EAAE,MAAM,CAAA;IAChB;;;;;;OAMG;IACH,OAAO,EAAE,OAAO,CAAA;CACjB;AAED;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,wBAAwB,GAAG,iBAAiB,CAanF"}
package/dist/app.js ADDED
@@ -0,0 +1,139 @@
1
+ // src/dev-worker.ts
2
+ var HEARTBEAT_MS = 5000;
3
+ var BOOT_ID = generateBootId();
4
+ function generateBootId() {
5
+ try {
6
+ return crypto.randomUUID();
7
+ } catch {
8
+ return Date.now().toString(36) + Math.random().toString(36).slice(2, 10);
9
+ }
10
+ }
11
+ function isDevDefault() {
12
+ return true;
13
+ }
14
+ function createDevReloader(options = {}) {
15
+ const { enabled = isDevDefault() } = options;
16
+ return (c) => {
17
+ if (!enabled)
18
+ return c.notFound();
19
+ const lastEventId = (c.req.header("Last-Event-ID") ?? "").trim();
20
+ const signal = c.req.raw.signal;
21
+ const stream = new ReadableStream({
22
+ start(controller) {
23
+ const encoder = new TextEncoder;
24
+ const send = (chunk) => {
25
+ try {
26
+ controller.enqueue(encoder.encode(chunk));
27
+ } catch {}
28
+ };
29
+ send(`retry: 1000
30
+
31
+ `);
32
+ const event = lastEventId && lastEventId !== BOOT_ID ? "reload" : "hello";
33
+ send(`event: ${event}
34
+ id: ${BOOT_ID}
35
+ data: ${BOOT_ID}
36
+
37
+ `);
38
+ const heartbeat = setInterval(() => send(`: hb
39
+
40
+ `), HEARTBEAT_MS);
41
+ const onAbort = () => {
42
+ clearInterval(heartbeat);
43
+ try {
44
+ controller.close();
45
+ } catch {}
46
+ };
47
+ if (signal.aborted)
48
+ onAbort();
49
+ else
50
+ signal.addEventListener("abort", onAbort, { once: true });
51
+ }
52
+ });
53
+ return new Response(stream, {
54
+ headers: {
55
+ "Content-Type": "text/event-stream",
56
+ "Cache-Control": "no-cache, no-transform",
57
+ Connection: "keep-alive",
58
+ "X-Accel-Buffering": "no"
59
+ }
60
+ });
61
+ };
62
+ }
63
+
64
+ // src/app.ts
65
+ import { html, raw } from "hono/html";
66
+ import { useRequestContext } from "hono/jsx-renderer";
67
+ var DEV_RELOAD_ENDPOINT_KEY = "bfDevReloadEndpoint";
68
+ function manifestToScriptUrls(manifest, base) {
69
+ const out = [];
70
+ const prefix = `${base.replace(/\/$/, "")}/`;
71
+ if (manifest.__barefoot__?.clientJs) {
72
+ out.push(prefix + relPathFromComponentsBase(manifest.__barefoot__.clientJs));
73
+ }
74
+ for (const [name, entry] of Object.entries(manifest)) {
75
+ if (name === "__barefoot__")
76
+ continue;
77
+ if (entry?.clientJs)
78
+ out.push(prefix + relPathFromComponentsBase(entry.clientJs));
79
+ }
80
+ return out;
81
+ }
82
+ function relPathFromComponentsBase(p) {
83
+ return p.startsWith("components/") ? p.slice("components/".length) : p;
84
+ }
85
+ function BfImportMap(props) {
86
+ const base = props.base.replace(/\/$/, "");
87
+ const json = JSON.stringify({
88
+ imports: {
89
+ "@barefootjs/client": `${base}/barefoot.js`,
90
+ "@barefootjs/client/runtime": `${base}/barefoot.js`
91
+ }
92
+ });
93
+ return html`<script type="importmap">${raw(json)}</script>`;
94
+ }
95
+ var __bfEmptyManifestWarned = false;
96
+ function BfScripts(props) {
97
+ const urls = manifestToScriptUrls(props.manifest, props.base);
98
+ if (urls.length === 0 && !__bfEmptyManifestWarned) {
99
+ __bfEmptyManifestWarned = true;
100
+ console.warn("[barefootjs] BfScripts: manifest is empty — no <script> tags emitted. " + "Run `bf build` to compile components and rebuild the manifest.");
101
+ }
102
+ const tags = urls.map((src) => `<script type="module" src="${src}"></script>`).join("");
103
+ return html`${raw(tags)}`;
104
+ }
105
+ function BfDevReload(props = {}) {
106
+ let endpoint = props.endpoint;
107
+ if (!endpoint) {
108
+ try {
109
+ endpoint = useRequestContext().get(DEV_RELOAD_ENDPOINT_KEY);
110
+ } catch {}
111
+ }
112
+ if (!endpoint)
113
+ return null;
114
+ const ep = JSON.stringify(endpoint);
115
+ const snippet = `(()=>{if(window.__bfDevReload)return;window.__bfDevReload=1;try{var s=sessionStorage.getItem('__bf_devreload_scroll');if(s){sessionStorage.removeItem('__bf_devreload_scroll');var y=parseInt(s,10);if(!isNaN(y)){var restore=function(){window.scrollTo(0,y)};if(document.readyState==='loading'){addEventListener('DOMContentLoaded',restore,{once:true})}else{restore()}}}}catch(e){}var es=new EventSource(${ep});es.addEventListener('reload',function(){try{sessionStorage.setItem('__bf_devreload_scroll',String(window.scrollY))}catch(e){}location.reload()});es.addEventListener('error',function(){})})();`;
116
+ return html`<script>${raw(snippet)}</script>`;
117
+ }
118
+ function barefootDevReload(opts) {
119
+ if (!opts.enabled) {
120
+ return async (_c, next) => next();
121
+ }
122
+ const reloader = createDevReloader();
123
+ const endpoint = opts.endpoint;
124
+ return async (c, next) => {
125
+ c.set(DEV_RELOAD_ENDPOINT_KEY, endpoint);
126
+ if (c.req.method === "GET" && c.req.path === endpoint) {
127
+ return reloader(c);
128
+ }
129
+ await next();
130
+ };
131
+ }
132
+ export {
133
+ relPathFromComponentsBase,
134
+ manifestToScriptUrls,
135
+ barefootDevReload,
136
+ BfScripts,
137
+ BfImportMap,
138
+ BfDevReload
139
+ };
@@ -0,0 +1,15 @@
1
+ import type { Child } from 'hono/jsx';
2
+ export interface BfAsyncProps {
3
+ /** Content to display while the async children are loading. */
4
+ fallback: Child;
5
+ /** Async children that will be streamed when resolved. */
6
+ children: Child;
7
+ }
8
+ /**
9
+ * Async streaming boundary component.
10
+ *
11
+ * Renders fallback content immediately (sent in the initial HTTP response
12
+ * for fast TTFB), then streams the resolved children when ready.
13
+ */
14
+ export declare function BfAsync(props: BfAsyncProps): import("hono/jsx/jsx-dev-runtime").JSX.Element;
15
+ //# sourceMappingURL=async.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"async.d.ts","sourceRoot":"","sources":["../src/async.tsx"],"names":[],"mappings":"AAiCA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,UAAU,CAAA;AAErC,MAAM,WAAW,YAAY;IAC3B,+DAA+D;IAC/D,QAAQ,EAAE,KAAK,CAAA;IACf,0DAA0D;IAC1D,QAAQ,EAAE,KAAK,CAAA;CAChB;AAED;;;;;GAKG;AACH,wBAAgB,OAAO,CAAC,KAAK,EAAE,YAAY,kDAM1C"}
package/dist/async.js ADDED
@@ -0,0 +1,12 @@
1
+ // src/async.tsx
2
+ import { Suspense } from "hono/jsx/streaming";
3
+ import { jsxDEV } from "hono/jsx/jsx-dev-runtime";
4
+ function BfAsync(props) {
5
+ return /* @__PURE__ */ jsxDEV(Suspense, {
6
+ fallback: props.fallback,
7
+ children: props.children
8
+ }, undefined, false, undefined, this);
9
+ }
10
+ export {
11
+ BfAsync
12
+ };
@@ -0,0 +1,65 @@
1
+ import type { BuildOptions } from '@barefootjs/jsx';
2
+ import { HonoAdapter } from './adapter';
3
+ import type { HonoAdapterOptions } from './adapter';
4
+ export interface HonoBuildOptions extends BuildOptions {
5
+ /** Inject Hono script collection wrapper (default: true) */
6
+ scriptCollection?: boolean;
7
+ /** Base path for client JS script URLs (default: '/static/components/') */
8
+ scriptBasePath?: string;
9
+ /** Adapter-specific options passed to HonoAdapter */
10
+ adapterOptions?: HonoAdapterOptions;
11
+ }
12
+ /**
13
+ * Create a BarefootBuildConfig for Hono projects.
14
+ *
15
+ * Uses structural typing — does not import BarefootBuildConfig to avoid
16
+ * circular dependency between @barefootjs/hono and @barefootjs/cli.
17
+ */
18
+ export declare function createConfig(options?: HonoBuildOptions): {
19
+ adapter: HonoAdapter;
20
+ paths: import("@barefootjs/jsx").BarefootPaths | undefined;
21
+ components: string[] | undefined;
22
+ outDir: string | undefined;
23
+ minify: boolean | undefined;
24
+ contentHash: boolean | undefined;
25
+ externals: Record<string, import("@barefootjs/jsx").ExternalSpec> | undefined;
26
+ externalsBasePath: string | undefined;
27
+ bundleEntries: import("@barefootjs/jsx").BundleEntry[] | undefined;
28
+ localImportPrefixes: string[] | undefined;
29
+ transformMarkedTemplate: ((content: string, componentId: string, clientJsPath: string) => string) | undefined;
30
+ };
31
+ /**
32
+ * Add Hono script collection wrapper to an SSR marked template.
33
+ * Injects imports, a helper function, and script collector into each
34
+ * exported component function.
35
+ */
36
+ export declare function addScriptCollection(content: string, componentId: string, clientJsPath: string, scriptBasePath?: string): string;
37
+ /**
38
+ * Replace comment contents with spaces (preserving length and newlines
39
+ * so indices computed against the masked text are valid in the
40
+ * original). Used by `addScriptCollection` so its `function Foo(`
41
+ * regex ignores JSDoc / inline comments — a docstring example like
42
+ * `function MyNode(this: HTMLElement, props)` previously masqueraded
43
+ * as a real function declaration (#1236).
44
+ *
45
+ * Handles `//` line comments and `/* ... *\/` block comments (incl.
46
+ * JSDoc). String literals are intentionally NOT masked: JSX text
47
+ * content routinely contains unbalanced apostrophes (`How's`) that a
48
+ * string-aware masker would misread as an open quote, blanking the
49
+ * rest of the file and hiding later function declarations.
50
+ *
51
+ * Strings inside comments are handled implicitly: the whole comment
52
+ * (including any quotes it contains) is blanked.
53
+ *
54
+ * **Known limitation**: this function does NOT track string
55
+ * boundaries, so a `//` or `/*` appearing INSIDE a string literal is
56
+ * still treated as a comment delimiter. Example: in
57
+ * `const u = "https://x.y" ; export function Foo() {}` the `//` in
58
+ * `https://` is misread as a line comment and the rest of the line is
59
+ * blanked — a `function Foo()` on that same line would be hidden from
60
+ * the regex. SSR template output (the only caller) does not embed
61
+ * such cases in practice. If a future caller can produce them, swap
62
+ * in a real lexer rather than extending this helper.
63
+ */
64
+ export declare function maskComments(s: string): string;
65
+ //# sourceMappingURL=build.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../src/build.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AACnD,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAA;AACvC,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAA;AAEnD,MAAM,WAAW,gBAAiB,SAAQ,YAAY;IACpD,4DAA4D;IAC5D,gBAAgB,CAAC,EAAE,OAAO,CAAA;IAC1B,2EAA2E;IAC3E,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,qDAAqD;IACrD,cAAc,CAAC,EAAE,kBAAkB,CAAA;CACpC;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,OAAO,GAAE,gBAAqB;IAIvD,OAAO;IACP,KAAK;IACL,UAAU;IACV,MAAM;IACN,MAAM;IACN,WAAW;IACX,SAAS;IACT,iBAAiB;IACjB,aAAa;IACb,mBAAmB;IACnB,uBAAuB,aACT,MAAM,eAAe,MAAM,gBAAgB,MAAM;EAIlE;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,cAAc,GAAE,MAA8B,GAAG,MAAM,CAiItJ;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,YAAY,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAwB9C"}