@nestia/core 12.0.0-dev.20260521.3 → 12.0.0-dev.20260521.5
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.
|
@@ -132,6 +132,21 @@ func runBuild(args []string) int {
|
|
|
132
132
|
if profile {
|
|
133
133
|
started = time.Now()
|
|
134
134
|
}
|
|
135
|
+
contributorRewriters, contributorDiags := collectContributorBuildOutputRewriters(prog, plan)
|
|
136
|
+
contributorCount := 0
|
|
137
|
+
for _, rewriter := range contributorRewriters {
|
|
138
|
+
if rewriter.Len != nil {
|
|
139
|
+
contributorCount += rewriter.Len()
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
profileBuildStepCount(profile, "contributor-rewrites", started, contributorCount)
|
|
143
|
+
if len(contributorDiags) > 0 {
|
|
144
|
+
WriteTypiaTransformDiagnostics(stderr, contributorDiags, cwd)
|
|
145
|
+
return 3
|
|
146
|
+
}
|
|
147
|
+
if profile {
|
|
148
|
+
started = time.Now()
|
|
149
|
+
}
|
|
135
150
|
newPathsRewriter(prog).applyAll(prog.SourceFiles())
|
|
136
151
|
profileBuildStep(profile, "paths-rewrite", started)
|
|
137
152
|
|
|
@@ -152,6 +167,15 @@ func runBuild(args []string) int {
|
|
|
152
167
|
if err != nil {
|
|
153
168
|
return err
|
|
154
169
|
}
|
|
170
|
+
for _, rewriter := range contributorRewriters {
|
|
171
|
+
if rewriter.Apply == nil {
|
|
172
|
+
continue
|
|
173
|
+
}
|
|
174
|
+
patched, err = rewriter.Apply(fileName, patched)
|
|
175
|
+
if err != nil {
|
|
176
|
+
return err
|
|
177
|
+
}
|
|
178
|
+
}
|
|
155
179
|
if profile {
|
|
156
180
|
patchStarted = time.Now()
|
|
157
181
|
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
package transform
|
|
2
|
+
|
|
3
|
+
import (
|
|
4
|
+
"github.com/samchon/nestia/packages/core/native/plugin"
|
|
5
|
+
"github.com/samchon/ttsc/packages/ttsc/driver"
|
|
6
|
+
)
|
|
7
|
+
|
|
8
|
+
// BuildOutputRewriter patches emitted JavaScript after the core native
|
|
9
|
+
// rewrites have been applied. Contributor packages register these from init().
|
|
10
|
+
type BuildOutputRewriter struct {
|
|
11
|
+
Len func() int
|
|
12
|
+
Apply func(outputName string, text string) (string, error)
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
type buildOutputRewriteCollector func(*driver.Program, plugin.Plan) (*BuildOutputRewriter, []Diagnostic)
|
|
16
|
+
type sourceRewriteCollector func(*driver.Program, plugin.Plan, string) (map[string][]SourceRewrite, []Diagnostic)
|
|
17
|
+
|
|
18
|
+
var buildOutputRewriteCollectors []buildOutputRewriteCollector
|
|
19
|
+
var sourceRewriteCollectors []sourceRewriteCollector
|
|
20
|
+
|
|
21
|
+
// RegisterBuildOutputRewriteCollector registers a statically linked
|
|
22
|
+
// contributor's emitted-JavaScript rewrite pass.
|
|
23
|
+
func RegisterBuildOutputRewriteCollector(collector buildOutputRewriteCollector) {
|
|
24
|
+
if collector != nil {
|
|
25
|
+
buildOutputRewriteCollectors = append(buildOutputRewriteCollectors, collector)
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// RegisterSourceRewriteCollector registers a statically linked contributor's
|
|
30
|
+
// TypeScript source-to-source rewrite pass.
|
|
31
|
+
func RegisterSourceRewriteCollector(collector sourceRewriteCollector) {
|
|
32
|
+
if collector != nil {
|
|
33
|
+
sourceRewriteCollectors = append(sourceRewriteCollectors, collector)
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
func collectContributorBuildOutputRewriters(
|
|
38
|
+
prog *driver.Program,
|
|
39
|
+
plan plugin.Plan,
|
|
40
|
+
) ([]BuildOutputRewriter, []Diagnostic) {
|
|
41
|
+
output := []BuildOutputRewriter{}
|
|
42
|
+
diagnostics := []Diagnostic{}
|
|
43
|
+
for _, collector := range buildOutputRewriteCollectors {
|
|
44
|
+
rewriter, diags := collector(prog, plan)
|
|
45
|
+
diagnostics = append(diagnostics, diags...)
|
|
46
|
+
if rewriter != nil && rewriter.Apply != nil {
|
|
47
|
+
output = append(output, *rewriter)
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return output, diagnostics
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
func collectContributorSourceRewriteMap(
|
|
54
|
+
prog *driver.Program,
|
|
55
|
+
plan plugin.Plan,
|
|
56
|
+
onlyFile string,
|
|
57
|
+
) (map[string][]SourceRewrite, []Diagnostic) {
|
|
58
|
+
output := map[string][]SourceRewrite{}
|
|
59
|
+
diagnostics := []Diagnostic{}
|
|
60
|
+
for _, collector := range sourceRewriteCollectors {
|
|
61
|
+
rewrites, diags := collector(prog, plan, onlyFile)
|
|
62
|
+
diagnostics = append(diagnostics, diags...)
|
|
63
|
+
for file, entries := range rewrites {
|
|
64
|
+
output[file] = append(output[file], entries...)
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
return output, diagnostics
|
|
68
|
+
}
|
package/native/transform/run.go
CHANGED
|
@@ -21,9 +21,10 @@ var (
|
|
|
21
21
|
// which is a pre-existing protocol shared by all `nestia.*` codes. The
|
|
22
22
|
// full stack is preserved behind NESTIA_NATIVE_DEBUG_STACK for triage.
|
|
23
23
|
//
|
|
24
|
-
// This is the `@nestia/core` plugin entry point
|
|
25
|
-
//
|
|
26
|
-
//
|
|
24
|
+
// This is the `@nestia/core` plugin entry point. It performs typia and core
|
|
25
|
+
// decorator rewrites, then runs any statically linked contributor rewrite
|
|
26
|
+
// collectors such as the SDK metadata pass when the caller explicitly enables
|
|
27
|
+
// them.
|
|
27
28
|
func Run(args []string) (code int) {
|
|
28
29
|
defer func() {
|
|
29
30
|
if exp := recover(); exp != nil {
|
|
@@ -103,6 +103,12 @@ func runTransform(args []string) int {
|
|
|
103
103
|
return 3
|
|
104
104
|
}
|
|
105
105
|
rewrites = append(rewrites, coreRewriteMap[filepath.ToSlash(absFile)]...)
|
|
106
|
+
contributorRewriteMap, contributorDiagnostics := collectContributorSourceRewriteMap(prog, plan, absFile)
|
|
107
|
+
if len(contributorDiagnostics) > 0 {
|
|
108
|
+
WriteTypiaTransformDiagnostics(stderr, contributorDiagnostics, cwd)
|
|
109
|
+
return 3
|
|
110
|
+
}
|
|
111
|
+
rewrites = append(rewrites, contributorRewriteMap[filepath.ToSlash(absFile)]...)
|
|
106
112
|
source, ok := SourceFileText(target)
|
|
107
113
|
if !ok {
|
|
108
114
|
fmt.Fprintf(stderr, "ttsc-nestia transform: source text is unavailable for %s\n", absFile)
|
|
@@ -143,7 +149,12 @@ func runTransformProject(prog *driver.Program, cwd string, tsconfigPath string,
|
|
|
143
149
|
for file, entries := range coreRewriteMap {
|
|
144
150
|
rewrites[file] = append(rewrites[file], entries...)
|
|
145
151
|
}
|
|
152
|
+
contributorRewriteMap, contributorDiags := collectContributorSourceRewriteMap(prog, plan, "")
|
|
153
|
+
for file, entries := range contributorRewriteMap {
|
|
154
|
+
rewrites[file] = append(rewrites[file], entries...)
|
|
155
|
+
}
|
|
146
156
|
diags = append(diags, coreDiags...)
|
|
157
|
+
diags = append(diags, contributorDiags...)
|
|
147
158
|
output := transformProjectOutput{
|
|
148
159
|
Diagnostics: make([]transformCompilerDiagnostic, 0, len(diags)),
|
|
149
160
|
TypeScript: map[string]string{},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nestia/core",
|
|
3
|
-
"version": "12.0.0-dev.20260521.
|
|
3
|
+
"version": "12.0.0-dev.20260521.5",
|
|
4
4
|
"description": "Super-fast validation decorators of NestJS",
|
|
5
5
|
"types": "lib/index.d.ts",
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
"tgrid": "^1.1.0",
|
|
58
58
|
"typia": "13.0.0-dev.20260521.1",
|
|
59
59
|
"ws": "^7.5.3",
|
|
60
|
-
"@nestia/fetcher": "^12.0.0-dev.20260521.
|
|
60
|
+
"@nestia/fetcher": "^12.0.0-dev.20260521.5"
|
|
61
61
|
},
|
|
62
62
|
"peerDependencies": {
|
|
63
63
|
"@nestjs/common": ">=7.0.1",
|
|
@@ -65,7 +65,7 @@
|
|
|
65
65
|
"reflect-metadata": ">=0.1.12",
|
|
66
66
|
"rxjs": ">=6.0.3",
|
|
67
67
|
"typia": "13.0.0-dev.20260521.1",
|
|
68
|
-
"@nestia/fetcher": "^12.0.0-dev.20260521.
|
|
68
|
+
"@nestia/fetcher": "^12.0.0-dev.20260521.5"
|
|
69
69
|
},
|
|
70
70
|
"devDependencies": {
|
|
71
71
|
"@nestjs/common": "^11.1.6",
|