gorsee 0.2.12 → 0.2.14
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/dist-pkg/cli/canonical-import-rewrite.js +4 -4
- package/dist-pkg/cli/canonical-imports.d.ts +2 -1
- package/dist-pkg/cli/canonical-imports.js +94 -0
- package/dist-pkg/cli/cmd-check.js +3 -3
- package/dist-pkg/cli/cmd-upgrade.js +1 -1
- package/dist-pkg/runtime/typed-routes.js +3 -4
- package/package.json +3 -3
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { readFile, readdir, stat, writeFile } from "node:fs/promises";
|
|
2
2
|
import { join, relative } from "node:path";
|
|
3
|
-
import { CLIENT_SCOPED_IMPORTS, SERVER_SCOPED_IMPORTS } from "./canonical-imports.js";
|
|
4
|
-
const IMPORT_RE = /import\s*\{([\s\S]*?)\}\s*from\s*(["'])(gorsee
|
|
3
|
+
import { CLIENT_SCOPED_IMPORTS, ROOT_SCOPED_IMPORTS, SERVER_SCOPED_IMPORTS } from "./canonical-imports.js";
|
|
4
|
+
const IMPORT_RE = /import\s*\{([\s\S]*?)\}\s*from\s*(["'])(gorsee(?:\/(?:server|client))?)\2/g;
|
|
5
5
|
export function rewriteCanonicalImports(source) {
|
|
6
6
|
let changed = !1;
|
|
7
7
|
const rewritten = source.replace(IMPORT_RE, (statement, bindings, _quote, specifier) => {
|
|
8
|
-
const scopedMap = specifier === "gorsee/server" ? SERVER_SCOPED_IMPORTS : CLIENT_SCOPED_IMPORTS, parsed = parseBindings(bindings), kept = [], moved = new Map;
|
|
8
|
+
const scopedMap = specifier === "gorsee" ? ROOT_SCOPED_IMPORTS : specifier === "gorsee/server" ? SERVER_SCOPED_IMPORTS : CLIENT_SCOPED_IMPORTS, parsed = parseBindings(bindings), kept = [], moved = new Map;
|
|
9
9
|
for (const binding of parsed) {
|
|
10
10
|
const target = scopedMap.get(binding.importedName);
|
|
11
11
|
if (!target) {
|
|
@@ -21,7 +21,7 @@ export function rewriteCanonicalImports(source) {
|
|
|
21
21
|
changed = !0;
|
|
22
22
|
const rewrittenImports = [];
|
|
23
23
|
if (kept.length > 0)
|
|
24
|
-
rewrittenImports.push(renderImport(specifier, kept));
|
|
24
|
+
rewrittenImports.push(renderImport(specifier === "gorsee" ? "gorsee/compat" : specifier, kept));
|
|
25
25
|
for (const target of [...moved.keys()].sort())
|
|
26
26
|
rewrittenImports.push(renderImport(target, moved.get(target) ?? []));
|
|
27
27
|
return rewrittenImports.join(`
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import type { ModuleImportFact } from "../compiler/module-analysis.js";
|
|
2
2
|
export declare const SERVER_SCOPED_IMPORTS: Map<string, string>;
|
|
3
3
|
export declare const CLIENT_SCOPED_IMPORTS: Map<string, string>;
|
|
4
|
+
export declare const ROOT_SCOPED_IMPORTS: Map<string, string>;
|
|
4
5
|
export interface CanonicalImportDrift {
|
|
5
|
-
source: "gorsee/server" | "gorsee/client";
|
|
6
|
+
source: "gorsee" | "gorsee/server" | "gorsee/client";
|
|
6
7
|
replacements: Map<string, string>;
|
|
7
8
|
}
|
|
8
9
|
export declare function collectCanonicalImportDrift(imports: ModuleImportFact[]): CanonicalImportDrift[];
|
|
@@ -103,10 +103,104 @@ export const SERVER_SCOPED_IMPORTS = new Map([
|
|
|
103
103
|
["extractRouteParamKeys", "gorsee/routes"],
|
|
104
104
|
["TypedRouteDefinition", "gorsee/routes"],
|
|
105
105
|
["TypedRouteTarget", "gorsee/routes"]
|
|
106
|
+
]), ROOT_SCOPED_IMPORTS = new Map([
|
|
107
|
+
["createSignal", "gorsee/client"],
|
|
108
|
+
["createComputed", "gorsee/client"],
|
|
109
|
+
["createEffect", "gorsee/client"],
|
|
110
|
+
["createResource", "gorsee/client"],
|
|
111
|
+
["createDataQuery", "gorsee/client"],
|
|
112
|
+
["createDataMutation", "gorsee/client"],
|
|
113
|
+
["createStore", "gorsee/client"],
|
|
114
|
+
["createLive", "gorsee/client"],
|
|
115
|
+
["invalidateResource", "gorsee/client"],
|
|
116
|
+
["invalidateAll", "gorsee/client"],
|
|
117
|
+
["createMutation", "gorsee/client"],
|
|
118
|
+
["Suspense", "gorsee/client"],
|
|
119
|
+
["Link", "gorsee/client"],
|
|
120
|
+
["Head", "gorsee/client"],
|
|
121
|
+
["navigate", "gorsee/client"],
|
|
122
|
+
["onNavigate", "gorsee/client"],
|
|
123
|
+
["beforeNavigate", "gorsee/client"],
|
|
124
|
+
["getCurrentPath", "gorsee/client"],
|
|
125
|
+
["useFormAction", "gorsee/forms"],
|
|
126
|
+
["FormActionResult", "gorsee/forms"],
|
|
127
|
+
["FormState", "gorsee/forms"],
|
|
128
|
+
["FormSubmitOptions", "gorsee/forms"],
|
|
129
|
+
["Image", "gorsee/client"],
|
|
130
|
+
["getImageProps", "gorsee/client"],
|
|
131
|
+
["buildImageSrcSet", "gorsee/client"],
|
|
132
|
+
["getImageCandidateWidths", "gorsee/client"],
|
|
133
|
+
["isAllowedRemoteImage", "gorsee/client"],
|
|
134
|
+
["defaultImageLoader", "gorsee/client"],
|
|
135
|
+
["ImageProps", "gorsee/client"],
|
|
136
|
+
["ImageLoader", "gorsee/client"],
|
|
137
|
+
["ImageLoaderParams", "gorsee/client"],
|
|
138
|
+
["ImageRuntimeConfig", "gorsee/client"],
|
|
139
|
+
["ImageRemotePattern", "gorsee/client"],
|
|
140
|
+
["ImageFormat", "gorsee/client"],
|
|
141
|
+
["ErrorBoundary", "gorsee/client"],
|
|
142
|
+
["island", "gorsee/client"],
|
|
143
|
+
["createEventSource", "gorsee/client"],
|
|
144
|
+
["setupI18n", "gorsee/i18n"],
|
|
145
|
+
["loadLocale", "gorsee/i18n"],
|
|
146
|
+
["getLocale", "gorsee/i18n"],
|
|
147
|
+
["getLocales", "gorsee/i18n"],
|
|
148
|
+
["getDefaultLocale", "gorsee/i18n"],
|
|
149
|
+
["getFallbackLocales", "gorsee/i18n"],
|
|
150
|
+
["setLocale", "gorsee/i18n"],
|
|
151
|
+
["t", "gorsee/i18n"],
|
|
152
|
+
["plural", "gorsee/i18n"],
|
|
153
|
+
["negotiateLocale", "gorsee/i18n"],
|
|
154
|
+
["resolveLocaleFromPath", "gorsee/i18n"],
|
|
155
|
+
["stripLocalePrefix", "gorsee/i18n"],
|
|
156
|
+
["withLocalePath", "gorsee/i18n"],
|
|
157
|
+
["buildHreflangLinks", "gorsee/i18n"],
|
|
158
|
+
["formatNumber", "gorsee/i18n"],
|
|
159
|
+
["formatDate", "gorsee/i18n"],
|
|
160
|
+
["formatRelativeTime", "gorsee/i18n"],
|
|
161
|
+
["I18nConfig", "gorsee/i18n"],
|
|
162
|
+
["LocaleNegotiationInput", "gorsee/i18n"],
|
|
163
|
+
["LocaleNegotiationResult", "gorsee/i18n"],
|
|
164
|
+
["typedLink", "gorsee/routes"],
|
|
165
|
+
["typedNavigate", "gorsee/routes"],
|
|
166
|
+
["typedPrefetch", "gorsee/routes"],
|
|
167
|
+
["buildSearchParams", "gorsee/routes"],
|
|
168
|
+
["buildTypedPath", "gorsee/routes"],
|
|
169
|
+
["createTypedRoute", "gorsee/routes"],
|
|
170
|
+
["extractRouteParamKeys", "gorsee/routes"],
|
|
171
|
+
["defineForm", "gorsee/forms"],
|
|
172
|
+
["defineFormAction", "gorsee/forms"],
|
|
173
|
+
["validateForm", "gorsee/forms"],
|
|
174
|
+
["validateAction", "gorsee/forms"],
|
|
175
|
+
["toFieldErrors", "gorsee/forms"],
|
|
176
|
+
["fieldAttrs", "gorsee/forms"],
|
|
177
|
+
["FormField", "gorsee/forms"],
|
|
178
|
+
["FormSchema", "gorsee/forms"],
|
|
179
|
+
["ValidationResult", "gorsee/forms"],
|
|
180
|
+
["ActionValidationResult", "gorsee/forms"],
|
|
181
|
+
["ValidationError", "gorsee/forms"],
|
|
182
|
+
["loadContentCollection", "gorsee/content"],
|
|
183
|
+
["parseFrontmatter", "gorsee/content"],
|
|
184
|
+
["extractExcerpt", "gorsee/content"],
|
|
185
|
+
["queryContent", "gorsee/content"],
|
|
186
|
+
["getContentEntryBySlug", "gorsee/content"],
|
|
187
|
+
["ContentCollectionOptions", "gorsee/content"],
|
|
188
|
+
["ContentEntry", "gorsee/content"],
|
|
189
|
+
["ContentQueryOptions", "gorsee/content"],
|
|
190
|
+
["createAuth", "gorsee/auth"],
|
|
191
|
+
["definePlugin", "gorsee/plugins"],
|
|
192
|
+
["createPluginRunner", "gorsee/plugins"],
|
|
193
|
+
["GorseePlugin", "gorsee/plugins"],
|
|
194
|
+
["PluginContext", "gorsee/plugins"]
|
|
106
195
|
]);
|
|
107
196
|
export function collectCanonicalImportDrift(imports) {
|
|
108
197
|
const drift = [];
|
|
109
198
|
for (const entry of imports) {
|
|
199
|
+
if (entry.specifier === "gorsee") {
|
|
200
|
+
const replacements = collectScopedReplacements(entry, ROOT_SCOPED_IMPORTS);
|
|
201
|
+
if (replacements.size > 0)
|
|
202
|
+
drift.push({ source: "gorsee", replacements });
|
|
203
|
+
}
|
|
110
204
|
if (entry.specifier === "gorsee/server") {
|
|
111
205
|
const replacements = collectScopedReplacements(entry, SERVER_SCOPED_IMPORTS);
|
|
112
206
|
if (replacements.size > 0)
|
|
@@ -350,10 +350,10 @@ function checkImportContracts(cwd, astFacts) {
|
|
|
350
350
|
for (const drift of collectCanonicalImportDrift(facts.imports)) {
|
|
351
351
|
const entries = [...drift.replacements.entries()].map(([name, target]) => `${name} -> ${target}`).join(", "), targets = [...new Set(drift.replacements.values())].join(", ");
|
|
352
352
|
issues.push({
|
|
353
|
-
code: drift.source === "gorsee/server" ? "W914" : "W915",
|
|
353
|
+
code: drift.source === "gorsee" ? "W927" : drift.source === "gorsee/server" ? "W914" : "W915",
|
|
354
354
|
file: rel,
|
|
355
|
-
message: `Domain APIs imported from "${drift.source}" should use scoped stable subpaths: ${entries}`,
|
|
356
|
-
fix: drift.source === "gorsee/server" ? `Keep runtime primitives on "gorsee/server" and move domain imports to scoped entrypoints such as ${targets}` : `Keep browser runtime primitives on "gorsee/client" and move domain imports to scoped entrypoints such as ${targets}`
|
|
355
|
+
message: drift.source === "gorsee" ? `Compatibility-root imports should move to canonical stable entrypoints: ${entries}` : `Domain APIs imported from "${drift.source}" should use scoped stable subpaths: ${entries}`,
|
|
356
|
+
fix: drift.source === "gorsee" ? `Split root imports across canonical stable entrypoints such as ${targets}, and keep "gorsee/compat" only for explicit legacy bridges` : drift.source === "gorsee/server" ? `Keep runtime primitives on "gorsee/server" and move domain imports to scoped entrypoints such as ${targets}` : `Keep browser runtime primitives on "gorsee/client" and move domain imports to scoped entrypoints such as ${targets}`
|
|
357
357
|
});
|
|
358
358
|
}
|
|
359
359
|
}
|
|
@@ -132,7 +132,7 @@ export async function collectUpgradeIssues(cwd) {
|
|
|
132
132
|
issues.push(issue("UG008", relative(cwd, file), 'Compatibility-only root "gorsee" import is still used in application code', 'Move browser-safe imports to "gorsee/client", server code to "gorsee/server", or explicit compatibility bridges to "gorsee/compat"'));
|
|
133
133
|
for (const drift of collectCanonicalImportDrift(facts.imports)) {
|
|
134
134
|
const entries = [...drift.replacements.entries()].map(([name, target]) => `${name} -> ${target}`).join(", "), targets = [...new Set(drift.replacements.values())].join(", ");
|
|
135
|
-
issues.push(issue(drift.source === "gorsee/server" ? "UG009" : "UG010", relative(cwd, file), `Domain APIs still come from "${drift.source}" instead of scoped stable subpaths: ${entries}`, drift.source === "gorsee/server" ? `Keep runtime primitives on "gorsee/server" and move domain imports to ${targets}` : `Keep browser runtime primitives on "gorsee/client" and move domain imports to ${targets}`, "info"));
|
|
135
|
+
issues.push(issue(drift.source === "gorsee" ? "UG013" : drift.source === "gorsee/server" ? "UG009" : "UG010", relative(cwd, file), drift.source === "gorsee" ? `Compatibility-root imports still hide canonical stable entrypoints: ${entries}` : `Domain APIs still come from "${drift.source}" instead of scoped stable subpaths: ${entries}`, drift.source === "gorsee" ? `Split root imports across canonical stable entrypoints such as ${targets}, and keep "gorsee/compat" only where the import is intentionally compatibility-bound` : drift.source === "gorsee/server" ? `Keep runtime primitives on "gorsee/server" and move domain imports to ${targets}` : `Keep browser runtime primitives on "gorsee/client" and move domain imports to ${targets}`, "info"));
|
|
136
136
|
}
|
|
137
137
|
if (facts.exportedNames.has("loader"))
|
|
138
138
|
issues.push(issue("UG011", relative(cwd, file), 'Route module still exports "loader" instead of canonical "load"', 'Rename exported "loader" to "load", or run `gorsee upgrade` to rewrite obvious cases automatically', "info"));
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { navigate, prefetch } from "./router.js";
|
|
1
2
|
function isTypedRouteOptions(value) {
|
|
2
3
|
return "params" in value || "search" in value || "hash" in value;
|
|
3
4
|
}
|
|
@@ -67,11 +68,9 @@ export function createTypedRoute(path) {
|
|
|
67
68
|
}
|
|
68
69
|
export function typedNavigate(target, paramsOrOptions = {}) {
|
|
69
70
|
const url = typedLink(target, paramsOrOptions);
|
|
70
|
-
return
|
|
71
|
+
return Promise.resolve().then(() => navigate(url));
|
|
71
72
|
}
|
|
72
73
|
export function typedPrefetch(target, paramsOrOptions = {}) {
|
|
73
74
|
const url = typedLink(target, paramsOrOptions);
|
|
74
|
-
return
|
|
75
|
-
m.prefetch(url);
|
|
76
|
-
});
|
|
75
|
+
return Promise.resolve().then(() => prefetch(url));
|
|
77
76
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "gorsee",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.14",
|
|
4
4
|
"description": "AI-first reactive full-stack TypeScript framework for deterministic human and agent collaboration",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"packageManager": "bun@1.3.9",
|
|
@@ -133,7 +133,7 @@
|
|
|
133
133
|
"backend:candidate:evidence:verify": "bun run compiler:evidence:verify && bun run build:evidence:verify && node scripts/backend-candidate-evidence-check.mjs && node scripts/backend-default-switch-review-check.mjs && node scripts/backend-switch-evidence-check.mjs"
|
|
134
134
|
},
|
|
135
135
|
"engines": {
|
|
136
|
-
"bun": "
|
|
136
|
+
"bun": "1.3.9"
|
|
137
137
|
},
|
|
138
138
|
"dependencies": {
|
|
139
139
|
"alien-signals": "3.1.2",
|
|
@@ -143,7 +143,7 @@
|
|
|
143
143
|
"typescript": "5.9.3"
|
|
144
144
|
},
|
|
145
145
|
"devDependencies": {
|
|
146
|
-
"@types/bun": "
|
|
146
|
+
"@types/bun": "1.3.10",
|
|
147
147
|
"playwright": "1.58.2"
|
|
148
148
|
},
|
|
149
149
|
"types": "./dist-pkg/index.d.ts"
|