@gridland/web 0.2.25 → 0.2.27
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/core-shims.js +43293 -0
- package/dist/core-shims.js.map +7 -0
- package/dist/next-plugin.cjs +35 -22
- package/dist/next-plugin.cjs.map +1 -1
- package/dist/next-plugin.js +35 -22
- package/dist/next-plugin.js.map +1 -1
- package/dist/vite-plugin.js +4 -0
- package/dist/vite-plugin.js.map +1 -1
- package/package.json +2 -2
package/dist/next-plugin.cjs
CHANGED
|
@@ -34,12 +34,15 @@ __export(next_plugin_exports, {
|
|
|
34
34
|
});
|
|
35
35
|
module.exports = __toCommonJS(next_plugin_exports);
|
|
36
36
|
var import_path = __toESM(require("path"), 1);
|
|
37
|
+
var import_fs = require("fs");
|
|
37
38
|
function withGridland(nextConfig = {}) {
|
|
38
39
|
const pkgRoot = import_path.default.resolve(__dirname, "..");
|
|
39
40
|
const opentuiRoot = import_path.default.resolve(pkgRoot, "../../opentui");
|
|
40
41
|
const coreRoot = import_path.default.resolve(opentuiRoot, "packages/core");
|
|
41
42
|
const reactRoot = import_path.default.resolve(opentuiRoot, "packages/react");
|
|
42
43
|
const uiRoot = import_path.default.resolve(opentuiRoot, "packages/ui");
|
|
44
|
+
const hasSource = (0, import_fs.existsSync)(import_path.default.resolve(reactRoot, "src/index.ts"));
|
|
45
|
+
const compiledCoreShims = import_path.default.resolve(pkgRoot, "dist/core-shims.js");
|
|
43
46
|
function shimPath(p) {
|
|
44
47
|
return import_path.default.resolve(pkgRoot, p);
|
|
45
48
|
}
|
|
@@ -66,42 +69,52 @@ function withGridland(nextConfig = {}) {
|
|
|
66
69
|
config = userWebpack(config, context);
|
|
67
70
|
}
|
|
68
71
|
const sharedAliases = {
|
|
69
|
-
//
|
|
70
|
-
|
|
71
|
-
"@
|
|
72
|
-
|
|
72
|
+
// In npm mode, @gridland/core bundles real opentui with native deps
|
|
73
|
+
// that browsers can't handle. Alias it to the core-shims bundle instead.
|
|
74
|
+
...!hasSource ? { "@gridland/core": compiledCoreShims } : {},
|
|
75
|
+
// @opentui packages — source mode only (monorepo dev)
|
|
76
|
+
...hasSource ? {
|
|
77
|
+
"@opentui/core": shimPath("src/core-shims/index.ts"),
|
|
78
|
+
"@opentui/react": import_path.default.resolve(reactRoot, "src/index.ts"),
|
|
79
|
+
"@opentui/ui": import_path.default.resolve(uiRoot, "src/index.ts")
|
|
80
|
+
} : {},
|
|
73
81
|
// FFI shims (no Zig/Bun on server or client in browser context)
|
|
74
82
|
"bun:ffi": shimPath("src/shims/bun-ffi.ts"),
|
|
75
83
|
"bun-ffi-structs": shimPath("src/shims/bun-ffi-structs.ts"),
|
|
76
84
|
bun: shimPath("src/shims/bun-ffi.ts"),
|
|
77
|
-
// Tree-sitter stubs
|
|
78
|
-
// "tree-sitter" matching "tree-sitter-styled-text" (webpack prefix match)
|
|
85
|
+
// Tree-sitter stubs
|
|
79
86
|
"tree-sitter-styled-text": shimPath("src/shims/tree-sitter-styled-text-stub.ts"),
|
|
80
87
|
"web-tree-sitter": shimPath("src/shims/tree-sitter-stub.ts"),
|
|
81
88
|
"hast-styled-text": shimPath("src/shims/hast-stub.ts"),
|
|
82
|
-
//
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
89
|
+
// Source-mode-only aliases: opentui source directories and file shims.
|
|
90
|
+
// In npm mode, these are already compiled into the core-shims bundle.
|
|
91
|
+
...hasSource ? {
|
|
92
|
+
[import_path.default.resolve(coreRoot, "src/lib/tree-sitter-styled-text")]: shimPath("src/shims/tree-sitter-styled-text-stub.ts"),
|
|
93
|
+
[import_path.default.resolve(coreRoot, "src/lib/tree-sitter")]: shimPath("src/shims/tree-sitter-stub.ts"),
|
|
94
|
+
[import_path.default.resolve(coreRoot, "src/lib/hast-styled-text")]: shimPath("src/shims/hast-stub.ts"),
|
|
95
|
+
[import_path.default.resolve(reactRoot, "src/reconciler/devtools-polyfill")]: shimPath("src/shims/devtools-polyfill-stub.ts")
|
|
96
|
+
} : {}
|
|
88
97
|
};
|
|
89
|
-
|
|
90
|
-
|
|
98
|
+
if (hasSource) {
|
|
99
|
+
for (const [key, shimFile] of Object.entries(coreFileShims)) {
|
|
100
|
+
sharedAliases[import_path.default.resolve(coreRoot, "src", key)] = shimPath(shimFile);
|
|
101
|
+
}
|
|
91
102
|
}
|
|
92
103
|
config.resolve = config.resolve || {};
|
|
93
104
|
config.resolve.alias = {
|
|
94
105
|
...config.resolve.alias,
|
|
95
106
|
...sharedAliases
|
|
96
107
|
};
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
resource.
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
108
|
+
if (hasSource) {
|
|
109
|
+
const renderablesDir = import_path.default.resolve(coreRoot, "src/renderables");
|
|
110
|
+
config.plugins.push(
|
|
111
|
+
new webpack.NormalModuleReplacementPlugin(/^\.\.\/index$/, (resource) => {
|
|
112
|
+
if (resource.context === renderablesDir) {
|
|
113
|
+
resource.request = shimPath("src/shims/slider-deps.ts");
|
|
114
|
+
}
|
|
115
|
+
})
|
|
116
|
+
);
|
|
117
|
+
}
|
|
105
118
|
if (!isServer) {
|
|
106
119
|
const clientAliases = {
|
|
107
120
|
"node:console": shimPath("src/shims/console.ts"),
|
package/dist/next-plugin.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/next-plugin.ts"],"sourcesContent":["import path from \"path\"\n\ntype WebpackConfig = any\ntype WebpackInstance = any\n\ninterface NextConfig {\n webpack?: (config: WebpackConfig, context: { isServer: boolean; webpack: WebpackInstance }) => WebpackConfig\n [key: string]: any\n}\n\n/**\n * Next.js plugin that configures webpack for Gridland.\n * Equivalent to `gridlandWebPlugin()` for Vite — handles module aliases,\n * FFI shims, tree-sitter stubs, Node.js built-in stubs, and circular\n * dependency fixes.\n *\n * Requires @opentui/core, @opentui/react, and @opentui/ui as peer dependencies.\n *\n * @param nextConfig - Optional additional Next.js config to merge\n */\nexport function withGridland(nextConfig: NextConfig = {}): NextConfig {\n // __dirname works natively in CJS; tsup shims it for ESM via import.meta.url\n const pkgRoot = path.resolve(__dirname, \"..\")\n\n // Resolve opentui package roots from the git submodule\n const opentuiRoot = path.resolve(pkgRoot, \"../../opentui\")\n const coreRoot = path.resolve(opentuiRoot, \"packages/core\")\n const reactRoot = path.resolve(opentuiRoot, \"packages/react\")\n const uiRoot = path.resolve(opentuiRoot, \"packages/ui\")\n\n function shimPath(p: string) {\n return path.resolve(pkgRoot, p)\n }\n\n // Core shims — same mappings as the Vite plugin\n const coreFileShims: Record<string, string> = {\n zig: \"src/shims/zig-stub.ts\",\n buffer: \"src/browser-buffer.ts\",\n \"text-buffer\": \"src/shims/text-buffer-shim.ts\",\n \"text-buffer-view\": \"src/shims/text-buffer-view-shim.ts\",\n \"syntax-style\": \"src/shims/syntax-style-shim.ts\",\n renderer: \"src/shims/renderer-stub.ts\",\n console: \"src/shims/console-stub.ts\",\n \"edit-buffer\": \"src/shims/edit-buffer-stub.ts\",\n \"editor-view\": \"src/shims/editor-view-stub.ts\",\n NativeSpanFeed: \"src/shims/native-span-feed-stub.ts\",\n \"post/filters\": \"src/shims/filters-stub.ts\",\n \"animation/Timeline\": \"src/shims/timeline-stub.ts\",\n }\n\n const userWebpack = nextConfig.webpack\n\n return {\n ...nextConfig,\n webpack: (config: WebpackConfig, context: { isServer: boolean; webpack: WebpackInstance }) => {\n const { isServer, webpack } = context\n\n // Chain user's webpack config first if provided\n if (userWebpack) {\n config = userWebpack(config, context)\n }\n\n // Aliases needed on BOTH server and client (opentui packages, FFI stubs,\n // tree-sitter stubs, core file shims). The server doesn't actually render\n // the TUI but still walks the module graph for \"use client\" components.\n const sharedAliases: Record<string, string> = {\n // @opentui packages — core-shims includes all exports @opentui/react needs\n \"@opentui/core\": shimPath(\"src/core-shims/index.ts\"),\n \"@opentui/react\": path.resolve(reactRoot, \"src/index.ts\"),\n \"@opentui/ui\": path.resolve(uiRoot, \"src/index.ts\"),\n\n // FFI shims (no Zig/Bun on server or client in browser context)\n \"bun:ffi\": shimPath(\"src/shims/bun-ffi.ts\"),\n \"bun-ffi-structs\": shimPath(\"src/shims/bun-ffi-structs.ts\"),\n bun: shimPath(\"src/shims/bun-ffi.ts\"),\n\n // Tree-sitter stubs — IMPORTANT: longer prefix must come first to avoid\n // \"tree-sitter\" matching \"tree-sitter-styled-text\" (webpack prefix match)\n \"tree-sitter-styled-text\": shimPath(\"src/shims/tree-sitter-styled-text-stub.ts\"),\n \"web-tree-sitter\": shimPath(\"src/shims/tree-sitter-stub.ts\"),\n \"hast-styled-text\": shimPath(\"src/shims/hast-stub.ts\"),\n // Internal tree-sitter source directories (pulled in via renderable imports)\n [path.resolve(coreRoot, \"src/lib/tree-sitter-styled-text\")]:\n shimPath(\"src/shims/tree-sitter-styled-text-stub.ts\"),\n [path.resolve(coreRoot, \"src/lib/tree-sitter\")]:\n shimPath(\"src/shims/tree-sitter-stub.ts\"),\n [path.resolve(coreRoot, \"src/lib/hast-styled-text\")]:\n shimPath(\"src/shims/hast-stub.ts\"),\n\n // Devtools polyfill stub (original uses top-level await for ws import)\n [path.resolve(reactRoot, \"src/reconciler/devtools-polyfill\")]:\n shimPath(\"src/shims/devtools-polyfill-stub.ts\"),\n }\n\n // Core file shims (opentui source → browser shim)\n for (const [key, shimFile] of Object.entries(coreFileShims)) {\n sharedAliases[path.resolve(coreRoot, \"src\", key)] = shimPath(shimFile)\n }\n\n config.resolve = config.resolve || {}\n config.resolve.alias = {\n ...config.resolve.alias,\n ...sharedAliases,\n }\n\n // Slider circular dependency fix: Slider.ts imports from \"../index\" which\n // creates barrel → renderables → Slider → barrel cycle. Redirect to a\n // minimal deps file that provides only what Slider needs.\n const renderablesDir = path.resolve(coreRoot, \"src/renderables\")\n config.plugins.push(\n new webpack.NormalModuleReplacementPlugin(/^\\.\\.\\/index$/, (resource: any) => {\n if (resource.context === renderablesDir) {\n resource.request = shimPath(\"src/shims/slider-deps.ts\")\n }\n }),\n )\n\n if (!isServer) {\n // Client-only: Node.js built-in stubs, events shim, console shim.\n // Use \"$\" suffix for exact match to prevent \"fs\" from matching \"fs/promises\".\n const clientAliases: Record<string, string> = {\n \"node:console\": shimPath(\"src/shims/console.ts\"),\n \"events$\": shimPath(\"src/shims/events-shim.ts\"),\n \"fs/promises\": shimPath(\"src/shims/node-fs.ts\"),\n \"fs$\": shimPath(\"src/shims/node-fs.ts\"),\n \"path$\": shimPath(\"src/shims/node-path.ts\"),\n \"util$\": shimPath(\"src/shims/node-util.ts\"),\n \"os$\": shimPath(\"src/shims/node-os.ts\"),\n \"stream$\": shimPath(\"src/shims/node-stream.ts\"),\n \"url$\": shimPath(\"src/shims/node-url.ts\"),\n }\n\n config.resolve.alias = {\n ...config.resolve.alias,\n ...clientAliases,\n }\n\n // Allow webpack to resolve modules from our workspace node_modules\n config.resolve.modules = [\n ...(config.resolve.modules || []),\n path.resolve(pkgRoot, \"node_modules\"),\n path.resolve(pkgRoot, \"../../node_modules\"),\n ]\n\n // Strip `node:` and `bun:` prefixes from imports so they resolve\n // through aliases. Webpack 5 treats these as unhandled URL schemes.\n config.plugins.push(\n new webpack.NormalModuleReplacementPlugin(/^node:/, (resource: any) => {\n resource.request = resource.request.replace(/^node:/, \"\")\n }),\n new webpack.NormalModuleReplacementPlugin(/^bun:/, (resource: any) => {\n resource.request = resource.request.replace(/^bun:/, \"\")\n }),\n )\n }\n\n // Enable top-level await (used by opentui source code)\n config.experiments = {\n ...config.experiments,\n topLevelAwait: true,\n }\n\n return config\n },\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAiB;AAoBV,SAAS,aAAa,aAAyB,CAAC,GAAe;AAEpE,QAAM,UAAU,YAAAA,QAAK,QAAQ,WAAW,IAAI;AAG5C,QAAM,cAAc,YAAAA,QAAK,QAAQ,SAAS,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AC;AAAA,UAC/B,YAAAA,QAAK,QAAQ,SAAS,cAAc;AAAA,UACpC,YAAAA,QAAK,QAAQ,SAAS,oBAAoB;AAAA,QAC5C;AAIA,eAAO,QAAQ;AAAA,UACb,IAAI,QAAQ,8BAA8B,UAAU,CAAC,aAAkB;AACrE,qBAAS,UAAU,SAAS,QAAQ,QAAQ,UAAU,EAAE;AAAA,UAC1D,CAAC;AAAA,UACD,IAAI,QAAQ,8BAA8B,SAAS,CAAC,aAAkB;AACpE,qBAAS,UAAU,SAAS,QAAQ,QAAQ,SAAS,EAAE;AAAA,UACzD,CAAC;AAAA,QACH;AAAA,MACF;AAGA,aAAO,cAAc;AAAA,QACnB,GAAG,OAAO;AAAA,QACV,eAAe;AAAA,MACjB;AAEA,aAAO;AAAA,IACT;AAAA,EACF;AACF;","names":["path"]}
|
|
1
|
+
{"version":3,"sources":["../src/next-plugin.ts"],"sourcesContent":["import path from \"path\"\nimport { existsSync } from \"fs\"\n\ntype WebpackConfig = any\ntype WebpackInstance = any\n\ninterface NextConfig {\n webpack?: (config: WebpackConfig, context: { isServer: boolean; webpack: WebpackInstance }) => WebpackConfig\n [key: string]: any\n}\n\n/**\n * Next.js plugin that configures webpack for Gridland.\n * Equivalent to `gridlandWebPlugin()` for Vite — handles module aliases,\n * FFI shims, tree-sitter stubs, Node.js built-in stubs, and circular\n * dependency fixes.\n *\n * Requires @opentui/core, @opentui/react, and @opentui/ui as peer dependencies.\n *\n * @param nextConfig - Optional additional Next.js config to merge\n */\nexport function withGridland(nextConfig: NextConfig = {}): NextConfig {\n // __dirname works natively in CJS; tsup shims it for ESM via import.meta.url\n const pkgRoot = path.resolve(__dirname, \"..\")\n\n // Resolve opentui package roots from the git submodule\n const opentuiRoot = path.resolve(pkgRoot, \"../../opentui\")\n const coreRoot = path.resolve(opentuiRoot, \"packages/core\")\n const reactRoot = path.resolve(opentuiRoot, \"packages/react\")\n const uiRoot = path.resolve(opentuiRoot, \"packages/ui\")\n\n // Detect whether opentui source is available (monorepo/submodule)\n const hasSource = existsSync(path.resolve(reactRoot, \"src/index.ts\"))\n // Pre-compiled core-shims for npm mode (no monorepo-relative paths)\n const compiledCoreShims = path.resolve(pkgRoot, \"dist/core-shims.js\")\n\n function shimPath(p: string) {\n return path.resolve(pkgRoot, p)\n }\n\n // Core shims — same mappings as the Vite plugin\n const coreFileShims: Record<string, string> = {\n zig: \"src/shims/zig-stub.ts\",\n buffer: \"src/browser-buffer.ts\",\n \"text-buffer\": \"src/shims/text-buffer-shim.ts\",\n \"text-buffer-view\": \"src/shims/text-buffer-view-shim.ts\",\n \"syntax-style\": \"src/shims/syntax-style-shim.ts\",\n renderer: \"src/shims/renderer-stub.ts\",\n console: \"src/shims/console-stub.ts\",\n \"edit-buffer\": \"src/shims/edit-buffer-stub.ts\",\n \"editor-view\": \"src/shims/editor-view-stub.ts\",\n NativeSpanFeed: \"src/shims/native-span-feed-stub.ts\",\n \"post/filters\": \"src/shims/filters-stub.ts\",\n \"animation/Timeline\": \"src/shims/timeline-stub.ts\",\n }\n\n const userWebpack = nextConfig.webpack\n\n return {\n ...nextConfig,\n webpack: (config: WebpackConfig, context: { isServer: boolean; webpack: WebpackInstance }) => {\n const { isServer, webpack } = context\n\n // Chain user's webpack config first if provided\n if (userWebpack) {\n config = userWebpack(config, context)\n }\n\n // Aliases needed on BOTH server and client (opentui packages, FFI stubs,\n // tree-sitter stubs, core file shims). The server doesn't actually render\n // the TUI but still walks the module graph for \"use client\" components.\n const sharedAliases: Record<string, string> = {\n // In npm mode, @gridland/core bundles real opentui with native deps\n // that browsers can't handle. Alias it to the core-shims bundle instead.\n ...(!hasSource ? { \"@gridland/core\": compiledCoreShims } : {}),\n\n // @opentui packages — source mode only (monorepo dev)\n ...(hasSource ? {\n \"@opentui/core\": shimPath(\"src/core-shims/index.ts\"),\n \"@opentui/react\": path.resolve(reactRoot, \"src/index.ts\"),\n \"@opentui/ui\": path.resolve(uiRoot, \"src/index.ts\"),\n } : {}),\n\n // FFI shims (no Zig/Bun on server or client in browser context)\n \"bun:ffi\": shimPath(\"src/shims/bun-ffi.ts\"),\n \"bun-ffi-structs\": shimPath(\"src/shims/bun-ffi-structs.ts\"),\n bun: shimPath(\"src/shims/bun-ffi.ts\"),\n\n // Tree-sitter stubs\n \"tree-sitter-styled-text\": shimPath(\"src/shims/tree-sitter-styled-text-stub.ts\"),\n \"web-tree-sitter\": shimPath(\"src/shims/tree-sitter-stub.ts\"),\n \"hast-styled-text\": shimPath(\"src/shims/hast-stub.ts\"),\n\n // Source-mode-only aliases: opentui source directories and file shims.\n // In npm mode, these are already compiled into the core-shims bundle.\n ...(hasSource ? {\n [path.resolve(coreRoot, \"src/lib/tree-sitter-styled-text\")]:\n shimPath(\"src/shims/tree-sitter-styled-text-stub.ts\"),\n [path.resolve(coreRoot, \"src/lib/tree-sitter\")]:\n shimPath(\"src/shims/tree-sitter-stub.ts\"),\n [path.resolve(coreRoot, \"src/lib/hast-styled-text\")]:\n shimPath(\"src/shims/hast-stub.ts\"),\n [path.resolve(reactRoot, \"src/reconciler/devtools-polyfill\")]:\n shimPath(\"src/shims/devtools-polyfill-stub.ts\"),\n } : {}),\n }\n\n // Core file shims (opentui source → browser shim) — source mode only\n if (hasSource) {\n for (const [key, shimFile] of Object.entries(coreFileShims)) {\n sharedAliases[path.resolve(coreRoot, \"src\", key)] = shimPath(shimFile)\n }\n }\n\n config.resolve = config.resolve || {}\n config.resolve.alias = {\n ...config.resolve.alias,\n ...sharedAliases,\n }\n\n // Slider circular dependency fix — source mode only\n if (hasSource) {\n const renderablesDir = path.resolve(coreRoot, \"src/renderables\")\n config.plugins.push(\n new webpack.NormalModuleReplacementPlugin(/^\\.\\.\\/index$/, (resource: any) => {\n if (resource.context === renderablesDir) {\n resource.request = shimPath(\"src/shims/slider-deps.ts\")\n }\n }),\n )\n }\n\n if (!isServer) {\n // Client-only: Node.js built-in stubs, events shim, console shim.\n // Use \"$\" suffix for exact match to prevent \"fs\" from matching \"fs/promises\".\n const clientAliases: Record<string, string> = {\n \"node:console\": shimPath(\"src/shims/console.ts\"),\n \"events$\": shimPath(\"src/shims/events-shim.ts\"),\n \"fs/promises\": shimPath(\"src/shims/node-fs.ts\"),\n \"fs$\": shimPath(\"src/shims/node-fs.ts\"),\n \"path$\": shimPath(\"src/shims/node-path.ts\"),\n \"util$\": shimPath(\"src/shims/node-util.ts\"),\n \"os$\": shimPath(\"src/shims/node-os.ts\"),\n \"stream$\": shimPath(\"src/shims/node-stream.ts\"),\n \"url$\": shimPath(\"src/shims/node-url.ts\"),\n }\n\n config.resolve.alias = {\n ...config.resolve.alias,\n ...clientAliases,\n }\n\n // Allow webpack to resolve modules from our workspace node_modules\n config.resolve.modules = [\n ...(config.resolve.modules || []),\n path.resolve(pkgRoot, \"node_modules\"),\n path.resolve(pkgRoot, \"../../node_modules\"),\n ]\n\n // Strip `node:` and `bun:` prefixes from imports so they resolve\n // through aliases. Webpack 5 treats these as unhandled URL schemes.\n config.plugins.push(\n new webpack.NormalModuleReplacementPlugin(/^node:/, (resource: any) => {\n resource.request = resource.request.replace(/^node:/, \"\")\n }),\n new webpack.NormalModuleReplacementPlugin(/^bun:/, (resource: any) => {\n resource.request = resource.request.replace(/^bun:/, \"\")\n }),\n )\n }\n\n // Enable top-level await (used by opentui source code)\n config.experiments = {\n ...config.experiments,\n topLevelAwait: true,\n }\n\n return config\n },\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAiB;AACjB,gBAA2B;AAoBpB,SAAS,aAAa,aAAyB,CAAC,GAAe;AAEpE,QAAM,UAAU,YAAAA,QAAK,QAAQ,WAAW,IAAI;AAG5C,QAAM,cAAc,YAAAA,QAAK,QAAQ,SAAS,eAAe;AACzD,QAAM,WAAW,YAAAA,QAAK,QAAQ,aAAa,eAAe;AAC1D,QAAM,YAAY,YAAAA,QAAK,QAAQ,aAAa,gBAAgB;AAC5D,QAAM,SAAS,YAAAA,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AA0B;AAAA,UAC9C,QAAQ,SAAS,uBAAuB;AAAA,QAC1C;AAEA,eAAO,QAAQ,QAAQ;AAAA,UACrB,GAAG,OAAO,QAAQ;AAAA,UAClB,GAAG;AAAA,QACL;AAGA,eAAO,QAAQ,UAAU;AAAA,UACvB,GAAI,OAAO,QAAQ,WAAW,CAAC;AAAA,UAC/B,YAAAA,QAAK,QAAQ,SAAS,cAAc;AAAA,UACpC,YAAAA,QAAK,QAAQ,SAAS,oBAAoB;AAAA,QAC5C;AAIA,eAAO,QAAQ;AAAA,UACb,IAAI,QAAQ,8BAA8B,UAAU,CAAC,aAAkB;AACrE,qBAAS,UAAU,SAAS,QAAQ,QAAQ,UAAU,EAAE;AAAA,UAC1D,CAAC;AAAA,UACD,IAAI,QAAQ,8BAA8B,SAAS,CAAC,aAAkB;AACpE,qBAAS,UAAU,SAAS,QAAQ,QAAQ,SAAS,EAAE;AAAA,UACzD,CAAC;AAAA,QACH;AAAA,MACF;AAGA,aAAO,cAAc;AAAA,QACnB,GAAG,OAAO;AAAA,QACV,eAAe;AAAA,MACjB;AAEA,aAAO;AAAA,IACT;AAAA,EACF;AACF;","names":["path"]}
|
package/dist/next-plugin.js
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
// src/next-plugin.ts
|
|
2
2
|
import path from "path";
|
|
3
|
+
import { existsSync } from "fs";
|
|
3
4
|
function withGridland(nextConfig = {}) {
|
|
4
5
|
const pkgRoot = path.resolve(__dirname, "..");
|
|
5
6
|
const opentuiRoot = path.resolve(pkgRoot, "../../opentui");
|
|
6
7
|
const coreRoot = path.resolve(opentuiRoot, "packages/core");
|
|
7
8
|
const reactRoot = path.resolve(opentuiRoot, "packages/react");
|
|
8
9
|
const uiRoot = path.resolve(opentuiRoot, "packages/ui");
|
|
10
|
+
const hasSource = existsSync(path.resolve(reactRoot, "src/index.ts"));
|
|
11
|
+
const compiledCoreShims = path.resolve(pkgRoot, "dist/core-shims.js");
|
|
9
12
|
function shimPath(p) {
|
|
10
13
|
return path.resolve(pkgRoot, p);
|
|
11
14
|
}
|
|
@@ -32,42 +35,52 @@ function withGridland(nextConfig = {}) {
|
|
|
32
35
|
config = userWebpack(config, context);
|
|
33
36
|
}
|
|
34
37
|
const sharedAliases = {
|
|
35
|
-
//
|
|
36
|
-
|
|
37
|
-
"@
|
|
38
|
-
|
|
38
|
+
// In npm mode, @gridland/core bundles real opentui with native deps
|
|
39
|
+
// that browsers can't handle. Alias it to the core-shims bundle instead.
|
|
40
|
+
...!hasSource ? { "@gridland/core": compiledCoreShims } : {},
|
|
41
|
+
// @opentui packages — source mode only (monorepo dev)
|
|
42
|
+
...hasSource ? {
|
|
43
|
+
"@opentui/core": shimPath("src/core-shims/index.ts"),
|
|
44
|
+
"@opentui/react": path.resolve(reactRoot, "src/index.ts"),
|
|
45
|
+
"@opentui/ui": path.resolve(uiRoot, "src/index.ts")
|
|
46
|
+
} : {},
|
|
39
47
|
// FFI shims (no Zig/Bun on server or client in browser context)
|
|
40
48
|
"bun:ffi": shimPath("src/shims/bun-ffi.ts"),
|
|
41
49
|
"bun-ffi-structs": shimPath("src/shims/bun-ffi-structs.ts"),
|
|
42
50
|
bun: shimPath("src/shims/bun-ffi.ts"),
|
|
43
|
-
// Tree-sitter stubs
|
|
44
|
-
// "tree-sitter" matching "tree-sitter-styled-text" (webpack prefix match)
|
|
51
|
+
// Tree-sitter stubs
|
|
45
52
|
"tree-sitter-styled-text": shimPath("src/shims/tree-sitter-styled-text-stub.ts"),
|
|
46
53
|
"web-tree-sitter": shimPath("src/shims/tree-sitter-stub.ts"),
|
|
47
54
|
"hast-styled-text": shimPath("src/shims/hast-stub.ts"),
|
|
48
|
-
//
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
55
|
+
// Source-mode-only aliases: opentui source directories and file shims.
|
|
56
|
+
// In npm mode, these are already compiled into the core-shims bundle.
|
|
57
|
+
...hasSource ? {
|
|
58
|
+
[path.resolve(coreRoot, "src/lib/tree-sitter-styled-text")]: shimPath("src/shims/tree-sitter-styled-text-stub.ts"),
|
|
59
|
+
[path.resolve(coreRoot, "src/lib/tree-sitter")]: shimPath("src/shims/tree-sitter-stub.ts"),
|
|
60
|
+
[path.resolve(coreRoot, "src/lib/hast-styled-text")]: shimPath("src/shims/hast-stub.ts"),
|
|
61
|
+
[path.resolve(reactRoot, "src/reconciler/devtools-polyfill")]: shimPath("src/shims/devtools-polyfill-stub.ts")
|
|
62
|
+
} : {}
|
|
54
63
|
};
|
|
55
|
-
|
|
56
|
-
|
|
64
|
+
if (hasSource) {
|
|
65
|
+
for (const [key, shimFile] of Object.entries(coreFileShims)) {
|
|
66
|
+
sharedAliases[path.resolve(coreRoot, "src", key)] = shimPath(shimFile);
|
|
67
|
+
}
|
|
57
68
|
}
|
|
58
69
|
config.resolve = config.resolve || {};
|
|
59
70
|
config.resolve.alias = {
|
|
60
71
|
...config.resolve.alias,
|
|
61
72
|
...sharedAliases
|
|
62
73
|
};
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
resource.
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
74
|
+
if (hasSource) {
|
|
75
|
+
const renderablesDir = path.resolve(coreRoot, "src/renderables");
|
|
76
|
+
config.plugins.push(
|
|
77
|
+
new webpack.NormalModuleReplacementPlugin(/^\.\.\/index$/, (resource) => {
|
|
78
|
+
if (resource.context === renderablesDir) {
|
|
79
|
+
resource.request = shimPath("src/shims/slider-deps.ts");
|
|
80
|
+
}
|
|
81
|
+
})
|
|
82
|
+
);
|
|
83
|
+
}
|
|
71
84
|
if (!isServer) {
|
|
72
85
|
const clientAliases = {
|
|
73
86
|
"node:console": shimPath("src/shims/console.ts"),
|
package/dist/next-plugin.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/next-plugin.ts"],"sourcesContent":["import path from \"path\"\n\ntype WebpackConfig = any\ntype WebpackInstance = any\n\ninterface NextConfig {\n webpack?: (config: WebpackConfig, context: { isServer: boolean; webpack: WebpackInstance }) => WebpackConfig\n [key: string]: any\n}\n\n/**\n * Next.js plugin that configures webpack for Gridland.\n * Equivalent to `gridlandWebPlugin()` for Vite — handles module aliases,\n * FFI shims, tree-sitter stubs, Node.js built-in stubs, and circular\n * dependency fixes.\n *\n * Requires @opentui/core, @opentui/react, and @opentui/ui as peer dependencies.\n *\n * @param nextConfig - Optional additional Next.js config to merge\n */\nexport function withGridland(nextConfig: NextConfig = {}): NextConfig {\n // __dirname works natively in CJS; tsup shims it for ESM via import.meta.url\n const pkgRoot = path.resolve(__dirname, \"..\")\n\n // Resolve opentui package roots from the git submodule\n const opentuiRoot = path.resolve(pkgRoot, \"../../opentui\")\n const coreRoot = path.resolve(opentuiRoot, \"packages/core\")\n const reactRoot = path.resolve(opentuiRoot, \"packages/react\")\n const uiRoot = path.resolve(opentuiRoot, \"packages/ui\")\n\n function shimPath(p: string) {\n return path.resolve(pkgRoot, p)\n }\n\n // Core shims — same mappings as the Vite plugin\n const coreFileShims: Record<string, string> = {\n zig: \"src/shims/zig-stub.ts\",\n buffer: \"src/browser-buffer.ts\",\n \"text-buffer\": \"src/shims/text-buffer-shim.ts\",\n \"text-buffer-view\": \"src/shims/text-buffer-view-shim.ts\",\n \"syntax-style\": \"src/shims/syntax-style-shim.ts\",\n renderer: \"src/shims/renderer-stub.ts\",\n console: \"src/shims/console-stub.ts\",\n \"edit-buffer\": \"src/shims/edit-buffer-stub.ts\",\n \"editor-view\": \"src/shims/editor-view-stub.ts\",\n NativeSpanFeed: \"src/shims/native-span-feed-stub.ts\",\n \"post/filters\": \"src/shims/filters-stub.ts\",\n \"animation/Timeline\": \"src/shims/timeline-stub.ts\",\n }\n\n const userWebpack = nextConfig.webpack\n\n return {\n ...nextConfig,\n webpack: (config: WebpackConfig, context: { isServer: boolean; webpack: WebpackInstance }) => {\n const { isServer, webpack } = context\n\n // Chain user's webpack config first if provided\n if (userWebpack) {\n config = userWebpack(config, context)\n }\n\n // Aliases needed on BOTH server and client (opentui packages, FFI stubs,\n // tree-sitter stubs, core file shims). The server doesn't actually render\n // the TUI but still walks the module graph for \"use client\" components.\n const sharedAliases: Record<string, string> = {\n // @opentui packages — core-shims includes all exports @opentui/react needs\n \"@opentui/core\": shimPath(\"src/core-shims/index.ts\"),\n \"@opentui/react\": path.resolve(reactRoot, \"src/index.ts\"),\n \"@opentui/ui\": path.resolve(uiRoot, \"src/index.ts\"),\n\n // FFI shims (no Zig/Bun on server or client in browser context)\n \"bun:ffi\": shimPath(\"src/shims/bun-ffi.ts\"),\n \"bun-ffi-structs\": shimPath(\"src/shims/bun-ffi-structs.ts\"),\n bun: shimPath(\"src/shims/bun-ffi.ts\"),\n\n // Tree-sitter stubs — IMPORTANT: longer prefix must come first to avoid\n // \"tree-sitter\" matching \"tree-sitter-styled-text\" (webpack prefix match)\n \"tree-sitter-styled-text\": shimPath(\"src/shims/tree-sitter-styled-text-stub.ts\"),\n \"web-tree-sitter\": shimPath(\"src/shims/tree-sitter-stub.ts\"),\n \"hast-styled-text\": shimPath(\"src/shims/hast-stub.ts\"),\n // Internal tree-sitter source directories (pulled in via renderable imports)\n [path.resolve(coreRoot, \"src/lib/tree-sitter-styled-text\")]:\n shimPath(\"src/shims/tree-sitter-styled-text-stub.ts\"),\n [path.resolve(coreRoot, \"src/lib/tree-sitter\")]:\n shimPath(\"src/shims/tree-sitter-stub.ts\"),\n [path.resolve(coreRoot, \"src/lib/hast-styled-text\")]:\n shimPath(\"src/shims/hast-stub.ts\"),\n\n // Devtools polyfill stub (original uses top-level await for ws import)\n [path.resolve(reactRoot, \"src/reconciler/devtools-polyfill\")]:\n shimPath(\"src/shims/devtools-polyfill-stub.ts\"),\n }\n\n // Core file shims (opentui source → browser shim)\n for (const [key, shimFile] of Object.entries(coreFileShims)) {\n sharedAliases[path.resolve(coreRoot, \"src\", key)] = shimPath(shimFile)\n }\n\n config.resolve = config.resolve || {}\n config.resolve.alias = {\n ...config.resolve.alias,\n ...sharedAliases,\n }\n\n // Slider circular dependency fix: Slider.ts imports from \"../index\" which\n // creates barrel → renderables → Slider → barrel cycle. Redirect to a\n // minimal deps file that provides only what Slider needs.\n const renderablesDir = path.resolve(coreRoot, \"src/renderables\")\n config.plugins.push(\n new webpack.NormalModuleReplacementPlugin(/^\\.\\.\\/index$/, (resource: any) => {\n if (resource.context === renderablesDir) {\n resource.request = shimPath(\"src/shims/slider-deps.ts\")\n }\n }),\n )\n\n if (!isServer) {\n // Client-only: Node.js built-in stubs, events shim, console shim.\n // Use \"$\" suffix for exact match to prevent \"fs\" from matching \"fs/promises\".\n const clientAliases: Record<string, string> = {\n \"node:console\": shimPath(\"src/shims/console.ts\"),\n \"events$\": shimPath(\"src/shims/events-shim.ts\"),\n \"fs/promises\": shimPath(\"src/shims/node-fs.ts\"),\n \"fs$\": shimPath(\"src/shims/node-fs.ts\"),\n \"path$\": shimPath(\"src/shims/node-path.ts\"),\n \"util$\": shimPath(\"src/shims/node-util.ts\"),\n \"os$\": shimPath(\"src/shims/node-os.ts\"),\n \"stream$\": shimPath(\"src/shims/node-stream.ts\"),\n \"url$\": shimPath(\"src/shims/node-url.ts\"),\n }\n\n config.resolve.alias = {\n ...config.resolve.alias,\n ...clientAliases,\n }\n\n // Allow webpack to resolve modules from our workspace node_modules\n config.resolve.modules = [\n ...(config.resolve.modules || []),\n path.resolve(pkgRoot, \"node_modules\"),\n path.resolve(pkgRoot, \"../../node_modules\"),\n ]\n\n // Strip `node:` and `bun:` prefixes from imports so they resolve\n // through aliases. Webpack 5 treats these as unhandled URL schemes.\n config.plugins.push(\n new webpack.NormalModuleReplacementPlugin(/^node:/, (resource: any) => {\n resource.request = resource.request.replace(/^node:/, \"\")\n }),\n new webpack.NormalModuleReplacementPlugin(/^bun:/, (resource: any) => {\n resource.request = resource.request.replace(/^bun:/, \"\")\n }),\n )\n }\n\n // Enable top-level await (used by opentui source code)\n config.experiments = {\n ...config.experiments,\n topLevelAwait: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,UAClB,GAAG;AAAA,QACL;AAGA,eAAO,QAAQ,UAAU;AAAA,UACvB,GAAI,OAAO,QAAQ,WAAW,CAAC;AAAA,UAC/B,KAAK,QAAQ,SAAS,cAAc;AAAA,UACpC,KAAK,QAAQ,SAAS,oBAAoB;AAAA,QAC5C;AAIA,eAAO,QAAQ;AAAA,UACb,IAAI,QAAQ,8BAA8B,UAAU,CAAC,aAAkB;AACrE,qBAAS,UAAU,SAAS,QAAQ,QAAQ,UAAU,EAAE;AAAA,UAC1D,CAAC;AAAA,UACD,IAAI,QAAQ,8BAA8B,SAAS,CAAC,aAAkB;AACpE,qBAAS,UAAU,SAAS,QAAQ,QAAQ,SAAS,EAAE;AAAA,UACzD,CAAC;AAAA,QACH;AAAA,MACF;AAGA,aAAO,cAAc;AAAA,QACnB,GAAG,OAAO;AAAA,QACV,eAAe;AAAA,MACjB;AAEA,aAAO;AAAA,IACT;AAAA,EACF;AACF;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/next-plugin.ts"],"sourcesContent":["import path from \"path\"\nimport { existsSync } from \"fs\"\n\ntype WebpackConfig = any\ntype WebpackInstance = any\n\ninterface NextConfig {\n webpack?: (config: WebpackConfig, context: { isServer: boolean; webpack: WebpackInstance }) => WebpackConfig\n [key: string]: any\n}\n\n/**\n * Next.js plugin that configures webpack for Gridland.\n * Equivalent to `gridlandWebPlugin()` for Vite — handles module aliases,\n * FFI shims, tree-sitter stubs, Node.js built-in stubs, and circular\n * dependency fixes.\n *\n * Requires @opentui/core, @opentui/react, and @opentui/ui as peer dependencies.\n *\n * @param nextConfig - Optional additional Next.js config to merge\n */\nexport function withGridland(nextConfig: NextConfig = {}): NextConfig {\n // __dirname works natively in CJS; tsup shims it for ESM via import.meta.url\n const pkgRoot = path.resolve(__dirname, \"..\")\n\n // Resolve opentui package roots from the git submodule\n const opentuiRoot = path.resolve(pkgRoot, \"../../opentui\")\n const coreRoot = path.resolve(opentuiRoot, \"packages/core\")\n const reactRoot = path.resolve(opentuiRoot, \"packages/react\")\n const uiRoot = path.resolve(opentuiRoot, \"packages/ui\")\n\n // Detect whether opentui source is available (monorepo/submodule)\n const hasSource = existsSync(path.resolve(reactRoot, \"src/index.ts\"))\n // Pre-compiled core-shims for npm mode (no monorepo-relative paths)\n const compiledCoreShims = path.resolve(pkgRoot, \"dist/core-shims.js\")\n\n function shimPath(p: string) {\n return path.resolve(pkgRoot, p)\n }\n\n // Core shims — same mappings as the Vite plugin\n const coreFileShims: Record<string, string> = {\n zig: \"src/shims/zig-stub.ts\",\n buffer: \"src/browser-buffer.ts\",\n \"text-buffer\": \"src/shims/text-buffer-shim.ts\",\n \"text-buffer-view\": \"src/shims/text-buffer-view-shim.ts\",\n \"syntax-style\": \"src/shims/syntax-style-shim.ts\",\n renderer: \"src/shims/renderer-stub.ts\",\n console: \"src/shims/console-stub.ts\",\n \"edit-buffer\": \"src/shims/edit-buffer-stub.ts\",\n \"editor-view\": \"src/shims/editor-view-stub.ts\",\n NativeSpanFeed: \"src/shims/native-span-feed-stub.ts\",\n \"post/filters\": \"src/shims/filters-stub.ts\",\n \"animation/Timeline\": \"src/shims/timeline-stub.ts\",\n }\n\n const userWebpack = nextConfig.webpack\n\n return {\n ...nextConfig,\n webpack: (config: WebpackConfig, context: { isServer: boolean; webpack: WebpackInstance }) => {\n const { isServer, webpack } = context\n\n // Chain user's webpack config first if provided\n if (userWebpack) {\n config = userWebpack(config, context)\n }\n\n // Aliases needed on BOTH server and client (opentui packages, FFI stubs,\n // tree-sitter stubs, core file shims). The server doesn't actually render\n // the TUI but still walks the module graph for \"use client\" components.\n const sharedAliases: Record<string, string> = {\n // In npm mode, @gridland/core bundles real opentui with native deps\n // that browsers can't handle. Alias it to the core-shims bundle instead.\n ...(!hasSource ? { \"@gridland/core\": compiledCoreShims } : {}),\n\n // @opentui packages — source mode only (monorepo dev)\n ...(hasSource ? {\n \"@opentui/core\": shimPath(\"src/core-shims/index.ts\"),\n \"@opentui/react\": path.resolve(reactRoot, \"src/index.ts\"),\n \"@opentui/ui\": path.resolve(uiRoot, \"src/index.ts\"),\n } : {}),\n\n // FFI shims (no Zig/Bun on server or client in browser context)\n \"bun:ffi\": shimPath(\"src/shims/bun-ffi.ts\"),\n \"bun-ffi-structs\": shimPath(\"src/shims/bun-ffi-structs.ts\"),\n bun: shimPath(\"src/shims/bun-ffi.ts\"),\n\n // Tree-sitter stubs\n \"tree-sitter-styled-text\": shimPath(\"src/shims/tree-sitter-styled-text-stub.ts\"),\n \"web-tree-sitter\": shimPath(\"src/shims/tree-sitter-stub.ts\"),\n \"hast-styled-text\": shimPath(\"src/shims/hast-stub.ts\"),\n\n // Source-mode-only aliases: opentui source directories and file shims.\n // In npm mode, these are already compiled into the core-shims bundle.\n ...(hasSource ? {\n [path.resolve(coreRoot, \"src/lib/tree-sitter-styled-text\")]:\n shimPath(\"src/shims/tree-sitter-styled-text-stub.ts\"),\n [path.resolve(coreRoot, \"src/lib/tree-sitter\")]:\n shimPath(\"src/shims/tree-sitter-stub.ts\"),\n [path.resolve(coreRoot, \"src/lib/hast-styled-text\")]:\n shimPath(\"src/shims/hast-stub.ts\"),\n [path.resolve(reactRoot, \"src/reconciler/devtools-polyfill\")]:\n shimPath(\"src/shims/devtools-polyfill-stub.ts\"),\n } : {}),\n }\n\n // Core file shims (opentui source → browser shim) — source mode only\n if (hasSource) {\n for (const [key, shimFile] of Object.entries(coreFileShims)) {\n sharedAliases[path.resolve(coreRoot, \"src\", key)] = shimPath(shimFile)\n }\n }\n\n config.resolve = config.resolve || {}\n config.resolve.alias = {\n ...config.resolve.alias,\n ...sharedAliases,\n }\n\n // Slider circular dependency fix — source mode only\n if (hasSource) {\n const renderablesDir = path.resolve(coreRoot, \"src/renderables\")\n config.plugins.push(\n new webpack.NormalModuleReplacementPlugin(/^\\.\\.\\/index$/, (resource: any) => {\n if (resource.context === renderablesDir) {\n resource.request = shimPath(\"src/shims/slider-deps.ts\")\n }\n }),\n )\n }\n\n if (!isServer) {\n // Client-only: Node.js built-in stubs, events shim, console shim.\n // Use \"$\" suffix for exact match to prevent \"fs\" from matching \"fs/promises\".\n const clientAliases: Record<string, string> = {\n \"node:console\": shimPath(\"src/shims/console.ts\"),\n \"events$\": shimPath(\"src/shims/events-shim.ts\"),\n \"fs/promises\": shimPath(\"src/shims/node-fs.ts\"),\n \"fs$\": shimPath(\"src/shims/node-fs.ts\"),\n \"path$\": shimPath(\"src/shims/node-path.ts\"),\n \"util$\": shimPath(\"src/shims/node-util.ts\"),\n \"os$\": shimPath(\"src/shims/node-os.ts\"),\n \"stream$\": shimPath(\"src/shims/node-stream.ts\"),\n \"url$\": shimPath(\"src/shims/node-url.ts\"),\n }\n\n config.resolve.alias = {\n ...config.resolve.alias,\n ...clientAliases,\n }\n\n // Allow webpack to resolve modules from our workspace node_modules\n config.resolve.modules = [\n ...(config.resolve.modules || []),\n path.resolve(pkgRoot, \"node_modules\"),\n path.resolve(pkgRoot, \"../../node_modules\"),\n ]\n\n // Strip `node:` and `bun:` prefixes from imports so they resolve\n // through aliases. Webpack 5 treats these as unhandled URL schemes.\n config.plugins.push(\n new webpack.NormalModuleReplacementPlugin(/^node:/, (resource: any) => {\n resource.request = resource.request.replace(/^node:/, \"\")\n }),\n new webpack.NormalModuleReplacementPlugin(/^bun:/, (resource: any) => {\n resource.request = resource.request.replace(/^bun:/, \"\")\n }),\n )\n }\n\n // Enable top-level await (used by opentui source code)\n config.experiments = {\n ...config.experiments,\n topLevelAwait: true,\n }\n\n return config\n },\n }\n}\n"],"mappings":";AAAA,OAAO,UAAU;AACjB,SAAS,kBAAkB;AAoBpB,SAAS,aAAa,aAAyB,CAAC,GAAe;AAEpE,QAAM,UAAU,KAAK,QAAQ,WAAW,IAAI;AAG5C,QAAM,cAAc,KAAK,QAAQ,SAAS,eAAe;AACzD,QAAM,WAAW,KAAK,QAAQ,aAAa,eAAe;AAC1D,QAAM,YAAY,KAAK,QAAQ,aAAa,gBAAgB;AAC5D,QAAM,SAAS,KAAK,QAAQ,aAAa,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AO,QAAQ;AAAA,UAClB,GAAG;AAAA,QACL;AAGA,eAAO,QAAQ,UAAU;AAAA,UACvB,GAAI,OAAO,QAAQ,WAAW,CAAC;AAAA,UAC/B,KAAK,QAAQ,SAAS,cAAc;AAAA,UACpC,KAAK,QAAQ,SAAS,oBAAoB;AAAA,QAC5C;AAIA,eAAO,QAAQ;AAAA,UACb,IAAI,QAAQ,8BAA8B,UAAU,CAAC,aAAkB;AACrE,qBAAS,UAAU,SAAS,QAAQ,QAAQ,UAAU,EAAE;AAAA,UAC1D,CAAC;AAAA,UACD,IAAI,QAAQ,8BAA8B,SAAS,CAAC,aAAkB;AACpE,qBAAS,UAAU,SAAS,QAAQ,QAAQ,SAAS,EAAE;AAAA,UACzD,CAAC;AAAA,QACH;AAAA,MACF;AAGA,aAAO,cAAc;AAAA,QACnB,GAAG,OAAO;AAAA,QACV,eAAe;AAAA,MACjB;AAEA,aAAO;AAAA,IACT;AAAA,EACF;AACF;","names":[]}
|
package/dist/vite-plugin.js
CHANGED
|
@@ -33,6 +33,7 @@ function gridlandWebPlugin() {
|
|
|
33
33
|
const uiRoot = resolvePackageRoot("@opentui/ui", "../../opentui/packages/ui");
|
|
34
34
|
const hasSource = existsSync(path.resolve(reactRoot, "src/index.ts"));
|
|
35
35
|
const coreShims = path.resolve(pkgRoot, "src/core-shims/index.ts");
|
|
36
|
+
const compiledCoreShims = path.resolve(pkgRoot, "dist/core-shims.js");
|
|
36
37
|
const opentuiCoreBarrel = path.resolve(coreRoot, "src/index.ts");
|
|
37
38
|
const sliderDeps = path.resolve(pkgRoot, "src/shims/slider-deps.ts");
|
|
38
39
|
const sliderFile = path.resolve(coreRoot, "src/renderables/Slider.ts");
|
|
@@ -182,6 +183,9 @@ function gridlandWebPlugin() {
|
|
|
182
183
|
name: "gridland-web-aliases",
|
|
183
184
|
config() {
|
|
184
185
|
const aliases = {};
|
|
186
|
+
if (!hasSource) {
|
|
187
|
+
aliases["@gridland/core"] = compiledCoreShims;
|
|
188
|
+
}
|
|
185
189
|
aliases["bun:ffi"] = path.resolve(pkgRoot, "src/shims/bun-ffi.ts");
|
|
186
190
|
aliases["bun-ffi-structs"] = path.resolve(pkgRoot, "src/shims/bun-ffi-structs.ts");
|
|
187
191
|
aliases["node:console"] = path.resolve(pkgRoot, "src/shims/console.ts");
|
package/dist/vite-plugin.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/vite-plugin.ts"],"sourcesContent":["import { type Plugin } from \"vite\"\nimport path from \"path\"\nimport { existsSync } from \"fs\"\nimport { createRequire } from \"module\"\nimport { fileURLToPath } from \"url\"\n\nconst __filename = fileURLToPath(import.meta.url)\nconst __dirname = path.dirname(__filename)\n\n/**\n * Vite plugin that sets up module resolution for Gridland.\n * Handles:\n * - Redirecting Zig/FFI imports to browser shims\n * - Resolving @opentui/core, @opentui/react, @opentui/ui\n * - Shimming Node.js built-ins\n * - Breaking circular dependencies\n *\n * Requires @opentui/core, @opentui/react, and @opentui/ui as peer dependencies.\n */\nexport function gridlandWebPlugin(): Plugin[] {\n const pkgRoot = path.resolve(__dirname, \"..\")\n const _require = createRequire(path.resolve(pkgRoot, \"package.json\"))\n // Separate require for resolving opentui packages from the consumer project's\n // node_modules (not from @gridland/web's location, which may differ when\n // using file: links or in monorepo setups).\n const _projectRequire = createRequire(path.resolve(process.cwd(), \"package.json\"))\n\n // Resolve opentui package roots — try installed packages first,\n // fall back to git submodule for monorepo development.\n // Some packages restrict their exports map (no ./package.json),\n // so we try the main entry point as a fallback.\n function resolvePackageRoot(pkg: string, fallbackRelative: string): string {\n // Try multiple require contexts: project-level first (for consumer apps),\n // then @gridland/web-level (for monorepo dev). This ensures we find\n // packages in the consumer's node_modules, not just our own.\n for (const req of [_projectRequire, _require]) {\n try {\n const pkgJson = req.resolve(`${pkg}/package.json`)\n return path.dirname(pkgJson)\n } catch {\n try {\n // Package exists but doesn't expose package.json in exports map.\n // Resolve the main entry and derive the root from it.\n const entry = req.resolve(pkg)\n let dir = path.dirname(entry)\n for (let i = 0; i < 5; i++) {\n if (existsSync(path.join(dir, \"package.json\"))) return dir\n dir = path.dirname(dir)\n }\n } catch {\n // Package not installed in this context\n }\n }\n }\n return path.resolve(pkgRoot, fallbackRelative)\n }\n const coreRoot = resolvePackageRoot(\"@opentui/core\", \"../../opentui/packages/core\")\n const reactRoot = resolvePackageRoot(\"@opentui/react\", \"../../opentui/packages/react\")\n const uiRoot = resolvePackageRoot(\"@opentui/ui\", \"../../opentui/packages/ui\")\n\n // Detect whether opentui packages have TypeScript source (monorepo/submodule)\n // or only compiled JS (npm install). When source is available, we resolve\n // imports to .ts files and apply shims. Otherwise, let Vite handle them normally.\n const hasSource = existsSync(path.resolve(reactRoot, \"src/index.ts\"))\n\n const coreShims = path.resolve(pkgRoot, \"src/core-shims/index.ts\")\n const opentuiCoreBarrel = path.resolve(coreRoot, \"src/index.ts\")\n const sliderDeps = path.resolve(pkgRoot, \"src/shims/slider-deps.ts\")\n const sliderFile = path.resolve(coreRoot, \"src/renderables/Slider.ts\")\n\n // Map of opentui source files that need browser shims\n const coreFileShims: Record<string, string> = {\n zig: \"src/shims/zig-stub.ts\",\n buffer: \"src/browser-buffer.ts\",\n \"text-buffer\": \"src/shims/text-buffer-shim.ts\",\n \"text-buffer-view\": \"src/shims/text-buffer-view-shim.ts\",\n \"syntax-style\": \"src/shims/syntax-style-shim.ts\",\n renderer: \"src/shims/renderer-stub.ts\",\n console: \"src/shims/console-stub.ts\",\n \"edit-buffer\": \"src/shims/edit-buffer-stub.ts\",\n \"editor-view\": \"src/shims/editor-view-stub.ts\",\n NativeSpanFeed: \"src/shims/native-span-feed-stub.ts\",\n \"post/filters\": \"src/shims/filters-stub.ts\",\n \"animation/Timeline\": \"src/shims/timeline-stub.ts\",\n }\n\n const resolvedCoreShims = new Map<string, string>()\n for (const [key, shimPath] of Object.entries(coreFileShims)) {\n const absoluteTarget = path.resolve(coreRoot, \"src\", key + \".ts\")\n resolvedCoreShims.set(absoluteTarget, path.resolve(pkgRoot, shimPath))\n }\n\n const treeStub = path.resolve(pkgRoot, \"src/shims/tree-sitter-stub.ts\")\n const styledTextStub = path.resolve(pkgRoot, \"src/shims/tree-sitter-styled-text-stub.ts\")\n\n // Lookup tables hoisted out of resolveId to avoid per-call allocation\n const pkgRoots: Record<string, string> = { core: coreRoot, react: reactRoot, ui: uiRoot }\n\n const nodeShims: Record<string, string> = {\n \"node:buffer\": \"src/shims/node-buffer.ts\",\n \"node:path\": \"src/shims/node-path.ts\",\n path: \"src/shims/node-path.ts\",\n \"node:fs\": \"src/shims/node-fs.ts\",\n fs: \"src/shims/node-fs.ts\",\n \"fs/promises\": \"src/shims/node-fs.ts\",\n \"node:util\": \"src/shims/node-util.ts\",\n util: \"src/shims/node-util.ts\",\n os: \"src/shims/node-os.ts\",\n \"node:os\": \"src/shims/node-os.ts\",\n stream: \"src/shims/node-stream.ts\",\n \"node:stream\": \"src/shims/node-stream.ts\",\n url: \"src/shims/node-url.ts\",\n \"node:url\": \"src/shims/node-url.ts\",\n console: \"src/shims/console.ts\",\n bun: \"src/shims/bun-ffi.ts\",\n }\n\n // Virtual module prefix for npm package redirects.\n // When external opentui code imports a bare npm package (e.g. \"react\"),\n // we can't return the raw file path because Vite would serve it via /@fs/\n // without CJS-to-ESM conversion. Instead, we return a virtual module that\n // re-exports from the bare package name, which Vite processes through its\n // normal pre-bundling pipeline (including CJS conversion).\n const NPM_REDIRECT = \"\\0npm-redirect:\"\n\n const shimPlugin: Plugin = {\n name: \"gridland-web-shims\",\n enforce: \"pre\",\n resolveId(source, importer) {\n if (!importer) return null\n\n // Virtual module redirects should not be re-intercepted\n if (importer.startsWith(NPM_REDIRECT)) return null\n\n // Check if importer is in an opentui package.\n // Use both resolved root paths AND path-based matching to handle\n // multiple copies (e.g. bun's cache when using file: links).\n const isExternalOpentui =\n importer.startsWith(coreRoot + path.sep) ||\n importer.startsWith(reactRoot + path.sep) ||\n importer.startsWith(uiRoot + path.sep) ||\n importer.includes(\"/@opentui/core/\") ||\n importer.includes(\"/@opentui/react/\") ||\n importer.includes(\"/@opentui/ui/\")\n\n // Source-mode-only shims: slider circular dep fix, relative import\n // shims, tree-sitter stubs, and node built-in stubs only apply when\n // processing opentui TypeScript source (monorepo/submodule).\n // Compiled npm packages have these already resolved.\n\n // Slider circular dep fix\n if (hasSource && source === \"../index\" && importer === sliderFile) {\n return sliderDeps\n }\n\n // Resolve @opentui packages — only intercept when we have source files.\n // When using npm-installed packages (compiled JS), let Vite resolve normally.\n if (hasSource) {\n if (source === \"@opentui/ui\") {\n return path.resolve(uiRoot, \"src/index.ts\")\n }\n if (source === \"@opentui/react\") {\n return path.resolve(reactRoot, \"src/index.ts\")\n }\n\n // @opentui/core routing\n if (source === \"@opentui/core\") {\n if (importer.startsWith(reactRoot + path.sep)) {\n return opentuiCoreBarrel\n }\n return coreShims\n }\n\n // @opentui/* subpath imports (e.g. @opentui/react/jsx-dev-runtime)\n if (source.startsWith(\"@opentui/\")) {\n const parts = source.split(\"/\")\n const pkgName = parts[1] // \"react\", \"core\", \"ui\"\n const subpath = parts.slice(2).join(\"/\") // \"jsx-dev-runtime\"\n if (subpath) {\n const root = pkgRoots[pkgName]\n if (root) return path.resolve(root, subpath + \".js\")\n }\n }\n }\n\n // Relative imports from opentui tree → check shims\n if (source.startsWith(\".\") && isExternalOpentui) {\n const importerDir = path.dirname(importer)\n const resolved = path.resolve(importerDir, source)\n // Devtools polyfill stub (uses top-level await for ws import)\n if (resolved.endsWith(\"devtools-polyfill\")) {\n return path.resolve(pkgRoot, \"src/shims/devtools-polyfill-stub.ts\")\n }\n // Source-mode shims for core files (only when processing TS source)\n if (hasSource) {\n const shim = resolvedCoreShims.get(resolved) || resolvedCoreShims.get(resolved + \".ts\")\n if (shim) return shim\n const indexShim = resolvedCoreShims.get(resolved + \"/index.ts\")\n if (indexShim) return indexShim\n }\n }\n\n // Tree-sitter and related stubs — needed in both source and npm mode\n // since the compiled @opentui/core still imports these\n if (isExternalOpentui) {\n // Stub .scm and .wasm asset imports first (before tree-sitter name match)\n if (source.endsWith(\".scm\") || source.endsWith(\".wasm\")) {\n return \"\\0opentui-asset-stub\"\n }\n if (source.includes(\"tree-sitter\")) {\n if (source.includes(\"tree-sitter-styled-text\")) return styledTextStub\n return treeStub\n }\n if (source.includes(\"hast-styled-text\")) {\n return path.resolve(pkgRoot, \"src/shims/hast-stub.ts\")\n }\n }\n\n // Events shim — applies to ALL importers (browser-compatible EventEmitter)\n if (source === \"events\") {\n return path.resolve(pkgRoot, \"src/shims/events-shim.ts\")\n }\n\n // Node.js built-in stubs — needed in both modes since compiled\n // @opentui/core still imports node builtins\n if (nodeShims[source] && isExternalOpentui) {\n return path.resolve(pkgRoot, nodeShims[source])\n }\n\n // Redirect bare npm imports from external opentui to virtual modules (source mode only)\n if (hasSource && !source.startsWith(\".\") && !source.startsWith(\"/\") && !source.startsWith(\"@opentui/\") && isExternalOpentui) {\n return NPM_REDIRECT + source\n }\n\n return null\n },\n load(id) {\n // Stub for .scm/.wasm asset imports from compiled opentui packages\n if (id === \"\\0opentui-asset-stub\") {\n return \"export default null;\"\n }\n if (id.startsWith(NPM_REDIRECT)) {\n const pkg = id.slice(NPM_REDIRECT.length)\n // Discover export names by require()-ing the module at build time.\n // We use `import * as __ns` (namespace import) which works for both\n // ESM packages (named exports on namespace) and CJS packages\n // (pre-bundled with only a default export, properties on __ns.default).\n // Each property checks both locations with a fallback.\n // NOTE: We use bare specifiers (not resolved paths) so Vite routes\n // these through its pre-bundling pipeline for CJS-to-ESM conversion.\n try {\n const mod = _require(pkg)\n if (typeof mod === \"object\" && mod !== null) {\n const names = Object.keys(mod).filter(\n (k) => k !== \"default\" && k !== \"__esModule\" && /^[a-zA-Z_$][\\w$]*$/.test(k),\n )\n if (names.length > 0) {\n return [\n `import * as __ns from \"${pkg}\";`,\n `export default __ns.default ?? __ns;`,\n ...names.map(\n (n) => `export const ${n} = __ns[\"${n}\"] ?? __ns.default?.[\"${n}\"];`,\n ),\n ].join(\"\\n\")\n }\n }\n } catch {\n // Fall through to generic approach\n }\n // Fallback for packages we can't introspect\n return [\n `export * from \"${pkg}\";`,\n `import * as __ns from \"${pkg}\";`,\n `export default __ns.default ?? __ns;`,\n ].join(\"\\n\")\n }\n },\n }\n\n const aliasPlugin: Plugin = {\n name: \"gridland-web-aliases\",\n config() {\n const aliases: Record<string, string> = {}\n\n // FFI shims\n aliases[\"bun:ffi\"] = path.resolve(pkgRoot, \"src/shims/bun-ffi.ts\")\n aliases[\"bun-ffi-structs\"] = path.resolve(pkgRoot, \"src/shims/bun-ffi-structs.ts\")\n aliases[\"node:console\"] = path.resolve(pkgRoot, \"src/shims/console.ts\")\n\n // Core file shims as aliases too\n for (const [key, shimPath] of Object.entries(coreFileShims)) {\n aliases[path.resolve(coreRoot, \"src\", key)] = path.resolve(pkgRoot, shimPath)\n }\n\n // Resolve npm packages from @gridland/web's dependency tree so\n // consuming projects don't need them as direct dependencies.\n // Uses _require to find the actual installed location (handles\n // hoisted node_modules). Directory aliases let subpath imports\n // (e.g. react-reconciler/constants) work via Vite's prefix\n // matching, and ensure CJS packages go through pre-bundling.\n for (const pkg of [\"react-reconciler\", \"yoga-layout\", \"diff\", \"marked\"]) {\n try {\n aliases[pkg] = path.dirname(_require.resolve(pkg + \"/package.json\"))\n } catch {\n aliases[pkg] = path.resolve(pkgRoot, \"node_modules\", pkg)\n }\n }\n\n return {\n define: {\n \"process.env\": JSON.stringify({}),\n },\n resolve: {\n alias: aliases,\n dedupe: [\"react\", \"react-dom\", \"react-reconciler\", \"yoga-layout\", \"events\"],\n },\n optimizeDeps: {\n // Pre-bundle npm packages imported by external opentui monorepo code.\n // These are resolved via virtual module redirects, so Vite's initial\n // crawl won't discover them — they must be listed explicitly.\n // Only needed in source mode; compiled npm packages are discovered normally.\n include: hasSource ? [\n \"react\",\n \"react-dom\",\n \"react-reconciler\",\n \"react-reconciler/constants\",\n \"diff\",\n \"yoga-layout\",\n \"marked\",\n ] : [\n \"react\",\n \"react-dom\",\n ],\n },\n server: {\n fs: {\n // Allow serving from opentui source dirs (for dev-from-source).\n // Use strict: false so Vite's default allow list (project root) is preserved.\n strict: false,\n },\n },\n }\n },\n }\n\n return [shimPlugin, aliasPlugin]\n}\n"],"mappings":";AACA,OAAO,UAAU;AACjB,SAAS,kBAAkB;AAC3B,SAAS,qBAAqB;AAC9B,SAAS,qBAAqB;AAE9B,IAAM,aAAa,cAAc,YAAY,GAAG;AAChD,IAAM,YAAY,KAAK,QAAQ,UAAU;AAYlC,SAAS,oBAA8B;AAC5C,QAAM,UAAU,KAAK,QAAQ,WAAW,IAAI;AAC5C,QAAM,WAAW,cAAc,KAAK,QAAQ,SAAS,cAAc,CAAC;AAIpE,QAAM,kBAAkB,cAAc,KAAK,QAAQ,QAAQ,IAAI,GAAG,cAAc,CAAC;AAMjF,WAAS,mBAAmB,KAAa,kBAAkC;AAIzE,eAAW,OAAO,CAAC,iBAAiB,QAAQ,GAAG;AAC7C,UAAI;AACF,cAAM,UAAU,IAAI,QAAQ,GAAG,GAAG,eAAe;AACjD,eAAO,KAAK,QAAQ,OAAO;AAAA,MAC7B,QAAQ;AACN,YAAI;AAGF,gBAAM,QAAQ,IAAI,QAAQ,GAAG;AAC7B,cAAI,MAAM,KAAK,QAAQ,KAAK;AAC5B,mBAAS,IAAI,GAAG,IAAI,GAAG,KAAK;AAC1B,gBAAI,WAAW,KAAK,KAAK,KAAK,cAAc,CAAC,EAAG,QAAO;AACvD,kBAAM,KAAK,QAAQ,GAAG;AAAA,UACxB;AAAA,QACF,QAAQ;AAAA,QAER;AAAA,MACF;AAAA,IACF;AACA,WAAO,KAAK,QAAQ,SAAS,gBAAgB;AAAA,EAC/C;AACA,QAAM,WAAW,mBAAmB,iBAAiB,6BAA6B;AAClF,QAAM,YAAY,mBAAmB,kBAAkB,8BAA8B;AACrF,QAAM,SAAS,mBAAmB,eAAe,2BAA2B;AAK5E,QAAM,YAAY,WAAW,KAAK,QAAQ,WAAW,cAAc,C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Z,SAAS,YAAY;AAAA,YACnB;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,UACF,IAAI;AAAA,YACF;AAAA,YACA;AAAA,UACF;AAAA,QACF;AAAA,QACA,QAAQ;AAAA,UACN,IAAI;AAAA;AAAA;AAAA,YAGF,QAAQ;AAAA,UACV;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAEA,SAAO,CAAC,YAAY,WAAW;AACjC;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/vite-plugin.ts"],"sourcesContent":["import { type Plugin } from \"vite\"\nimport path from \"path\"\nimport { existsSync } from \"fs\"\nimport { createRequire } from \"module\"\nimport { fileURLToPath } from \"url\"\n\nconst __filename = fileURLToPath(import.meta.url)\nconst __dirname = path.dirname(__filename)\n\n/**\n * Vite plugin that sets up module resolution for Gridland.\n * Handles:\n * - Redirecting Zig/FFI imports to browser shims\n * - Resolving @opentui/core, @opentui/react, @opentui/ui\n * - Shimming Node.js built-ins\n * - Breaking circular dependencies\n *\n * Requires @opentui/core, @opentui/react, and @opentui/ui as peer dependencies.\n */\nexport function gridlandWebPlugin(): Plugin[] {\n const pkgRoot = path.resolve(__dirname, \"..\")\n const _require = createRequire(path.resolve(pkgRoot, \"package.json\"))\n // Separate require for resolving opentui packages from the consumer project's\n // node_modules (not from @gridland/web's location, which may differ when\n // using file: links or in monorepo setups).\n const _projectRequire = createRequire(path.resolve(process.cwd(), \"package.json\"))\n\n // Resolve opentui package roots — try installed packages first,\n // fall back to git submodule for monorepo development.\n // Some packages restrict their exports map (no ./package.json),\n // so we try the main entry point as a fallback.\n function resolvePackageRoot(pkg: string, fallbackRelative: string): string {\n // Try multiple require contexts: project-level first (for consumer apps),\n // then @gridland/web-level (for monorepo dev). This ensures we find\n // packages in the consumer's node_modules, not just our own.\n for (const req of [_projectRequire, _require]) {\n try {\n const pkgJson = req.resolve(`${pkg}/package.json`)\n return path.dirname(pkgJson)\n } catch {\n try {\n // Package exists but doesn't expose package.json in exports map.\n // Resolve the main entry and derive the root from it.\n const entry = req.resolve(pkg)\n let dir = path.dirname(entry)\n for (let i = 0; i < 5; i++) {\n if (existsSync(path.join(dir, \"package.json\"))) return dir\n dir = path.dirname(dir)\n }\n } catch {\n // Package not installed in this context\n }\n }\n }\n return path.resolve(pkgRoot, fallbackRelative)\n }\n const coreRoot = resolvePackageRoot(\"@opentui/core\", \"../../opentui/packages/core\")\n const reactRoot = resolvePackageRoot(\"@opentui/react\", \"../../opentui/packages/react\")\n const uiRoot = resolvePackageRoot(\"@opentui/ui\", \"../../opentui/packages/ui\")\n\n // Detect whether opentui packages have TypeScript source (monorepo/submodule)\n // or only compiled JS (npm install). When source is available, we resolve\n // imports to .ts files and apply shims. Otherwise, let Vite handle them normally.\n const hasSource = existsSync(path.resolve(reactRoot, \"src/index.ts\"))\n\n const coreShims = path.resolve(pkgRoot, \"src/core-shims/index.ts\")\n // Pre-compiled core-shims for npm mode (no monorepo-relative paths)\n const compiledCoreShims = path.resolve(pkgRoot, \"dist/core-shims.js\")\n const opentuiCoreBarrel = path.resolve(coreRoot, \"src/index.ts\")\n const sliderDeps = path.resolve(pkgRoot, \"src/shims/slider-deps.ts\")\n const sliderFile = path.resolve(coreRoot, \"src/renderables/Slider.ts\")\n\n // Map of opentui source files that need browser shims\n const coreFileShims: Record<string, string> = {\n zig: \"src/shims/zig-stub.ts\",\n buffer: \"src/browser-buffer.ts\",\n \"text-buffer\": \"src/shims/text-buffer-shim.ts\",\n \"text-buffer-view\": \"src/shims/text-buffer-view-shim.ts\",\n \"syntax-style\": \"src/shims/syntax-style-shim.ts\",\n renderer: \"src/shims/renderer-stub.ts\",\n console: \"src/shims/console-stub.ts\",\n \"edit-buffer\": \"src/shims/edit-buffer-stub.ts\",\n \"editor-view\": \"src/shims/editor-view-stub.ts\",\n NativeSpanFeed: \"src/shims/native-span-feed-stub.ts\",\n \"post/filters\": \"src/shims/filters-stub.ts\",\n \"animation/Timeline\": \"src/shims/timeline-stub.ts\",\n }\n\n const resolvedCoreShims = new Map<string, string>()\n for (const [key, shimPath] of Object.entries(coreFileShims)) {\n const absoluteTarget = path.resolve(coreRoot, \"src\", key + \".ts\")\n resolvedCoreShims.set(absoluteTarget, path.resolve(pkgRoot, shimPath))\n }\n\n const treeStub = path.resolve(pkgRoot, \"src/shims/tree-sitter-stub.ts\")\n const styledTextStub = path.resolve(pkgRoot, \"src/shims/tree-sitter-styled-text-stub.ts\")\n\n // Lookup tables hoisted out of resolveId to avoid per-call allocation\n const pkgRoots: Record<string, string> = { core: coreRoot, react: reactRoot, ui: uiRoot }\n\n const nodeShims: Record<string, string> = {\n \"node:buffer\": \"src/shims/node-buffer.ts\",\n \"node:path\": \"src/shims/node-path.ts\",\n path: \"src/shims/node-path.ts\",\n \"node:fs\": \"src/shims/node-fs.ts\",\n fs: \"src/shims/node-fs.ts\",\n \"fs/promises\": \"src/shims/node-fs.ts\",\n \"node:util\": \"src/shims/node-util.ts\",\n util: \"src/shims/node-util.ts\",\n os: \"src/shims/node-os.ts\",\n \"node:os\": \"src/shims/node-os.ts\",\n stream: \"src/shims/node-stream.ts\",\n \"node:stream\": \"src/shims/node-stream.ts\",\n url: \"src/shims/node-url.ts\",\n \"node:url\": \"src/shims/node-url.ts\",\n console: \"src/shims/console.ts\",\n bun: \"src/shims/bun-ffi.ts\",\n }\n\n // Virtual module prefix for npm package redirects.\n // When external opentui code imports a bare npm package (e.g. \"react\"),\n // we can't return the raw file path because Vite would serve it via /@fs/\n // without CJS-to-ESM conversion. Instead, we return a virtual module that\n // re-exports from the bare package name, which Vite processes through its\n // normal pre-bundling pipeline (including CJS conversion).\n const NPM_REDIRECT = \"\\0npm-redirect:\"\n\n const shimPlugin: Plugin = {\n name: \"gridland-web-shims\",\n enforce: \"pre\",\n resolveId(source, importer) {\n if (!importer) return null\n\n // Virtual module redirects should not be re-intercepted\n if (importer.startsWith(NPM_REDIRECT)) return null\n\n // Check if importer is in an opentui package.\n // Use both resolved root paths AND path-based matching to handle\n // multiple copies (e.g. bun's cache when using file: links).\n const isExternalOpentui =\n importer.startsWith(coreRoot + path.sep) ||\n importer.startsWith(reactRoot + path.sep) ||\n importer.startsWith(uiRoot + path.sep) ||\n importer.includes(\"/@opentui/core/\") ||\n importer.includes(\"/@opentui/react/\") ||\n importer.includes(\"/@opentui/ui/\")\n\n // Source-mode-only shims: slider circular dep fix, relative import\n // shims, tree-sitter stubs, and node built-in stubs only apply when\n // processing opentui TypeScript source (monorepo/submodule).\n // Compiled npm packages have these already resolved.\n\n // Slider circular dep fix\n if (hasSource && source === \"../index\" && importer === sliderFile) {\n return sliderDeps\n }\n\n // Resolve @opentui packages — only intercept when we have source files.\n // When using npm-installed packages (compiled JS), let Vite resolve normally.\n if (hasSource) {\n if (source === \"@opentui/ui\") {\n return path.resolve(uiRoot, \"src/index.ts\")\n }\n if (source === \"@opentui/react\") {\n return path.resolve(reactRoot, \"src/index.ts\")\n }\n\n // @opentui/core routing\n if (source === \"@opentui/core\") {\n if (importer.startsWith(reactRoot + path.sep)) {\n return opentuiCoreBarrel\n }\n return coreShims\n }\n\n // @opentui/* subpath imports (e.g. @opentui/react/jsx-dev-runtime)\n if (source.startsWith(\"@opentui/\")) {\n const parts = source.split(\"/\")\n const pkgName = parts[1] // \"react\", \"core\", \"ui\"\n const subpath = parts.slice(2).join(\"/\") // \"jsx-dev-runtime\"\n if (subpath) {\n const root = pkgRoots[pkgName]\n if (root) return path.resolve(root, subpath + \".js\")\n }\n }\n }\n\n // Relative imports from opentui tree → check shims\n if (source.startsWith(\".\") && isExternalOpentui) {\n const importerDir = path.dirname(importer)\n const resolved = path.resolve(importerDir, source)\n // Devtools polyfill stub (uses top-level await for ws import)\n if (resolved.endsWith(\"devtools-polyfill\")) {\n return path.resolve(pkgRoot, \"src/shims/devtools-polyfill-stub.ts\")\n }\n // Source-mode shims for core files (only when processing TS source)\n if (hasSource) {\n const shim = resolvedCoreShims.get(resolved) || resolvedCoreShims.get(resolved + \".ts\")\n if (shim) return shim\n const indexShim = resolvedCoreShims.get(resolved + \"/index.ts\")\n if (indexShim) return indexShim\n }\n }\n\n // Tree-sitter and related stubs — needed in both source and npm mode\n // since the compiled @opentui/core still imports these\n if (isExternalOpentui) {\n // Stub .scm and .wasm asset imports first (before tree-sitter name match)\n if (source.endsWith(\".scm\") || source.endsWith(\".wasm\")) {\n return \"\\0opentui-asset-stub\"\n }\n if (source.includes(\"tree-sitter\")) {\n if (source.includes(\"tree-sitter-styled-text\")) return styledTextStub\n return treeStub\n }\n if (source.includes(\"hast-styled-text\")) {\n return path.resolve(pkgRoot, \"src/shims/hast-stub.ts\")\n }\n }\n\n // Events shim — applies to ALL importers (browser-compatible EventEmitter)\n if (source === \"events\") {\n return path.resolve(pkgRoot, \"src/shims/events-shim.ts\")\n }\n\n // Node.js built-in stubs — needed in both modes since compiled\n // @opentui/core still imports node builtins\n if (nodeShims[source] && isExternalOpentui) {\n return path.resolve(pkgRoot, nodeShims[source])\n }\n\n // Redirect bare npm imports from external opentui to virtual modules (source mode only)\n if (hasSource && !source.startsWith(\".\") && !source.startsWith(\"/\") && !source.startsWith(\"@opentui/\") && isExternalOpentui) {\n return NPM_REDIRECT + source\n }\n\n return null\n },\n load(id) {\n // Stub for .scm/.wasm asset imports from compiled opentui packages\n if (id === \"\\0opentui-asset-stub\") {\n return \"export default null;\"\n }\n if (id.startsWith(NPM_REDIRECT)) {\n const pkg = id.slice(NPM_REDIRECT.length)\n // Discover export names by require()-ing the module at build time.\n // We use `import * as __ns` (namespace import) which works for both\n // ESM packages (named exports on namespace) and CJS packages\n // (pre-bundled with only a default export, properties on __ns.default).\n // Each property checks both locations with a fallback.\n // NOTE: We use bare specifiers (not resolved paths) so Vite routes\n // these through its pre-bundling pipeline for CJS-to-ESM conversion.\n try {\n const mod = _require(pkg)\n if (typeof mod === \"object\" && mod !== null) {\n const names = Object.keys(mod).filter(\n (k) => k !== \"default\" && k !== \"__esModule\" && /^[a-zA-Z_$][\\w$]*$/.test(k),\n )\n if (names.length > 0) {\n return [\n `import * as __ns from \"${pkg}\";`,\n `export default __ns.default ?? __ns;`,\n ...names.map(\n (n) => `export const ${n} = __ns[\"${n}\"] ?? __ns.default?.[\"${n}\"];`,\n ),\n ].join(\"\\n\")\n }\n }\n } catch {\n // Fall through to generic approach\n }\n // Fallback for packages we can't introspect\n return [\n `export * from \"${pkg}\";`,\n `import * as __ns from \"${pkg}\";`,\n `export default __ns.default ?? __ns;`,\n ].join(\"\\n\")\n }\n },\n }\n\n const aliasPlugin: Plugin = {\n name: \"gridland-web-aliases\",\n config() {\n const aliases: Record<string, string> = {}\n\n // In npm mode, alias @gridland/core to the pre-compiled core-shims bundle.\n // @gridland/core bundles the real opentui (with native deps like bun:ffi),\n // which browsers can't handle. The core-shims bundle has browser stubs instead.\n // In source mode, the resolveId hook handles @opentui/core resolution\n // and @gridland/core resolves normally from the workspace.\n if (!hasSource) {\n aliases[\"@gridland/core\"] = compiledCoreShims\n }\n\n // FFI shims\n aliases[\"bun:ffi\"] = path.resolve(pkgRoot, \"src/shims/bun-ffi.ts\")\n aliases[\"bun-ffi-structs\"] = path.resolve(pkgRoot, \"src/shims/bun-ffi-structs.ts\")\n aliases[\"node:console\"] = path.resolve(pkgRoot, \"src/shims/console.ts\")\n\n // Core file shims as aliases too\n for (const [key, shimPath] of Object.entries(coreFileShims)) {\n aliases[path.resolve(coreRoot, \"src\", key)] = path.resolve(pkgRoot, shimPath)\n }\n\n // Resolve npm packages from @gridland/web's dependency tree so\n // consuming projects don't need them as direct dependencies.\n // Uses _require to find the actual installed location (handles\n // hoisted node_modules). Directory aliases let subpath imports\n // (e.g. react-reconciler/constants) work via Vite's prefix\n // matching, and ensure CJS packages go through pre-bundling.\n for (const pkg of [\"react-reconciler\", \"yoga-layout\", \"diff\", \"marked\"]) {\n try {\n aliases[pkg] = path.dirname(_require.resolve(pkg + \"/package.json\"))\n } catch {\n aliases[pkg] = path.resolve(pkgRoot, \"node_modules\", pkg)\n }\n }\n\n return {\n define: {\n \"process.env\": JSON.stringify({}),\n },\n resolve: {\n alias: aliases,\n dedupe: [\"react\", \"react-dom\", \"react-reconciler\", \"yoga-layout\", \"events\"],\n },\n optimizeDeps: {\n // Pre-bundle npm packages imported by external opentui monorepo code.\n // These are resolved via virtual module redirects, so Vite's initial\n // crawl won't discover them — they must be listed explicitly.\n // Only needed in source mode; compiled npm packages are discovered normally.\n include: hasSource ? [\n \"react\",\n \"react-dom\",\n \"react-reconciler\",\n \"react-reconciler/constants\",\n \"diff\",\n \"yoga-layout\",\n \"marked\",\n ] : [\n \"react\",\n \"react-dom\",\n ],\n },\n server: {\n fs: {\n // Allow serving from opentui source dirs (for dev-from-source).\n // Use strict: false so Vite's default allow list (project root) is preserved.\n strict: false,\n },\n },\n }\n },\n }\n\n return [shimPlugin, aliasPlugin]\n}\n"],"mappings":";AACA,OAAO,UAAU;AACjB,SAAS,kBAAkB;AAC3B,SAAS,qBAAqB;AAC9B,SAAS,qBAAqB;AAE9B,IAAM,aAAa,cAAc,YAAY,GAAG;AAChD,IAAM,YAAY,KAAK,QAAQ,UAAU;AAYlC,SAAS,oBAA8B;AAC5C,QAAM,UAAU,KAAK,QAAQ,WAAW,IAAI;AAC5C,QAAM,WAAW,cAAc,KAAK,QAAQ,SAAS,cAAc,CAAC;AAIpE,QAAM,kBAAkB,cAAc,KAAK,QAAQ,QAAQ,IAAI,GAAG,cAAc,CAAC;AAMjF,WAAS,mBAAmB,KAAa,kBAAkC;AAIzE,eAAW,OAAO,CAAC,iBAAiB,QAAQ,GAAG;AAC7C,UAAI;AACF,cAAM,UAAU,IAAI,QAAQ,GAAG,GAAG,eAAe;AACjD,eAAO,KAAK,QAAQ,OAAO;AAAA,MAC7B,QAAQ;AACN,YAAI;AAGF,gBAAM,QAAQ,IAAI,QAAQ,GAAG;AAC7B,cAAI,MAAM,KAAK,QAAQ,KAAK;AAC5B,mBAAS,IAAI,GAAG,IAAI,GAAG,KAAK;AAC1B,gBAA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MAC9E;AAQA,iBAAW,OAAO,CAAC,oBAAoB,eAAe,QAAQ,QAAQ,GAAG;AACvE,YAAI;AACF,kBAAQ,GAAG,IAAI,KAAK,QAAQ,SAAS,QAAQ,MAAM,eAAe,CAAC;AAAA,QACrE,QAAQ;AACN,kBAAQ,GAAG,IAAI,KAAK,QAAQ,SAAS,gBAAgB,GAAG;AAAA,QAC1D;AAAA,MACF;AAEA,aAAO;AAAA,QACL,QAAQ;AAAA,UACN,eAAe,KAAK,UAAU,CAAC,CAAC;AAAA,QAClC;AAAA,QACA,SAAS;AAAA,UACP,OAAO;AAAA,UACP,QAAQ,CAAC,SAAS,aAAa,oBAAoB,eAAe,QAAQ;AAAA,QAC5E;AAAA,QACA,cAAc;AAAA;AAAA;AAAA;AAAA;AAAA,UAKZ,SAAS,YAAY;AAAA,YACnB;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,UACF,IAAI;AAAA,YACF;AAAA,YACA;AAAA,UACF;AAAA,QACF;AAAA,QACA,QAAQ;AAAA,UACN,IAAI;AAAA;AAAA;AAAA,YAGF,QAAQ;AAAA,UACV;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAEA,SAAO,CAAC,YAAY,WAAW;AACjC;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gridland/web",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.27",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"test:ci": "bun test --preload ./test/preload.ts --randomize --rerun-each 3"
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@gridland/core": "^0.2.
|
|
43
|
+
"@gridland/core": "^0.2.27",
|
|
44
44
|
"diff": "^8.0.3",
|
|
45
45
|
"events": "^3.3.0",
|
|
46
46
|
"marked": "^17.0.3",
|