@noldova/code.editor.angular 0.0.0-stage → 0.0.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.
Files changed (107) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +12 -2
  3. package/api/index.d.ts +30 -0
  4. package/api/index.js +27 -0
  5. package/app/components/code-editor/code-editor.component.d.ts +332 -0
  6. package/app/components/code-editor/code-editor.component.js +648 -0
  7. package/app/components/code-text/code-text.component.d.ts +70 -0
  8. package/app/components/code-text/code-text.component.js +40 -0
  9. package/app/components/find-bar/find-bar.component.d.ts +40 -0
  10. package/app/components/find-bar/find-bar.component.js +95 -0
  11. package/app/enums/code-row-kind.d.ts +14 -0
  12. package/app/enums/code-row-kind.js +15 -0
  13. package/app/enums/fold-shortcut.d.ts +11 -0
  14. package/app/enums/fold-shortcut.js +12 -0
  15. package/app/exceptions/background-job-failed.exception.d.ts +33 -0
  16. package/app/exceptions/background-job-failed.exception.js +15 -0
  17. package/app/interfaces/i-code-decorations.d.ts +103 -0
  18. package/app/interfaces/i-code-decorations.js +7 -0
  19. package/app/interfaces/i-code-editor-view.d.ts +13 -0
  20. package/app/interfaces/i-code-editor-view.js +7 -0
  21. package/app/interfaces/i-code-numbering.d.ts +38 -0
  22. package/app/interfaces/i-code-numbering.js +7 -0
  23. package/app/models/code-editor-view.d.ts +18 -0
  24. package/app/models/code-editor-view.js +26 -0
  25. package/app/models/code-search.d.ts +18 -0
  26. package/app/models/code-search.js +52 -0
  27. package/app/models/code-text-line.d.ts +17 -0
  28. package/app/models/code-text-line.js +42 -0
  29. package/app/models/code-text-span.d.ts +15 -0
  30. package/app/models/code-text-span.js +19 -0
  31. package/app/models/decorations/code-bar-action-event.d.ts +39 -0
  32. package/app/models/decorations/code-bar-action-event.js +15 -0
  33. package/app/models/decorations/code-bar-action.d.ts +40 -0
  34. package/app/models/decorations/code-bar-action.js +17 -0
  35. package/app/models/decorations/code-bar.d.ts +78 -0
  36. package/app/models/decorations/code-bar.js +34 -0
  37. package/app/models/decorations/code-decorations.d.ts +121 -0
  38. package/app/models/decorations/code-decorations.js +42 -0
  39. package/app/models/decorations/code-gutter-marker.d.ts +46 -0
  40. package/app/models/decorations/code-gutter-marker.js +20 -0
  41. package/app/models/decorations/code-line-decoration.d.ts +48 -0
  42. package/app/models/decorations/code-line-decoration.js +21 -0
  43. package/app/models/decorations/code-range-decoration.d.ts +44 -0
  44. package/app/models/decorations/code-range-decoration.js +15 -0
  45. package/app/models/folding/code-block.d.ts +17 -0
  46. package/app/models/folding/code-block.js +21 -0
  47. package/app/models/folding/code-blocks.d.ts +17 -0
  48. package/app/models/folding/code-blocks.js +32 -0
  49. package/app/models/folding/code-fold.d.ts +53 -0
  50. package/app/models/folding/code-fold.js +23 -0
  51. package/app/models/folding/fold-shortcuts.d.ts +14 -0
  52. package/app/models/folding/fold-shortcuts.js +17 -0
  53. package/app/models/language-tokenizer.d.ts +39 -0
  54. package/app/models/language-tokenizer.js +22 -0
  55. package/app/models/rows/code-embedded-lines.d.ts +76 -0
  56. package/app/models/rows/code-embedded-lines.js +43 -0
  57. package/app/models/rows/code-inserted-rows.d.ts +19 -0
  58. package/app/models/rows/code-inserted-rows.js +7 -0
  59. package/app/models/rows/code-row.d.ts +27 -0
  60. package/app/models/rows/code-row.js +31 -0
  61. package/app/models/rows/code-spacer.d.ts +61 -0
  62. package/app/models/rows/code-spacer.js +30 -0
  63. package/app/models/rows/inserted-rows.d.ts +12 -0
  64. package/app/models/rows/inserted-rows.js +18 -0
  65. package/app/models/rows/layer-lines.d.ts +18 -0
  66. package/app/models/rows/layer-lines.js +17 -0
  67. package/app/models/rows/layout-row.d.ts +14 -0
  68. package/app/models/rows/layout-row.js +17 -0
  69. package/app/models/rows/line-index.d.ts +58 -0
  70. package/app/models/rows/line-index.js +50 -0
  71. package/app/models/rows/row-builder.d.ts +35 -0
  72. package/app/models/rows/row-builder.js +87 -0
  73. package/app/models/rows/row-layout.d.ts +22 -0
  74. package/app/models/rows/row-layout.js +58 -0
  75. package/app/models/rows/row-span.d.ts +13 -0
  76. package/app/models/rows/row-span.js +17 -0
  77. package/app/models/shapes/bar-shape.d.ts +13 -0
  78. package/app/models/shapes/bar-shape.js +15 -0
  79. package/app/models/shapes/change-shape.d.ts +14 -0
  80. package/app/models/shapes/change-shape.js +19 -0
  81. package/app/models/shapes/code-shape.d.ts +14 -0
  82. package/app/models/shapes/code-shape.js +19 -0
  83. package/app/models/shapes/match-shape.d.ts +14 -0
  84. package/app/models/shapes/match-shape.js +19 -0
  85. package/app/models/text-measure.d.ts +18 -0
  86. package/app/models/text-measure.js +50 -0
  87. package/app/models/view-command.d.ts +16 -0
  88. package/app/models/view-command.js +24 -0
  89. package/app/services/background-ticker.d.ts +47 -0
  90. package/app/services/background-ticker.js +34 -0
  91. package/app/services/code-editor-classes.d.ts +102 -0
  92. package/app/services/code-editor-classes.js +30 -0
  93. package/app/services/code-editor-contribution.d.ts +20 -0
  94. package/app/services/code-editor-contribution.js +41 -0
  95. package/app/services/code-editor-features.d.ts +13 -0
  96. package/app/services/code-editor-features.js +13 -0
  97. package/app/services/code-editor-registries.d.ts +43 -0
  98. package/app/services/code-editor-registries.js +23 -0
  99. package/app/services/key-scope.d.ts +79 -0
  100. package/app/services/key-scope.js +53 -0
  101. package/app/services/token-style-sheet.d.ts +11 -0
  102. package/app/services/token-style-sheet.js +44 -0
  103. package/app/services/worker-runner.d.ts +87 -0
  104. package/app/services/worker-runner.js +84 -0
  105. package/package.json +38 -4
  106. package/resources.d.ts +124 -0
  107. package/resources.js +137 -0
@@ -0,0 +1,70 @@
1
+ /**
2
+ * @license
3
+ * Copyright (c) Noldova.
4
+ *
5
+ * This source code is licensed under the license found in the
6
+ * LICENSE file in the root directory of this source tree.
7
+ */
8
+ import { type InputSignal, type Signal } from "@angular/core";
9
+ import { type ILanguageDefinition } from "@noldova/code.editor";
10
+ import type { IReadOnlyList } from "@noldova/context.collections";
11
+ import { CodeTextLine } from "../../models/code-text-line.js";
12
+ import type { CodeTextSpan } from "../../models/code-text-span.js";
13
+ import * as i0 from "@angular/core";
14
+ /**
15
+ * The `noldova-code-text` component: a read-only block of code, colored by
16
+ * its language and the token types of {@link CodeEditorRegistries}, with no
17
+ * gutter, caret or scrolling of its own.
18
+ *
19
+ * @example
20
+ * ```ts
21
+ * import { Component } from "@angular/core";
22
+ * import { CodeTextComponent } from "@noldova/code.editor.angular";
23
+ *
24
+ * @Component({
25
+ * selector: "app-snippet",
26
+ * imports: [CodeTextComponent],
27
+ * template: "<noldova-code-text text=\"const a = 1;\" />"
28
+ * })
29
+ * export class SnippetComponent {}
30
+ * ```
31
+ */
32
+ export declare class CodeTextComponent {
33
+ /**
34
+ * The code to show; required.
35
+ */
36
+ readonly text: InputSignal<string>;
37
+ /**
38
+ * The language that colors the code: its id in the app's
39
+ * {@link CodeEditorRegistries}, its definition, or null, when not bound,
40
+ * for plain text. The view finds the language's highlighter and makes its
41
+ * tokenizer in the background, showing the text plain until it is ready,
42
+ * and for good when no highlighter supports the language or its load fails.
43
+ */
44
+ readonly language: InputSignal<string | ILanguageDefinition | null>;
45
+ private readonly tokenizer;
46
+ protected readonly lines: Signal<IReadOnlyList<CodeTextLine>>;
47
+ private readonly app;
48
+ private readonly registries;
49
+ /**
50
+ * Creates the view, which Angular does for each `noldova-code-text`
51
+ * element, and puts the app's token rules in the page.
52
+ *
53
+ * @example
54
+ * ```ts
55
+ * import { Component } from "@angular/core";
56
+ * import { CodeTextComponent } from "@noldova/code.editor.angular";
57
+ *
58
+ * @Component({
59
+ * selector: "app-snippet",
60
+ * imports: [CodeTextComponent],
61
+ * template: "<noldova-code-text text=\"let a = 1;\" />"
62
+ * })
63
+ * export class SnippetComponent {}
64
+ * ```
65
+ */
66
+ constructor();
67
+ protected classOf(span: CodeTextSpan): string;
68
+ static ɵfac: i0.ɵɵFactoryDeclaration<CodeTextComponent, never>;
69
+ static ɵcmp: i0.ɵɵComponentDeclaration<CodeTextComponent, "noldova-code-text", never, { "text": { "alias": "text"; "required": true; "isSignal": true; }; "language": { "alias": "language"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
70
+ }
@@ -0,0 +1,40 @@
1
+ /**
2
+ * @license
3
+ * Copyright (c) Noldova.
4
+ *
5
+ * This source code is licensed under the license found in the
6
+ * LICENSE file in the root directory of this source tree.
7
+ */
8
+ import { Component, computed, inject, input } from "@angular/core";
9
+ import { EditorRegistries, TokenStyles } from "@noldova/code.editor";
10
+ import { Resources } from "../../../resources.js";
11
+ import { CodeTextLine } from "../../models/code-text-line.js";
12
+ import { LanguageTokenizer } from "../../models/language-tokenizer.js";
13
+ import { CodeEditorRegistries } from "../../services/code-editor-registries.js";
14
+ import { TokenStyleSheet } from "../../services/token-style-sheet.js";
15
+ import * as i0 from "@angular/core";
16
+ export class CodeTextComponent {
17
+ text = input.required(/* @ts-ignore */
18
+ ...(ngDevMode ? [{ debugName: "text" }] : /* istanbul ignore next */ []));
19
+ language = input(null, /* @ts-ignore */
20
+ ...(ngDevMode ? [{ debugName: "language" }] : /* istanbul ignore next */ []));
21
+ tokenizer = LanguageTokenizer.of(this.language);
22
+ lines = computed(() => CodeTextLine.linesOf(this.text(), this.tokenizer()), /* @ts-ignore */
23
+ ...(ngDevMode ? [{ debugName: "lines" }] : /* istanbul ignore next */ []));
24
+ app = inject(CodeEditorRegistries).registries;
25
+ registries = new EditorRegistries(this.app);
26
+ constructor() {
27
+ inject(TokenStyleSheet).apply(this.app.tokenTypes, Resources.textTokenClassPrefix);
28
+ }
29
+ classOf(span) {
30
+ return Resources.formatClassList(TokenStyles.classesOf(this.registries.tokenTypes, span.type, span.modifiers, Resources.textTokenClassPrefix));
31
+ }
32
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.3.0", ngImport: i0, type: CodeTextComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
33
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.3.0", type: CodeTextComponent, isStandalone: true, selector: "noldova-code-text", inputs: { text: { classPropertyName: "text", publicName: "text", isSignal: true, isRequired: true, transformFunction: null }, language: { classPropertyName: "language", publicName: "language", isSignal: true, isRequired: false, transformFunction: null } }, host: { classAttribute: "nol-code-text" }, ngImport: i0, template: "<!--\n@license\nCopyright (c) Noldova.\n\nThis source code is licensed under the license found in the\nLICENSE file in the root directory of this source tree.\n-->\n\n@for (line of lines(); track $index) {\n <span class=\"nol-code-text-line\">@for (span of line.spans; track $index) {@if (classOf(span) === \"\") {{{ span.text }}} @else {<span [class]=\"classOf(span)\">{{ span.text }}</span>}}</span>\n}\n", styles: ["/**\n * @license\n * Copyright (c) Noldova.\n *\n * This source code is licensed under the license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\n:host {\n display: block;\n font-family: var(--nol-font-mono);\n white-space: pre;\n}\n\n.nol-code-text-line {\n display: block;\n min-height: 1lh;\n}\n"] });
34
+ }
35
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.3.0", ngImport: i0, type: CodeTextComponent, decorators: [{
36
+ type: Component,
37
+ args: [{ selector: "noldova-code-text", host: {
38
+ "class": Resources.codeTextClass
39
+ }, template: "<!--\n@license\nCopyright (c) Noldova.\n\nThis source code is licensed under the license found in the\nLICENSE file in the root directory of this source tree.\n-->\n\n@for (line of lines(); track $index) {\n <span class=\"nol-code-text-line\">@for (span of line.spans; track $index) {@if (classOf(span) === \"\") {{{ span.text }}} @else {<span [class]=\"classOf(span)\">{{ span.text }}</span>}}</span>\n}\n", styles: ["/**\n * @license\n * Copyright (c) Noldova.\n *\n * This source code is licensed under the license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\n:host {\n display: block;\n font-family: var(--nol-font-mono);\n white-space: pre;\n}\n\n.nol-code-text-line {\n display: block;\n min-height: 1lh;\n}\n"] }]
40
+ }], ctorParameters: () => [], propDecorators: { text: [{ type: i0.Input, args: [{ isSignal: true, alias: "text", required: true }] }], language: [{ type: i0.Input, args: [{ isSignal: true, alias: "language", required: false }] }] } });
@@ -0,0 +1,40 @@
1
+ /**
2
+ * @license
3
+ * Copyright (c) Noldova.
4
+ *
5
+ * This source code is licensed under the license found in the
6
+ * LICENSE file in the root directory of this source tree.
7
+ */
8
+ import { type InputSignal, type OutputEmitterRef, type WritableSignal } from "@angular/core";
9
+ import { SearchQuery } from "@noldova/code.editor";
10
+ import { Resources } from "../../../resources.js";
11
+ import * as i0 from "@angular/core";
12
+ export declare class FindBarComponent {
13
+ private readonly findField;
14
+ private readonly replaceField;
15
+ readonly seed: InputSignal<string>;
16
+ readonly status: InputSignal<string>;
17
+ readonly replacing: InputSignal<boolean>;
18
+ readonly queryChange: OutputEmitterRef<SearchQuery>;
19
+ readonly next: OutputEmitterRef<void>;
20
+ readonly previous: OutputEmitterRef<void>;
21
+ readonly replace: OutputEmitterRef<string>;
22
+ readonly replaceAll: OutputEmitterRef<string>;
23
+ readonly dismiss: OutputEmitterRef<void>;
24
+ protected readonly text: WritableSignal<string>;
25
+ protected readonly caseSensitive: WritableSignal<boolean>;
26
+ protected readonly wholeWord: WritableSignal<boolean>;
27
+ protected readonly regex: WritableSignal<boolean>;
28
+ protected readonly replacement: WritableSignal<string>;
29
+ protected readonly resources: typeof Resources;
30
+ constructor();
31
+ open(text: string): void;
32
+ protected onText(): void;
33
+ protected onReplacement(): void;
34
+ protected toggle(option: WritableSignal<boolean>): void;
35
+ protected onFindKey(event: KeyboardEvent): void;
36
+ protected onReplaceKey(event: KeyboardEvent): void;
37
+ private emitQuery;
38
+ static ɵfac: i0.ɵɵFactoryDeclaration<FindBarComponent, never>;
39
+ static ɵcmp: i0.ɵɵComponentDeclaration<FindBarComponent, "noldova-find-bar", never, { "seed": { "alias": "seed"; "required": false; "isSignal": true; }; "status": { "alias": "status"; "required": true; "isSignal": true; }; "replacing": { "alias": "replacing"; "required": false; "isSignal": true; }; }, { "queryChange": "queryChange"; "next": "next"; "previous": "previous"; "replace": "replace"; "replaceAll": "replaceAll"; "dismiss": "dismiss"; }, never, never, true, never>;
40
+ }
@@ -0,0 +1,95 @@
1
+ /**
2
+ * @license
3
+ * Copyright (c) Noldova.
4
+ *
5
+ * This source code is licensed under the license found in the
6
+ * LICENSE file in the root directory of this source tree.
7
+ */
8
+ import { afterNextRender, Component, ElementRef, input, output, signal, viewChild } from "@angular/core";
9
+ import { Required, SearchQuery } from "@noldova/code.editor";
10
+ import { IconButtonComponent, TextFieldComponent } from "@noldova/ui.components.angular";
11
+ import { Resources } from "../../../resources.js";
12
+ import * as i0 from "@angular/core";
13
+ export class FindBarComponent {
14
+ findField = viewChild.required("find", { ...(ngDevMode ? { debugName: "findField" } : /* istanbul ignore next */ {}), read: ElementRef });
15
+ replaceField = viewChild("replaceField", { ...(ngDevMode ? { debugName: "replaceField" } : /* istanbul ignore next */ {}), read: ElementRef });
16
+ seed = input(Resources.empty, /* @ts-ignore */
17
+ ...(ngDevMode ? [{ debugName: "seed" }] : /* istanbul ignore next */ []));
18
+ status = input.required(/* @ts-ignore */
19
+ ...(ngDevMode ? [{ debugName: "status" }] : /* istanbul ignore next */ []));
20
+ replacing = input(false, /* @ts-ignore */
21
+ ...(ngDevMode ? [{ debugName: "replacing" }] : /* istanbul ignore next */ []));
22
+ queryChange = output();
23
+ next = output();
24
+ previous = output();
25
+ replace = output();
26
+ replaceAll = output();
27
+ dismiss = output();
28
+ text = signal(Resources.empty, /* @ts-ignore */
29
+ ...(ngDevMode ? [{ debugName: "text" }] : /* istanbul ignore next */ []));
30
+ caseSensitive = signal(false, /* @ts-ignore */
31
+ ...(ngDevMode ? [{ debugName: "caseSensitive" }] : /* istanbul ignore next */ []));
32
+ wholeWord = signal(false, /* @ts-ignore */
33
+ ...(ngDevMode ? [{ debugName: "wholeWord" }] : /* istanbul ignore next */ []));
34
+ regex = signal(false, /* @ts-ignore */
35
+ ...(ngDevMode ? [{ debugName: "regex" }] : /* istanbul ignore next */ []));
36
+ replacement = signal(Resources.empty, /* @ts-ignore */
37
+ ...(ngDevMode ? [{ debugName: "replacement" }] : /* istanbul ignore next */ []));
38
+ resources = Resources;
39
+ constructor() {
40
+ afterNextRender(() => this.open(this.seed()));
41
+ }
42
+ open(text) {
43
+ this.text.set(text);
44
+ this.emitQuery();
45
+ const field = this.findField().nativeElement;
46
+ field.value = text;
47
+ field.focus();
48
+ field.select();
49
+ }
50
+ onText() {
51
+ this.text.set(this.findField().nativeElement.value);
52
+ this.emitQuery();
53
+ }
54
+ onReplacement() {
55
+ this.replacement.set(Required.value(this.replaceField()).nativeElement.value);
56
+ }
57
+ toggle(option) {
58
+ option.update(t => !t);
59
+ this.emitQuery();
60
+ }
61
+ onFindKey(event) {
62
+ if (event.key === Resources.keyEnter) {
63
+ event.preventDefault();
64
+ if (event.shiftKey)
65
+ this.previous.emit();
66
+ else
67
+ this.next.emit();
68
+ }
69
+ else if (event.key === Resources.keyEscape) {
70
+ event.preventDefault();
71
+ this.dismiss.emit();
72
+ }
73
+ }
74
+ onReplaceKey(event) {
75
+ if (event.key === Resources.keyEnter) {
76
+ event.preventDefault();
77
+ this.replace.emit(this.replacement());
78
+ }
79
+ else if (event.key === Resources.keyEscape) {
80
+ event.preventDefault();
81
+ this.dismiss.emit();
82
+ }
83
+ }
84
+ emitQuery() {
85
+ this.queryChange.emit(new SearchQuery(this.text(), this.regex(), this.caseSensitive(), this.wholeWord()));
86
+ }
87
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.3.0", ngImport: i0, type: FindBarComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
88
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.3.0", type: FindBarComponent, isStandalone: true, selector: "noldova-find-bar", inputs: { seed: { classPropertyName: "seed", publicName: "seed", isSignal: true, isRequired: false, transformFunction: null }, status: { classPropertyName: "status", publicName: "status", isSignal: true, isRequired: true, transformFunction: null }, replacing: { classPropertyName: "replacing", publicName: "replacing", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { queryChange: "queryChange", next: "next", previous: "previous", replace: "replace", replaceAll: "replaceAll", dismiss: "dismiss" }, host: { classAttribute: "nol-find-bar" }, viewQueries: [{ propertyName: "findField", first: true, predicate: ["find"], descendants: true, read: ElementRef, isSignal: true }, { propertyName: "replaceField", first: true, predicate: ["replaceField"], descendants: true, read: ElementRef, isSignal: true }], ngImport: i0, template: "<!--\n@license\nCopyright (c) Noldova.\n\nThis source code is licensed under the license found in the\nLICENSE file in the root directory of this source tree.\n-->\n<div class=\"nol-find-bar-row\">\n <input #find nol-text-field class=\"nol-find-bar-field\" type=\"text\" [attr.aria-label]=\"resources.findLabel\" [placeholder]=\"resources.findLabel\"\n autocomplete=\"off\" spellcheck=\"false\" (input)=\"onText()\" (keydown)=\"onFindKey($event)\" />\n <button nol-icon-button type=\"button\" icon=\"match_case\" [label]=\"resources.matchCaseLabel\" [pressed]=\"caseSensitive()\" (click)=\"toggle(caseSensitive)\"></button>\n <button nol-icon-button type=\"button\" icon=\"match_word\" [label]=\"resources.wholeWordLabel\" [pressed]=\"wholeWord()\" (click)=\"toggle(wholeWord)\"></button>\n <button nol-icon-button type=\"button\" icon=\"regular_expression\" [label]=\"resources.regexLabel\" [pressed]=\"regex()\" (click)=\"toggle(regex)\"></button>\n <span class=\"nol-find-bar-status\" role=\"status\">{{ status() }}</span>\n <button nol-icon-button type=\"button\" icon=\"arrow_upward\" [label]=\"resources.previousMatchLabel\" (click)=\"previous.emit()\"></button>\n <button nol-icon-button type=\"button\" icon=\"arrow_downward\" [label]=\"resources.nextMatchLabel\" (click)=\"next.emit()\"></button>\n <button nol-icon-button type=\"button\" icon=\"close\" [label]=\"resources.closeLabel\" (click)=\"dismiss.emit()\"></button>\n</div>\n@if (replacing()) {\n <div class=\"nol-find-bar-row\">\n <input #replaceField nol-text-field class=\"nol-find-bar-field\" type=\"text\" [attr.aria-label]=\"resources.replaceLabel\" [placeholder]=\"resources.replaceLabel\"\n autocomplete=\"off\" spellcheck=\"false\" (input)=\"onReplacement()\" (keydown)=\"onReplaceKey($event)\" />\n <button nol-icon-button type=\"button\" icon=\"find_replace\" [label]=\"resources.replaceOneLabel\" (click)=\"replace.emit(replacement())\"></button>\n <button nol-icon-button type=\"button\" icon=\"done_all\" [label]=\"resources.replaceAllLabel\" (click)=\"replaceAll.emit(replacement())\"></button>\n </div>\n}\n", styles: ["/**\n * @license\n * Copyright (c) Noldova.\n *\n * This source code is licensed under the license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\n:host {\n display: flex;\n position: absolute;\n top: 0;\n inset-inline-end: var(--nol-space-4);\n z-index: 3;\n flex-direction: column;\n gap: var(--nol-space-1);\n box-sizing: border-box;\n max-width: calc(100% - var(--nol-space-4) * 2);\n padding: var(--nol-space-1) var(--nol-space-2);\n border: var(--nol-border-width) solid var(--nol-widget-border);\n border-block-start: none;\n border-end-start-radius: var(--nol-radius-small);\n border-end-end-radius: var(--nol-radius-small);\n background-color: var(--nol-hover-widget);\n box-shadow: var(--nol-shadow-large);\n color: var(--nol-text);\n font-family: var(--nol-font-sans);\n font-size: var(--nol-text-label);\n line-height: var(--nol-line-label);\n cursor: default;\n}\n\n.nol-find-bar-row {\n display: flex;\n align-items: center;\n gap: var(--nol-space-1);\n min-width: 0;\n}\n\n.nol-find-bar-field {\n flex: 1 1 auto;\n width: 14rem;\n min-width: 0;\n}\n\n.nol-find-bar-status {\n flex: none;\n min-width: 5rem;\n color: var(--nol-text-muted);\n text-align: center;\n white-space: nowrap;\n}\n"], dependencies: [{ kind: "component", type: IconButtonComponent, selector: "button[nol-icon-button]", inputs: ["icon", "label", "pressed", "filled", "overlay", "backdrop", "buttonHeight", "danger", "tabAction", "busy", "busyPressable"] }, { kind: "component", type: TextFieldComponent, selector: "input[nol-text-field], textarea[nol-text-field]", inputs: ["quiet"] }] });
89
+ }
90
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.3.0", ngImport: i0, type: FindBarComponent, decorators: [{
91
+ type: Component,
92
+ args: [{ selector: "noldova-find-bar", imports: [IconButtonComponent, TextFieldComponent], host: {
93
+ "class": Resources.findBarClass
94
+ }, template: "<!--\n@license\nCopyright (c) Noldova.\n\nThis source code is licensed under the license found in the\nLICENSE file in the root directory of this source tree.\n-->\n<div class=\"nol-find-bar-row\">\n <input #find nol-text-field class=\"nol-find-bar-field\" type=\"text\" [attr.aria-label]=\"resources.findLabel\" [placeholder]=\"resources.findLabel\"\n autocomplete=\"off\" spellcheck=\"false\" (input)=\"onText()\" (keydown)=\"onFindKey($event)\" />\n <button nol-icon-button type=\"button\" icon=\"match_case\" [label]=\"resources.matchCaseLabel\" [pressed]=\"caseSensitive()\" (click)=\"toggle(caseSensitive)\"></button>\n <button nol-icon-button type=\"button\" icon=\"match_word\" [label]=\"resources.wholeWordLabel\" [pressed]=\"wholeWord()\" (click)=\"toggle(wholeWord)\"></button>\n <button nol-icon-button type=\"button\" icon=\"regular_expression\" [label]=\"resources.regexLabel\" [pressed]=\"regex()\" (click)=\"toggle(regex)\"></button>\n <span class=\"nol-find-bar-status\" role=\"status\">{{ status() }}</span>\n <button nol-icon-button type=\"button\" icon=\"arrow_upward\" [label]=\"resources.previousMatchLabel\" (click)=\"previous.emit()\"></button>\n <button nol-icon-button type=\"button\" icon=\"arrow_downward\" [label]=\"resources.nextMatchLabel\" (click)=\"next.emit()\"></button>\n <button nol-icon-button type=\"button\" icon=\"close\" [label]=\"resources.closeLabel\" (click)=\"dismiss.emit()\"></button>\n</div>\n@if (replacing()) {\n <div class=\"nol-find-bar-row\">\n <input #replaceField nol-text-field class=\"nol-find-bar-field\" type=\"text\" [attr.aria-label]=\"resources.replaceLabel\" [placeholder]=\"resources.replaceLabel\"\n autocomplete=\"off\" spellcheck=\"false\" (input)=\"onReplacement()\" (keydown)=\"onReplaceKey($event)\" />\n <button nol-icon-button type=\"button\" icon=\"find_replace\" [label]=\"resources.replaceOneLabel\" (click)=\"replace.emit(replacement())\"></button>\n <button nol-icon-button type=\"button\" icon=\"done_all\" [label]=\"resources.replaceAllLabel\" (click)=\"replaceAll.emit(replacement())\"></button>\n </div>\n}\n", styles: ["/**\n * @license\n * Copyright (c) Noldova.\n *\n * This source code is licensed under the license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\n:host {\n display: flex;\n position: absolute;\n top: 0;\n inset-inline-end: var(--nol-space-4);\n z-index: 3;\n flex-direction: column;\n gap: var(--nol-space-1);\n box-sizing: border-box;\n max-width: calc(100% - var(--nol-space-4) * 2);\n padding: var(--nol-space-1) var(--nol-space-2);\n border: var(--nol-border-width) solid var(--nol-widget-border);\n border-block-start: none;\n border-end-start-radius: var(--nol-radius-small);\n border-end-end-radius: var(--nol-radius-small);\n background-color: var(--nol-hover-widget);\n box-shadow: var(--nol-shadow-large);\n color: var(--nol-text);\n font-family: var(--nol-font-sans);\n font-size: var(--nol-text-label);\n line-height: var(--nol-line-label);\n cursor: default;\n}\n\n.nol-find-bar-row {\n display: flex;\n align-items: center;\n gap: var(--nol-space-1);\n min-width: 0;\n}\n\n.nol-find-bar-field {\n flex: 1 1 auto;\n width: 14rem;\n min-width: 0;\n}\n\n.nol-find-bar-status {\n flex: none;\n min-width: 5rem;\n color: var(--nol-text-muted);\n text-align: center;\n white-space: nowrap;\n}\n"] }]
95
+ }], ctorParameters: () => [], propDecorators: { findField: [{ type: i0.ViewChild, args: ["find", { ...{ read: ElementRef }, isSignal: true }] }], replaceField: [{ type: i0.ViewChild, args: ["replaceField", { ...{ read: ElementRef }, isSignal: true }] }], seed: [{ type: i0.Input, args: [{ isSignal: true, alias: "seed", required: false }] }], status: [{ type: i0.Input, args: [{ isSignal: true, alias: "status", required: true }] }], replacing: [{ type: i0.Input, args: [{ isSignal: true, alias: "replacing", required: false }] }], queryChange: [{ type: i0.Output, args: ["queryChange"] }], next: [{ type: i0.Output, args: ["next"] }], previous: [{ type: i0.Output, args: ["previous"] }], replace: [{ type: i0.Output, args: ["replace"] }], replaceAll: [{ type: i0.Output, args: ["replaceAll"] }], dismiss: [{ type: i0.Output, args: ["dismiss"] }] } });
@@ -0,0 +1,14 @@
1
+ /**
2
+ * @license
3
+ * Copyright (c) Noldova.
4
+ *
5
+ * This source code is licensed under the license found in the
6
+ * LICENSE file in the root directory of this source tree.
7
+ */
8
+ export declare enum CodeRowKind {
9
+ Line = "Line",
10
+ Spacer = "Spacer",
11
+ Bar = "Bar",
12
+ Embedded = "Embedded",
13
+ Fold = "Fold"
14
+ }
@@ -0,0 +1,15 @@
1
+ /**
2
+ * @license
3
+ * Copyright (c) Noldova.
4
+ *
5
+ * This source code is licensed under the license found in the
6
+ * LICENSE file in the root directory of this source tree.
7
+ */
8
+ export var CodeRowKind;
9
+ (function (CodeRowKind) {
10
+ CodeRowKind["Line"] = "Line";
11
+ CodeRowKind["Spacer"] = "Spacer";
12
+ CodeRowKind["Bar"] = "Bar";
13
+ CodeRowKind["Embedded"] = "Embedded";
14
+ CodeRowKind["Fold"] = "Fold";
15
+ })(CodeRowKind || (CodeRowKind = {}));
@@ -0,0 +1,11 @@
1
+ /**
2
+ * @license
3
+ * Copyright (c) Noldova.
4
+ *
5
+ * This source code is licensed under the license found in the
6
+ * LICENSE file in the root directory of this source tree.
7
+ */
8
+ export declare enum FoldShortcut {
9
+ Fold = "Fold",
10
+ Unfold = "Unfold"
11
+ }
@@ -0,0 +1,12 @@
1
+ /**
2
+ * @license
3
+ * Copyright (c) Noldova.
4
+ *
5
+ * This source code is licensed under the license found in the
6
+ * LICENSE file in the root directory of this source tree.
7
+ */
8
+ export var FoldShortcut;
9
+ (function (FoldShortcut) {
10
+ FoldShortcut["Fold"] = "Fold";
11
+ FoldShortcut["Unfold"] = "Unfold";
12
+ })(FoldShortcut || (FoldShortcut = {}));
@@ -0,0 +1,33 @@
1
+ /**
2
+ * @license
3
+ * Copyright (c) Noldova.
4
+ *
5
+ * This source code is licensed under the license found in the
6
+ * LICENSE file in the root directory of this source tree.
7
+ */
8
+ import { Exception } from "@noldova/context.exceptions";
9
+ /**
10
+ * Reports that a background job failed in a {@link WorkerRunner}'s worker,
11
+ * or that the runner was disposed before the job ended.
12
+ */
13
+ export declare class BackgroundJobFailedException extends Exception {
14
+ /**
15
+ * `BackgroundJobFailedException`.
16
+ */
17
+ readonly name: string;
18
+ /**
19
+ * Creates the exception with the message
20
+ * "The background job `job` failed in the worker: `reason`."
21
+ *
22
+ * @param job The job's name.
23
+ * @param reason A short reason, such as an error's message; the message
24
+ * ends with one period whether or not it has one.
25
+ * @example
26
+ * ```ts
27
+ * import { BackgroundJobFailedException } from "@noldova/code.editor.angular";
28
+ *
29
+ * new BackgroundJobFailedException("sample.sum", "the runner was disposed").message;
30
+ * ```
31
+ */
32
+ constructor(job: string, reason: string);
33
+ }
@@ -0,0 +1,15 @@
1
+ /**
2
+ * @license
3
+ * Copyright (c) Noldova.
4
+ *
5
+ * This source code is licensed under the license found in the
6
+ * LICENSE file in the root directory of this source tree.
7
+ */
8
+ import { Exception } from "@noldova/context.exceptions";
9
+ import { Resources } from "../../resources.js";
10
+ export class BackgroundJobFailedException extends Exception {
11
+ name = Resources.backgroundJobFailedExceptionName;
12
+ constructor(job, reason) {
13
+ super(Resources.formatBackgroundJobFailed(job, reason));
14
+ }
15
+ }
@@ -0,0 +1,103 @@
1
+ /**
2
+ * @license
3
+ * Copyright (c) Noldova.
4
+ *
5
+ * This source code is licensed under the license found in the
6
+ * LICENSE file in the root directory of this source tree.
7
+ */
8
+ import type { IReadOnlyList } from "@noldova/context.collections";
9
+ import type { CodeGutterMarker } from "../models/decorations/code-gutter-marker.js";
10
+ import type { CodeInsertedRows } from "../models/rows/code-inserted-rows.js";
11
+ import type { CodeLineDecoration } from "../models/decorations/code-line-decoration.js";
12
+ import type { CodeRangeDecoration } from "../models/decorations/code-range-decoration.js";
13
+ import type { ICodeNumbering } from "./i-code-numbering.js";
14
+ /**
15
+ * A layer of decorations on the code view, which asks it only for the lines
16
+ * it draws, so a layer can compute them lazily; {@link CodeDecorations} is
17
+ * the layer held in lists.
18
+ *
19
+ * @remarks
20
+ * The view draws its layers in order, a later one over an earlier one. In
21
+ * 0.0.x the positions are the layer's owner's to remap after an edit.
22
+ *
23
+ * The interface grows only by optional members, so a layer written for an
24
+ * earlier version keeps compiling and drawing as it did.
25
+ */
26
+ export interface ICodeDecorations {
27
+ /**
28
+ * The rows the layer inserts between lines.
29
+ */
30
+ readonly rows: IReadOnlyList<CodeInsertedRows>;
31
+ /**
32
+ * A second line number column, or null; the latest layer that has one
33
+ * numbers the view.
34
+ */
35
+ readonly numbering: ICodeNumbering | null;
36
+ /**
37
+ * Gives the line decorations that reach a run of lines.
38
+ *
39
+ * @param start The run's first line, from 0.
40
+ * @param end The line after the run.
41
+ * @returns The line decorations, in the layer's order.
42
+ * @example
43
+ * ```ts
44
+ * import { type IReadOnlyList, List } from "@noldova/context.collections";
45
+ * import { type CodeGutterMarker, type CodeInsertedRows, CodeLineDecoration, type CodeRangeDecoration, type ICodeDecorations, type ICodeNumbering } from "@noldova/code.editor.angular";
46
+ *
47
+ * class EveryOtherLine implements ICodeDecorations {
48
+ * public readonly rows: IReadOnlyList<CodeInsertedRows> = new List<CodeInsertedRows>();
49
+ * public readonly numbering: ICodeNumbering | null = null;
50
+ *
51
+ * public linesIn(start: number, end: number): IReadOnlyList<CodeLineDecoration> {
52
+ * const lines: List<CodeLineDecoration> = new List<CodeLineDecoration>();
53
+ * for (let line = start + start % 2; line < end; line += 2)
54
+ * lines.add(new CodeLineDecoration(line, 1, "var(--nol-code-header)"));
55
+ *
56
+ * return lines;
57
+ * }
58
+ *
59
+ * public rangesIn(): IReadOnlyList<CodeRangeDecoration> {
60
+ * return new List<CodeRangeDecoration>();
61
+ * }
62
+ *
63
+ * public markersIn(): IReadOnlyList<CodeGutterMarker> {
64
+ * return new List<CodeGutterMarker>();
65
+ * }
66
+ * }
67
+ * ```
68
+ */
69
+ linesIn(start: number, end: number): IReadOnlyList<CodeLineDecoration>;
70
+ /**
71
+ * Gives the range decorations that reach a run of lines.
72
+ *
73
+ * @param start The run's first line, from 0.
74
+ * @param end The line after the run.
75
+ * @returns The range decorations, in the layer's order.
76
+ * @example
77
+ * ```ts
78
+ * import { type IReadOnlyList, List } from "@noldova/context.collections";
79
+ * import type { CodeRangeDecoration } from "@noldova/code.editor.angular";
80
+ *
81
+ * const matches: IReadOnlyList<CodeRangeDecoration> = new List<CodeRangeDecoration>();
82
+ * const rangesIn = (start: number, end: number): IReadOnlyList<CodeRangeDecoration> =>
83
+ * matches.where(t => t.range.start.line < end && t.range.end.line >= start).toList();
84
+ * ```
85
+ */
86
+ rangesIn(start: number, end: number): IReadOnlyList<CodeRangeDecoration>;
87
+ /**
88
+ * Gives the gutter markers on a run of lines.
89
+ *
90
+ * @param start The run's first line, from 0.
91
+ * @param end The line after the run.
92
+ * @returns The markers, in the layer's order; the last one on a line shows.
93
+ * @example
94
+ * ```ts
95
+ * import { type IReadOnlyList, List } from "@noldova/context.collections";
96
+ * import type { CodeGutterMarker } from "@noldova/code.editor.angular";
97
+ *
98
+ * const errors: IReadOnlyList<CodeGutterMarker> = new List<CodeGutterMarker>();
99
+ * const markersIn = (start: number, end: number): IReadOnlyList<CodeGutterMarker> => errors.where(t => t.line >= start && t.line < end).toList();
100
+ * ```
101
+ */
102
+ markersIn(start: number, end: number): IReadOnlyList<CodeGutterMarker>;
103
+ }
@@ -0,0 +1,7 @@
1
+ /**
2
+ * @license
3
+ * Copyright (c) Noldova.
4
+ *
5
+ * This source code is licensed under the license found in the
6
+ * LICENSE file in the root directory of this source tree.
7
+ */
@@ -0,0 +1,13 @@
1
+ /**
2
+ * @license
3
+ * Copyright (c) Noldova.
4
+ *
5
+ * This source code is licensed under the license found in the
6
+ * LICENSE file in the root directory of this source tree.
7
+ */
8
+ import type { FoldShortcut } from "../enums/fold-shortcut.js";
9
+ export interface ICodeEditorView {
10
+ openSearch(replace: boolean): void;
11
+ closeSearch(): void;
12
+ toggleFold(shortcut: FoldShortcut): void;
13
+ }
@@ -0,0 +1,7 @@
1
+ /**
2
+ * @license
3
+ * Copyright (c) Noldova.
4
+ *
5
+ * This source code is licensed under the license found in the
6
+ * LICENSE file in the root directory of this source tree.
7
+ */
@@ -0,0 +1,38 @@
1
+ /**
2
+ * @license
3
+ * Copyright (c) Noldova.
4
+ *
5
+ * This source code is licensed under the license found in the
6
+ * LICENSE file in the root directory of this source tree.
7
+ */
8
+ /**
9
+ * A second line number column, such as the original text's numbers in an
10
+ * inline diff; the view shows it before its own numbers.
11
+ */
12
+ export interface ICodeNumbering {
13
+ /**
14
+ * The largest number it gives, which sizes the gutter.
15
+ */
16
+ readonly largest: number;
17
+ /**
18
+ * Gives a line's number in the column.
19
+ *
20
+ * @param line A line of the view's document, from 0.
21
+ * @returns The number to show, or null for none.
22
+ * @example
23
+ * ```ts
24
+ * import type { ICodeNumbering } from "@noldova/code.editor.angular";
25
+ *
26
+ * class FromEleven implements ICodeNumbering {
27
+ * public readonly largest: number = 110;
28
+ *
29
+ * public numberOf(line: number): number | null {
30
+ * return line + 11;
31
+ * }
32
+ * }
33
+ *
34
+ * const fromEleven: ICodeNumbering = new FromEleven();
35
+ * ```
36
+ */
37
+ numberOf(line: number): number | null;
38
+ }
@@ -0,0 +1,7 @@
1
+ /**
2
+ * @license
3
+ * Copyright (c) Noldova.
4
+ *
5
+ * This source code is licensed under the license found in the
6
+ * LICENSE file in the root directory of this source tree.
7
+ */
@@ -0,0 +1,18 @@
1
+ /**
2
+ * @license
3
+ * Copyright (c) Noldova.
4
+ *
5
+ * This source code is licensed under the license found in the
6
+ * LICENSE file in the root directory of this source tree.
7
+ */
8
+ import type { FoldShortcut } from "../enums/fold-shortcut.js";
9
+ import type { ICodeEditorView } from "../interfaces/i-code-editor-view.js";
10
+ export declare class CodeEditorView implements ICodeEditorView {
11
+ private readonly open;
12
+ private readonly close;
13
+ private readonly fold;
14
+ constructor(open: (replace: boolean) => void, close: () => void, fold: (shortcut: FoldShortcut) => void);
15
+ openSearch(replace: boolean): void;
16
+ closeSearch(): void;
17
+ toggleFold(shortcut: FoldShortcut): void;
18
+ }
@@ -0,0 +1,26 @@
1
+ /**
2
+ * @license
3
+ * Copyright (c) Noldova.
4
+ *
5
+ * This source code is licensed under the license found in the
6
+ * LICENSE file in the root directory of this source tree.
7
+ */
8
+ export class CodeEditorView {
9
+ open;
10
+ close;
11
+ fold;
12
+ constructor(open, close, fold) {
13
+ this.open = open;
14
+ this.close = close;
15
+ this.fold = fold;
16
+ }
17
+ openSearch(replace) {
18
+ this.open(replace);
19
+ }
20
+ closeSearch() {
21
+ this.close();
22
+ }
23
+ toggleFold(shortcut) {
24
+ this.fold(shortcut);
25
+ }
26
+ }
@@ -0,0 +1,18 @@
1
+ /**
2
+ * @license
3
+ * Copyright (c) Noldova.
4
+ *
5
+ * This source code is licensed under the license found in the
6
+ * LICENSE file in the root directory of this source tree.
7
+ */
8
+ import "@noldova/context.core";
9
+ import { type SearchQuery, type SearchResults, type TextDocument, TextRange, TextSearch, type TextSelection } from "@noldova/code.editor";
10
+ import { MatchShape } from "./shapes/match-shape.js";
11
+ import type { RowLayout } from "./rows/row-layout.js";
12
+ import type { TextMeasure } from "./text-measure.js";
13
+ export declare class CodeSearch {
14
+ static rangeOf(selection: TextSelection): TextRange;
15
+ static searchOf(query: SearchQuery | null): TextSearch | null;
16
+ static statusOf(query: SearchQuery | null, results: SearchResults | null, current: TextRange): string;
17
+ static shapesOf(results: SearchResults, document: TextDocument, layout: RowLayout, rows: readonly number[], measure: TextMeasure, current: TextRange): readonly MatchShape[];
18
+ }