@canmi/seam-react 0.4.11 → 0.4.15
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/index.d.ts +7 -2
- package/dist/index.d.ts.map +1 -1
- package/package.json +4 -4
- package/scripts/build-skeletons.mjs +26 -2
package/dist/index.d.ts
CHANGED
|
@@ -11,9 +11,14 @@ interface LoaderDef {
|
|
|
11
11
|
procedure: string;
|
|
12
12
|
params?: Record<string, ParamMapping>;
|
|
13
13
|
}
|
|
14
|
+
/** Lazy component loader returned by dynamic import (per-page splitting) */
|
|
15
|
+
type LazyComponentLoader = () => Promise<{
|
|
16
|
+
default: ComponentType<Record<string, unknown>>;
|
|
17
|
+
[key: string]: unknown;
|
|
18
|
+
}>;
|
|
14
19
|
interface RouteDef {
|
|
15
20
|
path: string;
|
|
16
|
-
component?: ComponentType<Record<string, unknown
|
|
21
|
+
component?: ComponentType<Record<string, unknown>> | LazyComponentLoader;
|
|
17
22
|
layout?: ComponentType<{
|
|
18
23
|
children: ReactNode;
|
|
19
24
|
}>;
|
|
@@ -56,5 +61,5 @@ declare function useSeamSubscription<T>(baseUrl: string, procedure: string, inpu
|
|
|
56
61
|
declare const SeamNavigateProvider: react.Provider<(url: string) => void>;
|
|
57
62
|
declare function useSeamNavigate(): (url: string) => void;
|
|
58
63
|
//#endregion
|
|
59
|
-
export { type LoaderDef, type ParamMapping, type RouteDef, SeamDataProvider, SeamNavigateProvider, type SubscriptionStatus, type UseSeamSubscriptionResult, buildSentinelData, defineRoutes, parseSeamData, useSeamData, useSeamNavigate, useSeamSubscription };
|
|
64
|
+
export { type LazyComponentLoader, type LoaderDef, type ParamMapping, type RouteDef, SeamDataProvider, SeamNavigateProvider, type SubscriptionStatus, type UseSeamSubscriptionResult, buildSentinelData, defineRoutes, parseSeamData, useSeamData, useSeamNavigate, useSeamSubscription };
|
|
60
65
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/types.ts","../src/define-routes.ts","../src/use-seam-data.ts","../src/sentinel.ts","../src/use-seam-subscription.ts","../src/use-seam-navigate.ts"],"mappings":";;;;;UAIiB,YAAA;EACf,IAAA;EACA,IAAA;AAAA;AAAA,UAGe,SAAA;EACf,SAAA;EACA,MAAA,GAAS,MAAA,SAAe,YAAA;AAAA;AAAA,
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/types.ts","../src/define-routes.ts","../src/use-seam-data.ts","../src/sentinel.ts","../src/use-seam-subscription.ts","../src/use-seam-navigate.ts"],"mappings":";;;;;UAIiB,YAAA;EACf,IAAA;EACA,IAAA;AAAA;AAAA,UAGe,SAAA;EACf,SAAA;EACA,MAAA,GAAS,MAAA,SAAe,YAAA;AAAA;;KAId,mBAAA,SAA4B,OAAA;EACtC,OAAA,EAAS,aAAA,CAAc,MAAA;EAAA,CACtB,GAAA;AAAA;AAAA,UAGc,QAAA;EACf,IAAA;EACA,SAAA,GAAY,aAAA,CAAc,MAAA,qBAA2B,mBAAA;EACrD,MAAA,GAAS,aAAA;IAAgB,QAAA,EAAU,SAAA;EAAA;EACnC,QAAA,GAAW,QAAA;EACX,OAAA,GAAU,MAAA,SAAe,SAAA;EACzB,IAAA,GAAO,MAAA;EACP,QAAA;EACA,SAAA;AAAA;;;iBCxBc,YAAA,CAAa,MAAA,EAAQ,QAAA,KAAa,QAAA;;;cCErC,gBAAA,EAA2C,KAAA,CAA3B,QAAA;AAAA,iBAEb,WAAA,oBAA+B,MAAA,kBAAA,CAAA,GAA4B,CAAA;AAAA,iBAO3D,aAAA,CAAc,MAAA,YAAoB,MAAA;;;;;;;;AFXlD;;;iBGMgB,iBAAA,CACd,GAAA,EAAK,MAAA,mBACL,MAAA,WACA,SAAA,GAAY,GAAA,WACX,MAAA;;;KCTS,kBAAA;AAAA,UAEK,yBAAA;EACf,IAAA,EAAM,CAAA;EACN,KAAA,EAAO,eAAA;EACP,MAAA,EAAQ,kBAAA;AAAA;AAAA,iBAGM,mBAAA,GAAA,CACd,OAAA,UACA,SAAA,UACA,KAAA,YACC,yBAAA,CAA0B,CAAA;;;cCThB,oBAAA,EAAmD,KAAA,CAA/B,QAAA,EAAA,GAAA;AAAA,iBAEjB,eAAA,CAAA,IAAoB,GAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@canmi/seam-react",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.15",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist",
|
|
@@ -18,12 +18,12 @@
|
|
|
18
18
|
"test": "vitest run"
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@canmi/seam-client": "0.4.
|
|
21
|
+
"@canmi/seam-client": "0.4.15",
|
|
22
22
|
"esbuild": "^0.27.3"
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
|
-
"@canmi/seam-engine": "0.4.
|
|
26
|
-
"@canmi/seam-i18n": "0.4.
|
|
25
|
+
"@canmi/seam-engine": "0.4.15",
|
|
26
|
+
"@canmi/seam-i18n": "0.4.15",
|
|
27
27
|
"@types/react": "^19.2.14",
|
|
28
28
|
"@types/react-dom": "^19.2.3",
|
|
29
29
|
"jsdom": "^28.1.0",
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/* src/client/react/scripts/build-skeletons.mjs */
|
|
2
2
|
|
|
3
3
|
import { build } from "esbuild";
|
|
4
|
-
import { readFileSync, mkdirSync, unlinkSync } from "node:fs";
|
|
5
|
-
import { join, dirname, resolve } from "node:path";
|
|
4
|
+
import { readFileSync, mkdirSync, unlinkSync, existsSync } from "node:fs";
|
|
5
|
+
import { join, dirname, resolve, relative } from "node:path";
|
|
6
6
|
import { fileURLToPath } from "node:url";
|
|
7
7
|
|
|
8
8
|
import { SeamBuildError } from "./skeleton/render.mjs";
|
|
@@ -37,6 +37,16 @@ function loadI18nConfig(i18nArg) {
|
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
+
/** Resolve a source file path, probing for .tsx/.ts/.jsx/.js extensions */
|
|
41
|
+
function resolveSourcePath(p) {
|
|
42
|
+
if (existsSync(p)) return p;
|
|
43
|
+
const base = p.replace(/\.[jt]sx?$/, "");
|
|
44
|
+
for (const ext of [".tsx", ".ts", ".jsx", ".js"]) {
|
|
45
|
+
if (existsSync(base + ext)) return base + ext;
|
|
46
|
+
}
|
|
47
|
+
return p;
|
|
48
|
+
}
|
|
49
|
+
|
|
40
50
|
async function main() {
|
|
41
51
|
const routesFile = process.argv[2];
|
|
42
52
|
if (!routesFile) {
|
|
@@ -126,12 +136,26 @@ async function main() {
|
|
|
126
136
|
stats: { hits: 0, misses: 0 },
|
|
127
137
|
};
|
|
128
138
|
|
|
139
|
+
// Build sourceFileMap: route path -> component source file (relative to cwd)
|
|
140
|
+
const sourceFileMap = {};
|
|
141
|
+
for (const route of flat) {
|
|
142
|
+
if (route.component?.name) {
|
|
143
|
+
const specifier = importMap.get(route.component.name);
|
|
144
|
+
if (specifier) {
|
|
145
|
+
const abs = resolve(routesDir, specifier);
|
|
146
|
+
const resolved = resolveSourcePath(abs);
|
|
147
|
+
sourceFileMap[route.path] = relative(process.cwd(), resolved);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
|
|
129
152
|
const layouts = await processLayoutsWithCache(layoutMap, ctx);
|
|
130
153
|
const renderedRoutes = await processRoutesWithCache(flat, ctx);
|
|
131
154
|
|
|
132
155
|
const output = {
|
|
133
156
|
layouts,
|
|
134
157
|
routes: renderedRoutes,
|
|
158
|
+
sourceFileMap,
|
|
135
159
|
warnings: buildWarnings,
|
|
136
160
|
cacheStats: ctx.stats,
|
|
137
161
|
};
|