@pierre/diffs 1.0.0 → 1.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.
package/LICENSE.md ADDED
@@ -0,0 +1,189 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction, and
10
+ distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by the
13
+ copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all other
16
+ entities that control, are controlled by, or are under common control with
17
+ that entity. For the purposes of this definition, "control" means (i) the
18
+ power, direct or indirect, to cause the direction or management of such
19
+ entity, whether by contract or otherwise, or (ii) ownership of fifty percent
20
+ (50%) or more of the outstanding shares, or (iii) beneficial ownership of
21
+ such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity exercising
24
+ permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation source, and
28
+ configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical transformation
31
+ or translation of a Source form, including but not limited to compiled
32
+ object code, generated documentation, and conversions to other media types.
33
+
34
+ "Work" shall mean the work of authorship, whether in Source or Object form,
35
+ made available under the License, as indicated by a copyright notice that is
36
+ included in or attached to the work (an example is provided in the Appendix
37
+ below).
38
+
39
+ "Derivative Works" shall mean any work, whether in Source or Object form,
40
+ that is based on (or derived from) the Work and for which the editorial
41
+ revisions, annotations, elaborations, or other modifications represent, as a
42
+ whole, an original work of authorship. For the purposes of this License,
43
+ Derivative Works shall not include works that remain separable from, or
44
+ merely link (or bind by name) to the interfaces of, the Work and Derivative
45
+ Works thereof.
46
+
47
+ "Contribution" shall mean any work of authorship, including the original
48
+ version of the Work and any modifications or additions to that Work or
49
+ Derivative Works thereof, that is intentionally submitted to Licensor for
50
+ inclusion in the Work by the copyright owner or by an individual or Legal
51
+ Entity authorized to submit on behalf of the copyright owner. For the
52
+ purposes of this definition, "submitted" means any form of electronic,
53
+ verbal, or written communication sent to the Licensor or its
54
+ representatives, including but not limited to communication on electronic
55
+ mailing lists, source code control systems, and issue tracking systems that
56
+ are managed by, or on behalf of, the Licensor for the purpose of discussing
57
+ and improving the Work, but excluding communication that is conspicuously
58
+ marked or otherwise designated in writing by the copyright owner as "Not a
59
+ Contribution."
60
+
61
+ "Contributor" shall mean Licensor and any individual or Legal Entity on
62
+ behalf of whom a Contribution has been received by Licensor and subsequently
63
+ incorporated within the Work.
64
+
65
+ 2. Grant of Copyright License. Subject to the terms and conditions of this
66
+ License, each Contributor hereby grants to You a perpetual, worldwide,
67
+ non-exclusive, no-charge, royalty-free, irrevocable copyright license to
68
+ reproduce, prepare Derivative Works of, publicly display, publicly perform,
69
+ sublicense, and distribute the Work and such Derivative Works in Source or
70
+ Object form.
71
+
72
+ 3. Grant of Patent License. Subject to the terms and conditions of this
73
+ License, each Contributor hereby grants to You a perpetual, worldwide,
74
+ non-exclusive, no-charge, royalty-free, irrevocable (except as stated in
75
+ this section) patent license to make, have made, use, offer to sell, sell,
76
+ import, and otherwise transfer the Work, where such license applies only to
77
+ those patent claims licensable by such Contributor that are necessarily
78
+ infringed by their Contribution(s) alone or by combination of their
79
+ Contribution(s) with the Work to which such Contribution(s) was submitted.
80
+ If You institute patent litigation against any entity (including a
81
+ cross-claim or counterclaim in a lawsuit) alleging that the Work or a
82
+ Contribution incorporated within the Work constitutes direct or contributory
83
+ patent infringement, then any patent licenses granted to You under this
84
+ License for that Work shall terminate as of the date such litigation is
85
+ filed.
86
+
87
+ 4. Redistribution. You may reproduce and distribute copies of the Work or
88
+ Derivative Works thereof in any medium, with or without modifications, and
89
+ in Source or Object form, provided that You meet the following conditions:
90
+
91
+ (a) You must give any other recipients of the Work or Derivative Works a
92
+ copy of this License; and
93
+
94
+ (b) You must cause any modified files to carry prominent notices stating
95
+ that You changed the files; and
96
+
97
+ (c) You must retain, in the Source form of any Derivative Works that You
98
+ distribute, all copyright, patent, trademark, and attribution notices from
99
+ the Source form of the Work, excluding those notices that do not pertain to
100
+ any part of the Derivative Works; and
101
+
102
+ (d) If the Work includes a "NOTICE" text file as part of its distribution,
103
+ then any Derivative Works that You distribute must include a readable copy
104
+ of the attribution notices contained within such NOTICE file, excluding
105
+ those notices that do not pertain to any part of the Derivative Works, in at
106
+ least one of the following places: within a NOTICE text file distributed as
107
+ part of the Derivative Works; within the Source form or documentation, if
108
+ provided along with the Derivative Works; or, within a display generated by
109
+ the Derivative Works, if and wherever such third-party notices normally
110
+ appear. The contents of the NOTICE file are for informational purposes only
111
+ and do not modify the License. You may add Your own attribution notices
112
+ within Derivative Works that You distribute, alongside or as an addendum to
113
+ the NOTICE text from the Work, provided that such additional attribution
114
+ notices cannot be construed as modifying the License.
115
+
116
+ You may add Your own copyright statement to Your modifications and may
117
+ provide additional or different license terms and conditions for use,
118
+ reproduction, or distribution of Your modifications, or for any such
119
+ Derivative Works as a whole, provided Your use, reproduction, and
120
+ distribution of the Work otherwise complies with the conditions stated in
121
+ this License.
122
+
123
+ 5. Submission of Contributions. Unless You explicitly state otherwise, any
124
+ Contribution intentionally submitted for inclusion in the Work by You to the
125
+ Licensor shall be under the terms and conditions of this License, without
126
+ any additional terms or conditions. Notwithstanding the above, nothing
127
+ herein shall supersede or modify the terms of any separate license agreement
128
+ you may have executed with Licensor regarding such Contributions.
129
+
130
+ 6. Trademarks. This License does not grant permission to use the trade names,
131
+ trademarks, service marks, or product names of the Licensor, except as
132
+ required for reasonable and customary use in describing the origin of the
133
+ Work and reproducing the content of the NOTICE file.
134
+
135
+ 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in
136
+ writing, Licensor provides the Work (and each Contributor provides its
137
+ Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
138
+ KIND, either express or implied, including, without limitation, any
139
+ warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or
140
+ FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining
141
+ the appropriateness of using or redistributing the Work and assume any risks
142
+ associated with Your exercise of permissions under this License.
143
+
144
+ 8. Limitation of Liability. In no event and under no legal theory, whether in
145
+ tort (including negligence), contract, or otherwise, unless required by
146
+ applicable law (such as deliberate and grossly negligent acts) or agreed to
147
+ in writing, shall any Contributor be liable to You for damages, including
148
+ any direct, indirect, special, incidental, or consequential damages of any
149
+ character arising as a result of this License or out of the use or inability
150
+ to use the Work (including but not limited to damages for loss of goodwill,
151
+ work stoppage, computer failure or malfunction, or any and all other
152
+ commercial damages or losses), even if such Contributor has been advised of
153
+ the possibility of such damages.
154
+
155
+ 9. Accepting Warranty or Additional Liability. While redistributing the Work or
156
+ Derivative Works thereof, You may choose to offer, and charge a fee for,
157
+ acceptance of support, warranty, indemnity, or other liability obligations
158
+ and/or rights consistent with this License. However, in accepting such
159
+ obligations, You may act only on Your own behalf and on Your sole
160
+ responsibility, not on behalf of any other Contributor, and only if You
161
+ agree to indemnify, defend, and hold each Contributor harmless for any
162
+ liability incurred by, or claims asserted against, such Contributor by
163
+ reason of your accepting any such warranty or additional liability.
164
+
165
+ END OF TERMS AND CONDITIONS
166
+
167
+ APPENDIX: How to apply the Apache License to your work.
168
+
169
+ To apply the Apache License to your work, attach the following
170
+ boilerplate notice, with the fields enclosed by brackets "[]"
171
+ replaced with your own identifying information. (Don't include
172
+ the brackets!) The text should be enclosed in the appropriate
173
+ comment syntax for the file format. We also recommend that a
174
+ file or class name and description of purpose be included on the
175
+ same "printed page" as the copyright notice for easier
176
+ identification within third-party archives.
177
+
178
+ Copyright 2025 Pierre Computer Company
179
+
180
+ Licensed under the Apache License, Version 2.0 (the "License"); you may not use
181
+ this file except in compliance with the License. You may obtain a copy of the
182
+ License at
183
+
184
+ http://www.apache.org/licenses/LICENSE-2.0
185
+
186
+ Unless required by applicable law or agreed to in writing, software distributed
187
+ under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
188
+ CONDITIONS OF ANY KIND, either express or implied. See the License for the
189
+ specific language governing permissions and limitations under the License.
@@ -1 +1 @@
1
- {"version":3,"file":"parsePatchFiles.d.ts","names":[],"sources":["../../src/utils/parsePatchFiles.ts"],"sourcesContent":[],"mappings":";;;;;;AAqRA;;;;;;iBAAgB,eAAA,yCAGb"}
1
+ {"version":3,"file":"parsePatchFiles.d.ts","names":[],"sources":["../../src/utils/parsePatchFiles.ts"],"sourcesContent":[],"mappings":";;;;;;AA8RA;;;;;;iBAAgB,eAAA,yCAGb"}
@@ -131,7 +131,7 @@ function processPatch(data, cacheKeyPrefix) {
131
131
  collapsedBefore: 0,
132
132
  splitLineCount: 0,
133
133
  splitLineStart: 0,
134
- unifiedLineCount: lines.length,
134
+ unifiedLineCount: 0,
135
135
  unifiedLineStart: 0,
136
136
  additionCount: parseInt(match[4] ?? "1"),
137
137
  additionStart: parseInt(match[3]),
@@ -150,7 +150,13 @@ function processPatch(data, cacheKeyPrefix) {
150
150
  hunkData.collapsedBefore = Math.max(hunkData.additionStart - 1 - lastHunkEnd, 0);
151
151
  currentFile.hunks.push(hunkData);
152
152
  lastHunkEnd = hunkData.additionStart + hunkData.additionCount - 1;
153
- hunkData.splitLineCount = Math.max(hunkData.additionCount, hunkData.deletionCount);
153
+ for (const content of hunkContent) if (content.type === "context") {
154
+ hunkData.splitLineCount += content.lines.length;
155
+ hunkData.unifiedLineCount += content.lines.length;
156
+ } else {
157
+ hunkData.splitLineCount += Math.max(content.additions.length, content.deletions.length);
158
+ hunkData.unifiedLineCount += content.deletions.length + content.additions.length;
159
+ }
154
160
  hunkData.splitLineStart = currentFile.splitLineCount;
155
161
  hunkData.unifiedLineStart = currentFile.unifiedLineCount;
156
162
  currentFile.splitLineCount += hunkData.splitLineCount;
@@ -1 +1 @@
1
- {"version":3,"file":"parsePatchFiles.js","names":["patchMetadata: string | undefined","files: FileDiffMetadata[]","currentFile: FileDiffMetadata | undefined","hunkContent: (ContextContent | ChangeContent)[]","currentContent: ContextContent | ChangeContent | undefined","lastLineType: 'context' | 'addition' | 'deletion' | undefined","hunkData: Hunk","patches: ParsedPatch[]"],"sources":["../../src/utils/parsePatchFiles.ts"],"sourcesContent":["import {\n ALTERNATE_FILE_NAMES_GIT,\n COMMIT_METADATA_SPLIT,\n FILENAME_HEADER_REGEX,\n FILENAME_HEADER_REGEX_GIT,\n FILE_CONTEXT_BLOB,\n FILE_MODE_FROM_INDEX,\n GIT_DIFF_FILE_BREAK_REGEX,\n HUNK_HEADER,\n SPLIT_WITH_NEWLINES,\n UNIFIED_DIFF_FILE_BREAK_REGEX,\n} from '../constants';\nimport type {\n ChangeContent,\n ContextContent,\n FileDiffMetadata,\n Hunk,\n ParsedPatch,\n} from '../types';\nimport { cleanLastNewline } from './cleanLastNewline';\nimport { parseLineType } from './parseLineType';\n\nfunction processPatch(data: string, cacheKeyPrefix?: string): ParsedPatch {\n const isGitDiff = GIT_DIFF_FILE_BREAK_REGEX.test(data);\n const rawFiles = data.split(\n isGitDiff ? GIT_DIFF_FILE_BREAK_REGEX : UNIFIED_DIFF_FILE_BREAK_REGEX\n );\n let patchMetadata: string | undefined;\n const files: FileDiffMetadata[] = [];\n let currentFile: FileDiffMetadata | undefined;\n for (const file of rawFiles) {\n if (isGitDiff && !GIT_DIFF_FILE_BREAK_REGEX.test(file)) {\n if (patchMetadata == null) {\n patchMetadata = file;\n } else {\n console.error('parsePatchContent: unknown file blob:', file);\n }\n // If we get in here, it's most likely the introductory metadata from the\n // patch, or something is fucked with the diff format\n continue;\n } else if (!isGitDiff && !UNIFIED_DIFF_FILE_BREAK_REGEX.test(file)) {\n if (patchMetadata == null) {\n patchMetadata = file;\n } else {\n console.error('parsePatchContent: unknown file blob:', file);\n }\n continue;\n }\n let lastHunkEnd = 0;\n const hunks = file.split(FILE_CONTEXT_BLOB);\n currentFile = undefined;\n for (const hunk of hunks) {\n const lines = hunk.split(SPLIT_WITH_NEWLINES);\n const firstLine = lines.shift();\n if (firstLine == null) {\n console.error('parsePatchContent: invalid hunk', hunk);\n continue;\n }\n const match = firstLine.match(HUNK_HEADER);\n const hunkContent: (ContextContent | ChangeContent)[] = [];\n let additionLines = 0;\n let deletionLines = 0;\n if (match == null || currentFile == null) {\n if (currentFile != null) {\n console.error('parsePatchContent: Invalid hunk', hunk);\n continue;\n }\n currentFile = {\n name: '',\n prevName: undefined,\n type: 'change',\n hunks: [],\n splitLineCount: 0,\n unifiedLineCount: 0,\n cacheKey:\n cacheKeyPrefix != null\n ? `${cacheKeyPrefix}-${files.length}`\n : undefined,\n };\n // Push that first line back into the group of lines so we can properly\n // parse it out\n lines.unshift(firstLine);\n for (const line of lines) {\n const filenameMatch = line.match(\n isGitDiff ? FILENAME_HEADER_REGEX_GIT : FILENAME_HEADER_REGEX\n );\n if (line.startsWith('diff --git')) {\n const [, , prevName, , name] =\n line.trim().match(ALTERNATE_FILE_NAMES_GIT) ?? [];\n currentFile.name = name.trim();\n if (prevName !== name) {\n currentFile.prevName = prevName.trim();\n }\n } else if (filenameMatch != null) {\n const [, type, fileName] = filenameMatch;\n if (type === '---' && fileName !== '/dev/null') {\n currentFile.prevName = fileName.trim();\n currentFile.name = fileName.trim();\n } else if (type === '+++' && fileName !== '/dev/null') {\n currentFile.name = fileName.trim();\n }\n }\n // Git diffs have a bunch of additional metadata we can pull from\n else if (isGitDiff) {\n if (line.startsWith('new mode ')) {\n currentFile.mode = line.replace('new mode', '').trim();\n }\n if (line.startsWith('old mode ')) {\n currentFile.oldMode = line.replace('old mode', '').trim();\n }\n if (line.startsWith('new file mode')) {\n currentFile.type = 'new';\n currentFile.mode = line.replace('new file mode', '').trim();\n }\n if (line.startsWith('deleted file mode')) {\n currentFile.type = 'deleted';\n currentFile.mode = line.replace('deleted file mode', '').trim();\n }\n if (line.startsWith('similarity index')) {\n if (line.startsWith('similarity index 100%')) {\n currentFile.type = 'rename-pure';\n } else {\n currentFile.type = 'rename-changed';\n }\n }\n if (line.startsWith('index ')) {\n const [, mode] = line.trim().match(FILE_MODE_FROM_INDEX) ?? [];\n if (mode != null) {\n currentFile.mode = mode;\n }\n }\n // We have to handle these for pure renames because there won't be\n // --- and +++ lines\n if (line.startsWith('rename from ')) {\n currentFile.prevName = line.replace('rename from ', '');\n }\n if (line.startsWith('rename to ')) {\n currentFile.name = line.replace('rename to ', '').trim();\n }\n }\n }\n continue;\n } else {\n let currentContent: ContextContent | ChangeContent | undefined;\n let lastLineType: 'context' | 'addition' | 'deletion' | undefined;\n // Strip trailing bare newlines (format-patch separators between commits)\n while (\n lines.length > 0 &&\n (lines[lines.length - 1] === '\\n' || lines[lines.length - 1] === '')\n ) {\n lines.pop();\n }\n for (const rawLine of lines) {\n const parsedLine = parseLineType(rawLine);\n if (parsedLine == null) {\n continue;\n }\n const { type, line } = parsedLine;\n if (type === 'addition') {\n if (currentContent == null || currentContent.type !== 'change') {\n currentContent = createContentGroup('change');\n hunkContent.push(currentContent);\n }\n currentContent.additions.push(line);\n additionLines++;\n lastLineType = 'addition';\n } else if (type === 'deletion') {\n if (currentContent == null || currentContent.type !== 'change') {\n currentContent = createContentGroup('change');\n hunkContent.push(currentContent);\n }\n currentContent.deletions.push(line);\n deletionLines++;\n lastLineType = 'deletion';\n } else if (type === 'context') {\n if (currentContent == null || currentContent.type !== 'context') {\n currentContent = createContentGroup('context');\n hunkContent.push(currentContent);\n }\n currentContent.lines.push(line);\n lastLineType = 'context';\n } else if (type === 'metadata' && currentContent != null) {\n if (currentContent.type === 'context') {\n currentContent.noEOFCR = true;\n } else if (lastLineType === 'deletion') {\n currentContent.noEOFCRDeletions = true;\n const lastIndex = currentContent.deletions.length - 1;\n if (lastIndex >= 0) {\n currentContent.deletions[lastIndex] = cleanLastNewline(\n currentContent.deletions[lastIndex]\n );\n }\n } else if (lastLineType === 'addition') {\n currentContent.noEOFCRAdditions = true;\n const lastIndex = currentContent.additions.length - 1;\n if (lastIndex >= 0) {\n currentContent.additions[lastIndex] = cleanLastNewline(\n currentContent.additions[lastIndex]\n );\n }\n }\n }\n }\n }\n const hunkData: Hunk = {\n collapsedBefore: 0,\n splitLineCount: 0,\n splitLineStart: 0,\n unifiedLineCount: lines.length,\n unifiedLineStart: 0,\n additionCount: parseInt(match[4] ?? '1'),\n additionStart: parseInt(match[3]),\n additionLines,\n deletionCount: parseInt(match[2] ?? '1'),\n deletionStart: parseInt(match[1]),\n deletionLines,\n hunkContent,\n hunkContext: match[5],\n hunkSpecs: firstLine,\n };\n if (\n isNaN(hunkData.additionCount) ||\n isNaN(hunkData.deletionCount) ||\n isNaN(hunkData.additionStart) ||\n isNaN(hunkData.deletionStart)\n ) {\n console.error('parsePatchContent: invalid hunk metadata', hunkData);\n continue;\n }\n hunkData.collapsedBefore = Math.max(\n hunkData.additionStart - 1 - lastHunkEnd,\n 0\n );\n currentFile.hunks.push(hunkData);\n lastHunkEnd = hunkData.additionStart + hunkData.additionCount - 1;\n hunkData.splitLineCount = Math.max(\n hunkData.additionCount,\n hunkData.deletionCount\n );\n hunkData.splitLineStart = currentFile.splitLineCount;\n hunkData.unifiedLineStart = currentFile.unifiedLineCount;\n\n currentFile.splitLineCount += hunkData.splitLineCount;\n currentFile.unifiedLineCount += hunkData.unifiedLineCount;\n }\n if (currentFile != null) {\n if (\n !isGitDiff &&\n currentFile.prevName != null &&\n currentFile.name !== currentFile.prevName\n ) {\n if (currentFile.hunks.length > 0) {\n currentFile.type = 'rename-changed';\n } else {\n currentFile.type = 'rename-pure';\n }\n }\n if (\n currentFile.type !== 'rename-pure' &&\n currentFile.type !== 'rename-changed'\n ) {\n currentFile.prevName = undefined;\n }\n files.push(currentFile);\n }\n }\n return { patchMetadata, files };\n}\n\n/**\n * Parses a patch file string into an array of parsed patches.\n *\n * @param data - The raw patch file content (supports multi-commit patches)\n * @param cacheKeyPrefix - Optional prefix for generating cache keys. When provided,\n * each file in the patch will get a cache key in the format `prefix-patchIndex-fileIndex`.\n * This enables caching of rendered diff results in the worker pool.\n */\nexport function parsePatchFiles(\n data: string,\n cacheKeyPrefix?: string\n): ParsedPatch[] {\n // NOTE(amadeus): This function is pretty forgiving in that it can accept a\n // patch file that includes commit metdata, multiple commits, or not\n const patches: ParsedPatch[] = [];\n for (const patch of data.split(COMMIT_METADATA_SPLIT)) {\n try {\n patches.push(\n processPatch(\n patch,\n cacheKeyPrefix != null\n ? `${cacheKeyPrefix}-${patches.length}`\n : undefined\n )\n );\n } catch (error) {\n console.error(error);\n }\n }\n return patches;\n}\n\nfunction createContentGroup(type: 'change'): ChangeContent;\nfunction createContentGroup(type: 'context'): ContextContent;\nfunction createContentGroup(\n type: 'change' | 'context'\n): ChangeContent | ContextContent {\n if (type === 'change') {\n return {\n type: 'change',\n additions: [],\n deletions: [],\n noEOFCRAdditions: false,\n noEOFCRDeletions: false,\n };\n }\n return { type: 'context', lines: [], noEOFCR: false };\n}\n"],"mappings":";;;;;AAsBA,SAAS,aAAa,MAAc,gBAAsC;CACxE,MAAM,YAAY,0BAA0B,KAAK,KAAK;CACtD,MAAM,WAAW,KAAK,MACpB,YAAY,4BAA4B,8BACzC;CACD,IAAIA;CACJ,MAAMC,QAA4B,EAAE;CACpC,IAAIC;AACJ,MAAK,MAAM,QAAQ,UAAU;AAC3B,MAAI,aAAa,CAAC,0BAA0B,KAAK,KAAK,EAAE;AACtD,OAAI,iBAAiB,KACnB,iBAAgB;OAEhB,SAAQ,MAAM,yCAAyC,KAAK;AAI9D;aACS,CAAC,aAAa,CAAC,8BAA8B,KAAK,KAAK,EAAE;AAClE,OAAI,iBAAiB,KACnB,iBAAgB;OAEhB,SAAQ,MAAM,yCAAyC,KAAK;AAE9D;;EAEF,IAAI,cAAc;EAClB,MAAM,QAAQ,KAAK,MAAM,kBAAkB;AAC3C,gBAAc;AACd,OAAK,MAAM,QAAQ,OAAO;GACxB,MAAM,QAAQ,KAAK,MAAM,oBAAoB;GAC7C,MAAM,YAAY,MAAM,OAAO;AAC/B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,YAAY,YAAY,QACxB,YAAY,SAAS,YAAY,SAEjC,KAAI,YAAY,MAAM,SAAS,EAC7B,aAAY,OAAO;OAEnB,aAAY,OAAO;AAGvB,OACE,YAAY,SAAS,iBACrB,YAAY,SAAS,iBAErB,aAAY,WAAW;AAEzB,SAAM,KAAK,YAAY;;;AAG3B,QAAO;EAAE;EAAe;EAAO;;;;;;;;;;AAWjC,SAAgB,gBACd,MACA,gBACe;CAGf,MAAMC,UAAyB,EAAE;AACjC,MAAK,MAAM,SAAS,KAAK,MAAM,sBAAsB,CACnD,KAAI;AACF,UAAQ,KACN,aACE,OACA,kBAAkB,OACd,GAAG,eAAe,GAAG,QAAQ,WAC7B,OACL,CACF;UACM,OAAO;AACd,UAAQ,MAAM,MAAM;;AAGxB,QAAO;;AAKT,SAAS,mBACP,MACgC;AAChC,KAAI,SAAS,SACX,QAAO;EACL,MAAM;EACN,WAAW,EAAE;EACb,WAAW,EAAE;EACb,kBAAkB;EAClB,kBAAkB;EACnB;AAEH,QAAO;EAAE,MAAM;EAAW,OAAO,EAAE;EAAE,SAAS;EAAO"}
1
+ {"version":3,"file":"parsePatchFiles.js","names":["patchMetadata: string | undefined","files: FileDiffMetadata[]","currentFile: FileDiffMetadata | undefined","hunkContent: (ContextContent | ChangeContent)[]","currentContent: ContextContent | ChangeContent | undefined","lastLineType: 'context' | 'addition' | 'deletion' | undefined","hunkData: Hunk","patches: ParsedPatch[]"],"sources":["../../src/utils/parsePatchFiles.ts"],"sourcesContent":["import {\n ALTERNATE_FILE_NAMES_GIT,\n COMMIT_METADATA_SPLIT,\n FILENAME_HEADER_REGEX,\n FILENAME_HEADER_REGEX_GIT,\n FILE_CONTEXT_BLOB,\n FILE_MODE_FROM_INDEX,\n GIT_DIFF_FILE_BREAK_REGEX,\n HUNK_HEADER,\n SPLIT_WITH_NEWLINES,\n UNIFIED_DIFF_FILE_BREAK_REGEX,\n} from '../constants';\nimport type {\n ChangeContent,\n ContextContent,\n FileDiffMetadata,\n Hunk,\n ParsedPatch,\n} from '../types';\nimport { cleanLastNewline } from './cleanLastNewline';\nimport { parseLineType } from './parseLineType';\n\nfunction processPatch(data: string, cacheKeyPrefix?: string): ParsedPatch {\n const isGitDiff = GIT_DIFF_FILE_BREAK_REGEX.test(data);\n const rawFiles = data.split(\n isGitDiff ? GIT_DIFF_FILE_BREAK_REGEX : UNIFIED_DIFF_FILE_BREAK_REGEX\n );\n let patchMetadata: string | undefined;\n const files: FileDiffMetadata[] = [];\n let currentFile: FileDiffMetadata | undefined;\n for (const file of rawFiles) {\n if (isGitDiff && !GIT_DIFF_FILE_BREAK_REGEX.test(file)) {\n if (patchMetadata == null) {\n patchMetadata = file;\n } else {\n console.error('parsePatchContent: unknown file blob:', file);\n }\n // If we get in here, it's most likely the introductory metadata from the\n // patch, or something is fucked with the diff format\n continue;\n } else if (!isGitDiff && !UNIFIED_DIFF_FILE_BREAK_REGEX.test(file)) {\n if (patchMetadata == null) {\n patchMetadata = file;\n } else {\n console.error('parsePatchContent: unknown file blob:', file);\n }\n continue;\n }\n let lastHunkEnd = 0;\n const hunks = file.split(FILE_CONTEXT_BLOB);\n currentFile = undefined;\n for (const hunk of hunks) {\n const lines = hunk.split(SPLIT_WITH_NEWLINES);\n const firstLine = lines.shift();\n if (firstLine == null) {\n console.error('parsePatchContent: invalid hunk', hunk);\n continue;\n }\n const match = firstLine.match(HUNK_HEADER);\n const hunkContent: (ContextContent | ChangeContent)[] = [];\n let additionLines = 0;\n let deletionLines = 0;\n if (match == null || currentFile == null) {\n if (currentFile != null) {\n console.error('parsePatchContent: Invalid hunk', hunk);\n continue;\n }\n currentFile = {\n name: '',\n prevName: undefined,\n type: 'change',\n hunks: [],\n splitLineCount: 0,\n unifiedLineCount: 0,\n cacheKey:\n cacheKeyPrefix != null\n ? `${cacheKeyPrefix}-${files.length}`\n : undefined,\n };\n // Push that first line back into the group of lines so we can properly\n // parse it out\n lines.unshift(firstLine);\n for (const line of lines) {\n const filenameMatch = line.match(\n isGitDiff ? FILENAME_HEADER_REGEX_GIT : FILENAME_HEADER_REGEX\n );\n if (line.startsWith('diff --git')) {\n const [, , prevName, , name] =\n line.trim().match(ALTERNATE_FILE_NAMES_GIT) ?? [];\n currentFile.name = name.trim();\n if (prevName !== name) {\n currentFile.prevName = prevName.trim();\n }\n } else if (filenameMatch != null) {\n const [, type, fileName] = filenameMatch;\n if (type === '---' && fileName !== '/dev/null') {\n currentFile.prevName = fileName.trim();\n currentFile.name = fileName.trim();\n } else if (type === '+++' && fileName !== '/dev/null') {\n currentFile.name = fileName.trim();\n }\n }\n // Git diffs have a bunch of additional metadata we can pull from\n else if (isGitDiff) {\n if (line.startsWith('new mode ')) {\n currentFile.mode = line.replace('new mode', '').trim();\n }\n if (line.startsWith('old mode ')) {\n currentFile.oldMode = line.replace('old mode', '').trim();\n }\n if (line.startsWith('new file mode')) {\n currentFile.type = 'new';\n currentFile.mode = line.replace('new file mode', '').trim();\n }\n if (line.startsWith('deleted file mode')) {\n currentFile.type = 'deleted';\n currentFile.mode = line.replace('deleted file mode', '').trim();\n }\n if (line.startsWith('similarity index')) {\n if (line.startsWith('similarity index 100%')) {\n currentFile.type = 'rename-pure';\n } else {\n currentFile.type = 'rename-changed';\n }\n }\n if (line.startsWith('index ')) {\n const [, mode] = line.trim().match(FILE_MODE_FROM_INDEX) ?? [];\n if (mode != null) {\n currentFile.mode = mode;\n }\n }\n // We have to handle these for pure renames because there won't be\n // --- and +++ lines\n if (line.startsWith('rename from ')) {\n currentFile.prevName = line.replace('rename from ', '');\n }\n if (line.startsWith('rename to ')) {\n currentFile.name = line.replace('rename to ', '').trim();\n }\n }\n }\n continue;\n } else {\n let currentContent: ContextContent | ChangeContent | undefined;\n let lastLineType: 'context' | 'addition' | 'deletion' | undefined;\n // Strip trailing bare newlines (format-patch separators between commits)\n while (\n lines.length > 0 &&\n (lines[lines.length - 1] === '\\n' || lines[lines.length - 1] === '')\n ) {\n lines.pop();\n }\n for (const rawLine of lines) {\n const parsedLine = parseLineType(rawLine);\n if (parsedLine == null) {\n continue;\n }\n const { type, line } = parsedLine;\n if (type === 'addition') {\n if (currentContent == null || currentContent.type !== 'change') {\n currentContent = createContentGroup('change');\n hunkContent.push(currentContent);\n }\n currentContent.additions.push(line);\n additionLines++;\n lastLineType = 'addition';\n } else if (type === 'deletion') {\n if (currentContent == null || currentContent.type !== 'change') {\n currentContent = createContentGroup('change');\n hunkContent.push(currentContent);\n }\n currentContent.deletions.push(line);\n deletionLines++;\n lastLineType = 'deletion';\n } else if (type === 'context') {\n if (currentContent == null || currentContent.type !== 'context') {\n currentContent = createContentGroup('context');\n hunkContent.push(currentContent);\n }\n currentContent.lines.push(line);\n lastLineType = 'context';\n } else if (type === 'metadata' && currentContent != null) {\n if (currentContent.type === 'context') {\n currentContent.noEOFCR = true;\n } else if (lastLineType === 'deletion') {\n currentContent.noEOFCRDeletions = true;\n const lastIndex = currentContent.deletions.length - 1;\n if (lastIndex >= 0) {\n currentContent.deletions[lastIndex] = cleanLastNewline(\n currentContent.deletions[lastIndex]\n );\n }\n } else if (lastLineType === 'addition') {\n currentContent.noEOFCRAdditions = true;\n const lastIndex = currentContent.additions.length - 1;\n if (lastIndex >= 0) {\n currentContent.additions[lastIndex] = cleanLastNewline(\n currentContent.additions[lastIndex]\n );\n }\n }\n }\n }\n }\n const hunkData: Hunk = {\n collapsedBefore: 0,\n splitLineCount: 0,\n splitLineStart: 0,\n unifiedLineCount: 0,\n unifiedLineStart: 0,\n additionCount: parseInt(match[4] ?? '1'),\n additionStart: parseInt(match[3]),\n additionLines,\n deletionCount: parseInt(match[2] ?? '1'),\n deletionStart: parseInt(match[1]),\n deletionLines,\n hunkContent,\n hunkContext: match[5],\n hunkSpecs: firstLine,\n };\n if (\n isNaN(hunkData.additionCount) ||\n isNaN(hunkData.deletionCount) ||\n isNaN(hunkData.additionStart) ||\n isNaN(hunkData.deletionStart)\n ) {\n console.error('parsePatchContent: invalid hunk metadata', hunkData);\n continue;\n }\n hunkData.collapsedBefore = Math.max(\n hunkData.additionStart - 1 - lastHunkEnd,\n 0\n );\n currentFile.hunks.push(hunkData);\n lastHunkEnd = hunkData.additionStart + hunkData.additionCount - 1;\n for (const content of hunkContent) {\n if (content.type === 'context') {\n hunkData.splitLineCount += content.lines.length;\n hunkData.unifiedLineCount += content.lines.length;\n } else {\n hunkData.splitLineCount += Math.max(\n content.additions.length,\n content.deletions.length\n );\n hunkData.unifiedLineCount +=\n content.deletions.length + content.additions.length;\n }\n }\n hunkData.splitLineStart = currentFile.splitLineCount;\n hunkData.unifiedLineStart = currentFile.unifiedLineCount;\n\n currentFile.splitLineCount += hunkData.splitLineCount;\n currentFile.unifiedLineCount += hunkData.unifiedLineCount;\n }\n if (currentFile != null) {\n if (\n !isGitDiff &&\n currentFile.prevName != null &&\n currentFile.name !== currentFile.prevName\n ) {\n if (currentFile.hunks.length > 0) {\n currentFile.type = 'rename-changed';\n } else {\n currentFile.type = 'rename-pure';\n }\n }\n if (\n currentFile.type !== 'rename-pure' &&\n currentFile.type !== 'rename-changed'\n ) {\n currentFile.prevName = undefined;\n }\n files.push(currentFile);\n }\n }\n return { patchMetadata, files };\n}\n\n/**\n * Parses a patch file string into an array of parsed patches.\n *\n * @param data - The raw patch file content (supports multi-commit patches)\n * @param cacheKeyPrefix - Optional prefix for generating cache keys. When provided,\n * each file in the patch will get a cache key in the format `prefix-patchIndex-fileIndex`.\n * This enables caching of rendered diff results in the worker pool.\n */\nexport function parsePatchFiles(\n data: string,\n cacheKeyPrefix?: string\n): ParsedPatch[] {\n // NOTE(amadeus): This function is pretty forgiving in that it can accept a\n // patch file that includes commit metdata, multiple commits, or not\n const patches: ParsedPatch[] = [];\n for (const patch of data.split(COMMIT_METADATA_SPLIT)) {\n try {\n patches.push(\n processPatch(\n patch,\n cacheKeyPrefix != null\n ? `${cacheKeyPrefix}-${patches.length}`\n : undefined\n )\n );\n } catch (error) {\n console.error(error);\n }\n }\n return patches;\n}\n\nfunction createContentGroup(type: 'change'): ChangeContent;\nfunction createContentGroup(type: 'context'): ContextContent;\nfunction createContentGroup(\n type: 'change' | 'context'\n): ChangeContent | ContextContent {\n if (type === 'change') {\n return {\n type: 'change',\n additions: [],\n deletions: [],\n noEOFCRAdditions: false,\n noEOFCRDeletions: false,\n };\n }\n return { type: 'context', lines: [], noEOFCR: false };\n}\n"],"mappings":";;;;;AAsBA,SAAS,aAAa,MAAc,gBAAsC;CACxE,MAAM,YAAY,0BAA0B,KAAK,KAAK;CACtD,MAAM,WAAW,KAAK,MACpB,YAAY,4BAA4B,8BACzC;CACD,IAAIA;CACJ,MAAMC,QAA4B,EAAE;CACpC,IAAIC;AACJ,MAAK,MAAM,QAAQ,UAAU;AAC3B,MAAI,aAAa,CAAC,0BAA0B,KAAK,KAAK,EAAE;AACtD,OAAI,iBAAiB,KACnB,iBAAgB;OAEhB,SAAQ,MAAM,yCAAyC,KAAK;AAI9D;aACS,CAAC,aAAa,CAAC,8BAA8B,KAAK,KAAK,EAAE;AAClE,OAAI,iBAAiB,KACnB,iBAAgB;OAEhB,SAAQ,MAAM,yCAAyC,KAAK;AAE9D;;EAEF,IAAI,cAAc;EAClB,MAAM,QAAQ,KAAK,MAAM,kBAAkB;AAC3C,gBAAc;AACd,OAAK,MAAM,QAAQ,OAAO;GACxB,MAAM,QAAQ,KAAK,MAAM,oBAAoB;GAC7C,MAAM,YAAY,MAAM,OAAO;AAC/B,OAAI,aAAa,MAAM;AACrB,YAAQ,MAAM,mCAAmC,KAAK;AACtD;;GAEF,MAAM,QAAQ,UAAU,MAAM,YAAY;GAC1C,MAAMC,cAAkD,EAAE;GAC1D,IAAI,gBAAgB;GACpB,IAAI,gBAAgB;AACpB,OAAI,SAAS,QAAQ,eAAe,MAAM;AACxC,QAAI,eAAe,MAAM;AACvB,aAAQ,MAAM,mCAAmC,KAAK;AACtD;;AAEF,kBAAc;KACZ,MAAM;KACN,UAAU;KACV,MAAM;KACN,OAAO,EAAE;KACT,gBAAgB;KAChB,kBAAkB;KAClB,UACE,k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M,KAAK,YAAY;;;AAG3B,QAAO;EAAE;EAAe;EAAO;;;;;;;;;;AAWjC,SAAgB,gBACd,MACA,gBACe;CAGf,MAAMC,UAAyB,EAAE;AACjC,MAAK,MAAM,SAAS,KAAK,MAAM,sBAAsB,CACnD,KAAI;AACF,UAAQ,KACN,aACE,OACA,kBAAkB,OACd,GAAG,eAAe,GAAG,QAAQ,WAC7B,OACL,CACF;UACM,OAAO;AACd,UAAQ,MAAM,MAAM;;AAGxB,QAAO;;AAKT,SAAS,mBACP,MACgC;AAChC,KAAI,SAAS,SACX,QAAO;EACL,MAAM;EACN,WAAW,EAAE;EACb,WAAW,EAAE;EACb,kBAAkB;EAClB,kBAAkB;EACnB;AAEH,QAAO;EAAE,MAAM;EAAW,OAAO,EAAE;EAAE,SAAS;EAAO"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pierre/diffs",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "type": "module",
5
5
  "license": "apache-2.0",
6
6
  "scripts": {
@@ -41,7 +41,7 @@
41
41
  },
42
42
  "files": [
43
43
  "dist",
44
- "LICENSE.txt",
44
+ "LICENSE.md",
45
45
  "README.md"
46
46
  ],
47
47
  "devDependencies": {
@@ -58,7 +58,7 @@
58
58
  "typescript": "5.9.2"
59
59
  },
60
60
  "dependencies": {
61
- "@shikijs/core": "3.19.0",
61
+ "@shikijs/core": "^3.0.0",
62
62
  "@shikijs/engine-javascript": "3.19.0",
63
63
  "@shikijs/transformers": "3.19.0",
64
64
  "diff": "8.0.2",
package/LICENSE.txt DELETED
@@ -1,201 +0,0 @@
1
- Apache License
2
- Version 2.0, January 2004
3
- http://www.apache.org/licenses/
4
-
5
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
-
7
- 1. Definitions.
8
-
9
- "License" shall mean the terms and conditions for use, reproduction,
10
- and distribution as defined by Sections 1 through 9 of this document.
11
-
12
- "Licensor" shall mean the copyright owner or entity authorized by
13
- the copyright owner that is granting the License.
14
-
15
- "Legal Entity" shall mean the union of the acting entity and all
16
- other entities that control, are controlled by, or are under common
17
- control with that entity. For the purposes of this definition,
18
- "control" means (i) the power, direct or indirect, to cause the
19
- direction or management of such entity, whether by contract or
20
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
- outstanding shares, or (iii) beneficial ownership of such entity.
22
-
23
- "You" (or "Your") shall mean an individual or Legal Entity
24
- exercising permissions granted by this License.
25
-
26
- "Source" form shall mean the preferred form for making modifications,
27
- including but not limited to software source code, documentation
28
- source, and configuration files.
29
-
30
- "Object" form shall mean any form resulting from mechanical
31
- transformation or translation of a Source form, including but
32
- not limited to compiled object code, generated documentation,
33
- and conversions to other media types.
34
-
35
- "Work" shall mean the work of authorship, whether in Source or
36
- Object form, made available under the License, as indicated by a
37
- copyright notice that is included in or attached to the work
38
- (an example is provided in the Appendix below).
39
-
40
- "Derivative Works" shall mean any work, whether in Source or Object
41
- form, that is based on (or derived from) the Work and for which the
42
- editorial revisions, annotations, elaborations, or other modifications
43
- represent, as a whole, an original work of authorship. For the purposes
44
- of this License, Derivative Works shall not include works that remain
45
- separable from, or merely link (or bind by name) to the interfaces of,
46
- the Work and Derivative Works thereof.
47
-
48
- "Contribution" shall mean any work of authorship, including
49
- the original version of the Work and any modifications or additions
50
- to that Work or Derivative Works thereof, that is intentionally
51
- submitted to Licensor for inclusion in the Work by the copyright owner
52
- or by an individual or Legal Entity authorized to submit on behalf of
53
- the copyright owner. For the purposes of this definition, "submitted"
54
- means any form of electronic, verbal, or written communication sent
55
- to the Licensor or its representatives, including but not limited to
56
- communication on electronic mailing lists, source code control systems,
57
- and issue tracking systems that are managed by, or on behalf of, the
58
- Licensor for the purpose of discussing and improving the Work, but
59
- excluding communication that is conspicuously marked or otherwise
60
- designated in writing by the copyright owner as "Not a Contribution."
61
-
62
- "Contributor" shall mean Licensor and any individual or Legal Entity
63
- on behalf of whom a Contribution has been received by Licensor and
64
- subsequently incorporated within the Work.
65
-
66
- 2. Grant of Copyright License. Subject to the terms and conditions of
67
- this License, each Contributor hereby grants to You a perpetual,
68
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
- copyright license to reproduce, prepare Derivative Works of,
70
- publicly display, publicly perform, sublicense, and distribute the
71
- Work and such Derivative Works in Source or Object form.
72
-
73
- 3. Grant of Patent License. Subject to the terms and conditions of
74
- this License, each Contributor hereby grants to You a perpetual,
75
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
- (except as stated in this section) patent license to make, have made,
77
- use, offer to sell, sell, import, and otherwise transfer the Work,
78
- where such license applies only to those patent claims licensable
79
- by such Contributor that are necessarily infringed by their
80
- Contribution(s) alone or by combination of their Contribution(s)
81
- with the Work to which such Contribution(s) was submitted. If You
82
- institute patent litigation against any entity (including a
83
- cross-claim or counterclaim in a lawsuit) alleging that the Work
84
- or a Contribution incorporated within the Work constitutes direct
85
- or contributory patent infringement, then any patent licenses
86
- granted to You under this License for that Work shall terminate
87
- as of the date such litigation is filed.
88
-
89
- 4. Redistribution. You may reproduce and distribute copies of the
90
- Work or Derivative Works thereof in any medium, with or without
91
- modifications, and in Source or Object form, provided that You
92
- meet the following conditions:
93
-
94
- (a) You must give any other recipients of the Work or
95
- Derivative Works a copy of this License; and
96
-
97
- (b) You must cause any modified files to carry prominent notices
98
- stating that You changed the files; and
99
-
100
- (c) You must retain, in the Source form of any Derivative Works
101
- that You distribute, all copyright, patent, trademark, and
102
- attribution notices from the Source form of the Work,
103
- excluding those notices that do not pertain to any part of
104
- the Derivative Works; and
105
-
106
- (d) If the Work includes a "NOTICE" text file as part of its
107
- distribution, then any Derivative Works that You distribute must
108
- include a readable copy of the attribution notices contained
109
- within such NOTICE file, excluding those notices that do not
110
- pertain to any part of the Derivative Works, in at least one
111
- of the following places: within a NOTICE text file distributed
112
- as part of the Derivative Works; within the Source form or
113
- documentation, if provided along with the Derivative Works; or,
114
- within a display generated by the Derivative Works, if and
115
- wherever such third-party notices normally appear. The contents
116
- of the NOTICE file are for informational purposes only and
117
- do not modify the License. You may add Your own attribution
118
- notices within Derivative Works that You distribute, alongside
119
- or as an addendum to the NOTICE text from the Work, provided
120
- that such additional attribution notices cannot be construed
121
- as modifying the License.
122
-
123
- You may add Your own copyright statement to Your modifications and
124
- may provide additional or different license terms and conditions
125
- for use, reproduction, or distribution of Your modifications, or
126
- for any such Derivative Works as a whole, provided Your use,
127
- reproduction, and distribution of the Work otherwise complies with
128
- the conditions stated in this License.
129
-
130
- 5. Submission of Contributions. Unless You explicitly state otherwise,
131
- any Contribution intentionally submitted for inclusion in the Work
132
- by You to the Licensor shall be under the terms and conditions of
133
- this License, without any additional terms or conditions.
134
- Notwithstanding the above, nothing herein shall supersede or modify
135
- the terms of any separate license agreement you may have executed
136
- with Licensor regarding such Contributions.
137
-
138
- 6. Trademarks. This License does not grant permission to use the trade
139
- names, trademarks, service marks, or product names of the Licensor,
140
- except as required for reasonable and customary use in describing the
141
- origin of the Work and reproducing the content of the NOTICE file.
142
-
143
- 7. Disclaimer of Warranty. Unless required by applicable law or
144
- agreed to in writing, Licensor provides the Work (and each
145
- Contributor provides its Contributions) on an "AS IS" BASIS,
146
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
- implied, including, without limitation, any warranties or conditions
148
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
- PARTICULAR PURPOSE. You are solely responsible for determining the
150
- appropriateness of using or redistributing the Work and assume any
151
- risks associated with Your exercise of permissions under this License.
152
-
153
- 8. Limitation of Liability. In no event and under no legal theory,
154
- whether in tort (including negligence), contract, or otherwise,
155
- unless required by applicable law (such as deliberate and grossly
156
- negligent acts) or agreed to in writing, shall any Contributor be
157
- liable to You for damages, including any direct, indirect, special,
158
- incidental, or consequential damages of any character arising as a
159
- result of this License or out of the use or inability to use the
160
- Work (including but not limited to damages for loss of goodwill,
161
- work stoppage, computer failure or malfunction, or any and all
162
- other commercial damages or losses), even if such Contributor
163
- has been advised of the possibility of such damages.
164
-
165
- 9. Accepting Warranty or Additional Liability. While redistributing
166
- the Work or Derivative Works thereof, You may choose to offer,
167
- and charge a fee for, acceptance of support, warranty, indemnity,
168
- or other liability obligations and/or rights consistent with this
169
- License. However, in accepting such obligations, You may act only
170
- on Your own behalf and on Your sole responsibility, not on behalf
171
- of any other Contributor, and only if You agree to indemnify,
172
- defend, and hold each Contributor harmless for any liability
173
- incurred by, or claims asserted against, such Contributor by reason
174
- of your accepting any such warranty or additional liability.
175
-
176
- END OF TERMS AND CONDITIONS
177
-
178
- APPENDIX: How to apply the Apache License to your work.
179
-
180
- To apply the Apache License to your work, attach the following
181
- boilerplate notice, with the fields enclosed by brackets "[]"
182
- replaced with your own identifying information. (Don't include
183
- the brackets!) The text should be enclosed in the appropriate
184
- comment syntax for the file format. We also recommend that a
185
- file or class name and description of purpose be included on the
186
- same "printed page" as the copyright notice for easier
187
- identification within third-party archives.
188
-
189
- Copyright 2025 Pierre Computer Company
190
-
191
- Licensed under the Apache License, Version 2.0 (the "License");
192
- you may not use this file except in compliance with the License.
193
- You may obtain a copy of the License at
194
-
195
- http://www.apache.org/licenses/LICENSE-2.0
196
-
197
- Unless required by applicable law or agreed to in writing, software
198
- distributed under the License is distributed on an "AS IS" BASIS,
199
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
- See the License for the specific language governing permissions and
201
- limitations under the License.