@mnemonik/shared 7.154.3 → 7.156.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 (46) hide show
  1. package/dist/ast/grammars.d.ts +4 -2
  2. package/dist/ast/grammars.d.ts.map +1 -1
  3. package/dist/ast/grammars.js +45 -3
  4. package/dist/ast/grammars.js.map +1 -1
  5. package/dist/codeScanner.d.ts +26 -329
  6. package/dist/codeScanner.d.ts.map +1 -1
  7. package/dist/codeScanner.js +65 -1141
  8. package/dist/codeScanner.js.map +1 -1
  9. package/dist/fileSelection.d.ts +451 -0
  10. package/dist/fileSelection.d.ts.map +1 -0
  11. package/dist/fileSelection.js +1256 -0
  12. package/dist/fileSelection.js.map +1 -0
  13. package/dist/hookTrace.d.ts +40 -0
  14. package/dist/hookTrace.d.ts.map +1 -1
  15. package/dist/hookTrace.js +126 -0
  16. package/dist/hookTrace.js.map +1 -1
  17. package/dist/index.d.ts +3 -2
  18. package/dist/index.d.ts.map +1 -1
  19. package/dist/index.js +3 -2
  20. package/dist/index.js.map +1 -1
  21. package/dist/runtimeAssets.d.ts +12 -0
  22. package/dist/runtimeAssets.d.ts.map +1 -0
  23. package/dist/runtimeAssets.js +43 -0
  24. package/dist/runtimeAssets.js.map +1 -0
  25. package/dist/sourceRedaction.d.ts +45 -1
  26. package/dist/sourceRedaction.d.ts.map +1 -1
  27. package/dist/sourceRedaction.js +62 -22
  28. package/dist/sourceRedaction.js.map +1 -1
  29. package/dist/sourceRedactionPool.d.ts +198 -0
  30. package/dist/sourceRedactionPool.d.ts.map +1 -0
  31. package/dist/sourceRedactionPool.js +756 -0
  32. package/dist/sourceRedactionPool.js.map +1 -0
  33. package/dist/vueSource.d.ts +0 -2
  34. package/dist/vueSource.d.ts.map +1 -1
  35. package/dist/vueSource.js +8 -19
  36. package/dist/vueSource.js.map +1 -1
  37. package/package.json +5 -1
  38. package/src/ast/grammars.ts +52 -7
  39. package/src/codeScanner.ts +121 -1321
  40. package/src/fileSelection.ts +1440 -0
  41. package/src/hookTrace.ts +143 -0
  42. package/src/index.ts +31 -2
  43. package/src/runtimeAssets.ts +49 -0
  44. package/src/sourceRedaction.ts +85 -20
  45. package/src/sourceRedactionPool.ts +877 -0
  46. package/src/vueSource.ts +8 -23
package/src/vueSource.ts CHANGED
@@ -1,5 +1,4 @@
1
1
  import type { SFCDescriptor } from '@vue/compiler-sfc';
2
- import { MAX_AST_PARSE_BYTES } from './ast/astChunker.js';
3
2
  import { MAX_SCANNED_FILE_BYTES } from './codeScanner.js';
4
3
 
5
4
  /** A fallback scrub may repair syntax; it must never become graph evidence. */
@@ -11,18 +10,7 @@ export type VueTemplateNode = TemplateRoot | TemplateRoot['children'][number];
11
10
  type ParsedVueSource = {
12
11
  descriptor: SFCDescriptor;
13
12
  nodeTypes: typeof import('@vue/compiler-core').NodeTypes;
14
- /** Set on the sanitation path only; the template walk throws past it. */
15
- templateNodeLimit?: number;
16
13
  };
17
-
18
- /**
19
- * Sanitation runs on the API server's event loop (scan push, file push, documents), and
20
- * its edit loop costs the file's length per edit, so it keeps the 2 MiB and 200,000-node
21
- * bounds until it moves off that loop. Connected-code reads run in the parse pool and
22
- * take any file up to the product's 10 MB ceiling.
23
- */
24
- const SANITATION_MAX_BYTES = MAX_AST_PARSE_BYTES;
25
- const SANITATION_TEMPLATE_NODE_LIMIT = 200_000;
26
14
  export async function parseVueSource(
27
15
  source: string,
28
16
  forSanitation = false
@@ -30,10 +18,11 @@ export async function parseVueSource(
30
18
  // Sanitation still inspects marked bytes; graph extraction must continue to reject them.
31
19
  if (!forSanitation && source.includes(VUE_FIDELITY_MARKER))
32
20
  return { reason: 'vue_source_fidelity_unavailable' };
33
- if (
34
- Buffer.byteLength(source, 'utf8') >
35
- (forSanitation ? SANITATION_MAX_BYTES : MAX_SCANNED_FILE_BYTES)
36
- )
21
+ // One ceiling for sanitation and connected code: the product's 10 MB scan
22
+ // ceiling. Sanitation no longer stops at 2 MiB: its edits are applied in one
23
+ // pass (sourceRedaction.ts applySpanEdits), and on the API server components
24
+ // are scrubbed in a redaction child, off the event loop (sourceRedactionServer.ts).
25
+ if (Buffer.byteLength(source, 'utf8') > MAX_SCANNED_FILE_BYTES)
37
26
  return { reason: 'file_too_large' };
38
27
  let clearCache: (() => void) | undefined;
39
28
  try {
@@ -56,9 +45,7 @@ export async function parseVueSource(
56
45
  descriptor.customBlocks.length
57
46
  )
58
47
  return { reason: 'vue_preprocessor_or_custom_block_unsupported' };
59
- return forSanitation
60
- ? { descriptor, nodeTypes, templateNodeLimit: SANITATION_TEMPLATE_NODE_LIMIT }
61
- : { descriptor, nodeTypes };
48
+ return { descriptor, nodeTypes };
62
49
  } catch {
63
50
  return { reason: 'vue_parse_failed' };
64
51
  } finally {
@@ -76,13 +63,11 @@ export function walkVueTemplate(
76
63
  const pending: Array<{ node: VueTemplateNode; scoped: boolean }> = descriptor.template?.ast
77
64
  ? [{ node: descriptor.template.ast, scoped: false }]
78
65
  : [];
79
- // Iterative and linear in the template's nodes; only sanitation is bounded by count.
80
- const limit = parsed.templateNodeLimit ?? Infinity;
81
- let count = 0;
66
+ // Iterative and linear in the template's nodes, with no count limit: the
67
+ // 200,000-node bound guarded a scrubber that copied the file per edit.
82
68
  while (pending.length) {
83
69
  const item = pending.pop();
84
70
  if (!item) break;
85
- if (++count > limit) throw new Error('vue_template_work_limit');
86
71
  const { node } = item;
87
72
  const scoped =
88
73
  item.scoped ||