@swissjs/swite 0.3.0 → 0.3.2
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/CHANGELOG.md +15 -0
- package/dist/adapters/proxy/SwiteProxyError.d.ts.map +1 -0
- package/dist/{proxy → adapters/proxy}/proxyToPython.d.ts +1 -1
- package/dist/adapters/proxy/proxyToPython.d.ts.map +1 -0
- package/dist/build-engine/builder.d.ts.map +1 -0
- package/dist/{builder.js → build-engine/builder.js} +8 -14
- package/dist/cli.js +5 -5
- package/dist/config/config-loader.d.ts.map +1 -0
- package/dist/{config.d.ts → config/config.d.ts} +11 -0
- package/dist/config/config.d.ts.map +1 -0
- package/dist/config/env.d.ts +25 -0
- package/dist/config/env.d.ts.map +1 -0
- package/dist/config/env.js +84 -0
- package/dist/{handlers → dev-engine/handlers}/base-handler.d.ts +5 -1
- package/dist/dev-engine/handlers/base-handler.d.ts.map +1 -0
- package/dist/dev-engine/handlers/base-handler.js +58 -0
- package/dist/dev-engine/handlers/js-handler.d.ts.map +1 -0
- package/dist/{handlers → dev-engine/handlers}/js-handler.js +1 -1
- package/dist/dev-engine/handlers/mjs-handler.d.ts.map +1 -0
- package/dist/{handlers → dev-engine/handlers}/mjs-handler.js +1 -1
- package/dist/dev-engine/handlers/node-module-handler.d.ts.map +1 -0
- package/dist/{handlers → dev-engine/handlers}/node-module-handler.js +33 -44
- package/dist/{handlers → dev-engine/handlers}/ts-handler.d.ts +0 -4
- package/dist/dev-engine/handlers/ts-handler.d.ts.map +1 -0
- package/dist/{handlers → dev-engine/handlers}/ts-handler.js +5 -28
- package/dist/{handlers → dev-engine/handlers}/ui-handler.d.ts +0 -4
- package/dist/dev-engine/handlers/ui-handler.d.ts.map +1 -0
- package/dist/dev-engine/handlers/ui-handler.js +84 -0
- package/dist/{handlers → dev-engine/handlers}/uix-handler.d.ts +0 -4
- package/dist/dev-engine/handlers/uix-handler.d.ts.map +1 -0
- package/dist/dev-engine/handlers/uix-handler.js +70 -0
- package/dist/dev-engine/hmr/hmr-client-template.d.ts +10 -0
- package/dist/dev-engine/hmr/hmr-client-template.d.ts.map +1 -0
- package/dist/dev-engine/hmr/hmr-client-template.js +122 -0
- package/dist/dev-engine/hmr/hmr.d.ts.map +1 -0
- package/dist/{hmr.js → dev-engine/hmr/hmr.js} +2 -134
- package/dist/{middleware → dev-engine/middleware}/hmr-routes.d.ts +2 -2
- package/dist/dev-engine/middleware/hmr-routes.d.ts.map +1 -0
- package/dist/{middleware → dev-engine/middleware}/hmr-routes.js +1 -1
- package/dist/dev-engine/middleware/middleware-setup.d.ts +35 -0
- package/dist/dev-engine/middleware/middleware-setup.d.ts.map +1 -0
- package/dist/dev-engine/middleware/middleware-setup.js +327 -0
- package/dist/dev-engine/middleware/static-files.d.ts.map +1 -0
- package/dist/{middleware → dev-engine/middleware}/static-files.js +2 -2
- package/dist/{dev → dev-engine}/pythonDevManager.d.ts +1 -1
- package/dist/dev-engine/pythonDevManager.d.ts.map +1 -0
- package/dist/{dev → dev-engine}/pythonDevManager.js +1 -1
- package/dist/{router → dev-engine/router}/file-router.d.ts +4 -4
- package/dist/dev-engine/router/file-router.d.ts.map +1 -0
- package/dist/{router → dev-engine/router}/file-router.js +4 -4
- package/dist/dev-engine/server.d.ts.map +1 -0
- package/dist/{server.js → dev-engine/server.js} +10 -6
- package/dist/index.d.ts +13 -13
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -9
- package/dist/internal/cache/compilation-cache.d.ts.map +1 -0
- package/dist/{cache → internal/cache}/compilation-cache.js +3 -2
- package/dist/internal/generate-import-map-cli.d.ts.map +1 -0
- package/dist/{utils → internal}/generate-import-map-cli.js +1 -1
- package/dist/internal/generate-import-map.d.ts.map +1 -0
- package/dist/{utils → internal}/generate-import-map.js +3 -3
- package/dist/{utils → kernel}/package-finder.d.ts +7 -5
- package/dist/kernel/package-finder.d.ts.map +1 -0
- package/dist/kernel/package-finder.js +154 -0
- package/dist/kernel/package-registry.d.ts.map +1 -0
- package/dist/kernel/workspace.d.ts.map +1 -0
- package/dist/{resolver → resolution}/bare-import-resolver.d.ts +1 -1
- package/dist/resolution/bare-import-resolver.d.ts.map +1 -0
- package/dist/{resolver → resolution}/bare-import-resolver.js +25 -53
- package/dist/resolution/cdn/cdn-fallback.d.ts.map +1 -0
- package/dist/{utils → resolution/path}/file-path-resolver.d.ts +2 -1
- package/dist/resolution/path/file-path-resolver.d.ts.map +1 -0
- package/dist/{utils → resolution/path}/file-path-resolver.js +46 -28
- package/dist/resolution/path/path-fixup.d.ts +13 -0
- package/dist/resolution/path/path-fixup.d.ts.map +1 -0
- package/dist/resolution/path/path-fixup.js +20 -0
- package/dist/{resolver.d.ts → resolution/resolver.d.ts} +1 -1
- package/dist/resolution/resolver.d.ts.map +1 -0
- package/dist/{resolver.js → resolution/resolver.js} +8 -37
- package/dist/{import-rewriter.d.ts → resolution/rewriting/import-rewriter.d.ts} +1 -1
- package/dist/resolution/rewriting/import-rewriter.d.ts.map +1 -0
- package/dist/resolution/rewriting/import-rewriter.js +199 -0
- package/dist/{resolver → resolution}/symlink-registry.d.ts +1 -1
- package/dist/resolution/symlink-registry.d.ts.map +1 -0
- package/dist/{resolver → resolution}/symlink-registry.js +1 -1
- package/dist/resolution/url-resolver.d.ts.map +1 -0
- package/dist/{resolver → resolution}/url-resolver.js +38 -109
- package/dist/resolution/workspace-package-resolver.d.ts.map +1 -0
- package/dist/resolution/workspace-package-resolver.js +77 -0
- package/docs/architecture/build-pipeline.md +97 -0
- package/docs/architecture/dev-server.md +87 -0
- package/docs/architecture/hmr.md +78 -0
- package/docs/architecture/import-rewriting.md +101 -0
- package/docs/architecture/index.md +16 -0
- package/docs/architecture/python-integration.md +93 -0
- package/docs/architecture/resolution.md +92 -0
- package/docs/cli/build.md +78 -0
- package/docs/cli/dev.md +90 -0
- package/docs/cli/index.md +15 -0
- package/docs/cli/start.md +45 -0
- package/docs/development/contributing.md +74 -0
- package/docs/development/index.md +12 -0
- package/docs/development/internals.md +101 -0
- package/docs/guide/configuration.md +89 -0
- package/docs/guide/index.md +13 -0
- package/docs/guide/project-structure.md +75 -0
- package/docs/guide/quickstart.md +113 -0
- package/docs/index.md +16 -0
- package/package.json +5 -5
- package/src/cli.ts +1 -1
- package/src/config/config.ts +11 -0
- package/src/dev-engine/handlers/base-handler.ts +4 -2
- package/src/dev-engine/handlers/node-module-handler.ts +51 -78
- package/src/dev-engine/middleware/middleware-setup.ts +1 -0
- package/src/dev-engine/server.ts +38 -33
- package/src/kernel/package-finder.ts +59 -43
- package/src/resolution/bare-import-resolver.ts +14 -4
- package/src/resolution/path/file-path-resolver.ts +44 -10
- package/src/resolution/url-resolver.ts +1 -1
- package/dist/builder.d.ts.map +0 -1
- package/dist/cache/compilation-cache.d.ts.map +0 -1
- package/dist/config-loader.d.ts.map +0 -1
- package/dist/config.d.ts.map +0 -1
- package/dist/dev/pythonDevManager.d.ts.map +0 -1
- package/dist/env.d.ts +0 -19
- package/dist/env.d.ts.map +0 -1
- package/dist/env.js +0 -112
- package/dist/handlers/base-handler.d.ts.map +0 -1
- package/dist/handlers/base-handler.js +0 -38
- package/dist/handlers/js-handler.d.ts.map +0 -1
- package/dist/handlers/mjs-handler.d.ts.map +0 -1
- package/dist/handlers/node-module-handler.d.ts.map +0 -1
- package/dist/handlers/ts-handler.d.ts.map +0 -1
- package/dist/handlers/ui-handler.d.ts.map +0 -1
- package/dist/handlers/ui-handler.js +0 -182
- package/dist/handlers/uix-handler.d.ts.map +0 -1
- package/dist/handlers/uix-handler.js +0 -135
- package/dist/hmr.d.ts.map +0 -1
- package/dist/import-rewriter.d.ts.map +0 -1
- package/dist/import-rewriter.js +0 -351
- package/dist/middleware/hmr-routes.d.ts.map +0 -1
- package/dist/middleware/middleware-setup.d.ts +0 -23
- package/dist/middleware/middleware-setup.d.ts.map +0 -1
- package/dist/middleware/middleware-setup.js +0 -596
- package/dist/middleware/static-files.d.ts.map +0 -1
- package/dist/proxy/SwiteProxyError.d.ts.map +0 -1
- package/dist/proxy/proxyToPython.d.ts.map +0 -1
- package/dist/resolver/bare-import-resolver.d.ts.map +0 -1
- package/dist/resolver/symlink-registry.d.ts.map +0 -1
- package/dist/resolver/url-resolver.d.ts.map +0 -1
- package/dist/resolver/workspace-package-resolver.d.ts.map +0 -1
- package/dist/resolver/workspace-package-resolver.js +0 -185
- package/dist/resolver.d.ts.map +0 -1
- package/dist/router/file-router.d.ts.map +0 -1
- package/dist/server.d.ts.map +0 -1
- package/dist/utils/cdn-fallback.d.ts.map +0 -1
- package/dist/utils/file-path-resolver.d.ts.map +0 -1
- package/dist/utils/generate-import-map-cli.d.ts.map +0 -1
- package/dist/utils/generate-import-map.d.ts.map +0 -1
- package/dist/utils/package-finder.d.ts.map +0 -1
- package/dist/utils/package-finder.js +0 -161
- package/dist/utils/package-registry.d.ts.map +0 -1
- package/dist/utils/workspace.d.ts.map +0 -1
- /package/dist/{proxy → adapters/proxy}/SwiteProxyError.d.ts +0 -0
- /package/dist/{proxy → adapters/proxy}/SwiteProxyError.js +0 -0
- /package/dist/{proxy → adapters/proxy}/proxyToPython.js +0 -0
- /package/dist/{builder.d.ts → build-engine/builder.d.ts} +0 -0
- /package/dist/{config-loader.d.ts → config/config-loader.d.ts} +0 -0
- /package/dist/{config-loader.js → config/config-loader.js} +0 -0
- /package/dist/{config.js → config/config.js} +0 -0
- /package/dist/{handlers → dev-engine/handlers}/js-handler.d.ts +0 -0
- /package/dist/{handlers → dev-engine/handlers}/mjs-handler.d.ts +0 -0
- /package/dist/{handlers → dev-engine/handlers}/node-module-handler.d.ts +0 -0
- /package/dist/{hmr.d.ts → dev-engine/hmr/hmr.d.ts} +0 -0
- /package/dist/{middleware → dev-engine/middleware}/static-files.d.ts +0 -0
- /package/dist/{server.d.ts → dev-engine/server.d.ts} +0 -0
- /package/dist/{cache → internal/cache}/compilation-cache.d.ts +0 -0
- /package/dist/{utils → internal}/generate-import-map-cli.d.ts +0 -0
- /package/dist/{utils → internal}/generate-import-map.d.ts +0 -0
- /package/dist/{utils → kernel}/package-registry.d.ts +0 -0
- /package/dist/{utils → kernel}/package-registry.js +0 -0
- /package/dist/{utils → kernel}/workspace.d.ts +0 -0
- /package/dist/{utils → kernel}/workspace.js +0 -0
- /package/dist/{utils → resolution/cdn}/cdn-fallback.d.ts +0 -0
- /package/dist/{utils → resolution/cdn}/cdn-fallback.js +0 -0
- /package/dist/{resolver → resolution}/url-resolver.d.ts +0 -0
- /package/dist/{resolver → resolution}/workspace-package-resolver.d.ts +0 -0
|
@@ -1,185 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Workspace Package Resolver - Finds packages in workspace
|
|
3
|
-
* Uses dynamic package registry instead of hardcoded paths
|
|
4
|
-
*/
|
|
5
|
-
import path from "node:path";
|
|
6
|
-
import { findSwissLibMonorepo } from "../utils/package-finder.js";
|
|
7
|
-
import { getPackageRegistry } from "../utils/package-registry.js";
|
|
8
|
-
/**
|
|
9
|
-
* Resolve workspace package location
|
|
10
|
-
*/
|
|
11
|
-
export async function resolveWorkspacePackage(pkgName, context) {
|
|
12
|
-
let workspaceRoot = null;
|
|
13
|
-
const workspaceRoots = [];
|
|
14
|
-
if (pkgName.startsWith("@swiss-enterprise/") ||
|
|
15
|
-
pkgName.startsWith("@swiss-module/") ||
|
|
16
|
-
pkgName.startsWith("@kibologic/") ||
|
|
17
|
-
pkgName.startsWith("@swiss-framework/")) {
|
|
18
|
-
console.log(`[SWITE] Looking for SWS root for @swiss-enterprise package...`);
|
|
19
|
-
console.log(`[SWITE] Starting from app root: ${context.root}`);
|
|
20
|
-
const fallbackPaths = [
|
|
21
|
-
path.join(context.root, "..", ".."),
|
|
22
|
-
path.join(context.root, ".."),
|
|
23
|
-
];
|
|
24
|
-
const detectedWorkspaceRoot = await context.getWorkspaceRoot();
|
|
25
|
-
if (detectedWorkspaceRoot) {
|
|
26
|
-
const hasLibraries = await context.fileExists(path.join(detectedWorkspaceRoot, "libraries"));
|
|
27
|
-
const hasModules = await context.fileExists(path.join(detectedWorkspaceRoot, "modules"));
|
|
28
|
-
if (hasLibraries || hasModules) {
|
|
29
|
-
console.log(`[SWITE] ✅ Found workspace root via getWorkspaceRoot(): ${detectedWorkspaceRoot}`);
|
|
30
|
-
workspaceRoot = detectedWorkspaceRoot;
|
|
31
|
-
workspaceRoots.push(workspaceRoot);
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
for (const fallbackPath of fallbackPaths) {
|
|
35
|
-
const normalizedFallback = path.resolve(fallbackPath);
|
|
36
|
-
console.log(`[SWITE] Checking path: ${normalizedFallback}`);
|
|
37
|
-
const hasWorkspace = await context.fileExists(path.join(normalizedFallback, "pnpm-workspace.yaml"));
|
|
38
|
-
const hasModules = await context.fileExists(path.join(normalizedFallback, "modules"));
|
|
39
|
-
const hasLibraries = await context.fileExists(path.join(normalizedFallback, "libraries"));
|
|
40
|
-
const hasPackages = await context.fileExists(path.join(normalizedFallback, "packages"));
|
|
41
|
-
const hasAiAgents = await context.fileExists(path.join(normalizedFallback, "packages", "ai-agents", "package.json"));
|
|
42
|
-
console.log(`[SWITE] hasWorkspace: ${hasWorkspace}, hasModules: ${hasModules}, hasLibraries: ${hasLibraries}, hasPackages: ${hasPackages}, hasAiAgents: ${hasAiAgents}`);
|
|
43
|
-
if (hasWorkspace || hasModules || hasLibraries || hasPackages || hasAiAgents) {
|
|
44
|
-
workspaceRoot = normalizedFallback;
|
|
45
|
-
console.log(`[SWITE] ✅ Found workspace root at: ${workspaceRoot}`);
|
|
46
|
-
workspaceRoots.push(workspaceRoot);
|
|
47
|
-
break;
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
if (!workspaceRoot) {
|
|
51
|
-
console.warn(`[SWITE] ⚠️ Could not find workspace root via fallback paths, trying getWorkspaceRoot()...`);
|
|
52
|
-
workspaceRoot = await context.getWorkspaceRoot();
|
|
53
|
-
if (workspaceRoot) {
|
|
54
|
-
console.log(`[SWITE] ✅ Found workspace root via fallback getWorkspaceRoot(): ${workspaceRoot}`);
|
|
55
|
-
workspaceRoots.push(workspaceRoot);
|
|
56
|
-
}
|
|
57
|
-
else {
|
|
58
|
-
console.warn(`[SWITE] ⚠️ Could not find workspace root, using last resort path...`);
|
|
59
|
-
workspaceRoots.push(path.join(context.root, "..", ".."));
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
else {
|
|
64
|
-
workspaceRoot = await context.getWorkspaceRoot();
|
|
65
|
-
if (!workspaceRoot) {
|
|
66
|
-
console.log(`[SWITE] Workspace root not found via pnpm-workspace.yaml, trying fallbacks...`);
|
|
67
|
-
const fallbackPaths = [
|
|
68
|
-
path.join(context.root, "..", ".."),
|
|
69
|
-
path.join(context.root, ".."),
|
|
70
|
-
];
|
|
71
|
-
for (const fallbackPath of fallbackPaths) {
|
|
72
|
-
const normalizedFallback = path.resolve(fallbackPath);
|
|
73
|
-
if ((await context.fileExists(path.join(normalizedFallback, "pnpm-workspace.yaml"))) ||
|
|
74
|
-
(await context.fileExists(path.join(normalizedFallback, "modules"))) ||
|
|
75
|
-
(await context.fileExists(path.join(normalizedFallback, "libraries")))) {
|
|
76
|
-
workspaceRoot = normalizedFallback;
|
|
77
|
-
console.log(`[SWITE] Found workspace root via fallback: ${workspaceRoot}`);
|
|
78
|
-
break;
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
if (workspaceRoot) {
|
|
83
|
-
workspaceRoots.push(workspaceRoot);
|
|
84
|
-
}
|
|
85
|
-
else {
|
|
86
|
-
workspaceRoots.push(path.join(context.root, "..", ".."));
|
|
87
|
-
workspaceRoots.push(path.join(context.root, "..", "..", ".."));
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
// For @kibologic/* packages, also check swiss-lib monorepo
|
|
91
|
-
if (pkgName.startsWith("@kibologic/")) {
|
|
92
|
-
const swissLib = await findSwissLibMonorepo(context.root);
|
|
93
|
-
if (swissLib) {
|
|
94
|
-
console.log(`[SWITE] Found swiss-lib monorepo at ${swissLib}`);
|
|
95
|
-
workspaceRoots.unshift(swissLib);
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
console.log(`[SWITE] Searching for workspace package: ${pkgName}`);
|
|
99
|
-
console.log(`[SWITE] Workspace roots: ${workspaceRoots.map((r) => path.resolve(r)).join(", ")}`);
|
|
100
|
-
// Use dynamic package registry instead of hardcoded directory searches
|
|
101
|
-
const registry = getPackageRegistry();
|
|
102
|
-
// Determine primary workspace root for scanning
|
|
103
|
-
let primaryRoot = workspaceRoots[0] ?? "";
|
|
104
|
-
if (!primaryRoot) {
|
|
105
|
-
primaryRoot = (await context.getWorkspaceRoot()) ?? context.root;
|
|
106
|
-
}
|
|
107
|
-
if (!primaryRoot) {
|
|
108
|
-
primaryRoot = context.root;
|
|
109
|
-
}
|
|
110
|
-
const additionalRoots = workspaceRoots.slice(1);
|
|
111
|
-
// Add swiss-lib monorepo if it exists (for @kibologic/* packages)
|
|
112
|
-
if (pkgName.startsWith("@kibologic/")) {
|
|
113
|
-
try {
|
|
114
|
-
const swissLib = await findSwissLibMonorepo(context.root);
|
|
115
|
-
if (swissLib && !additionalRoots.includes(swissLib) && swissLib !== primaryRoot) {
|
|
116
|
-
additionalRoots.unshift(swissLib); // Prioritize swiss-lib
|
|
117
|
-
}
|
|
118
|
-
// Also add swiss-lib/packages to ensure packages are found
|
|
119
|
-
if (swissLib) {
|
|
120
|
-
const swissLibPackages = path.join(swissLib, "packages");
|
|
121
|
-
if (await context.fileExists(swissLibPackages) && !additionalRoots.includes(swissLibPackages)) {
|
|
122
|
-
console.log(`[SWITE] Adding swiss-lib/packages to scan roots: ${swissLibPackages}`);
|
|
123
|
-
additionalRoots.unshift(swissLibPackages);
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
catch (error) {
|
|
128
|
-
console.warn(`[SWITE] Error finding swiss-lib monorepo:`, error.message);
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
// Ensure registry is scanned
|
|
132
|
-
if (!registry.getPackageCount() && primaryRoot) {
|
|
133
|
-
console.log(`[SWITE] Package registry not scanned yet, scanning workspace at ${primaryRoot}...`);
|
|
134
|
-
try {
|
|
135
|
-
await registry.scanWorkspace(primaryRoot, additionalRoots);
|
|
136
|
-
}
|
|
137
|
-
catch (error) {
|
|
138
|
-
console.error(`[SWITE] Error scanning package registry:`, error.message);
|
|
139
|
-
console.error(`[SWITE] Stack:`, error.stack);
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
else if (registry.getPackageCount() && pkgName.startsWith("@kibologic/")) {
|
|
143
|
-
// Registry already scanned but may not have swiss-lib/packages
|
|
144
|
-
// Check if @kibologic/core is missing from registry
|
|
145
|
-
const existingPkg = registry.findPackage(pkgName);
|
|
146
|
-
if (!existingPkg) {
|
|
147
|
-
console.log(`[SWITE] ${pkgName} not in registry, forcing rescan with swiss-lib/packages...`);
|
|
148
|
-
await registry.rescan();
|
|
149
|
-
// After rescan, if still not found, explicitly scan swiss-lib/packages
|
|
150
|
-
const stillMissing = !registry.findPackage(pkgName);
|
|
151
|
-
if (stillMissing) {
|
|
152
|
-
const swissLib = await findSwissLibMonorepo(context.root);
|
|
153
|
-
if (swissLib) {
|
|
154
|
-
const swissLibPackages = path.join(swissLib, "packages");
|
|
155
|
-
if (await context.fileExists(swissLibPackages)) {
|
|
156
|
-
console.log(`[SWITE] Explicitly scanning swiss-lib/packages: ${swissLibPackages}`);
|
|
157
|
-
await registry.scanWorkspace(swissLibPackages, []);
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
else if (!primaryRoot) {
|
|
164
|
-
console.warn(`[SWITE] No workspace root found, cannot scan packages`);
|
|
165
|
-
}
|
|
166
|
-
// Look up package in registry
|
|
167
|
-
let packageInfo = registry.findPackage(pkgName);
|
|
168
|
-
if (packageInfo) {
|
|
169
|
-
console.log(`[SWITE] ✅ Found ${pkgName} at ${packageInfo.path} (via dynamic registry)`);
|
|
170
|
-
return packageInfo.path;
|
|
171
|
-
}
|
|
172
|
-
// If not found, try rescanning (in case packages were added or registry was stale)
|
|
173
|
-
console.log(`[SWITE] Package ${pkgName} not in registry, rescanning...`);
|
|
174
|
-
await registry.rescan();
|
|
175
|
-
packageInfo = registry.findPackage(pkgName);
|
|
176
|
-
if (packageInfo) {
|
|
177
|
-
console.log(`[SWITE] ✅ Found ${pkgName} at ${packageInfo.path} (after rescan)`);
|
|
178
|
-
return packageInfo.path;
|
|
179
|
-
}
|
|
180
|
-
// Log all found packages for debugging
|
|
181
|
-
const allPackages = registry.getAllPackages().map(p => p.name).join(", ");
|
|
182
|
-
console.log(`[SWITE] ❌ Package ${pkgName} not found in workspace`);
|
|
183
|
-
console.log(`[SWITE] Scanned ${registry.getPackageCount()} packages: ${allPackages}`);
|
|
184
|
-
return null;
|
|
185
|
-
}
|
package/dist/resolver.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"resolver.d.ts","sourceRoot":"","sources":["../src/resolver.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gCAAgC,CAAC;AAMhE,qBAAa,cAAc;IAIb,OAAO,CAAC,IAAI;IAHxB,OAAO,CAAC,aAAa,CAAuB;IAC5C,OAAO,CAAC,SAAS,CAA0B;gBAEvB,IAAI,EAAE,MAAM;IAEhC;;OAEG;IACH,YAAY,CAAC,SAAS,EAAE,SAAS,GAAG,IAAI,GAAG,IAAI;YAWjC,gBAAgB;IA4BxB,OAAO,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;YAqJrD,UAAU;YASV,uBAAuB;YAavB,KAAK;CAUpB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"file-router.d.ts","sourceRoot":"","sources":["../../src/router/file-router.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AACvD,OAAO,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAC;AAClE,OAAO,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AACtE,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAGtC,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,SAAS,CAAC;CAChB;AAED,MAAM,WAAW,gBAAgB;IAC/B,YAAY,EAAE,YAAY,GAAG,IAAI,CAAC;IAClC,YAAY,EAAE,OAAO,CAAC,UAAU,CAAC,OAAO,iBAAiB,CAAC,CAAC,GAAG,IAAI,CAAC;IACnE,MAAM,EAAE,eAAe,EAAE,CAAC;CAC3B;AAED;;;GAGG;AACH,wBAAsB,eAAe,CACnC,MAAM,EAAE,gBAAgB,GACvB,OAAO,CAAC,gBAAgB,CAAC,CAmI3B"}
|
package/dist/server.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAmBA,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IAKb,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,OAAO,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,qBAAa,WAAW;IACtB,OAAO,CAAC,GAAG,CAAa;IACxB,OAAO,CAAC,QAAQ,CAAiB;IACjC,OAAO,CAAC,GAAG,CAAY;IACvB,OAAO,CAAC,MAAM,CAAc;IAC5B,OAAO,CAAC,YAAY,CAA6B;IACjD,OAAO,CAAC,YAAY,CACb;IACP,OAAO,CAAC,MAAM,CAAyB;gBAE3B,MAAM,GAAE,OAAO,CAAC,WAAW,CAAM;YAe/B,iBAAiB;IAuBzB,KAAK;CAsEZ"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cdn-fallback.d.ts","sourceRoot":"","sources":["../../src/utils/cdn-fallback.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAmBH,wBAAgB,oBAAoB,CAAC,cAAc,EAAE,MAAM,GAAG,OAAO,CAKpE"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"file-path-resolver.d.ts","sourceRoot":"","sources":["../../src/utils/file-path-resolver.ts"],"names":[],"mappings":"AAWA,MAAM,WAAW,mBAAmB;IAClC,IAAI,EAAE,MAAM,CAAC;IACb,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;CAC9B;AAED;;GAEG;AACH,wBAAsB,eAAe,CACnC,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,MAAM,EACZ,aAAa,GAAE,MAAM,GAAG,IAAW,GAClC,OAAO,CAAC,MAAM,CAAC,CAmLjB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"generate-import-map-cli.d.ts","sourceRoot":"","sources":["../../src/utils/generate-import-map-cli.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"generate-import-map.d.ts","sourceRoot":"","sources":["../../src/utils/generate-import-map.ts"],"names":[],"mappings":"AAcA,MAAM,WAAW,SAAS;IACxB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE;QACP,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAAC;KAC7B,CAAC;CACH;AAED;;;GAGG;AACH,wBAAsB,iBAAiB,CACrC,IAAI,EAAE,MAAM,EACZ,aAAa,EAAE,MAAM,GAAG,IAAI,GAC3B,OAAO,CAAC,SAAS,CAAC,CAkGpB;AAED;;GAEG;AACH,wBAAsB,aAAa,CACjC,SAAS,EAAE,SAAS,EACpB,UAAU,EAAE,MAAM,GACjB,OAAO,CAAC,IAAI,CAAC,CAIf;AAED;;GAEG;AACH,wBAAsB,aAAa,CACjC,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,SAAS,GAAG,IAAI,CAAC,CAO3B"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"package-finder.d.ts","sourceRoot":"","sources":["../../src/utils/package-finder.ts"],"names":[],"mappings":"AASA;;;GAGG;AAEH,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,WAAW,GAAG,WAAW,GAAG,cAAc,CAAC;CAClD;AAED;;GAEG;AACH,wBAAsB,oBAAoB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CA0DpF;AAED;;;;;GAKG;AACH,wBAAsB,WAAW,CAC/B,WAAW,EAAE,MAAM,EACnB,SAAS,EAAE,MAAM,EACjB,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,GAC5B,OAAO,CAAC,eAAe,GAAG,IAAI,CAAC,CAoDjC;AAED;;GAEG;AACH,wBAAsB,kBAAkB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CA2B7E"}
|
|
@@ -1,161 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright (c) 2024 Themba Mzumara
|
|
3
|
-
* SWITE - SWISS Development Server
|
|
4
|
-
* Licensed under the MIT License.
|
|
5
|
-
*/
|
|
6
|
-
import { promises as fs } from "node:fs";
|
|
7
|
-
import path from "node:path";
|
|
8
|
-
/**
|
|
9
|
-
* Find swiss-lib monorepo by searching for swiss-lib/package.json or swiss-lib/packages/core
|
|
10
|
-
*/
|
|
11
|
-
export async function findSwissLibMonorepo(startPath) {
|
|
12
|
-
let current = startPath;
|
|
13
|
-
for (let i = 0; i < 20; i++) { // Search up to 20 levels
|
|
14
|
-
// Check for swiss-lib directory with packages/core
|
|
15
|
-
const swissLibPath = path.join(current, "swiss-lib");
|
|
16
|
-
const swissLibPackageJson = path.join(swissLibPath, "package.json");
|
|
17
|
-
const corePackage = path.join(swissLibPath, "packages", "core", "package.json");
|
|
18
|
-
try {
|
|
19
|
-
// Check if swiss-lib exists and has core package
|
|
20
|
-
if (await fileExists(swissLibPackageJson) || await fileExists(corePackage)) {
|
|
21
|
-
console.log(`[package-finder] Found swiss-lib at: ${swissLibPath}`);
|
|
22
|
-
return swissLibPath;
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
catch {
|
|
26
|
-
// Continue searching
|
|
27
|
-
}
|
|
28
|
-
// Also check for legacy SWISS directory
|
|
29
|
-
const swissPath = path.join(current, "SWISS");
|
|
30
|
-
const swissPackageJson = path.join(swissPath, "package.json");
|
|
31
|
-
const swissCorePackage = path.join(swissPath, "packages", "core", "package.json");
|
|
32
|
-
try {
|
|
33
|
-
if (await fileExists(swissPackageJson) || await fileExists(swissCorePackage)) {
|
|
34
|
-
console.log(`[package-finder] Found legacy SWISS at: ${swissPath}`);
|
|
35
|
-
return swissPath;
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
catch {
|
|
39
|
-
// Continue searching
|
|
40
|
-
}
|
|
41
|
-
// Scan immediate subdirectories of `current` for a swiss-lib/ child
|
|
42
|
-
try {
|
|
43
|
-
const entries = await fs.readdir(current, { withFileTypes: true });
|
|
44
|
-
const subdirs = entries.filter((e) => e.name !== "node_modules" && (e.isDirectory() || e.isSymbolicLink()));
|
|
45
|
-
for (const entry of subdirs) {
|
|
46
|
-
const sub = path.join(current, entry.name);
|
|
47
|
-
const subSwissLib = path.join(sub, "swiss-lib");
|
|
48
|
-
const subPkgJson = path.join(subSwissLib, "package.json");
|
|
49
|
-
const subCorePkgJson = path.join(subSwissLib, "packages", "core", "package.json");
|
|
50
|
-
if (await fileExists(subPkgJson) || await fileExists(subCorePkgJson)) {
|
|
51
|
-
console.log(`[package-finder] Found swiss-lib via subdir scan at: ${subSwissLib}`);
|
|
52
|
-
return subSwissLib;
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
catch {
|
|
57
|
-
// Skip on permission errors
|
|
58
|
-
}
|
|
59
|
-
const parent = path.dirname(current);
|
|
60
|
-
if (parent === current)
|
|
61
|
-
break;
|
|
62
|
-
current = parent;
|
|
63
|
-
}
|
|
64
|
-
return null;
|
|
65
|
-
}
|
|
66
|
-
/**
|
|
67
|
-
* Find a specific package by name, searching in:
|
|
68
|
-
* 1. node_modules (local and workspace)
|
|
69
|
-
* 2. swiss-lib/packages (if found)
|
|
70
|
-
* 3. workspace packages (lib/, packages/, modules/)
|
|
71
|
-
*/
|
|
72
|
-
export async function findPackage(packageName, startPath, workspaceRoot) {
|
|
73
|
-
// 1. Check local node_modules
|
|
74
|
-
const localNodeModules = path.join(startPath, "node_modules", packageName);
|
|
75
|
-
if (await fileExists(path.join(localNodeModules, "package.json"))) {
|
|
76
|
-
return { path: localNodeModules, type: 'node_modules' };
|
|
77
|
-
}
|
|
78
|
-
// 2. Check workspace root node_modules
|
|
79
|
-
if (workspaceRoot) {
|
|
80
|
-
const workspaceNodeModules = path.join(workspaceRoot, "node_modules", packageName);
|
|
81
|
-
if (await fileExists(path.join(workspaceNodeModules, "package.json"))) {
|
|
82
|
-
return { path: workspaceNodeModules, type: 'node_modules' };
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
// 3. Check swiss-lib monorepo (for @kibologic/* packages)
|
|
86
|
-
if (packageName.startsWith("@kibologic/")) {
|
|
87
|
-
const swissLib = await findSwissLibMonorepo(startPath);
|
|
88
|
-
if (swissLib) {
|
|
89
|
-
const packageDir = packageName.replace("@kibologic/", "");
|
|
90
|
-
const swissPackage = path.join(swissLib, "packages", packageDir);
|
|
91
|
-
if (await fileExists(path.join(swissPackage, "package.json"))) {
|
|
92
|
-
return { path: swissPackage, type: 'swiss-lib' };
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
// 4. Check workspace packages (lib/, packages/, modules/)
|
|
97
|
-
if (workspaceRoot) {
|
|
98
|
-
const packageDirs = ["lib", "packages", "modules", "libraries", "apps"];
|
|
99
|
-
for (const dir of packageDirs) {
|
|
100
|
-
const searchDir = path.join(workspaceRoot, dir);
|
|
101
|
-
if (!(await fileExists(searchDir)))
|
|
102
|
-
continue;
|
|
103
|
-
// Try scoped package name
|
|
104
|
-
if (packageName.startsWith("@")) {
|
|
105
|
-
const unscoped = packageName.split("/")[1];
|
|
106
|
-
const packagePath = path.join(searchDir, unscoped);
|
|
107
|
-
if (await fileExists(path.join(packagePath, "package.json"))) {
|
|
108
|
-
return { path: packagePath, type: 'workspace' };
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
// Try full package name
|
|
112
|
-
const packagePath = path.join(searchDir, packageName);
|
|
113
|
-
if (await fileExists(path.join(packagePath, "package.json"))) {
|
|
114
|
-
return { path: packagePath, type: 'workspace' };
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
return null;
|
|
119
|
-
}
|
|
120
|
-
/**
|
|
121
|
-
* Find all possible workspace roots by searching up the tree
|
|
122
|
-
*/
|
|
123
|
-
export async function findWorkspaceRoots(startPath) {
|
|
124
|
-
const roots = [];
|
|
125
|
-
let current = startPath;
|
|
126
|
-
for (let i = 0; i < 20; i++) {
|
|
127
|
-
const workspaceFile = path.join(current, "pnpm-workspace.yaml");
|
|
128
|
-
const packageJson = path.join(current, "package.json");
|
|
129
|
-
try {
|
|
130
|
-
if (await fileExists(workspaceFile)) {
|
|
131
|
-
roots.push(current);
|
|
132
|
-
}
|
|
133
|
-
else if (await fileExists(packageJson)) {
|
|
134
|
-
const pkg = JSON.parse(await fs.readFile(packageJson, "utf-8"));
|
|
135
|
-
if (pkg?.workspaces) {
|
|
136
|
-
roots.push(current);
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
catch {
|
|
141
|
-
// Continue
|
|
142
|
-
}
|
|
143
|
-
const parent = path.dirname(current);
|
|
144
|
-
if (parent === current)
|
|
145
|
-
break;
|
|
146
|
-
current = parent;
|
|
147
|
-
}
|
|
148
|
-
return roots;
|
|
149
|
-
}
|
|
150
|
-
/**
|
|
151
|
-
* Check if a file exists
|
|
152
|
-
*/
|
|
153
|
-
async function fileExists(filePath) {
|
|
154
|
-
try {
|
|
155
|
-
await fs.access(filePath);
|
|
156
|
-
return true;
|
|
157
|
-
}
|
|
158
|
-
catch {
|
|
159
|
-
return false;
|
|
160
|
-
}
|
|
161
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"package-registry.d.ts","sourceRoot":"","sources":["../../src/utils/package-registry.ts"],"names":[],"mappings":"AAUA,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,GAAG,CAAC;CAClB;AAED,qBAAa,eAAe;IAC1B,OAAO,CAAC,QAAQ,CAAkC;IAClD,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,SAAS,CAAgB;IAEjC;;OAEG;IACG,aAAa,CACjB,aAAa,EAAE,MAAM,EACrB,eAAe,GAAE,MAAM,EAAO,GAC7B,OAAO,CAAC,IAAI,CAAC;IAwChB;;OAEG;YACW,aAAa;IAmF3B;;OAEG;IACH,WAAW,CAAC,WAAW,EAAE,MAAM,GAAG,WAAW,GAAG,IAAI;IAIpD;;OAEG;IACH,cAAc,IAAI,WAAW,EAAE;IAI/B;;OAEG;IACG,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC;IAW7B;;OAEG;IACH,eAAe,IAAI,MAAM;CAG1B;AAKD,wBAAgB,kBAAkB,IAAI,eAAe,CAKpD"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"workspace.d.ts","sourceRoot":"","sources":["../../src/utils/workspace.ts"],"names":[],"mappings":"AASA;;;GAGG;AACH,wBAAsB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAgD5E"}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|