You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
PR #168 landed JSExport bridge methods for six previously-unreachable DocxSession methods, restoring parity at the bridge layer. The TypeScript wrapper at npm/src/session.ts does not yet expose them — so they're callable from the raw WASM exports but not from the typed DocxSession TS API consumers actually use.
Scope
Add typed TS wrappers + types for the methods now exposed on DocxSessionBridge:
Note: getAnchorInfo and getAnchorInfos already landed via #162 / #169 — no action needed on those.
What to mirror
Use the existing wrapper methods that match this shape as templates:
session.findByAnnotation / findByLabel / findByBookmark / listAnnotations in npm/src/session.ts — same passthrough-with-JSON-parse pattern.
The new FindByText etc. take an optionsJson string arg on the WASM side (same shape as Grep's options): {ignoreCase?, ignoreWhitespace?, kindFilter?, scopeFilter?}. Serialize an empty string when no options.
findByText returns nullable single → handle null in the TS layer.
Extend the DocxSessionBridge exports interface (around lines 700-970) with the new method signatures.
Tests
Playwright spec at npm/tests/find-by.spec.ts (or extend an existing session spec):
findByText / findAllByText with and without ignoreCase
findByRegex with a pattern that matches multiple anchors
findByKind('p') returns body paragraphs
findByKind('h', 'body') filter by scope
exists true/false for known + bogus anchor ids
replaceMatch workflow: grep('foo') → replaceMatch(match, 'bar') → verify text updated
Use existing test fixtures (HC001-5DayTourPlanTemplate.docx is a good starting point — has both paragraphs and headings).
Acceptance
All new methods callable from the typed TS API
npm run build clean
npm test green (new specs + no regressions)
Wire shapes byte-identical to what tools/python-host would consume — preserves the cross-transport parity invariant
Out of scope
Reworking the React hook layer (npm/src/react.ts) — separate concern.
Worker proxy plumbing — these are session methods, not stateless ones; the worker doesn't currently expose DocxSession (per the comment in npm/src/docxodus.worker.ts).
Context
PR #168 landed JSExport bridge methods for six previously-unreachable
DocxSessionmethods, restoring parity at the bridge layer. The TypeScript wrapper atnpm/src/session.tsdoes not yet expose them — so they're callable from the raw WASM exports but not from the typedDocxSessionTS API consumers actually use.Scope
Add typed TS wrappers + types for the methods now exposed on
DocxSessionBridge:session.exists(anchorId: string): booleansession.findByText(needle: string, options?: FindOptions): AnchorTarget | nullsession.findAllByText(needle: string, options?: FindOptions): AnchorTarget[]session.findByRegex(pattern: string, regexOptions?: number, options?: FindOptions): AnchorTarget[]session.findByKind(kind: string, scope?: string): AnchorTarget[]session.replaceMatch(match: TextMatch, replace: string): EditResult— client-side helper that callsreplaceTextAtSpan(match.enclosingAnchor.id, match.span.start, match.span.length, replace)(no new wire op needed — see PR feat(pyhost): shared DocxSession bridge core + stdio NDJSON host + parity ops for python-docxodus #168 rationale)Note:
getAnchorInfoandgetAnchorInfosalready landed via #162 / #169 — no action needed on those.What to mirror
Use the existing wrapper methods that match this shape as templates:
session.findByAnnotation/findByLabel/findByBookmark/listAnnotationsinnpm/src/session.ts— same passthrough-with-JSON-parse pattern.FindByTextetc. take anoptionsJsonstring arg on the WASM side (same shape asGrep's options):{ignoreCase?, ignoreWhitespace?, kindFilter?, scopeFilter?}. Serialize an empty string when no options.findByTextreturns nullable single → handlenullin the TS layer.Type additions to
npm/src/types.tsFindOptions { ignoreCase?: boolean; ignoreWhitespace?: boolean; kindFilter?: string; scopeFilter?: string }— matches the C#FindOptionsrecord. Wire keys already camelCase.DocxSessionBridgeexports interface (around lines 700-970) with the new method signatures.Tests
Playwright spec at
npm/tests/find-by.spec.ts(or extend an existing session spec):findByText/findAllByTextwith and withoutignoreCasefindByRegexwith a pattern that matches multiple anchorsfindByKind('p')returns body paragraphsfindByKind('h', 'body')filter by scopeexiststrue/false for known + bogus anchor idsreplaceMatchworkflow:grep('foo')→replaceMatch(match, 'bar')→ verify text updatedUse existing test fixtures (
HC001-5DayTourPlanTemplate.docxis a good starting point — has both paragraphs and headings).Acceptance
npm run buildcleannpm testgreen (new specs + no regressions)tools/python-hostwould consume — preserves the cross-transport parity invariantOut of scope
npm/src/react.ts) — separate concern.DocxSession(per the comment innpm/src/docxodus.worker.ts).