@pbuilder/sdk 0.11.0 → 0.13.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/README.md CHANGED
@@ -606,8 +606,10 @@ untrusted input is the author's responsibility to sanitize.
606
606
 
607
607
  ### `@pbuilder/sdk/react`
608
608
 
609
- Mutates `.tsx` files — `find()` requires the explicit `.tsx` extension (extensionless and
610
- `.jsx` paths are rejected, never normalized). The handle carries every
609
+ Mutates `.tsx` and `.jsx` files — `find()` requires one of those extensions explicitly
610
+ (extensionless paths are rejected, never normalized). On `.jsx`, the ops that write TypeScript
611
+ syntax (`addTypeImport`, `addComponentProp`, `addClassProperty`'s `scope`/`readonly`) reject,
612
+ leaving the file unchanged. The handle carries every
611
613
  `@pbuilder/sdk/typescript` op plus the JSX ops below, with `.modify(fn)` as the escape hatch
612
614
  for everything else:
613
615
 
@@ -96,3 +96,47 @@ export declare const RESERVED_HANDLE_NAMES: readonly ["then", "read", "raw", "mo
96
96
  * const tsDialect = withOps(baseTsDialect, addImportPack);
97
97
  */
98
98
  export declare function withOps<Ast, B extends OpPack<Ast>, P extends OpPack<Ast>[]>(base: Dialect<Ast, B>, ...packs: P): Dialect<Ast, B & UnionToIntersection<P[number]>>;
99
+ /**
100
+ * Derives a dialect whose named ops reject at call time, leaving the file unchanged, with a
101
+ * message naming the op, the dialect's extensions and `reason`. The ops stay on the handle and
102
+ * in its type, so one handle shape can serve every extension of a routed dialect
103
+ * (`byExtension`). Throws at composition on an op name the dialect does not have.
104
+ *
105
+ * @example
106
+ * const jsx = withoutOps(defineDialect({ extensions: [".jsx"], ast: jsxAst, ops: tsx.ops }), ["addTypeImport"], ".jsx files have no type syntax");
107
+ */
108
+ export declare function withoutOps<Ast, Ops extends OpPack<Ast>>(dialect: Dialect<Ast, Ops>, names: readonly (keyof Ops & string)[], reason: string): Dialect<Ast, Ops>;
109
+ /**
110
+ * Derives a dialect whose named ops run `overrides` instead, with the same signatures. Throws at
111
+ * composition on an op name the dialect does not have; adding new ops is `withOps`'s job.
112
+ *
113
+ * @example
114
+ * const jsx = overrideOps(tsx, { addClassProperty: jsxClassProperty });
115
+ */
116
+ export declare function overrideOps<Ast, Ops extends OpPack<Ast>>(dialect: Dialect<Ast, Ops>, overrides: Partial<Ops>): Dialect<Ast, Ops>;
117
+ type DialectsByExtension = {
118
+ readonly [extension: string]: Dialect;
119
+ };
120
+ type HandleOf<D> = D extends Dialect<infer A, infer O> ? Handle<"found", A, O> : never;
121
+ type MatchingKey<M, P extends string> = {
122
+ [K in keyof M & string]: P extends `${string}${K}` ? K : never;
123
+ }[keyof M & string];
124
+ type LongestKey<Ks extends string> = {
125
+ [K in Ks]: [Extract<Exclude<Ks, K>, `${string}${K}`>] extends [never] ? K : never;
126
+ }[Ks];
127
+ type RoutedHandle<M extends DialectsByExtension, P extends string> = string extends P ? HandleOf<M[keyof M]> : HandleOf<M[LongestKey<MatchingKey<M, P>>]>;
128
+ export interface ExtensionRouter<M extends DialectsByExtension> {
129
+ readonly extensions: readonly (keyof M & string)[];
130
+ find<P extends string>(path: P): RoutedHandle<M, P>;
131
+ }
132
+ /**
133
+ * Routes `find` by file extension to one dialect per extension, each with its own AST and ops —
134
+ * a `.ts` dialect and an `.html` dialect may parse to different AST types. The longest matching
135
+ * extension wins (`.component.html` over `.html`); a path matching none rejects synchronously,
136
+ * naming every routed extension. Throws at composition on a key its dialect does not declare.
137
+ *
138
+ * @example
139
+ * export const react = byExtension({ ".tsx": tsxDialect, ".jsx": jsxDialect });
140
+ * react.find("src/App.jsx").setJsxProp("div", "hidden");
141
+ */
142
+ export declare function byExtension<M extends DialectsByExtension>(dialects: M): ExtensionRouter<M>;
@@ -127,3 +127,70 @@ export function withOps(base, ...packs) {
127
127
  const merged = Object.assign({}, base.ops, ...packs);
128
128
  return defineDialect({ extensions: [...base.extensions], ast: base.ast, ops: merged });
129
129
  }
130
+ function assertKnownOps(ops, names, composer) {
131
+ for (const name of names) {
132
+ if (!Object.hasOwn(ops, name))
133
+ throw new Error(`${composer} failed: the dialect has no op "${name}".`);
134
+ }
135
+ }
136
+ /**
137
+ * Derives a dialect whose named ops reject at call time, leaving the file unchanged, with a
138
+ * message naming the op, the dialect's extensions and `reason`. The ops stay on the handle and
139
+ * in its type, so one handle shape can serve every extension of a routed dialect
140
+ * (`byExtension`). Throws at composition on an op name the dialect does not have.
141
+ *
142
+ * @example
143
+ * const jsx = withoutOps(defineDialect({ extensions: [".jsx"], ast: jsxAst, ops: tsx.ops }), ["addTypeImport"], ".jsx files have no type syntax");
144
+ */
145
+ export function withoutOps(dialect, names, reason) {
146
+ assertKnownOps(dialect.ops, names, "withoutOps");
147
+ const files = dialect.extensions.join(", ");
148
+ const blocked = Object.fromEntries(names.map((name) => [
149
+ name,
150
+ () => {
151
+ throw dialectError(`${name} is not available for ${files} files — ${reason}. Use .modify() to make this edit directly.`);
152
+ },
153
+ ]));
154
+ return defineDialect({ extensions: [...dialect.extensions], ast: dialect.ast, ops: { ...dialect.ops, ...blocked } });
155
+ }
156
+ /**
157
+ * Derives a dialect whose named ops run `overrides` instead, with the same signatures. Throws at
158
+ * composition on an op name the dialect does not have; adding new ops is `withOps`'s job.
159
+ *
160
+ * @example
161
+ * const jsx = overrideOps(tsx, { addClassProperty: jsxClassProperty });
162
+ */
163
+ export function overrideOps(dialect, overrides) {
164
+ assertKnownOps(dialect.ops, Object.keys(overrides), "overrideOps");
165
+ return defineDialect({ extensions: [...dialect.extensions], ast: dialect.ast, ops: { ...dialect.ops, ...overrides } });
166
+ }
167
+ /**
168
+ * Routes `find` by file extension to one dialect per extension, each with its own AST and ops —
169
+ * a `.ts` dialect and an `.html` dialect may parse to different AST types. The longest matching
170
+ * extension wins (`.component.html` over `.html`); a path matching none rejects synchronously,
171
+ * naming every routed extension. Throws at composition on a key its dialect does not declare.
172
+ *
173
+ * @example
174
+ * export const react = byExtension({ ".tsx": tsxDialect, ".jsx": jsxDialect });
175
+ * react.find("src/App.jsx").setJsxProp("div", "hidden");
176
+ */
177
+ export function byExtension(dialects) {
178
+ const extensions = Object.keys(dialects);
179
+ for (const extension of extensions) {
180
+ const declared = dialects[extension].extensions;
181
+ if (!declared.includes(extension)) {
182
+ throw new Error(`dialect routing failed: "${extension}" is not an extension its dialect declares (${declared.join(", ")}).`);
183
+ }
184
+ }
185
+ const longestFirst = [...extensions].sort((a, b) => b.length - a.length);
186
+ return {
187
+ extensions,
188
+ find(path) {
189
+ const extension = longestFirst.find((candidate) => hasDeclaredExtension(path, [candidate]));
190
+ if (extension === undefined) {
191
+ throw dialectError(`find(${JSON.stringify(path)}) — the file's extension is not one this dialect declares (${extensions.join(", ")}).`);
192
+ }
193
+ return dialects[extension].find(path);
194
+ },
195
+ };
196
+ }
@@ -4,12 +4,12 @@
4
4
  export function forceEntry(force) {
5
5
  return force !== undefined ? { force } : {};
6
6
  }
7
- // REQ-TOE-01: shallow top-level composite (array/plain-object) -> JSON string; everything
8
- // else passes through verbatim. Assembly uses Object.defineProperty (never spread/`result[k]=`)
7
+ // REQ-TOE-01: top-level composite (array/plain-object) values are copied as native JSON;
8
+ // everything else passes through verbatim. Assembly uses Object.defineProperty (never spread/`result[k]=`)
9
9
  // per REQ-TOE-05 — enumerable:true is load-bearing, defineProperty defaults it to false and an
10
10
  // unenumerable key silently drops from JSON.stringify at the wire boundary.
11
11
  // REQ-TOE-01.5: a null-prototype object (Object.create(null)) is a plain, dict-like data
12
- // container and encodes like any other plain object — only a prototype OUTSIDE
12
+ // container and is copied like any other plain object — only a prototype OUTSIDE
13
13
  // {Object.prototype, null} (Date/Map/class instances) is non-plain (REQ-TOE-04, S-002).
14
14
  function isPlainObject(v) {
15
15
  if (typeof v !== "object" || v === null || Array.isArray(v))
@@ -44,7 +44,9 @@ function rejectOption(optionKey, detail) {
44
44
  // ascent (add-recurse-delete, scoped per top-level call via the default parameter) — never a
45
45
  // global "ever-visited" set. Only a value that is its own ancestor (a true cycle) rejects; an
46
46
  // acyclic SHARED reference (`const s = {x:1}; {a:s,b:s}`) is revisited from a clean ancestor
47
- // path each time and encodes normally, matching native JSON.stringify.
47
+ // path each time and is copied normally, matching native JSON.stringify.
48
+ // Returns a structural copy of a valid value: composites are rebuilt (plain-object keys via
49
+ // Object.defineProperty, REQ-TOE-05), scalars are returned as they are.
48
50
  function assertEncodable(value, optionKey, ancestors = new Set(), path = optionKey) {
49
51
  if (value === undefined)
50
52
  rejectOption(optionKey, `undefined at ${path}`);
@@ -54,40 +56,42 @@ function assertEncodable(value, optionKey, ancestors = new Set(), path = optionK
54
56
  rejectOption(optionKey, `symbol at ${path}`);
55
57
  if (typeof value === "bigint")
56
58
  rejectOption(optionKey, `BigInt at ${path}`);
57
- if (value === null || typeof value !== "object")
58
- return; // string/number/boolean/null: fine
59
+ if (value === null || typeof value !== "object") {
60
+ // A nested -0 inside the old JSON-string form became 0; keep that, or the round-trip
61
+ // guard rejects it (-0 === 0, so this also catches -0). A top-level -0 was never encoded, so it is left alone.
62
+ return value === 0 && path !== optionKey ? 0 : value;
63
+ }
59
64
  if (Array.isArray(value) || isPlainObject(value)) {
60
65
  if (ancestors.has(value))
61
66
  rejectOption(optionKey, `a circular reference at ${path}`);
62
67
  ancestors.add(value);
63
68
  try {
64
69
  if (Array.isArray(value)) {
65
- value.forEach((item, i) => assertEncodable(item, optionKey, ancestors, `${path}[${i}]`));
66
- }
67
- else {
68
- for (const [k, v] of Object.entries(value)) {
69
- assertEncodable(v, optionKey, ancestors, `${path}.${k}`);
70
- }
70
+ return value.map((item, i) => assertEncodable(item, optionKey, ancestors, `${path}[${i}]`));
71
71
  }
72
+ return copyEntries(value, ([k, v]) => assertEncodable(v, optionKey, ancestors, `${path}.${k}`));
72
73
  }
73
74
  finally {
74
75
  ancestors.delete(value);
75
76
  }
76
- return;
77
77
  }
78
- rejectOption(optionKey, `${kindOf(value)} at ${path}`);
78
+ return rejectOption(optionKey, `${kindOf(value)} at ${path}`);
79
79
  }
80
- export function encodeOptions(options) {
81
- if (!isPlainObject(options))
82
- return options;
80
+ function copyEntries(source, copy) {
83
81
  const result = {};
84
- for (const [key, value] of Object.entries(options)) {
85
- assertEncodable(value, key);
86
- const encoded = Array.isArray(value) || isPlainObject(value) ? JSON.stringify(value) : value;
87
- Object.defineProperty(result, key, { value: encoded, enumerable: true, writable: true, configurable: true });
82
+ for (const entry of Object.entries(source)) {
83
+ Object.defineProperty(result, entry[0], { value: copy(entry), enumerable: true, writable: true, configurable: true });
88
84
  }
89
85
  return result;
90
86
  }
87
+ // ADR-0082: composites reach the wire as native JSON. The copy snapshots the author's value
88
+ // at scheduling time and keeps nested non-finite numbers, so the flush-time round-trip
89
+ // guard sees them (REQ-TOE-03.3).
90
+ export function encodeOptions(options) {
91
+ if (!isPlainObject(options))
92
+ return options;
93
+ return copyEntries(options, ([key, value]) => assertEncodable(value, key));
94
+ }
91
95
  export class DirectiveFactory {
92
96
  create(a) {
93
97
  return {
@@ -18,6 +18,8 @@ import { type SourceFile } from "ts-morph";
18
18
  * never surfaced directly to the author.
19
19
  */
20
20
  export declare function parse(source: string): SourceFile;
21
+ /** `parse` for `.jsx` files: `ScriptKind.JSX`, so `<div>` is always JSX, never a cast. */
22
+ export declare function parseJsx(source: string): SourceFile;
21
23
  /**
22
24
  * Prints the live AST back to a string — the ONLY serialization point for a React handle's
23
25
  * flush. Re-prepends a BOM if the original parse observed one (see `hadBom` above) — ts-morph's
@@ -10,7 +10,8 @@ import { Project, NewLineKind, QuoteKind, IndentationText } from "ts-morph";
10
10
  // `.tsx` extension is what engages `ScriptKind.Tsx` (ts-morph infers script kind from the
11
11
  // extension, verified empirically against ts-morph@28.0.0 — no explicit scriptKind option
12
12
  // needed, mirroring typescript/ast.ts's "the extension drives it" shape).
13
- const VIRTUAL_PATH = "dialect-source.tsx";
13
+ const TSX_PATH = "dialect-source.tsx";
14
+ const JSX_PATH = "dialect-source.jsx";
14
15
  const BOM = "";
15
16
  // ts-morph@28's `getFullText()` does not round-trip a leading UTF-8 BOM (same finding as
16
17
  // typescript/ast.ts, same pinned ts-morph version) — a private per-SourceFile flag remembers
@@ -60,6 +61,13 @@ function detectQuoteKind(sourceFile) {
60
61
  * never surfaced directly to the author.
61
62
  */
62
63
  export function parse(source) {
64
+ return parseAs(source, TSX_PATH);
65
+ }
66
+ /** `parse` for `.jsx` files: `ScriptKind.JSX`, so `<div>` is always JSX, never a cast. */
67
+ export function parseJsx(source) {
68
+ return parseAs(source, JSX_PATH);
69
+ }
70
+ function parseAs(source, virtualPath) {
63
71
  const startsWithBom = source.startsWith(BOM);
64
72
  const body = startsWithBom ? source.slice(BOM.length) : source;
65
73
  const project = new Project({
@@ -71,13 +79,13 @@ export function parse(source) {
71
79
  usePrefixAndSuffixTextForRename: false,
72
80
  },
73
81
  });
74
- const sourceFile = project.createSourceFile(VIRTUAL_PATH, body);
82
+ const sourceFile = project.createSourceFile(virtualPath, body);
75
83
  project.manipulationSettings.set({ quoteKind: detectQuoteKind(sourceFile) });
76
84
  if (startsWithBom)
77
85
  hadBom.set(sourceFile, true);
78
86
  const syntacticErrors = project.getProgram().getSyntacticDiagnostics(sourceFile);
79
87
  if (syntacticErrors.length > 0) {
80
- throw new Error("syntactically invalid TSX source");
88
+ throw new Error("syntactically invalid JSX source");
81
89
  }
82
90
  return sourceFile;
83
91
  }
@@ -17,15 +17,16 @@ type JsxOps = {
17
17
  };
18
18
  type ReactOps = typeof typescriptOps & JsxOps;
19
19
  /**
20
- * Opens a `.tsx` file for React-dialect-aware editing — the dialect's entry verb into a Session
21
- * that carries every `@pbuilder/sdk/typescript` op plus the JSX ops, chained on one handle
22
- * (REQ-DG-01.2). `path` MUST end in `.tsx`: the gate below runs SYNCHRONOUSLY, before any op
23
- * is chained and before any run flush, so a rejected path throws on the bare `find()` call
24
- * itself. `.ts` files are TypeScript, not this dialect — use `@pbuilder/sdk/typescript`.
25
- * `.jsx` is not supported in v1: the extension must stay explicit so a future `.jsx` dialect
26
- * addition never has to disambiguate an assumed `.tsx` default (tracked as a React op-catalog
27
- * follow-up). Every other extension, dotfile basename, trailing-dot basename, and
28
- * extensionless path is rejected the same way — no normalization, always an explicit `.tsx`.
20
+ * Opens a `.tsx` or `.jsx` file for React-dialect-aware editing — the dialect's entry verb into
21
+ * a Session that carries every `@pbuilder/sdk/typescript` op plus the JSX ops, chained on one
22
+ * handle (REQ-DG-01.2). Both extensions get the same handle: on `.jsx`, which parses as plain
23
+ * JavaScript with JSX, `addTypeImport`, `addComponentProp` and `addClassProperty`'s `scope`/
24
+ * `readonly` reject at call time because they write TypeScript syntax, leaving the file
25
+ * unchanged. The gate below runs SYNCHRONOUSLY, before any op is chained and before any run
26
+ * flush, so a rejected path throws on the bare `find()` call itself. `.ts` files are TypeScript,
27
+ * not this dialect — use `@pbuilder/sdk/typescript`. Every other extension, dotfile basename,
28
+ * trailing-dot basename, and extensionless path is rejected the same way —
29
+ * no normalization, always an explicit `.tsx` or `.jsx`, so neither extension is ever assumed.
29
30
  * Every gate rejection throws via `dialectError`, so its message carries the standard
30
31
  * `dialect operation failed: ` prefix.
31
32
  *
@@ -4,29 +4,36 @@
4
4
  // no port-internal machinery imported anywhere in this tree (REQ-DG-04.1, fit-08/fit-10).
5
5
  // The parser stays local: typescript/ast.ts parses as `.ts`, which rejects JSX syntax.
6
6
  import { basename } from "node:path";
7
- import { defineDialect, defineOpPack, withOps } from "../../core/define-dialect.js";
7
+ import { byExtension, defineDialect, defineOpPack, overrideOps, withOps, withoutOps } from "../../core/define-dialect.js";
8
8
  import { dialectError } from "../../core/dialect-error.js";
9
+ import { addClassProperty } from "../typescript/class-property.js";
9
10
  import { typescriptOps } from "../typescript/pack.js";
10
- import { parse, print } from "./ast.js";
11
+ import { parse, parseJsx, print } from "./ast.js";
11
12
  import { addComponentProp, addHookCall, addJsxChild, removeJsxProp, renameJsxElement, setJsxProp, wrapJsxElement, } from "./ops.js";
12
13
  export * as astLibrary from "ts-morph";
13
14
  const jsxOps = defineOpPack({ setJsxProp, removeJsxProp, addJsxChild, wrapJsxElement, addHookCall, addComponentProp, renameJsxElement });
14
- const baseDialect = defineDialect({
15
- extensions: [".tsx"],
16
- ast: { parse, print },
17
- ops: {},
15
+ const tsxDialect = withOps(defineDialect({ extensions: [".tsx"], ast: { parse, print }, ops: {} }), typescriptOps, jsxOps);
16
+ const jsxDialect = overrideOps(withoutOps(defineDialect({ extensions: [".jsx"], ast: { parse: parseJsx, print }, ops: tsxDialect.ops }), ["addTypeImport", "addComponentProp"], "they write TypeScript type syntax, which a .jsx file cannot hold"), {
17
+ addClassProperty: (ast, className, name, initializer, options) => {
18
+ if (options?.scope !== undefined || options?.readonly !== undefined) {
19
+ throw dialectError("addClassProperty's `scope` and `readonly` are TypeScript modifiers, which a .jsx file cannot hold — " +
20
+ "omit them, or use .modify() to make this edit directly.");
21
+ }
22
+ addClassProperty(ast, className, name, initializer);
23
+ },
18
24
  });
19
- const reactDialect = withOps(baseDialect, typescriptOps, jsxOps);
25
+ const reactDialect = byExtension({ ".tsx": tsxDialect, ".jsx": jsxDialect });
20
26
  /**
21
- * Opens a `.tsx` file for React-dialect-aware editing — the dialect's entry verb into a Session
22
- * that carries every `@pbuilder/sdk/typescript` op plus the JSX ops, chained on one handle
23
- * (REQ-DG-01.2). `path` MUST end in `.tsx`: the gate below runs SYNCHRONOUSLY, before any op
24
- * is chained and before any run flush, so a rejected path throws on the bare `find()` call
25
- * itself. `.ts` files are TypeScript, not this dialect — use `@pbuilder/sdk/typescript`.
26
- * `.jsx` is not supported in v1: the extension must stay explicit so a future `.jsx` dialect
27
- * addition never has to disambiguate an assumed `.tsx` default (tracked as a React op-catalog
28
- * follow-up). Every other extension, dotfile basename, trailing-dot basename, and
29
- * extensionless path is rejected the same way — no normalization, always an explicit `.tsx`.
27
+ * Opens a `.tsx` or `.jsx` file for React-dialect-aware editing — the dialect's entry verb into
28
+ * a Session that carries every `@pbuilder/sdk/typescript` op plus the JSX ops, chained on one
29
+ * handle (REQ-DG-01.2). Both extensions get the same handle: on `.jsx`, which parses as plain
30
+ * JavaScript with JSX, `addTypeImport`, `addComponentProp` and `addClassProperty`'s `scope`/
31
+ * `readonly` reject at call time because they write TypeScript syntax, leaving the file
32
+ * unchanged. The gate below runs SYNCHRONOUSLY, before any op is chained and before any run
33
+ * flush, so a rejected path throws on the bare `find()` call itself. `.ts` files are TypeScript,
34
+ * not this dialect — use `@pbuilder/sdk/typescript`. Every other extension, dotfile basename,
35
+ * trailing-dot basename, and extensionless path is rejected the same way —
36
+ * no normalization, always an explicit `.tsx` or `.jsx`, so neither extension is ever assumed.
30
37
  * Every gate rejection throws via `dialectError`, so its message carries the standard
31
38
  * `dialect operation failed: ` prefix.
32
39
  *
@@ -51,23 +58,16 @@ const reactDialect = withOps(baseDialect, typescriptOps, jsxOps);
51
58
  */
52
59
  export function find(path) {
53
60
  const base = basename(path);
54
- // A non-empty STEM before `.tsx` is required — `base.endsWith(".tsx")` alone is true for
55
- // `base === ".tsx"` itself (and for a degenerate `..tsx`, whose stem is a lone dot), which
56
- // would pass a basename with no real name before the extension. That is the SAME "dotfile
57
- // with no usable name" shape as `.babelrc` (suffix `babelrc`, not `.tsx`) — by the suffix
58
- // rule REQ-RXD-02 already applies to dotfiles, `.tsx`'s suffix is `tsx`, not `.tsx`.
59
- const stem = base.substring(0, base.length - ".tsx".length);
60
- if (base.endsWith(".tsx") && stem.length > 0 && !stem.endsWith(".")) {
61
+ // A non-empty stem that does not end in a dot: `.tsx` and `a..tsx` name no file of that type.
62
+ const routed = reactDialect.extensions.some((extension) => base.endsWith(extension) && base.length > extension.length && !base.endsWith(`.${extension}`));
63
+ if (routed) {
61
64
  return reactDialect.find(path);
62
65
  }
63
66
  if (!base.includes(".")) {
64
- throw dialectError("find(path) — the React dialect requires an explicit .tsx extension; received a path with no extension. Append .tsx to the path.");
67
+ throw dialectError("find(path) — the React dialect requires an explicit .tsx or .jsx extension; received a path with no extension. Append .tsx or .jsx to the path.");
65
68
  }
66
69
  if (base.endsWith(".ts")) {
67
70
  throw dialectError("find(path) — .ts is not a React file; use @pbuilder/sdk/typescript for TypeScript sources.");
68
71
  }
69
- if (base.endsWith(".jsx")) {
70
- throw dialectError("find(path) — .jsx is not supported in v1; tracked as a follow-up in the React dialect's op catalog.");
71
- }
72
- throw dialectError("find(path) — .tsx is the only extension the React dialect supports.");
72
+ throw dialectError("find(path) — .tsx and .jsx are the only extensions the React dialect supports.");
73
73
  }
@@ -2,7 +2,7 @@
2
2
  "manifestVersion": 1,
3
3
  "algorithm": "sha256",
4
4
  "entry": "dist/bin/pbuilder-runner.js",
5
- "packageVersion": "0.11.0",
5
+ "packageVersion": "0.13.0",
6
6
  "files": [
7
7
  {
8
8
  "path": "dist/bin/pbuilder-runner.js",
@@ -18,7 +18,7 @@
18
18
  },
19
19
  {
20
20
  "path": "dist/core/directive-factory.js",
21
- "sha256": "06f13f234f77bfd749139d937b7d2381a0d72b364d9f68912a0bccbc7ee43cf3"
21
+ "sha256": "9aad2b51eec7679dbf031e2b9e71276d86ac4ce3ad6f0411e88d4d8a966cb3ae"
22
22
  },
23
23
  {
24
24
  "path": "dist/core/emit-rejection.js",
@@ -98,7 +98,7 @@
98
98
  },
99
99
  {
100
100
  "path": "package.json",
101
- "sha256": "c9ff8f1cb38b30f9fceb5b43ad9d074cf1b47c2cb96c0efbdc241d31e94c463b"
101
+ "sha256": "9751fadd8a84cde86463e3a32f80d93bc791f233ca96783715193b9fc5514657"
102
102
  }
103
103
  ]
104
104
  }
@@ -102,12 +102,8 @@ export function classifyTransport(params) {
102
102
  // `>` (not `>=`) — exactly-at-budget still fits (REQ-CCL-02.3).
103
103
  //
104
104
  // REQ-CCL-02.4: `options` is run through the SAME shared `encodeOptions` (fit-39's one
105
- // other sanctioned call site) real `create()` emission applies — never the caller's raw,
106
- // pre-encode shape. A composite option value's JSON-string form carries its own
107
- // quote/backslash-escaping inflation once re-embedded and serialized again here, closing
108
- // the pre-encode/post-encode misclassification gap: measuring the raw shape would
109
- // under-count and could wrongly classify by-value a directive that is actually over
110
- // budget once the real encode step runs.
105
+ // other sanctioned call site) real `create()` emission applies, so the measure and the
106
+ // emitted directive can never disagree on the options' wire form.
111
107
  const prospectiveDirective = {
112
108
  op: "create",
113
109
  create: { pathTemplate: destPath, template: content, options: encodeOptions(options), ...forceEntry(force) },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pbuilder/sdk",
3
- "version": "0.11.0",
3
+ "version": "0.13.0",
4
4
  "description": "The public TypeScript/Bun authoring layer for Project Builder schematics. Authors file mutations (create, replaceContent, remove, rename, move, copy, copyIn), lowers them to IR, and talks to the Project Builder engine over framed stdio (see docs/engine-sdk-wire-spec.md).",
5
5
  "license": "MIT",
6
6
  "type": "module",