@phoenix-wing/code-core 0.4.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 +201 -0
- package/NOTICE +4 -0
- package/README.md +14 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +10 -0
- package/dist/index.js.map +1 -0
- package/dist/pnwCaaDialogHandoff.d.ts +17 -0
- package/dist/pnwCaaDialogHandoff.d.ts.map +1 -0
- package/dist/pnwCaaDialogHandoff.js +34 -0
- package/dist/pnwCaaDialogHandoff.js.map +1 -0
- package/dist/pnwCaaEnvironment.d.ts +17 -0
- package/dist/pnwCaaEnvironment.d.ts.map +1 -0
- package/dist/pnwCaaEnvironment.js +23 -0
- package/dist/pnwCaaEnvironment.js.map +1 -0
- package/dist/pnwCodeRenamePlan.d.ts +47 -0
- package/dist/pnwCodeRenamePlan.d.ts.map +1 -0
- package/dist/pnwCodeRenamePlan.js +105 -0
- package/dist/pnwCodeRenamePlan.js.map +1 -0
- package/dist/pnwFileResultTree.d.ts +25 -0
- package/dist/pnwFileResultTree.d.ts.map +1 -0
- package/dist/pnwFileResultTree.js +37 -0
- package/dist/pnwFileResultTree.js.map +1 -0
- package/dist/pnwReorderCpp.d.ts +7 -0
- package/dist/pnwReorderCpp.d.ts.map +1 -0
- package/dist/pnwReorderCpp.js +389 -0
- package/dist/pnwReorderCpp.js.map +1 -0
- package/dist/pnwReorderHeader.d.ts +21 -0
- package/dist/pnwReorderHeader.d.ts.map +1 -0
- package/dist/pnwReorderHeader.js +896 -0
- package/dist/pnwReorderHeader.js.map +1 -0
- package/dist/pnwUuid.d.ts +25 -0
- package/dist/pnwUuid.d.ts.map +1 -0
- package/dist/pnwUuid.js +140 -0
- package/dist/pnwUuid.js.map +1 -0
- package/dist/pnwUuidReplacementPlan.d.ts +57 -0
- package/dist/pnwUuidReplacementPlan.d.ts.map +1 -0
- package/dist/pnwUuidReplacementPlan.js +101 -0
- package/dist/pnwUuidReplacementPlan.js.map +1 -0
- package/dist/pnwWorkset.d.ts +20 -0
- package/dist/pnwWorkset.d.ts.map +1 -0
- package/dist/pnwWorkset.js +51 -0
- package/dist/pnwWorkset.js.map +1 -0
- package/package.json +50 -0
- package/src/fixtures/annotation_sep.cpp +27 -0
- package/src/fixtures/caa2_wizard_section.h +17 -0
- package/src/fixtures/clang_format_class_tail.h +23 -0
- package/src/fixtures/clang_format_doubled.h +16 -0
- package/src/fixtures/clang_format_nested_markers.h +24 -0
- package/src/fixtures/clang_format_off_on.h +18 -0
- package/src/fixtures/internal_calls.cpp +29 -0
- package/src/fixtures/kevin_wizard_section.h +23 -0
- package/src/fixtures/ktalarmclock.clang-format.yaml +57 -0
- package/src/fixtures/ktca_KTCAutoCodeFrm_KTCAutoCodeUI.m_src_KTCAutoDialog.cpp +242 -0
- package/src/fixtures/ktca_KTCAutoCodeFrm_PublicInterfaces_KTCAutoDialog.h +165 -0
- package/src/fixtures/ktca_KTCAutoCodeInterfaces_KTCAutoCodeItf.m_src_KTCAutoAttrAccess.cpp +423 -0
- package/src/fixtures/ktca_KTCAutoCodeInterfaces_KTCAutoCodeItf.m_src_KTCAutoBuildGSM.cpp +105 -0
- package/src/fixtures/ktca_KTCAutoCodeInterfaces_KTCAutoCodeItf.m_src_KTCAutoPartDoc.cpp +121 -0
- package/src/fixtures/ktca_KTCAutoCodeInterfaces_PublicInterfaces_KTCAutoAttrAccess.h +310 -0
- package/src/fixtures/ktca_KTCAutoCodeInterfaces_PublicInterfaces_KTCAutoBuildGSM.h +56 -0
- package/src/fixtures/ktca_KTCAutoCodeInterfaces_PublicInterfaces_KTCAutoCatalogParam.h +52 -0
- package/src/fixtures/ktca_KTCAutoCodeInterfaces_PublicInterfaces_KTCAutoGSM.h +91 -0
- package/src/fixtures/ktca_KTCAutoCodeInterfaces_PublicInterfaces_KTCAutoPartDoc.h +106 -0
- package/src/fixtures/pnx_bom_analysis_cmd_min.cpp +72 -0
- package/src/fixtures/pnx_bom_analysis_param_min.h +49 -0
- package/src/fixtures/pnx_bom_param_system_split.h +39 -0
- package/src/fixtures/pnx_caa2_widget_decl.h +19 -0
- package/src/fixtures/pragma_region.h +18 -0
- package/src/index.ts +78 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
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 2024–2026 上海锟钛
|
|
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.
|
package/NOTICE
ADDED
package/README.md
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# @phoenix-wing/code-core
|
|
2
|
+
|
|
3
|
+
Phoenix Code 可跨宿主复用的纯 TypeScript 算法与数据契约。包内不依赖 Vue、Element Plus、Node 运行时 API、VS Code、Tauri、数据库驱动或平台二进制。
|
|
4
|
+
|
|
5
|
+
当前公共能力包括:
|
|
6
|
+
|
|
7
|
+
- C++ 实现文件与头文件成员排序、锁定区保护;
|
|
8
|
+
- UUID 识别、格式保持、替换计划与纯文本 apply;
|
|
9
|
+
- Code Rename 计划与纯文本 apply;
|
|
10
|
+
- 工作集 Schema 与安全相对路径校验;
|
|
11
|
+
- CAA 工程环境和对话框 handoff 数据契约;
|
|
12
|
+
- 跨宿主文件结果分组与排序 ViewModel。
|
|
13
|
+
|
|
14
|
+
`kt-auto-code` 与 Desk Tools 应直接消费本包。旧 `phoenix-wing/code-core` subpath 仅保留兼容 re-export,不再持有算法真源。
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export { type PnwCppReorderResult, pnwReorderCppText, } from "./pnwReorderCpp.js";
|
|
2
|
+
export { type PnwHeaderReorderOptions, type PnwHeaderReorderResult, type PnwLockedRegion, pnwExtractLockedRegionContents, pnwFindLockedRegions, pnwReorderHeaderText, } from "./pnwReorderHeader.js";
|
|
3
|
+
export { type PnwFileResultGroup, type PnwFileResultGroupId, type PnwFileResultItem, type PnwFileResultSortMode, type PnwGroupFileResultOptions, pnwCompareFileResults, pnwGroupFileResults, } from "./pnwFileResultTree.js";
|
|
4
|
+
export { type PnwUuidOccurrence, type PnwUuidKind, type PnwUuidReplacement, pnwFindUuidOccurrences, pnwFormatUuidForTemplate, pnwIsUuid, pnwNormalizeUuid, pnwReplaceUuidOccurrences, } from "./pnwUuid.js";
|
|
5
|
+
export { type PnwUuidPlanApplyResult, type PnwUuidPlanFile, type PnwUuidReplacementPlan, type PnwUuidReplacementPlanGroup, type PnwUuidReplacementPlanHit, type PnwUuidReplacementPlanOptions, type PnwUuidReplacementStrategy, pnwApplyUuidReplacementPlan, pnwPlanUuidReplacements, } from "./pnwUuidReplacementPlan.js";
|
|
6
|
+
export { type PnwCaaDialogHandoff, type PnwCaaDialogHandoffFile, pnwIsCaaDialogHandoff, } from "./pnwCaaDialogHandoff.js";
|
|
7
|
+
export { type PnwCodeRenameChange, type PnwCodeRenameEntry, type PnwCodeRenameLevel, type PnwCodeRenameOptions, type PnwCodeRenamePlan, pnwApplyCodeRenameText, pnwPlanCodeRename, } from "./pnwCodeRenamePlan.js";
|
|
8
|
+
export { type PnwWorkset, type PnwWorksetDocument, type PnwWorksetParseResult, pnwIsSafeWorkspacePath, pnwParseWorksetDocument, } from "./pnwWorkset.js";
|
|
9
|
+
export { type PnwCaaEnvironment, type PnwCaaEnvironmentKey, type PnwCaaEnvironmentSource, type PnwCaaEnvironmentValue, pnwResolveCaaEnvironment, } from "./pnwCaaEnvironment.js";
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,mBAAmB,EACxB,iB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,MAAM,wBAAwB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export { pnwReorderCppText, } from "./pnwReorderCpp.js";
|
|
2
|
+
export { pnwExtractLockedRegionContents, pnwFindLockedRegions, pnwReorderHeaderText, } from "./pnwReorderHeader.js";
|
|
3
|
+
export { pnwCompareFileResults, pnwGroupFileResults, } from "./pnwFileResultTree.js";
|
|
4
|
+
export { pnwFindUuidOccurrences, pnwFormatUuidForTemplate, pnwIsUuid, pnwNormalizeUuid, pnwReplaceUuidOccurrences, } from "./pnwUuid.js";
|
|
5
|
+
export { pnwApplyUuidReplacementPlan, pnwPlanUuidReplacements, } from "./pnwUuidReplacementPlan.js";
|
|
6
|
+
export { pnwIsCaaDialogHandoff, } from "./pnwCaaDialogHandoff.js";
|
|
7
|
+
export { pnwApplyCodeRenameText, pnwPlanCodeRename, } from "./pnwCodeRenamePlan.js";
|
|
8
|
+
export { pnwIsSafeWorkspacePath, pnwParseWorksetDocument, } from "./pnwWorkset.js";
|
|
9
|
+
export { pnwResolveCaaEnvironment, } from "./pnwCaaEnvironment.js";
|
|
10
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,iBAAiB,GAClB,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EAIL,8BAA8B,EAC9B,oBAAoB,EACpB,oBAAoB,GACrB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EAML,qBAAqB,EACrB,mBAAmB,GACpB,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EAIL,sBAAsB,EACtB,wBAAwB,EACxB,SAAS,EACT,gBAAgB,EAChB,yBAAyB,GAC1B,MAAM,cAAc,CAAC;AAEtB,OAAO,EAQL,2BAA2B,EAC3B,uBAAuB,GACxB,MAAM,6BAA6B,CAAC;AAErC,OAAO,EAGL,qBAAqB,GACtB,MAAM,0BAA0B,CAAC;AAElC,OAAO,EAML,sBAAsB,EACtB,iBAAiB,GAClB,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EAIL,sBAAsB,EACtB,uBAAuB,GACxB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAKL,wBAAwB,GACzB,MAAM,wBAAwB,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export type PnwCaaDialogHandoffFile = {
|
|
2
|
+
readonly uri: string;
|
|
3
|
+
readonly relativePath: string;
|
|
4
|
+
};
|
|
5
|
+
/** Versioned, data-only handoff from a file selector to a CAA editor host. */
|
|
6
|
+
export type PnwCaaDialogHandoff = {
|
|
7
|
+
readonly protocol: "phoenix-desk-tools.caa-dialog.v1";
|
|
8
|
+
readonly workspaceUri: string;
|
|
9
|
+
readonly selectedFiles: readonly PnwCaaDialogHandoffFile[];
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Validates the v1 handoff shape before a local bridge accepts file paths.
|
|
13
|
+
* It deliberately only allows file URIs and relative display paths without
|
|
14
|
+
* parent traversal; the receiving host must still authorize file access.
|
|
15
|
+
*/
|
|
16
|
+
export declare function pnwIsCaaDialogHandoff(value: unknown): value is PnwCaaDialogHandoff;
|
|
17
|
+
//# sourceMappingURL=pnwCaaDialogHandoff.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pnwCaaDialogHandoff.d.ts","sourceRoot":"","sources":["../src/pnwCaaDialogHandoff.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,uBAAuB,GAAG;IACpC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;CAC/B,CAAC;AAEF,8EAA8E;AAC9E,MAAM,MAAM,mBAAmB,GAAG;IAChC,QAAQ,CAAC,QAAQ,EAAE,kCAAkC,CAAC;IACtD,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,aAAa,EAAE,SAAS,uBAAuB,EAAE,CAAC;CAC5D,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,mBAAmB,CAQlF"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Validates the v1 handoff shape before a local bridge accepts file paths.
|
|
3
|
+
* It deliberately only allows file URIs and relative display paths without
|
|
4
|
+
* parent traversal; the receiving host must still authorize file access.
|
|
5
|
+
*/
|
|
6
|
+
export function pnwIsCaaDialogHandoff(value) {
|
|
7
|
+
if (!value || typeof value !== "object")
|
|
8
|
+
return false;
|
|
9
|
+
const handoff = value;
|
|
10
|
+
return handoff.protocol === "phoenix-desk-tools.caa-dialog.v1"
|
|
11
|
+
&& pnwIsFileUri(handoff.workspaceUri)
|
|
12
|
+
&& Array.isArray(handoff.selectedFiles)
|
|
13
|
+
&& handoff.selectedFiles.length > 0
|
|
14
|
+
&& handoff.selectedFiles.every((file) => pnwIsCaaDialogHandoffFile(file));
|
|
15
|
+
}
|
|
16
|
+
function pnwIsCaaDialogHandoffFile(value) {
|
|
17
|
+
if (!value || typeof value !== "object")
|
|
18
|
+
return false;
|
|
19
|
+
const file = value;
|
|
20
|
+
return pnwIsFileUri(file.uri)
|
|
21
|
+
&& typeof file.relativePath === "string"
|
|
22
|
+
&& file.relativePath.length > 0
|
|
23
|
+
&& !file.relativePath.startsWith("/")
|
|
24
|
+
&& !file.relativePath.split(/[\\/]+/).includes("..");
|
|
25
|
+
}
|
|
26
|
+
function pnwIsFileUri(value) {
|
|
27
|
+
try {
|
|
28
|
+
return typeof value === "string" && new URL(value).protocol === "file:";
|
|
29
|
+
}
|
|
30
|
+
catch {
|
|
31
|
+
return false;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=pnwCaaDialogHandoff.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pn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;AAC1G,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export type PnwCaaEnvironmentKey = "customRoot" | "thirdPartyRoot" | "coreRoot" | "caaMkVersion";
|
|
2
|
+
export type PnwCaaEnvironmentSource = "workspace" | "system" | "missing";
|
|
3
|
+
export type PnwCaaEnvironmentValue = {
|
|
4
|
+
readonly key: PnwCaaEnvironmentKey;
|
|
5
|
+
readonly environmentVariable: "ROOT_DIR" | "ROOT_DIR_3rdParty" | "ROOT_DIR_CORE" | "CAA_MK_VERSION";
|
|
6
|
+
readonly required: boolean;
|
|
7
|
+
readonly source: PnwCaaEnvironmentSource;
|
|
8
|
+
readonly value?: string;
|
|
9
|
+
readonly suggestedValue?: string;
|
|
10
|
+
};
|
|
11
|
+
export type PnwCaaEnvironment = {
|
|
12
|
+
readonly values: readonly PnwCaaEnvironmentValue[];
|
|
13
|
+
readonly complete: boolean;
|
|
14
|
+
};
|
|
15
|
+
/** Resolves explicit workspace overrides before inherited system values; it never mutates `process.env`. */
|
|
16
|
+
export declare function pnwResolveCaaEnvironment(system: Readonly<Record<string, string | undefined>>, workspaceOverrides?: Partial<Record<PnwCaaEnvironmentKey, string | undefined>>): PnwCaaEnvironment;
|
|
17
|
+
//# sourceMappingURL=pnwCaaEnvironment.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pnwCaaEnvironment.d.ts","sourceRoot":"","sources":["../src/pnwCaaEnvironment.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,oBAAoB,GAAG,YAAY,GAAG,gBAAgB,GAAG,UAAU,GAAG,cAAc,CAAC;AACjG,MAAM,MAAM,uBAAuB,GAAG,WAAW,GAAG,QAAQ,GAAG,SAAS,CAAC;AACzE,MAAM,MAAM,sBAAsB,GAAG;IACnC,QAAQ,CAAC,GAAG,EAAE,oBAAoB,CAAC;IACnC,QAAQ,CAAC,mBAAmB,EAAE,UAAU,GAAG,mBAAmB,GAAG,eAAe,GAAG,gBAAgB,CAAC;IACpG,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;IAC3B,QAAQ,CAAC,MAAM,EAAE,uBAAuB,CAAC;IACzC,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,CAAC;CAClC,CAAC;AACF,MAAM,MAAM,iBAAiB,GAAG;IAAE,QAAQ,CAAC,MAAM,EAAE,SAAS,sBAAsB,EAAE,CAAC;IAAC,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAA;CAAE,CAAC;AAEnH,4GAA4G;AAC5G,wBAAgB,wBAAwB,CACtC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC,EACpD,kBAAkB,GAAE,OAAO,CAAC,MAAM,CAAC,oBAAoB,EAAE,MAAM,GAAG,SAAS,CAAC,CAAM,GACjF,iBAAiB,CAoBnB"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/** Resolves explicit workspace overrides before inherited system values; it never mutates `process.env`. */
|
|
2
|
+
export function pnwResolveCaaEnvironment(system, workspaceOverrides = {}) {
|
|
3
|
+
const definitions = [
|
|
4
|
+
{ key: "customRoot", environmentVariable: "ROOT_DIR", required: true },
|
|
5
|
+
{ key: "thirdPartyRoot", environmentVariable: "ROOT_DIR_3rdParty", required: true },
|
|
6
|
+
{ key: "coreRoot", environmentVariable: "ROOT_DIR_CORE", required: true },
|
|
7
|
+
{ key: "caaMkVersion", environmentVariable: "CAA_MK_VERSION", required: false },
|
|
8
|
+
];
|
|
9
|
+
const values = definitions.map((definition) => {
|
|
10
|
+
const override = workspaceOverrides[definition.key]?.trim();
|
|
11
|
+
const inherited = system[definition.environmentVariable]?.trim();
|
|
12
|
+
const value = override || inherited;
|
|
13
|
+
const source = value ? (override ? "workspace" : "system") : "missing";
|
|
14
|
+
return {
|
|
15
|
+
...definition,
|
|
16
|
+
source,
|
|
17
|
+
...(value ? { value } : {}),
|
|
18
|
+
...(!value && definition.key === "caaMkVersion" ? { suggestedValue: "19" } : {}),
|
|
19
|
+
};
|
|
20
|
+
});
|
|
21
|
+
return { values, complete: values.filter((value) => value.required).every((value) => Boolean(value.value)) };
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=pnwCaaEnvironment.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pnwCaaEnvironment.js","sourceRoot":"","sources":["../src/pnwCaaEnvironment.ts"],"names":[],"mappings":"AAYA,4GAA4G;AAC5G,MAAM,UAAU,wBAAwB,CACtC,MAAoD,EACpD,qBAAgF,EAAE;IAElF,MAAM,WAAW,GAAwF;QACvG,EAAE,GAAG,EAAE,YAAY,EAAE,mBAAmB,EAAE,UAAU,EAAE,QAAQ,EAAE,IAAI,EAAE;QACtE,EAAE,GAAG,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,QAAQ,EAAE,IAAI,EAAE;QACnF,EAAE,GAAG,EAAE,UAAU,EAAE,mBAAmB,EAAE,eAAe,EAAE,QAAQ,EAAE,IAAI,EAAE;QACzE,EAAE,GAAG,EAAE,cAAc,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,QAAQ,EAAE,KAAK,EAAE;KAChF,CAAC;IACF,MAAM,MAAM,GAA6B,WAAW,CAAC,GAAG,CAAC,CAAC,UAAU,EAA0B,EAAE;QAC9F,MAAM,QAAQ,GAAG,kBAAkB,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,IAAI,EAAE,CAAC;QAC5D,MAAM,SAAS,GAAG,MAAM,CAAC,UAAU,CAAC,mBAAmB,CAAC,EAAE,IAAI,EAAE,CAAC;QACjE,MAAM,KAAK,GAAG,QAAQ,IAAI,SAAS,CAAC;QACpC,MAAM,MAAM,GAA4B,KAAK,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;QAChG,OAAO;YACL,GAAG,UAAU;YACb,MAAM;YACN,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YAC3B,GAAG,CAAC,CAAC,KAAK,IAAI,UAAU,CAAC,GAAG,KAAK,cAAc,CAAC,CAAC,CAAC,EAAE,cAAc,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SACjF,CAAC;IACJ,CAAC,CAAC,CAAC;IACH,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC;AAC/G,CAAC"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
export type PnwCodeRenameLevel = "dir" | "file" | "text";
|
|
2
|
+
export type PnwCodeRenameEntry = {
|
|
3
|
+
readonly relativePath: string;
|
|
4
|
+
readonly kind: "file" | "dir";
|
|
5
|
+
/** Required only for file entries when text replacement is requested. */
|
|
6
|
+
readonly text?: string;
|
|
7
|
+
};
|
|
8
|
+
export type PnwCodeRenameOptions = {
|
|
9
|
+
readonly oldText: string;
|
|
10
|
+
readonly newText: string;
|
|
11
|
+
readonly levels?: readonly PnwCodeRenameLevel[];
|
|
12
|
+
/** Default true. Set false for Windows/macOS case-insensitive target checks. */
|
|
13
|
+
readonly caseSensitivePaths?: boolean;
|
|
14
|
+
};
|
|
15
|
+
export type PnwCodeRenameChange = {
|
|
16
|
+
readonly level: PnwCodeRenameLevel;
|
|
17
|
+
readonly relativePath: string;
|
|
18
|
+
readonly targetPath?: string;
|
|
19
|
+
readonly occurrences: number;
|
|
20
|
+
readonly lines?: readonly number[];
|
|
21
|
+
readonly status: "preview" | "conflict" | "invalid";
|
|
22
|
+
readonly detail?: string;
|
|
23
|
+
};
|
|
24
|
+
export type PnwCodeRenamePlan = {
|
|
25
|
+
readonly valid: boolean;
|
|
26
|
+
readonly oldText: string;
|
|
27
|
+
readonly newText: string;
|
|
28
|
+
readonly levels: readonly PnwCodeRenameLevel[];
|
|
29
|
+
readonly changes: readonly PnwCodeRenameChange[];
|
|
30
|
+
readonly summary: {
|
|
31
|
+
readonly dirs: number;
|
|
32
|
+
readonly files: number;
|
|
33
|
+
readonly textFiles: number;
|
|
34
|
+
readonly occurrences: number;
|
|
35
|
+
readonly conflicts: number;
|
|
36
|
+
};
|
|
37
|
+
readonly diagnostics: readonly string[];
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* Produces a side-effect-free plan for literal source text, filename and
|
|
41
|
+
* directory-basename renames. Hosts remain responsible for filesystem reads,
|
|
42
|
+
* case-only renames, encoding, confirmation and writes.
|
|
43
|
+
*/
|
|
44
|
+
export declare function pnwPlanCodeRename(entries: readonly PnwCodeRenameEntry[], options: PnwCodeRenameOptions): PnwCodeRenamePlan;
|
|
45
|
+
/** Applies only literal text changes after a host has accepted a preview plan. */
|
|
46
|
+
export declare function pnwApplyCodeRenameText(text: string, oldText: string, newText: string): string;
|
|
47
|
+
//# sourceMappingURL=pnwCodeRenamePlan.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pnwCodeRenamePlan.d.ts","sourceRoot":"","sources":["../src/pnwCodeRenamePlan.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,kBAAkB,GAAG,KAAK,GAAG,MAAM,GAAG,MAAM,CAAC;AAEzD,MAAM,MAAM,kBAAkB,GAAG;IAC/B,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,KAAK,CAAC;IAC9B,yEAAyE;IACzE,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;CACxB,CAAC;AAEF,MAAM,MAAM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MAAM,EAAE,CAAC;CACzC,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,iBAAiB,CAC/B,OAAO,EAAE,SAAS,kBAAkB,EAAE,EACtC,OAAO,EAAE,oBAAoB,GAC5B,iBAAiB,CAyDnB;AAED,kFAAkF;AAClF,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAE7F"}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Produces a side-effect-free plan for literal source text, filename and
|
|
3
|
+
* directory-basename renames. Hosts remain responsible for filesystem reads,
|
|
4
|
+
* case-only renames, encoding, confirmation and writes.
|
|
5
|
+
*/
|
|
6
|
+
export function pnwPlanCodeRename(entries, options) {
|
|
7
|
+
const oldText = options.oldText;
|
|
8
|
+
const newText = options.newText;
|
|
9
|
+
const levels = pnwNormalizeRenameLevels(options.levels);
|
|
10
|
+
const diagnostics = [];
|
|
11
|
+
if (!oldText || !newText)
|
|
12
|
+
diagnostics.push("旧值和新值均不能为空");
|
|
13
|
+
if (oldText === newText)
|
|
14
|
+
diagnostics.push("旧值与新值相同");
|
|
15
|
+
if (newText.includes("/") || newText.includes("\\"))
|
|
16
|
+
diagnostics.push("新名称不能包含路径分隔符");
|
|
17
|
+
const normalizedEntries = entries.map((entry) => ({ ...entry, relativePath: pnwNormalizeRelativePath(entry.relativePath) }));
|
|
18
|
+
if (normalizedEntries.some((entry) => !pnwIsSafeRelativePath(entry.relativePath)))
|
|
19
|
+
diagnostics.push("输入包含越出工作区的相对路径");
|
|
20
|
+
if (diagnostics.length)
|
|
21
|
+
return pnwEmptyRenamePlan(oldText, newText, levels, diagnostics);
|
|
22
|
+
const changes = [];
|
|
23
|
+
if (levels.includes("text")) {
|
|
24
|
+
for (const entry of normalizedEntries) {
|
|
25
|
+
if (entry.kind !== "file" || entry.text === undefined)
|
|
26
|
+
continue;
|
|
27
|
+
const occurrences = pnwCountOccurrences(entry.text, oldText);
|
|
28
|
+
if (!occurrences)
|
|
29
|
+
continue;
|
|
30
|
+
changes.push({ level: "text", relativePath: entry.relativePath, occurrences, lines: pnwHitLines(entry.text, oldText), status: "preview" });
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
const pathChanges = [];
|
|
34
|
+
for (const level of ["dir", "file"]) {
|
|
35
|
+
if (!levels.includes(level))
|
|
36
|
+
continue;
|
|
37
|
+
for (const entry of normalizedEntries) {
|
|
38
|
+
if ((level === "dir" ? "dir" : "file") !== entry.kind)
|
|
39
|
+
continue;
|
|
40
|
+
const targetPath = pnwRenameBasename(entry.relativePath, oldText, newText);
|
|
41
|
+
if (!targetPath)
|
|
42
|
+
continue;
|
|
43
|
+
pathChanges.push({ level, relativePath: entry.relativePath, targetPath, occurrences: 1, status: "preview" });
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
const caseSensitive = options.caseSensitivePaths !== false;
|
|
47
|
+
const existing = new Set(normalizedEntries.map((entry) => pnwPathKey(entry.relativePath, caseSensitive)));
|
|
48
|
+
const targetCounts = new Map();
|
|
49
|
+
for (const change of pathChanges) {
|
|
50
|
+
const key = pnwPathKey(change.targetPath, caseSensitive);
|
|
51
|
+
targetCounts.set(key, (targetCounts.get(key) ?? 0) + 1);
|
|
52
|
+
}
|
|
53
|
+
for (const change of pathChanges) {
|
|
54
|
+
const targetKey = pnwPathKey(change.targetPath, caseSensitive);
|
|
55
|
+
const sourceKey = pnwPathKey(change.relativePath, caseSensitive);
|
|
56
|
+
const collides = targetKey !== sourceKey && (existing.has(targetKey) || (targetCounts.get(targetKey) ?? 0) > 1);
|
|
57
|
+
changes.push(collides
|
|
58
|
+
? { ...change, status: "conflict", detail: existing.has(targetKey) ? `目标已存在:${change.targetPath}` : `多个条目指向同一目标:${change.targetPath}` }
|
|
59
|
+
: change);
|
|
60
|
+
}
|
|
61
|
+
changes.sort((left, right) => pnwRenameLevelOrder(left.level) - pnwRenameLevelOrder(right.level) || left.relativePath.localeCompare(right.relativePath));
|
|
62
|
+
const summary = {
|
|
63
|
+
dirs: changes.filter((change) => change.level === "dir" && change.status === "preview").length,
|
|
64
|
+
files: changes.filter((change) => change.level === "file" && change.status === "preview").length,
|
|
65
|
+
textFiles: changes.filter((change) => change.level === "text" && change.status === "preview").length,
|
|
66
|
+
occurrences: changes.reduce((count, change) => count + (change.status === "preview" ? change.occurrences : 0), 0),
|
|
67
|
+
conflicts: changes.filter((change) => change.status === "conflict").length,
|
|
68
|
+
};
|
|
69
|
+
return { valid: true, oldText, newText, levels, changes, summary, diagnostics };
|
|
70
|
+
}
|
|
71
|
+
/** Applies only literal text changes after a host has accepted a preview plan. */
|
|
72
|
+
export function pnwApplyCodeRenameText(text, oldText, newText) {
|
|
73
|
+
return oldText ? text.split(oldText).join(newText) : text;
|
|
74
|
+
}
|
|
75
|
+
function pnwEmptyRenamePlan(oldText, newText, levels, diagnostics) {
|
|
76
|
+
return { valid: false, oldText, newText, levels, changes: [], summary: { dirs: 0, files: 0, textFiles: 0, occurrences: 0, conflicts: 0 }, diagnostics };
|
|
77
|
+
}
|
|
78
|
+
function pnwNormalizeRenameLevels(levels) {
|
|
79
|
+
const allowed = ["dir", "file", "text"];
|
|
80
|
+
const selected = levels?.filter((level) => allowed.includes(level)) ?? [];
|
|
81
|
+
const resolved = selected.length ? selected : ["text"];
|
|
82
|
+
return [...new Set(resolved)];
|
|
83
|
+
}
|
|
84
|
+
function pnwNormalizeRelativePath(value) { return value.replace(/\\/g, "/").replace(/^\.\//, ""); }
|
|
85
|
+
function pnwIsSafeRelativePath(value) { return Boolean(value) && !value.startsWith("/") && !value.split("/").includes(".."); }
|
|
86
|
+
function pnwPathKey(value, caseSensitive) { return caseSensitive ? value : value.toLocaleLowerCase(); }
|
|
87
|
+
function pnwRenameBasename(path, oldText, newText) {
|
|
88
|
+
const slash = path.lastIndexOf("/");
|
|
89
|
+
const base = path.slice(slash + 1);
|
|
90
|
+
return base === oldText ? `${slash < 0 ? "" : `${path.slice(0, slash + 1)}`}${newText}` : undefined;
|
|
91
|
+
}
|
|
92
|
+
function pnwCountOccurrences(text, needle) {
|
|
93
|
+
let count = 0;
|
|
94
|
+
let offset = 0;
|
|
95
|
+
while ((offset = text.indexOf(needle, offset)) >= 0) {
|
|
96
|
+
count += 1;
|
|
97
|
+
offset += needle.length;
|
|
98
|
+
}
|
|
99
|
+
return count;
|
|
100
|
+
}
|
|
101
|
+
function pnwHitLines(text, needle) {
|
|
102
|
+
return text.split(/\r?\n/).flatMap((line, index) => line.includes(needle) ? [index + 1] : []);
|
|
103
|
+
}
|
|
104
|
+
function pnwRenameLevelOrder(level) { return level === "dir" ? 0 : level === "file" ? 1 : 2; }
|
|
105
|
+
//# sourceMappingURL=pnwCodeRenamePlan.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pnwCodeRenamePlan.js","sourceRoot":"","sources":["../src/pnwCodeRenamePlan.ts"],"names":[],"mappings":"AAqCA;;;;GAIG;AACH,MAAM,UAAU,iBAAiB,CAC/B,OAAsC,EACtC,OAA6B;IAE7B,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;IAChC,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;IAChC,MAAM,MAAM,GAAG,wBAAwB,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IACxD,MAAM,WAAW,GAAa,EAAE,CAAC;IACjC,IAAI,CAAC,OAAO,IAAI,CAAC,OAAO;QAAE,WAAW,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;IACzD,IAAI,OAAO,KAAK,OAAO;QAAE,WAAW,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IACrD,IAAI,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC;QAAE,WAAW,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;IACtF,MAAM,iBAAiB,GAAG,OAAO,CAAC,G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IAAI,KAAK,GAAG,CAAC,CAAC;IAAC,IAAI,MAAM,GAAG,CAAC,CAAC;IAC9B,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC;QAAC,KAAK,IAAI,CAAC,CAAC;QAAC,MAAM,IAAI,MAAM,CAAC,MAAM,CAAC;IAAC,CAAC;IAC7F,OAAO,KAAK,CAAC;AACf,CAAC;AACD,SAAS,WAAW,CAAC,IAAY,EAAE,MAAc;IAC/C,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;AAChG,CAAC;AACD,SAAS,mBAAmB,CAAC,KAAyB,IAAY,OAAO,KAAK,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,KAAK,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/** A serializable file result which can be displayed by any host UI. */
|
|
2
|
+
export type PnwFileResultItem = {
|
|
3
|
+
readonly relativePath: string;
|
|
4
|
+
readonly changed: boolean;
|
|
5
|
+
};
|
|
6
|
+
export type PnwFileResultGroupId = "changed" | "unchanged";
|
|
7
|
+
export type PnwFileResultSortMode = "filename" | "directory";
|
|
8
|
+
export type PnwFileResultGroup<T extends PnwFileResultItem> = {
|
|
9
|
+
readonly id: PnwFileResultGroupId;
|
|
10
|
+
readonly items: readonly T[];
|
|
11
|
+
};
|
|
12
|
+
export type PnwGroupFileResultOptions = {
|
|
13
|
+
/** Default: filename. Ties are always resolved by the full relative path. */
|
|
14
|
+
readonly sortMode?: PnwFileResultSortMode;
|
|
15
|
+
/** Default: true. Hosts may hide the unchanged group without losing its data. */
|
|
16
|
+
readonly includeUnchanged?: boolean;
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Groups file-operation results for native or web UIs without depending on a
|
|
20
|
+
* specific editor framework. Changed files are always returned first.
|
|
21
|
+
*/
|
|
22
|
+
export declare function pnwGroupFileResults<T extends PnwFileResultItem>(items: readonly T[], options?: PnwGroupFileResultOptions): readonly PnwFileResultGroup<T>[];
|
|
23
|
+
/** Compares file-operation results deterministically for a requested display mode. */
|
|
24
|
+
export declare function pnwCompareFileResults(left: PnwFileResultItem, right: PnwFileResultItem, sortMode?: PnwFileResultSortMode): number;
|
|
25
|
+
//# sourceMappingURL=pnwFileResultTree.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pnwFileResultTree.d.ts","sourceRoot":"","sources":["../src/pnwFileResultTree.ts"],"names":[],"mappings":"AAAA,wEAAwE;AACxE,MAAM,MAAM,iBAAiB,GAAG;IAC9B,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;CAC3B,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG,SAAS,GAAG,WAAW,CAAC;AAC3D,MAAM,MAAM,qBAAqB,GAAG,UAAU,GAAG,WAAW,CAAC;AAE7D,MAAM,MAAM,kBAAkB,CAAC,CAAC,SAAS,iBAAiB,IAAI;IAC5D,QAAQ,CAAC,EAAE,EAAE,oBAAoB,CAAC;IAClC,QAAQ,CAAC,KAAK,EAAE,SAAS,CAAC,EAAE,CAAC;CAC9B,CAAC;AAEF,MAAM,MAAM,yBAAyB,GAAG;IACtC,6EAA6E;IAC7E,QAAQ,CAAC,QAAQ,CAAC,EAAE,qBAAqB,CAAC;IAC1C,iFAAiF;IACjF,QAAQ,CAAC,gBAAgB,CAAC,EAAE,OAAO,CAAC;CACrC,CAAC;AAEF;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,CAAC,SAAS,iBAAiB,EAC7D,KAAK,EAAE,SAAS,CAAC,EAAE,EACnB,OAAO,GAAE,yBAA8B,GACtC,SAAS,kBAAkB,CAAC,CAAC,CAAC,EAAE,CAOlC;AAED,sFAAsF;AACtF,wBAAgB,qBAAqB,CACnC,IAAI,EAAE,iBAAiB,EACvB,KAAK,EAAE,iBAAiB,EACxB,QAAQ,GAAE,qBAAkC,GAC3C,MAAM,CAMR"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Groups file-operation results for native or web UIs without depending on a
|
|
3
|
+
* specific editor framework. Changed files are always returned first.
|
|
4
|
+
*/
|
|
5
|
+
export function pnwGroupFileResults(items, options = {}) {
|
|
6
|
+
const sortMode = options.sortMode ?? "filename";
|
|
7
|
+
const changed = items.filter((item) => item.changed).sort((a, b) => pnwCompareFileResults(a, b, sortMode));
|
|
8
|
+
const unchanged = items.filter((item) => !item.changed).sort((a, b) => pnwCompareFileResults(a, b, sortMode));
|
|
9
|
+
const groups = [{ id: "changed", items: changed }];
|
|
10
|
+
if (options.includeUnchanged !== false)
|
|
11
|
+
groups.push({ id: "unchanged", items: unchanged });
|
|
12
|
+
return groups;
|
|
13
|
+
}
|
|
14
|
+
/** Compares file-operation results deterministically for a requested display mode. */
|
|
15
|
+
export function pnwCompareFileResults(left, right, sortMode = "filename") {
|
|
16
|
+
const leftPath = pnwNormalizeRelativePath(left.relativePath);
|
|
17
|
+
const rightPath = pnwNormalizeRelativePath(right.relativePath);
|
|
18
|
+
const leftKey = sortMode === "filename" ? pnwFileName(leftPath) : pnwDirectoryName(leftPath);
|
|
19
|
+
const rightKey = sortMode === "filename" ? pnwFileName(rightPath) : pnwDirectoryName(rightPath);
|
|
20
|
+
return pnwCompareText(leftKey, rightKey) || pnwCompareText(leftPath, rightPath);
|
|
21
|
+
}
|
|
22
|
+
function pnwNormalizeRelativePath(value) {
|
|
23
|
+
return value.replace(/\\/g, "/");
|
|
24
|
+
}
|
|
25
|
+
function pnwFileName(value) {
|
|
26
|
+
return value.slice(value.lastIndexOf("/") + 1);
|
|
27
|
+
}
|
|
28
|
+
function pnwDirectoryName(value) {
|
|
29
|
+
const index = value.lastIndexOf("/");
|
|
30
|
+
return index < 0 ? "" : value.slice(0, index);
|
|
31
|
+
}
|
|
32
|
+
function pnwCompareText(left, right) {
|
|
33
|
+
const leftFolded = left.toLocaleLowerCase();
|
|
34
|
+
const rightFolded = right.toLocaleLowerCase();
|
|
35
|
+
return leftFolded < rightFolded ? -1 : leftFolded > rightFolded ? 1 : left < right ? -1 : left > right ? 1 : 0;
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=pnwFileResultTree.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pnwFileResultTree.js","sourceRoot":"","sources":["../src/pnwFileResultTree.ts"],"names":[],"mappings":"AAqBA;;;GAGG;AACH,MAAM,UAAU,mBAAmB,CACjC,KAAmB,EACnB,UAAqC,EAAE;IAEvC,MAAM,QAAQ,GAAG,OAAO,CAAC,QAAQ,IAAI,UAAU,CAAC;IAChD,MAAM,OAAO,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,qBAAqB,CAAC,CAAC,EAAE,CAAC,EAAE,QAAQ,CAAC,CAAC,CAAC;IAC3G,MAAM,SAAS,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,qBAAqB,CAAC,CAAC,EAAE,CAAC,EAAE,QAAQ,CAAC,CAAC,CAAC;IAC9G,MAAM,MAAM,GAA4B,CAAC,EAAE,EAAE,EAAE,SAAS,EAAE,KA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