@mark1russell7/typeset 0.8.0 → 0.8.1

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.
@@ -249,7 +249,7 @@ function fontAdvance(options) {
249
249
  if (candidates.length === 0) return void 0;
250
250
  const style = styleOrder[spec.style].find((value) => candidates.some((entry) => (entry.face.style ?? "normal") === value));
251
251
  let best;
252
- let bestRank = Infinity;
252
+ let bestRank = 1e400;
253
253
  for (const entry of candidates) {
254
254
  if ((entry.face.style ?? "normal") !== style) continue;
255
255
  const rank = weightRank(entry.range, spec.weight);
@@ -1 +1 @@
1
- {"version":3,"file":"text.js","names":[],"sources":["../../src/text/rope.ts","../../src/text.ts"],"sourcesContent":["/**\n * The `Text` rope: a persistent balanced tree of strings with the width and the length of each subtree. An edit makes a\n * new rope. The new rope shares the subtrees that do not change. The tree is the `summary-tree` record of\n * `@mark1russell7/collections`, and this module gives it the summary of a text.\n *\n * A width function gives the width of a run of text. The rope uses it only for the leaves and for the windows at the\n * seams. Thus an edit uses it of the order of `log n` times. The rope keeps the widths of the short windows, so an edit\n * measures only the windows that it changes. `Text.from` clears this memory.\n *\n * The seams are exact when the width function obeys the separator law. For each text `p + s + q` with a separator `s`:\n * `width(p + s + q) = width(p + s) + width(s + q) - width(s)`. The model of `@mark1russell7/typeset/fonts` obeys it for a space and a\n * tab. It shapes each word alone, and its kerning goes only between two adjacent glyphs.\n */\nimport * as Tree from \"@mark1russell7/collections/summary-tree\";\nimport type { SummarySpec, SummaryTreeRecord } from \"@mark1russell7/collections/summary-tree\";\nimport type { WidthOf } from \"../breaking/paragraph.ts\";\n\n/** The options of a rope. */\nexport interface TextOptions {\n /**\n * The separators of the separator law: each character is one UTF-16 code unit. The default is a space and a tab. An\n * empty string makes each seam measure the full text of the two sides.\n */\n readonly separators?: string;\n /** The largest count of UTF-16 code units in a leaf. The default is 256. */\n readonly chunk?: number;\n}\n\n/** The summary of a run of text: its length, its width, and the two ends that a seam measures again. */\ninterface Summary {\n /** The count of UTF-16 code units. */\n readonly length: number;\n readonly width: number;\n /** This value is `true` when the text has a separator. */\n readonly separated: boolean;\n /** The text through the first separator, or all the text when the text has no separator. */\n readonly head: string;\n readonly headWidth: number;\n /** The text from the last separator, or all the text when the text has no separator. */\n readonly tail: string;\n readonly tailWidth: number;\n}\n\n/** The summary of the empty text. */\nconst noText: Summary = { length: 0, width: 0, separated: false, head: \"\", headWidth: 0, tail: \"\", tailWidth: 0 };\n\n/** The shared state of the ropes of one width function and one set of options. */\ninterface Context {\n readonly width: WidthOf;\n readonly separators: string;\n readonly chunk: number;\n readonly spec: SummarySpec<string, Summary>;\n /** The widths of the short windows. An edit gives the tree new paths, and most windows on these paths do not change. */\n readonly windows: Map<string, number>;\n}\n\n/** The largest count of windows in the memory of a context. */\nconst windowLimit = 16_384;\n\n/** This function gives the width of a window. A window longer than a leaf stays out of the memory. */\nfunction windowWidth(context: Context, window: string): number {\n if (window.length > context.chunk) return context.width(window);\n const known = context.windows.get(window);\n if (known !== undefined) return known;\n const width = context.width(window);\n if (context.windows.size >= windowLimit) context.windows.clear();\n context.windows.set(window, width);\n return width;\n}\n\nfunction isSeparator(separators: string, code: number): boolean {\n for (let i = 0; i < separators.length; i++) if (separators.charCodeAt(i) === code) return true;\n return false;\n}\n\nfunction summaryOfLeaf(context: Context, text: string): Summary {\n const { separators } = context;\n const whole = context.width(text);\n let first = -1;\n let last = -1;\n for (let i = 0; i < text.length; i++) {\n if (!isSeparator(separators, text.charCodeAt(i))) continue;\n if (first < 0) first = i;\n last = i;\n }\n if (first < 0) return { length: text.length, width: whole, separated: false, head: text, headWidth: whole, tail: text, tailWidth: whole };\n const head = text.slice(0, first + 1);\n const tail = text.slice(last);\n return { length: text.length, width: whole, separated: true, head, headWidth: windowWidth(context, head), tail, tailWidth: windowWidth(context, tail) };\n}\n\n/**\n * This function gives the summary of two runs in the order of the text. It measures one window: the tail of the left run and\n * the head of the right run. The separator law then gives the width of all the text from the widths of the two runs.\n */\nfunction combine(context: Context, left: Summary, right: Summary): Summary {\n if (left.length === 0) return right;\n if (right.length === 0) return left;\n const seam = left.tail + right.head;\n const seamWidth = windowWidth(context, seam);\n let width: number;\n if (!left.separated && !right.separated) width = seamWidth;\n else if (!left.separated) width = right.width - right.headWidth + seamWidth;\n else if (!right.separated) width = left.width - left.tailWidth + seamWidth;\n else width = left.width + right.width - left.tailWidth - right.headWidth + seamWidth;\n return {\n length: left.length + right.length,\n width,\n separated: left.separated || right.separated,\n head: left.separated ? left.head : seam,\n headWidth: left.separated ? left.headWidth : seamWidth,\n tail: right.separated ? right.tail : seam,\n tailWidth: right.separated ? right.tailWidth : seamWidth,\n };\n}\n\n/** The contexts of each width function. Two ropes join only when their trees have the same spec. */\nconst contexts = new WeakMap<WidthOf, Map<string, Context>>();\n\nfunction contextOf(width: WidthOf, separators: string, chunk: number): Context {\n const own = contexts.get(width) ?? new Map<string, Context>();\n contexts.set(width, own);\n const key = `${chunk}/${separators}`;\n const known = own.get(key);\n if (known !== undefined) return known;\n const spec: SummarySpec<string, Summary> = {\n monoid: { empty: noText, combine: (left, right) => combine(context, left, right) },\n measure: (leaf) => summaryOfLeaf(context, leaf),\n merge: (left, right) => (left.length + right.length <= chunk ? left + right : undefined),\n };\n const context: Context = { width, separators, chunk, spec, windows: new Map() };\n own.set(key, context);\n return context;\n}\n\n/** This function gives the end of the next leaf of `text` from `start`: after a separator when it can, and not in a surrogate pair. */\nfunction chunkEnd(context: Context, text: string, start: number): number {\n const limit = start + context.chunk;\n if (limit >= text.length) return text.length;\n for (let i = limit - 1; i >= start + context.chunk / 2; i--) if (isSeparator(context.separators, text.charCodeAt(i))) return i + 1;\n const code = text.charCodeAt(limit - 1);\n return code >= 0xd800 && code <= 0xdbff ? limit - 1 : limit;\n}\n\n/** This function divides a text into leaves of at most `chunk` code units. */\nfunction chunksOf(context: Context, text: string): string[] {\n const out: string[] = [];\n for (let start = 0; start < text.length; ) {\n const end = chunkEnd(context, text, start);\n out.push(text.slice(start, end));\n start = end;\n }\n return out;\n}\n\nconst lengthOf = (summary: Summary): number => summary.length;\n\n/**\n * A text with its width: a persistent balanced rope. Each edit gives a new `Text` and does not change this one. The offsets\n * are in UTF-16 code units, as the offsets of a JavaScript string.\n */\nexport class Text {\n readonly #context: Context;\n readonly #tree: SummaryTreeRecord<string, Summary>;\n\n private constructor(context: Context, tree: SummaryTreeRecord<string, Summary>) {\n this.#context = context;\n this.#tree = tree;\n }\n\n /** This function makes the rope of `text` with the width function `width`. */\n static from(text: string, width: WidthOf, options: TextOptions = {}): Text {\n const separators = options.separators ?? \" \\t\";\n const chunk = options.chunk ?? 256;\n if (!Number.isInteger(chunk) || chunk < 2) throw new RangeError(`the chunk is ${chunk}, not an integer of 2 or more`);\n for (let i = 0; i < separators.length; i++) {\n const code = separators.charCodeAt(i);\n if (code >= 0xd800 && code <= 0xdfff) throw new RangeError(\"a separator is one UTF-16 code unit, not a half of a surrogate pair\");\n }\n const context = contextOf(width, separators, chunk);\n // A new rope measures again: the width function can change its result when a font loads\n context.windows.clear();\n return new Text(context, Tree.of(context.spec, chunksOf(context, text)));\n }\n\n /** The count of UTF-16 code units of the text. */\n get length(): number {\n return Tree.summary(this.#tree).length;\n }\n\n /** The width of the text. It is equal to the width of the flat string when the width function obeys the separator law. */\n get width(): number {\n return Tree.summary(this.#tree).width;\n }\n\n /** The height of the tree: 0 for a text of one leaf. The tests use it to examine the balance. */\n get height(): number {\n return Math.max(0, Tree.height(this.#tree) - 1);\n }\n\n /** This function gives the flat string. */\n toString(): string {\n return this.chunks().join(\"\");\n }\n\n /** This function gives the strings of the leaves in the order of the text. */\n chunks(): string[] {\n return Tree.toArray(this.#tree);\n }\n\n /** This function gives the text from `start` to `end`, as a new rope. */\n slice(start: number, end: number = this.length): Text {\n this.#check(start, end);\n if (start === end) return new Text(this.#context, Tree.slice(this.#tree, 0, 0));\n const first = Tree.locate(this.#tree, lengthOf, start)!;\n const last = Tree.locate(this.#tree, lengthOf, end - 1)!;\n const stop = first.offset + end - start;\n const middle = Tree.slice(this.#tree, first.index, last.index + 1);\n if (first.index === last.index) return new Text(this.#context, Tree.set(middle, 0, first.leaf.slice(first.offset, stop)));\n return new Text(this.#context, Tree.set(Tree.set(middle, -1, last.leaf.slice(0, last.offset + 1)), 0, first.leaf.slice(first.offset)));\n }\n\n /** This function gives the width of the text from `start` to `end`. */\n widthOf(start: number, end: number = this.length): number {\n return this.slice(start, end).width;\n }\n\n /** This function gives this text and then `other`. The two ropes must have the same width function and options. */\n concat(other: Text): Text {\n if (other.#context !== this.#context) throw new TypeError(\"the two ropes have different width functions or options\");\n return new Text(this.#context, Tree.concat(this.#tree, other.#tree));\n }\n\n /** This function puts `text` at the offset `at`. */\n insert(at: number, text: string): Text {\n return this.replace(at, at, text);\n }\n\n /** This function removes the text from `start` to `end`. */\n remove(start: number, end: number): Text {\n return this.replace(start, end, \"\");\n }\n\n /** This function puts `text` in place of the text from `start` to `end`. */\n replace(start: number, end: number, text: string): Text {\n this.#check(start, end);\n if (start === end && text.length === 0) return this;\n const size = Tree.size(this.#tree);\n if (size === 0) return Text.from(text, this.#context.width, this.#context);\n const first = Tree.locate(this.#tree, lengthOf, start) ?? this.#lastPlace();\n const last = start === end ? first : Tree.locate(this.#tree, lengthOf, end - 1)!;\n const lastEnd = start === end ? first.offset : last.offset + 1;\n const fresh = first.leaf.slice(0, first.offset) + text + last.leaf.slice(lastEnd);\n const leaves = chunksOf(this.#context, fresh);\n // One long leaf in place of one leaf changes only a path. A short leaf goes through the seams, so that it can merge\n if (first.index === last.index && leaves.length === 1 && leaves[0]!.length * 2 >= this.#context.chunk) {\n return new Text(this.#context, Tree.set(this.#tree, first.index, leaves[0]!));\n }\n return new Text(this.#context, Tree.splice(this.#tree, first.index, last.index - first.index + 1, leaves));\n }\n\n /** This function gives the place after the last code unit: the end of the last leaf. */\n #lastPlace(): { index: number; leaf: string; offset: number } {\n const leaf = Tree.at(this.#tree, -1)!;\n return { index: Tree.size(this.#tree) - 1, leaf, offset: leaf.length };\n }\n\n #check(start: number, end: number): void {\n if (!Number.isInteger(start) || !Number.isInteger(end) || start < 0 || end < start || end > this.length) {\n throw new RangeError(`the range ${start} to ${end} is not in the text of length ${this.length}`);\n }\n }\n}\n","export { Text, type TextOptions } from \"./text/rope.ts\";\n"],"mappings":";;;;;;;;;;;;;;;;;AA4CA,MAAM,SAAkB;CAAE,QAAQ;CAAG,OAAO;CAAG,WAAW;CAAO,MAAM;CAAI,WAAW;CAAG,MAAM;CAAI,WAAW;AAAE;;AAahH,MAAM,cAAc;;AAGpB,SAAS,YAAY,SAAkB,QAAwB;CAC7D,IAAI,OAAO,SAAS,QAAQ,OAAO,OAAO,QAAQ,MAAM,MAAM;CAC9D,MAAM,QAAQ,QAAQ,QAAQ,IAAI,MAAM;CACxC,IAAI,UAAU,KAAA,GAAW,OAAO;CAChC,MAAM,QAAQ,QAAQ,MAAM,MAAM;CAClC,IAAI,QAAQ,QAAQ,QAAQ,aAAa,QAAQ,QAAQ,MAAM;CAC/D,QAAQ,QAAQ,IAAI,QAAQ,KAAK;CACjC,OAAO;AACT;AAEA,SAAS,YAAY,YAAoB,MAAuB;CAC9D,KAAK,IAAI,IAAI,GAAG,IAAI,WAAW,QAAQ,KAAK,IAAI,WAAW,WAAW,CAAC,MAAM,MAAM,OAAO;CAC1F,OAAO;AACT;AAEA,SAAS,cAAc,SAAkB,MAAuB;CAC9D,MAAM,EAAE,eAAe;CACvB,MAAM,QAAQ,QAAQ,MAAM,IAAI;CAChC,IAAI,QAAQ;CACZ,IAAI,OAAO;CACX,KAAK,IAAI,IAAI,GAAG,IAAI,KAAK,QAAQ,KAAK;EACpC,IAAI,CAAC,YAAY,YAAY,KAAK,WAAW,CAAC,CAAC,GAAG;EAClD,IAAI,QAAQ,GAAG,QAAQ;EACvB,OAAO;CACT;CACA,IAAI,QAAQ,GAAG,OAAO;EAAE,QAAQ,KAAK;EAAQ,OAAO;EAAO,WAAW;EAAO,MAAM;EAAM,WAAW;EA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S,OAAO,WAAW,KAAK,OAAO,EAAE,CAAE,SAAS,KAAK,KAAK,SAAS,OAC9F,OAAO,IAAI,KAAK,KAAK,UAAU,KAAK,IAAI,KAAK,OAAO,MAAM,OAAO,OAAO,EAAG,CAAC;EAE9E,OAAO,IAAI,KAAK,KAAK,UAAU,KAAK,OAAO,KAAK,OAAO,MAAM,OAAO,KAAK,QAAQ,MAAM,QAAQ,GAAG,MAAM,CAAC;CAC3G;;CAGA,aAA8D;EAC5D,MAAM,OAAO,KAAK,GAAG,KAAK,OAAO,EAAE;EACnC,OAAO;GAAE,OAAO,KAAK,KAAK,KAAK,KAAK,IAAI;GAAG;GAAM,QAAQ,KAAK;EAAO;CACvE;CAEA,OAAO,OAAe,KAAmB;EACvC,IAAI,CAAC,OAAO,UAAU,KAAK,KAAK,CAAC,OAAO,UAAU,GAAG,KAAK,QAAQ,KAAK,MAAM,SAAS,MAAM,KAAK,QAC/F,MAAM,IAAI,WAAW,aAAa,MAAM,MAAM,IAAI,gCAAgC,KAAK,QAAQ;CAEnG;AACF"}
1
+ {"version":3,"file":"text.js","names":[],"sources":["../../src/text/rope.ts","../../src/text.ts"],"sourcesContent":["/**\n * The `Text` rope: a persistent balanced tree of strings with the width and the length of each subtree. An edit makes a\n * new rope. The new rope shares the subtrees that do not change. The tree is the `summary-tree` record of\n * `@mark1russell7/collections`, and this module gives it the summary of a text.\n *\n * A width function gives the width of a run of text. The rope uses it only for the leaves and for the windows at the\n * seams. Thus an edit uses it of the order of `log n` times. The rope keeps the widths of the short windows, so an edit\n * measures only the windows that it changes. `Text.from` clears this memory.\n *\n * The seams are exact when the width function obeys the separator law. For each text `p + s + q` with a separator `s`:\n * `width(p + s + q) = width(p + s) + width(s + q) - width(s)`. The model of `@mark1russell7/typeset/fonts` obeys it for a space and a\n * tab. It shapes each word alone, and its kerning goes only between two adjacent glyphs.\n */\nimport * as Tree from \"@mark1russell7/collections/summary-tree\";\nimport type { SummarySpec, SummaryTreeRecord } from \"@mark1russell7/collections/summary-tree\";\nimport type { WidthOf } from \"../breaking/paragraph.ts\";\n\n/** The options of a rope. */\nexport interface TextOptions {\n /**\n * The separators of the separator law: each character is one UTF-16 code unit. The default is a space and a tab. An\n * empty string makes each seam measure the full text of the two sides.\n */\n readonly separators?: string;\n /** The largest count of UTF-16 code units in a leaf. The default is 256. */\n readonly chunk?: number;\n}\n\n/** The summary of a run of text: its length, its width, and the two ends that a seam measures again. */\ninterface Summary {\n /** The count of UTF-16 code units. */\n readonly length: number;\n readonly width: number;\n /** This value is `true` when the text has a separator. */\n readonly separated: boolean;\n /** The text through the first separator, or all the text when the text has no separator. */\n readonly head: string;\n readonly headWidth: number;\n /** The text from the last separator, or all the text when the text has no separator. */\n readonly tail: string;\n readonly tailWidth: number;\n}\n\n/** The summary of the empty text. */\nconst noText: Summary = { length: 0, width: 0, separated: false, head: \"\", headWidth: 0, tail: \"\", tailWidth: 0 };\n\n/** The shared state of the ropes of one width function and one set of options. */\ninterface Context {\n readonly width: WidthOf;\n readonly separators: string;\n readonly chunk: number;\n readonly spec: SummarySpec<string, Summary>;\n /** The widths of the short windows. An edit gives the tree new paths, and most windows on these paths do not change. */\n readonly windows: Map<string, number>;\n}\n\n/** The largest count of windows in the memory of a context. */\nconst windowLimit = 16_384;\n\n/** This function gives the width of a window. A window longer than a leaf stays out of the memory. */\nfunction windowWidth(context: Context, window: string): number {\n if (window.length > context.chunk) return context.width(window);\n const known = context.windows.get(window);\n if (known !== undefined) return known;\n const width = context.width(window);\n if (context.windows.size >= windowLimit) context.windows.clear();\n context.windows.set(window, width);\n return width;\n}\n\nfunction isSeparator(separators: string, code: number): boolean {\n for (let i = 0; i < separators.length; i++) if (separators.charCodeAt(i) === code) return true;\n return false;\n}\n\nfunction summaryOfLeaf(context: Context, text: string): Summary {\n const { separators } = context;\n const whole = context.width(text);\n let first = -1;\n let last = -1;\n for (let i = 0; i < text.length; i++) {\n if (!isSeparator(separators, text.charCodeAt(i))) continue;\n if (first < 0) first = i;\n last = i;\n }\n if (first < 0) return { length: text.length, width: whole, separated: false, head: text, headWidth: whole, tail: text, tailWidth: whole };\n const head = text.slice(0, first + 1);\n const tail = text.slice(last);\n return { length: text.length, width: whole, separated: true, head, headWidth: windowWidth(context, head), tail, tailWidth: windowWidth(context, tail) };\n}\n\n/**\n * This function gives the summary of two runs in the order of the text. It measures one window: the tail of the left run and\n * the head of the right run. The separator law then gives the width of all the text from the widths of the two runs.\n */\nfunction combine(context: Context, left: Summary, right: Summary): Summary {\n if (left.length === 0) return right;\n if (right.length === 0) return left;\n const seam = left.tail + right.head;\n const seamWidth = windowWidth(context, seam);\n let width: number;\n if (!left.separated && !right.separated) width = seamWidth;\n else if (!left.separated) width = right.width - right.headWidth + seamWidth;\n else if (!right.separated) width = left.width - left.tailWidth + seamWidth;\n else width = left.width + right.width - left.tailWidth - right.headWidth + seamWidth;\n return {\n length: left.length + right.length,\n width,\n separated: left.separated || right.separated,\n head: left.separated ? left.head : seam,\n headWidth: left.separated ? left.headWidth : seamWidth,\n tail: right.separated ? right.tail : seam,\n tailWidth: right.separated ? right.tailWidth : seamWidth,\n };\n}\n\n/** The contexts of each width function. Two ropes join only when their trees have the same spec. */\nconst contexts = new WeakMap<WidthOf, Map<string, Context>>();\n\nfunction contextOf(width: WidthOf, separators: string, chunk: number): Context {\n const own = contexts.get(width) ?? new Map<string, Context>();\n contexts.set(width, own);\n const key = `${chunk}/${separators}`;\n const known = own.get(key);\n if (known !== undefined) return known;\n const spec: SummarySpec<string, Summary> = {\n monoid: { empty: noText, combine: (left, right) => combine(context, left, right) },\n measure: (leaf) => summaryOfLeaf(context, leaf),\n merge: (left, right) => (left.length + right.length <= chunk ? left + right : undefined),\n };\n const context: Context = { width, separators, chunk, spec, windows: new Map() };\n own.set(key, context);\n return context;\n}\n\n/** This function gives the end of the next leaf of `text` from `start`: after a separator when it can, and not in a surrogate pair. */\nfunction chunkEnd(context: Context, text: string, start: number): number {\n const limit = start + context.chunk;\n if (limit >= text.length) return text.length;\n for (let i = limit - 1; i >= start + context.chunk / 2; i--) if (isSeparator(context.separators, text.charCodeAt(i))) return i + 1;\n const code = text.charCodeAt(limit - 1);\n return code >= 0xd800 && code <= 0xdbff ? limit - 1 : limit;\n}\n\n/** This function divides a text into leaves of at most `chunk` code units. */\nfunction chunksOf(context: Context, text: string): string[] {\n const out: string[] = [];\n for (let start = 0; start < text.length; ) {\n const end = chunkEnd(context, text, start);\n out.push(text.slice(start, end));\n start = end;\n }\n return out;\n}\n\nconst lengthOf = (summary: Summary): number => summary.length;\n\n/**\n * A text with its width: a persistent balanced rope. Each edit gives a new `Text` and does not change this one. The offsets\n * are in UTF-16 code units, as the offsets of a JavaScript string.\n */\nexport class Text {\n readonly #context: Context;\n readonly #tree: SummaryTreeRecord<string, Summary>;\n\n private constructor(context: Context, tree: SummaryTreeRecord<string, Summary>) {\n this.#context = context;\n this.#tree = tree;\n }\n\n /** This function makes the rope of `text` with the width function `width`. */\n static from(text: string, width: WidthOf, options: TextOptions = {}): Text {\n const separators = options.separators ?? \" \\t\";\n const chunk = options.chunk ?? 256;\n if (!Number.isInteger(chunk) || chunk < 2) throw new RangeError(`the chunk is ${chunk}, not an integer of 2 or more`);\n for (let i = 0; i < separators.length; i++) {\n const code = separators.charCodeAt(i);\n if (code >= 0xd800 && code <= 0xdfff) throw new RangeError(\"a separator is one UTF-16 code unit, not a half of a surrogate pair\");\n }\n const context = contextOf(width, separators, chunk);\n // A new rope measures again: the width function can change its result when a font loads\n context.windows.clear();\n return new Text(context, Tree.of(context.spec, chunksOf(context, text)));\n }\n\n /** The count of UTF-16 code units of the text. */\n get length(): number {\n return Tree.summary(this.#tree).length;\n }\n\n /** The width of the text. It is equal to the width of the flat string when the width function obeys the separator law. */\n get width(): number {\n return Tree.summary(this.#tree).width;\n }\n\n /** The height of the tree: 0 for a text of one leaf. The tests use it to examine the balance. */\n get height(): number {\n return Math.max(0, Tree.height(this.#tree) - 1);\n }\n\n /** This function gives the flat string. */\n toString(): string {\n return this.chunks().join(\"\");\n }\n\n /** This function gives the strings of the leaves in the order of the text. */\n chunks(): string[] {\n return Tree.toArray(this.#tree);\n }\n\n /** This function gives the text from `start` to `end`, as a new rope. */\n slice(start: number, end: number = this.length): Text {\n this.#check(start, end);\n if (start === end) return new Text(this.#context, Tree.slice(this.#tree, 0, 0));\n const first = Tree.locate(this.#tree, lengthOf, start)!;\n const last = Tree.locate(this.#tree, lengthOf, end - 1)!;\n const stop = first.offset + end - start;\n const middle = Tree.slice(this.#tree, first.index, last.index + 1);\n if (first.index === last.index) return new Text(this.#context, Tree.set(middle, 0, first.leaf.slice(first.offset, stop)));\n return new Text(this.#context, Tree.set(Tree.set(middle, -1, last.leaf.slice(0, last.offset + 1)), 0, first.leaf.slice(first.offset)));\n }\n\n /** This function gives the width of the text from `start` to `end`. */\n widthOf(start: number, end: number = this.length): number {\n return this.slice(start, end).width;\n }\n\n /** This function gives this text and then `other`. The two ropes must have the same width function and options. */\n concat(other: Text): Text {\n if (other.#context !== this.#context) throw new TypeError(\"the two ropes have different width functions or options\");\n return new Text(this.#context, Tree.concat(this.#tree, other.#tree));\n }\n\n /** This function puts `text` at the offset `at`. */\n insert(at: number, text: string): Text {\n return this.replace(at, at, text);\n }\n\n /** This function removes the text from `start` to `end`. */\n remove(start: number, end: number): Text {\n return this.replace(start, end, \"\");\n }\n\n /** This function puts `text` in place of the text from `start` to `end`. */\n replace(start: number, end: number, text: string): Text {\n this.#check(start, end);\n if (start === end && text.length === 0) return this;\n const size = Tree.size(this.#tree);\n if (size === 0) return Text.from(text, this.#context.width, this.#context);\n const first = Tree.locate(this.#tree, lengthOf, start) ?? this.#lastPlace();\n const last = start === end ? first : Tree.locate(this.#tree, lengthOf, end - 1)!;\n const lastEnd = start === end ? first.offset : last.offset + 1;\n const fresh = first.leaf.slice(0, first.offset) + text + last.leaf.slice(lastEnd);\n const leaves = chunksOf(this.#context, fresh);\n // One long leaf in place of one leaf changes only a path. A short leaf goes through the seams, so that it can merge\n if (first.index === last.index && leaves.length === 1 && leaves[0]!.length * 2 >= this.#context.chunk) {\n return new Text(this.#context, Tree.set(this.#tree, first.index, leaves[0]!));\n }\n return new Text(this.#context, Tree.splice(this.#tree, first.index, last.index - first.index + 1, leaves));\n }\n\n /** This function gives the place after the last code unit: the end of the last leaf. */\n #lastPlace(): { index: number; leaf: string; offset: number } {\n const leaf = Tree.at(this.#tree, -1)!;\n return { index: Tree.size(this.#tree) - 1, leaf, offset: leaf.length };\n }\n\n #check(start: number, end: number): void {\n if (!Number.isInteger(start) || !Number.isInteger(end) || start < 0 || end < start || end > this.length) {\n throw new RangeError(`the range ${start} to ${end} is not in the text of length ${this.length}`);\n }\n }\n}\n","export { Text, type TextOptions } from \"./text/rope.ts\";\n"],"mappings":";;;;;;;;;;;;;;;;;AA4CA,MAAM,SAAkB;CAAE,QAAQ;CAAG,OAAO;CAAG,WAAW;CAAO,MAAM;CAAI,WAAW;CAAG,MAAM;CAAI,WAAW;AAAE;;AAahH,MAAM,cAAc;;AAGpB,SAAS,YAAY,SAAkB,QAAwB;CAC7D,IAAI,OAAO,SAAS,QAAQ,OAAO,OAAO,QAAQ,MAAM,MAAM;CAC9D,MAAM,QAAQ,QAAQ,QAAQ,IAAI,MAAM;CACxC,IAAI,UAAU,KAAA,GAAW,OAAO;CAChC,MAAM,QAAQ,QAAQ,MAAM,MAAM;CAClC,IAAI,QAAQ,QAAQ,QAAQ,aAAa,QAAQ,QAAQ,MAAM;CAC/D,QAAQ,QAAQ,IAAI,QAAQ,KAAK;CACjC,OAAO;AACT;AAEA,SAAS,YAAY,YAAoB,MAAuB;CAC9D,KAAK,IAAI,IAAI,GAAG,IAAI,WAAW,QAAQ,KAAK,IAAI,WAAW,WAAW,CAAC,MAAM,MAAM,OAAO;CAC1F,OAAO;AACT;AAEA,SAAS,cAAc,SAAkB,MAAuB;CAC9D,MAAM,EAAE,eAAe;CACvB,MAAM,QAAQ,QAAQ,MAAM,IAAI;CAChC,IAAI,QAAQ;CACZ,IAAI,O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AAK,OAAO,KAAK,OAAO,UAAU,MAAM,CAAC;EAC9E,MAAM,UAAU,UAAU,MAAM,MAAM,SAAS,KAAK,SAAS;EAC7D,MAAM,QAAQ,MAAM,KAAK,MAAM,GAAG,MAAM,MAAM,IAAI,OAAO,KAAK,KAAK,MAAM,OAAO;EAChF,MAAM,SAAS,SAAS,KAAK,UAAU,KAAK;EAE5C,IAAI,MAAM,UAAU,KAAK,SAAS,OAAO,WAAW,KAAK,OAAO,EAAE,CAAE,SAAS,KAAK,KAAK,SAAS,OAC9F,OAAO,IAAI,KAAK,KAAK,UAAU,KAAK,IAAI,KAAK,OAAO,MAAM,OAAO,OAAO,EAAG,CAAC;EAE9E,OAAO,IAAI,KAAK,KAAK,UAAU,KAAK,OAAO,KAAK,OAAO,MAAM,OAAO,KAAK,QAAQ,MAAM,QAAQ,GAAG,MAAM,CAAC;CAC3G;;CAGA,aAA8D;EAC5D,MAAM,OAAO,KAAK,GAAG,KAAK,OAAO,EAAE;EACnC,OAAO;GAAE,OAAO,KAAK,KAAK,KAAK,KAAK,IAAI;GAAG;GAAM,QAAQ,KAAK;EAAO;CACvE;CAEA,OAAO,OAAe,KAAmB;EACvC,IAAI,CAAC,OAAO,UAAU,KAAK,KAAK,CAAC,OAAO,UAAU,GAAG,KAAK,QAAQ,KAAK,MAAM,SAAS,MAAM,KAAK,QAC/F,MAAM,IAAI,WAAW,aAAa,MAAM,MAAM,IAAI,gCAAgC,KAAK,QAAQ;CAEnG;AACF"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/package",
3
3
  "name": "@mark1russell7/typeset",
4
- "version": "0.8.0",
4
+ "version": "0.8.1",
5
5
  "description": "Text measurement and line breaking. The subpath ./fonts reads font tables and gives widths, ./measurer gives the advance function of a layout, ./breaking has the line breakers, ./hyphen has hyphen patterns for each language, ./segmentation has the break positions of Unicode, ./bidi has the bidirectional algorithm of Unicode, and ./text has a rope.",
6
6
  "keywords": [
7
7
  "typeset",