parseman 0.61.2 → 0.61.4

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":"evaluator.d.ts","sourceRoot":"","sources":["../../src/plugin/evaluator.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,KAAK,EACV,UAAU,EAAE,IAAI,EAMjB,MAAM,oBAAoB,CAAA;AAC3B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAG7C,OAAO,EAAwC,KAAK,YAAY,EAAE,KAAK,WAAW,EAAE,MAAM,0BAA0B,CAAA;AAIpH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AAsG5D,qFAAqF;AACrF,wBAAgB,kBAAkB,CAAC,CAAC,EAAE,eAAe,GAAG,IAAI,EAAE,WAAW,GAAE,MAAM,GAAG,IAAW,GAAG,IAAI,CAGrG;AAED;;;;;;GAMG;AACH,MAAM,MAAM,qBAAqB,GAAG,CAAC,IAAI,EAAE,MAAM,KAAK;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAAA;AAEjG,uGAAuG;AACvG,wBAAgB,wBAAwB,CAAC,CAAC,EAAE,qBAAqB,GAAG,IAAI,GAAG,IAAI,CAE9E;AAWD,MAAM,MAAM,UAAU,GAAG;IACvB,KAAK,EAAE,UAAU,CAAC,OAAO,CAAC,CAAA;IAC1B,MAAM,EAAE,MAAM,EAAE,CAAA;CACjB,CAAA;AACD,MAAM,MAAM,KAAK,GAAG,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,CAAA;AAE3C;;0DAE0D;AAC1D,MAAM,MAAM,kBAAkB,GAAG;IAAE,KAAK,EAAE,OAAO,CAAA;CAAE,GAAG;IAAE,UAAU,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAAA;AAEnF;;;;;;;;;;;;;;;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,MAAM,gBAAgB,sEAA6E,CAAA;AAE1G,oEAAoE;AACpE,KAAK,YAAY,GAAG,UAAU,CAAC,OAAO,CAAC,GAAG;IAAE,MAAM,CAAC,CAAC,EAAE,UAAU,CAAC,OAAO,CAAC,GAAG,IAAI,CAAA;CAAE,CAAA;AAQlF;;;;;GAKG;AACH,wBAAgB,sBAAsB,CACpC,IAAI,EAAE,UAAU,EAChB,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,KAAK,GACX,YAAY,GAAG,IAAI,CAQrB;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAClC,QAAQ,EAAE,UAAU,EACpB,KAAK,EAAE,KAAK,EACZ,IAAI,EAAE,MAAM,GACX,OAAO,CAoBT;AAED,kFAAkF;AAClF,wBAAgB,aAAa,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,KAAK,GAAG,OAAO,CAiBnF"}
@@ -71,23 +71,41 @@ export type ParsecraftPluginOptions = {
71
71
  */
72
72
  assemblyProfile?: AssemblyProfile;
73
73
  /**
74
- * Generated assembly bytes each module may spend, as a multiple of its own source
75
- * length. **Default `0.25`.** `0` ships no assembly. The right number is
74
+ * Generated assembly bytes each module may spend, as a multiple of its own code,
75
+ * comments and whitespace aside. **Default `0.5`.** `0` ships no assembly. The right number is
76
76
  * per grammar: a larger one parses faster in steady state and costs import and
77
77
  * first-parse time, so measure both, and keep the artifact within 5× its source
78
- * (docs/design/runtime-and-size-contract.md, rules 4 and 6).
78
+ * (docs/design/runtime-and-size-contract.md, rules 4 and 6). A larger budget never
79
+ * loses a site, with one limit: a module with two AST grammars spends it in order, so
80
+ * a larger budget can buy the first a big site and leave the second fewer.
79
81
  */
80
82
  assemblyBudget?: number;
81
83
  };
82
84
  /** A corpus a build parses to rank selective-assembly sites — see `assemblyProfile`. */
83
85
  export type AssemblyProfile = {
84
- /** The rule each corpus file is parsed from, e.g. `'Stylesheet'`. A grammar
85
- * without this rule keeps the static ranking. */
86
+ /** The rule each corpus file is parsed from, e.g. `'Stylesheet'`. A grammar without
87
+ * this rule keeps the static ranking. A build fails when grammars were profiled and
88
+ * none has the rule. A direct `transformMacro` caller gets `assemblyProfile:
89
+ * 'no-entry'` on the result instead, and has to read it. */
86
90
  readonly entry: string;
87
91
  /** Paths of representative inputs. At least one must have content, and each that
88
92
  * does has to parse in full without recovery, or the build fails. A file with only
89
- * whitespace counts as empty. */
93
+ * whitespace counts as empty. A callback the corpus doesn't reach is never run, so
94
+ * nothing checks it. */
90
95
  readonly files: readonly string[];
96
+ /**
97
+ * The values of names a grammar's reducers and gates import, for the corpus run.
98
+ * Their source runs at build time with no module around it, so a grammar whose
99
+ * callbacks read imported helpers passes those helpers here. See
100
+ * `docs/guide/macro-mode.md` for what this does and doesn't cover.
101
+ *
102
+ * It's one flat namespace, so two modules can't bind one name to different helpers.
103
+ * A name that's already a global fails the build. A helper named like a global and
104
+ * left out of `scope` silently uses the global. A direct `node()` builder doesn't
105
+ * run in the corpus run: a plain node stands in for it, so a helper only a builder
106
+ * reads is neither needed here nor checked.
107
+ */
108
+ readonly scope?: Readonly<Record<string, unknown>>;
91
109
  };
92
110
  declare const _default: import("unplugin").UnpluginInstance<ParsecraftPluginOptions, boolean>;
93
111
  export default _default;
@@ -96,6 +114,11 @@ export type TransformMacroResult = {
96
114
  map: ReturnType<MagicString['generateMap']>;
97
115
  /** Diagnostics for macro-referencing shapes that fell back to the interpreter. */
98
116
  warnings: string[];
117
+ /** With an `assemblyProfile`: `'ran'` when a grammar here parsed the corpus,
118
+ * `'no-entry'` when the grammars that could have don't have its `entry` rule. */
119
+ assemblyProfile?: 'ran' | 'no-entry';
120
+ /** The sites the module's `assemblyBudget` bought, by program offset, in rank order. */
121
+ assemblySites: number[];
99
122
  };
100
123
  /**
101
124
  * Transform one module, ALWAYS releasing the process-global capture state.
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/plugin/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IAAI,CAW7B"}
@@ -2,7 +2,7 @@
2
2
  import * as fs2 from "node:fs";
3
3
  import * as path2 from "node:path";
4
4
  import { createUnplugin } from "unplugin";
5
- import { parseSync as parseSync5 } from "oxc-parser";
5
+ import { parseSync as parseSync6 } from "oxc-parser";
6
6
  import { ResolverFactory } from "oxc-resolver";
7
7
  import MagicString from "magic-string";
8
8
 
@@ -2081,6 +2081,9 @@ function linkRules(recipes, link) {
2081
2081
  return cache;
2082
2082
  }
2083
2083
 
2084
+ // src/plugin/evaluator.ts
2085
+ import { parseSync as parseSync2 } from "oxc-parser";
2086
+
2084
2087
  // src/combinators/probe.ts
2085
2088
  function failAt(ctx, expected, pos) {
2086
2089
  const r = { ok: false, expected, span: { start: pos, end: pos } };
@@ -5619,7 +5622,7 @@ function sourceLeaf(root, fn) {
5619
5622
  }
5620
5623
 
5621
5624
  // src/version.ts
5622
- var PARSEMAN_VERSION = "0.61.2";
5625
+ var PARSEMAN_VERSION = "0.61.4";
5623
5626
 
5624
5627
  // src/table/lex-body.ts
5625
5628
  function buildLexBodyRecognizer(spec, constants) {
@@ -19148,13 +19151,21 @@ function selectHotSites(code, entries, siteBytes, budget, profile) {
19148
19151
  let spent = 0;
19149
19152
  for (const ip of ranked) {
19150
19153
  if (w(ip) === 0) break;
19151
- const bytes = siteBytes.get(ip);
19152
- if (spent + bytes > budget) continue;
19153
- spent += bytes;
19154
+ spent += siteBytes.get(ip);
19155
+ if (spent > budget) break;
19154
19156
  selected.add(ip);
19155
19157
  }
19156
19158
  return selected;
19157
19159
  }
19160
+ function fitHotSites(code, entries, siteBytes, fixed, ceiling, sourceBytes, profile) {
19161
+ const ranked = [...selectHotSites(code, entries, siteBytes, ceiling - fixed, profile)];
19162
+ for (; ranked.length > 0; ranked.pop()) {
19163
+ const sites = new Set(ranked);
19164
+ const bytes = sourceBytes(sites);
19165
+ if (bytes <= ceiling) return { sites, bytes };
19166
+ }
19167
+ return void 0;
19168
+ }
19158
19169
  function staticWeights(code, entries) {
19159
19170
  let weight = /* @__PURE__ */ new Map();
19160
19171
  const kids = [];
@@ -19294,19 +19305,20 @@ function compileRuleMap(ruleMap, opts = {}) {
19294
19305
  }
19295
19306
  const ceiling = budget / SUPERCOMPILE_GROWTH;
19296
19307
  if (ceiling <= fixed) return none;
19297
- let target = ceiling;
19298
- for (; ; ) {
19299
- const sites = selectHotSites(artifact.code, Object.values(artifact.rules), siteBytes, target - fixed, profile);
19300
- if (sites.size === 0) {
19301
- return {
19302
- ...none,
19303
- refusal: `a site within its ${Math.floor(ceiling)} B selection ceiling (the prelude alone is ${fixed} B)`
19304
- };
19305
- }
19306
- const bytes = emitAssemblySource(table, artifact, cfg, roots, true, sites, true).source.length;
19307
- if (bytes <= ceiling) return { sites, bytes: Math.ceil(bytes * SUPERCOMPILE_GROWTH) };
19308
- target *= Math.min(ceiling / bytes, 0.99);
19309
- }
19308
+ const fit = fitHotSites(
19309
+ artifact.code,
19310
+ Object.values(artifact.rules),
19311
+ siteBytes,
19312
+ fixed,
19313
+ ceiling,
19314
+ (sites) => emitAssemblySource(table, artifact, cfg, roots, true, sites, true).source.length,
19315
+ profile
19316
+ );
19317
+ if (fit !== void 0) return { sites: fit.sites, bytes: Math.ceil(fit.bytes * SUPERCOMPILE_GROWTH) };
19318
+ return {
19319
+ ...none,
19320
+ refusal: `a site within its ${Math.floor(ceiling)} B selection ceiling (the prelude alone is ${fixed} B)`
19321
+ };
19310
19322
  };
19311
19323
  return {
19312
19324
  keys: ruleMap.map(([key]) => key),
@@ -20719,7 +20731,7 @@ function stripTsFromSource(node2, code) {
20719
20731
  walk(node2);
20720
20732
  const start = node2.start;
20721
20733
  const end = node2.end;
20722
- if (cuts.length === 0) return code.slice(start, end);
20734
+ if (cuts.length === 0) return stripComments(code.slice(start, end));
20723
20735
  cuts.sort((a, b) => a[0] - b[0]);
20724
20736
  let out = "";
20725
20737
  let cur = start;
@@ -20728,7 +20740,36 @@ function stripTsFromSource(node2, code) {
20728
20740
  out += code.slice(cur, s);
20729
20741
  cur = e;
20730
20742
  }
20731
- return out + code.slice(cur, end);
20743
+ return stripComments(out + code.slice(cur, end));
20744
+ }
20745
+ var LINE_TERMINATOR = /[\n\r\u2028\u2029]/;
20746
+ function stripComments(text) {
20747
+ if (!text.includes("/*") && !text.includes("//")) return text;
20748
+ const wrapped = `(${text})`;
20749
+ let out = "";
20750
+ let cur = 0;
20751
+ let lineEnd = false;
20752
+ const comments = parseSync2("reducer.ts", wrapped).comments;
20753
+ comments.forEach((c, i) => {
20754
+ const before = text.slice(cur, c.start - 1);
20755
+ const kept = before.trimEnd();
20756
+ out += kept;
20757
+ lineEnd ||= LINE_TERMINATOR.test(before.slice(kept.length)) || LINE_TERMINATOR.test(c.value);
20758
+ cur = c.end - 1;
20759
+ const after = /^\s*/.exec(text.slice(cur))[0];
20760
+ const endsLine = LINE_TERMINATOR.test(after);
20761
+ if (comments[i + 1]?.start === c.end + after.length) {
20762
+ lineEnd ||= endsLine;
20763
+ cur += after.length;
20764
+ return;
20765
+ }
20766
+ if (out !== "" && cur + after.length < text.length && !endsLine) {
20767
+ if (lineEnd) out += "\n";
20768
+ else if (after === "") out += " ";
20769
+ }
20770
+ lineEnd = false;
20771
+ });
20772
+ return out + text.slice(cur);
20732
20773
  }
20733
20774
  var UnevaluatedExtra = class {
20734
20775
  };
@@ -21754,7 +21795,7 @@ function referencesAny(node2, names, scope2) {
21754
21795
  import * as fs from "node:fs";
21755
21796
  import * as path from "node:path";
21756
21797
  import { createRequire } from "node:module";
21757
- import { parseSync as parseSync2 } from "oxc-parser";
21798
+ import { parseSync as parseSync3 } from "oxc-parser";
21758
21799
  var FUNCTION_TYPES = /* @__PURE__ */ new Set(["FunctionDeclaration", "FunctionExpression", "ArrowFunctionExpression"]);
21759
21800
  var SCOPE_TYPES = /* @__PURE__ */ new Set([
21760
21801
  ...FUNCTION_TYPES,
@@ -21960,7 +22001,7 @@ function analyseModuleFile(file) {
21960
22001
  let mod = null;
21961
22002
  try {
21962
22003
  const src = fs.readFileSync(file, "utf8");
21963
- const r = parseSync2(file, src);
22004
+ const r = parseSync3(file, src);
21964
22005
  if (r.errors.length === 0) {
21965
22006
  const body = r.program.body;
21966
22007
  const scopes = buildScopeTree(body, src.length);
@@ -22138,7 +22179,7 @@ function createReducerResolver(entryFile, body, src) {
22138
22179
  }
22139
22180
 
22140
22181
  // src/plugin/free-identifiers.ts
22141
- import { parseSync as parseSync3 } from "oxc-parser";
22182
+ import { parseSync as parseSync4 } from "oxc-parser";
22142
22183
  var isNode = (v) => typeof v === "object" && v !== null && typeof v.type === "string";
22143
22184
  var TYPE_KEYS = /* @__PURE__ */ new Set([
22144
22185
  "typeAnnotation",
@@ -22286,7 +22327,7 @@ function describeTopLevel(stmt) {
22286
22327
  function findFreeIdentifiers(code, filename) {
22287
22328
  let parsed;
22288
22329
  try {
22289
- parsed = parseSync3(filename, code);
22330
+ parsed = parseSync4(filename, code);
22290
22331
  } catch {
22291
22332
  return [];
22292
22333
  }
@@ -22363,7 +22404,7 @@ function findFreeIdentifiers(code, filename) {
22363
22404
  }
22364
22405
 
22365
22406
  // src/plugin/entry-supercompiler.ts
22366
- import { parseSync as parseSync4 } from "oxc-parser";
22407
+ import { parseSync as parseSync5 } from "oxc-parser";
22367
22408
  var PIECE = /^_pf(\d+)$/;
22368
22409
  var WRAP = "function __parseman_supercompile__(){\n";
22369
22410
  var SUFFIX = "\n}";
@@ -22512,7 +22553,7 @@ function supercompileRuleMapReplacement(prog, replacement, select) {
22512
22553
  }
22513
22554
  if (!candidate.supercompile.activated) return replacement;
22514
22555
  const prefix = "const __parseman_macro_replacement__=";
22515
- const parsed = parseSync4("parseman-entry-supercompile-replacement.js", prefix + replacement);
22556
+ const parsed = parseSync5("parseman-entry-supercompile-replacement.js", prefix + replacement);
22516
22557
  if (parsed.errors.length > 0) return replacement;
22517
22558
  const program = parsed.program;
22518
22559
  const declaration = nodes(program.body)[0];
@@ -22533,12 +22574,12 @@ function supercompileRuleMapReplacement(prog, replacement, select) {
22533
22574
  const end = body.end - prefix.length - 1;
22534
22575
  if (replacement.slice(start, end) !== FACTORY_ARITY_GUARD + canonical2.source + "\n") return replacement;
22535
22576
  const transformed = replacement.slice(0, start) + FACTORY_ARITY_GUARD + candidate.source + "\n" + replacement.slice(end);
22536
- const checked = parseSync4("parseman-entry-supercompile-replacement-result.js", prefix + transformed);
22577
+ const checked = parseSync5("parseman-entry-supercompile-replacement-result.js", prefix + transformed);
22537
22578
  return checked.errors.length === 0 ? transformed : replacement;
22538
22579
  }
22539
22580
  function supercompileEmittedAssembly(prog, _cfg, extraIps, emitted) {
22540
22581
  const source = emitted.source;
22541
- const parsed = parseSync4("parseman-entry-supercompile.js", WRAP + source + SUFFIX);
22582
+ const parsed = parseSync5("parseman-entry-supercompile.js", WRAP + source + SUFFIX);
22542
22583
  if (parsed.errors.length > 0) {
22543
22584
  const zero = { functionsBefore: 0, pieceCallsBefore: 0, sourceBefore: source.length, barriers: {} };
22544
22585
  return fallback(emitted, "canonical emitted source did not parse", zero);
@@ -22764,7 +22805,7 @@ ${nested}
22764
22805
  }
22765
22806
  const functionsAfter = roots.length;
22766
22807
  const removed = fns.size - functionsAfter;
22767
- const checked = parseSync4("parseman-entry-supercompile-result.js", WRAP + candidate + SUFFIX);
22808
+ const checked = parseSync5("parseman-entry-supercompile-result.js", WRAP + candidate + SUFFIX);
22768
22809
  if (checked.errors.length > 0) return fallback(emitted, "structured candidate did not parse", before);
22769
22810
  const declared = /* @__PURE__ */ new Set();
22770
22811
  const referenced = /* @__PURE__ */ new Set();
@@ -23039,7 +23080,17 @@ function corpusTexts(profile) {
23039
23080
  });
23040
23081
  }
23041
23082
  var PARSEMAN_MODULE = "parseman";
23042
- var DEFAULT_ASSEMBLY_BUDGET = 0.25;
23083
+ var DEFAULT_ASSEMBLY_BUDGET = 0.5;
23084
+ function codeBytes(code, comments, end = code.length) {
23085
+ let bytes = 0;
23086
+ let at = 0;
23087
+ for (const c of comments) {
23088
+ if (c.start >= end) break;
23089
+ bytes += code.slice(at, c.start).replace(/\s+/g, "").length;
23090
+ at = c.end;
23091
+ }
23092
+ return bytes + code.slice(at, end).replace(/\s+/g, "").length;
23093
+ }
23043
23094
  var LinkRefusal = class extends Error {
23044
23095
  };
23045
23096
  function reasonSuffix(runtimeOnly) {
@@ -23140,7 +23191,7 @@ function parseModuleCached(filePath) {
23140
23191
  let parsed = null;
23141
23192
  try {
23142
23193
  const src = fs2.readFileSync(filePath, "utf8");
23143
- const r = parseSync5(filePath, src);
23194
+ const r = parseSync6(filePath, src);
23144
23195
  if (r.errors.length === 0) parsed = { body: r.program.body, src };
23145
23196
  } catch {
23146
23197
  }
@@ -23181,7 +23232,7 @@ async function followCarried(sinks, moduleId, name, depth = 0) {
23181
23232
  if (own !== void 0) return { items: own, recorder: moduleId };
23182
23233
  const code = this.getModuleInfo(moduleId)?.code;
23183
23234
  if (!code) return void 0;
23184
- const parsed = parseSync5(moduleId, code);
23235
+ const parsed = parseSync6(moduleId, code);
23185
23236
  if (parsed.errors.length > 0) return void 0;
23186
23237
  const origin = exportOrigin(parsed.program.body, name);
23187
23238
  if (origin === "local") return null;
@@ -23242,6 +23293,7 @@ async function emitCarriedSidecars(sinks, bundle) {
23242
23293
  var SIDECAR_FRAMEWORKS = /* @__PURE__ */ new Set(["rollup", "rolldown", "vite"]);
23243
23294
  var plugin_default = createUnplugin((opts = {}, meta) => {
23244
23295
  const sinks = SIDECAR_FRAMEWORKS.has(meta.framework) ? /* @__PURE__ */ new Map() : void 0;
23296
+ const profiled = /* @__PURE__ */ new Map();
23245
23297
  const generateBundle = sinks === void 0 ? void 0 : {
23246
23298
  generateBundle: {
23247
23299
  order: "post",
@@ -23260,8 +23312,15 @@ var plugin_default = createUnplugin((opts = {}, meta) => {
23260
23312
  transformInclude(id) {
23261
23313
  return /\.[jt]sx?$/.test(id) && !id.includes("node_modules");
23262
23314
  },
23315
+ buildEnd(error) {
23316
+ if (error) return;
23317
+ const ids = [...this.getModuleIds?.() ?? profiled.keys()].filter((id) => profiled.has(id));
23318
+ if (ids.length === 0 || ids.some((id) => profiled.get(id) === "ran")) return;
23319
+ throw new Error(`assemblyProfile: no grammar has rule "${opts.assemblyProfile?.entry}", so the corpus never ran (${ids.join(", ")})`);
23320
+ },
23263
23321
  transform(code, id) {
23264
23322
  sinks?.delete(id);
23323
+ profiled.delete(id);
23265
23324
  if (!code.includes("parseman")) return null;
23266
23325
  if (!code.includes("macro")) return null;
23267
23326
  for (const file of opts.assemblyProfile?.files ?? []) this?.addWatchFile?.(file);
@@ -23269,6 +23328,7 @@ var plugin_default = createUnplugin((opts = {}, meta) => {
23269
23328
  const sink = sinks && /* @__PURE__ */ new Map();
23270
23329
  const result = transformMacro(code, id, moduleAliases, opts.warnUnloweredRegex === true, opts.recovery === true, opts.grammarCoverage === true, opts.assemblyProfile, opts.assemblyBudget, sink);
23271
23330
  if (sinks && sink && sink.size > 0) sinks.set(id, sink);
23331
+ if (result?.assemblyProfile !== void 0) profiled.set(id, result.assemblyProfile);
23272
23332
  if (result?.warnings.length) {
23273
23333
  for (const w of result.warnings) {
23274
23334
  if (typeof this?.warn === "function") this.warn(`[parseman] ${w}`);
@@ -23415,7 +23475,7 @@ function lowerPrivateSourceModule(file, moduleAliases, warnUnloweredRegex, recov
23415
23475
  const source = fs2.readFileSync(file, "utf8");
23416
23476
  const transformed = transformMacro(source, file, moduleAliases, warnUnloweredRegex, recovery);
23417
23477
  if (!transformed || transformed.warnings.length > 0) return null;
23418
- const parsed = parseSync5(file, transformed.code);
23478
+ const parsed = parseSync6(file, transformed.code);
23419
23479
  parsedModule = parsed.errors.length === 0 ? { body: parsed.program.body, src: transformed.code } : null;
23420
23480
  return parsedModule;
23421
23481
  } catch {
@@ -23438,7 +23498,7 @@ function transformMacro(code, id, moduleAliases = /* @__PURE__ */ new Set([PARSE
23438
23498
  function transformMacroImpl(code, id, moduleAliases, warnUnloweredRegex, recovery, grammarCoverage, assemblyProfile, assemblyBudgetShare, carriedSink) {
23439
23499
  let result;
23440
23500
  try {
23441
- result = parseSync5(id, code);
23501
+ result = parseSync6(id, code);
23442
23502
  } catch {
23443
23503
  return null;
23444
23504
  }
@@ -23997,6 +24057,7 @@ ${names.map((n) => ` - ${n}`).join("\n")}` : " (it is not a static combinator/v
23997
24057
  const localRuleMaps = /* @__PURE__ */ new Map();
23998
24058
  const localGrammarTrivia = /* @__PURE__ */ new Map();
23999
24059
  const localGrammarScanSkip = /* @__PURE__ */ new Map();
24060
+ const callLabel = (fn, start) => `${fn}${codeBytes(code, result.comments, start)}`;
24000
24061
  const nsFor = (label2) => `_${createHash("sha1").update(`${id}#${label2}`).digest("hex").slice(0, 8)}_`;
24001
24062
  const isSpread = (it) => "__spreadLocal" in it;
24002
24063
  const isIR = (it) => "ir" in it;
@@ -24252,7 +24313,7 @@ ${names.map((n) => ` - ${n}`).join("\n")}` : " (it is not a static combinator/v
24252
24313
  const carried = [];
24253
24314
  const importedFactories = [];
24254
24315
  for (let i = 0; i < elements.length; i++) {
24255
- const r = argPieces(elements[i], `compose${init.start}_${i}`, composing);
24316
+ const r = argPieces(elements[i], `${callLabel("compose", init.start)}_${i}`, composing);
24256
24317
  if (!r) {
24257
24318
  const el = elements[i];
24258
24319
  const name = el.type === "Identifier" ? el.name : void 0;
@@ -24315,7 +24376,8 @@ ${names.map((n) => ` - ${n}`).join("\n")}` : " (it is not a static combinator/v
24315
24376
  warn(init.start, "compose(): a carried piece has no re-lowerable IR; leaving the runtime compose() in place");
24316
24377
  return null;
24317
24378
  };
24318
- let assemblyBudget = Math.floor(code.length * assemblyBudgetShare);
24379
+ let assemblyBudget = Math.floor(codeBytes(code, result.comments) * assemblyBudgetShare);
24380
+ const assemblySites = [];
24319
24381
  let leafDeclared;
24320
24382
  const declaresLeaf = () => leafDeclared ??= body.some((stmt) => {
24321
24383
  const vd = unwrapVd(stmt);
@@ -24328,10 +24390,17 @@ ${names.map((n) => ` - ${n}`).join("\n")}` : " (it is not a static combinator/v
24328
24390
  warnings.push(`${id}:${lineOf(pos)} \u2014 ${label2}: its precompiled assembly cannot emit ${refusal}; the artifact runs on the closure engine`);
24329
24391
  }
24330
24392
  assemblyBudget -= bytes;
24393
+ assemblySites.push(...sites);
24331
24394
  return sites;
24332
24395
  };
24396
+ let profileOutcome;
24333
24397
  const profileOf = (compiled) => {
24334
- if (assemblyProfile === void 0 || compiled.hostMode !== "ast" || compiled.prog.lines === 1 || !(assemblyProfile.entry in compiled.prog.rules)) return void 0;
24398
+ if (assemblyProfile === void 0 || compiled.hostMode !== "ast" || compiled.prog.lines === 1) return void 0;
24399
+ if (!(assemblyProfile.entry in compiled.prog.rules)) {
24400
+ profileOutcome ??= "no-entry";
24401
+ return void 0;
24402
+ }
24403
+ profileOutcome = "ran";
24335
24404
  const refuse = (why) => {
24336
24405
  throw new Error(`${id} \u2014 assemblyProfile: ${why}`);
24337
24406
  };
@@ -24351,26 +24420,36 @@ ${names.map((n) => ` - ${n}`).join("\n")}` : " (it is not a static combinator/v
24351
24420
  }
24352
24421
  });
24353
24422
  });
24354
- return countSiteVisits(compiled.prog, (rules3) => {
24355
- const entry = rules3[assemblyProfile.entry];
24356
- corpusTexts(assemblyProfile).forEach((text, i) => {
24357
- const file = assemblyProfile.files[i];
24358
- if (text.trim() === "") return;
24359
- let result2;
24360
- try {
24361
- result2 = run(entry, text);
24362
- } catch (e) {
24363
- const source = String(thrower).replace(/\s+/g, " ").slice(0, 200);
24364
- throw new Error(`${id} \u2014 assemblyProfile: ${thrower === void 0 ? "the parse" : `gate or reducer \`${source}\``} threw on ${file}: ${String(e)}`, { cause: e });
24365
- }
24366
- if (!result2.ok || result2.unconsumedFrom !== null) {
24367
- refuse(`${file} does not parse from rule "${assemblyProfile.entry}": it stops at offset ${result2.ok ? result2.unconsumedFrom : result2.span.end}`);
24368
- }
24369
- if (result2.errors.length > 0) {
24370
- refuse(`${file} parses only by recovering from ${result2.errors.length} error(s), first at offset ${result2.errors[0].span.start}`);
24371
- }
24372
- });
24373
- }, fns);
24423
+ const scope3 = assemblyProfile.scope ?? {};
24424
+ const names = Object.keys(scope3);
24425
+ for (const name of names) {
24426
+ if (name in globalThis) refuse(`\`scope\` name "${name}" is already a global; a callback couldn't tell which one it reads`);
24427
+ }
24428
+ try {
24429
+ for (const name of names) Object.defineProperty(globalThis, name, { value: scope3[name], configurable: true });
24430
+ return countSiteVisits(compiled.prog, (rules3) => {
24431
+ const entry = rules3[assemblyProfile.entry];
24432
+ corpusTexts(assemblyProfile).forEach((text, i) => {
24433
+ const file = assemblyProfile.files[i];
24434
+ if (text.trim() === "") return;
24435
+ let result2;
24436
+ try {
24437
+ result2 = run(entry, text);
24438
+ } catch (e) {
24439
+ const source = String(thrower).replace(/\s+/g, " ").slice(0, 200);
24440
+ throw new Error(`${id} \u2014 assemblyProfile: ${thrower === void 0 ? "the parse" : `gate or reducer \`${source}\``} threw on ${file}: ${String(e)}`, { cause: e });
24441
+ }
24442
+ if (!result2.ok || result2.unconsumedFrom !== null) {
24443
+ refuse(`${file} does not parse from rule "${assemblyProfile.entry}": it stops at offset ${result2.ok ? result2.unconsumedFrom : result2.span.end}`);
24444
+ }
24445
+ if (result2.errors.length > 0) {
24446
+ refuse(`${file} parses only by recovering from ${result2.errors.length} error(s), first at offset ${result2.errors[0].span.start}`);
24447
+ }
24448
+ });
24449
+ }, fns);
24450
+ } finally {
24451
+ for (const name of names) Reflect.deleteProperty(globalThis, name);
24452
+ }
24374
24453
  };
24375
24454
  const assembledReplacement = (compiled, metadata, select) => select.size === 0 ? compiled.replacementWithMetadata(metadata) : supercompileRuleMapReplacement(compiled.prog, compiled.replacementWithMetadata(metadata, { select }), select);
24376
24455
  const compileComposeLeafCall = (init) => {
@@ -24389,7 +24468,7 @@ ${names.map((n) => ` - ${n}`).join("\n")}` : " (it is not a static combinator/v
24389
24468
  let localRules = null;
24390
24469
  const importedFactories = [];
24391
24470
  if (isRulesCall(localArg)) {
24392
- const evaluated = evaluateRulesFactory(localArg, `composeLeaf${init.start}`);
24471
+ const evaluated = evaluateRulesFactory(localArg, callLabel("composeLeaf", init.start));
24393
24472
  localRules = evaluated?.ruleMap ?? null;
24394
24473
  if (evaluated?.importedFactory) importedFactories.push(evaluated.importedFactory);
24395
24474
  } else if (localArg.type === "Identifier") {
@@ -24404,7 +24483,7 @@ ${names.map((n) => ` - ${n}`).join("\n")}` : " (it is not a static combinator/v
24404
24483
  const composing = composingTrivia(elements);
24405
24484
  const carried = [];
24406
24485
  for (let i = 0; i < elements.length - 1; i++) {
24407
- const r = argPieces(elements[i], `composeLeaf${init.start}_${i}`, composing);
24486
+ const r = argPieces(elements[i], `${callLabel("composeLeaf", init.start)}_${i}`, composing);
24408
24487
  if (!r) {
24409
24488
  warn(init.start, `composeLeaf(): argument ${i} isn't a build-resolvable recognition grammar`);
24410
24489
  return null;
@@ -24880,9 +24959,11 @@ ${lines2.join("\n")}`);
24880
24959
  for (const l of lines2) warnings.push(`${id}: ${l}`);
24881
24960
  }
24882
24961
  return {
24962
+ assemblySites: applied.length > 0 ? assemblySites : [],
24883
24963
  code: ms.toString(),
24884
24964
  map: ms.generateMap({ hires: true }),
24885
- warnings
24965
+ warnings,
24966
+ ...profileOutcome === void 0 ? {} : { assemblyProfile: profileOutcome }
24886
24967
  };
24887
24968
  }
24888
24969
  export {