@gridland/web 0.2.27 → 0.2.29

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.
@@ -42,21 +42,16 @@ function withGridland(nextConfig = {}) {
42
42
  const reactRoot = import_path.default.resolve(opentuiRoot, "packages/react");
43
43
  const uiRoot = import_path.default.resolve(opentuiRoot, "packages/ui");
44
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");
46
45
  function shimPath(p) {
47
46
  return import_path.default.resolve(pkgRoot, p);
48
47
  }
49
48
  const coreFileShims = {
50
- zig: "src/shims/zig-stub.ts",
51
49
  buffer: "src/browser-buffer.ts",
52
50
  "text-buffer": "src/shims/text-buffer-shim.ts",
53
51
  "text-buffer-view": "src/shims/text-buffer-view-shim.ts",
54
52
  "syntax-style": "src/shims/syntax-style-shim.ts",
55
- renderer: "src/shims/renderer-stub.ts",
56
- console: "src/shims/console-stub.ts",
57
53
  "edit-buffer": "src/shims/edit-buffer-stub.ts",
58
54
  "editor-view": "src/shims/editor-view-stub.ts",
59
- NativeSpanFeed: "src/shims/native-span-feed-stub.ts",
60
55
  "post/filters": "src/shims/filters-stub.ts",
61
56
  "animation/Timeline": "src/shims/timeline-stub.ts"
62
57
  };
@@ -69,12 +64,11 @@ function withGridland(nextConfig = {}) {
69
64
  config = userWebpack(config, context);
70
65
  }
71
66
  const sharedAliases = {
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 } : {},
67
+ // npm mode: @gridland/core resolves via package.json conditional exports.
68
+ // No alias needed.
75
69
  // @opentui packages — source mode only (monorepo dev)
76
70
  ...hasSource ? {
77
- "@opentui/core": shimPath("src/core-shims/index.ts"),
71
+ "@opentui/core": import_path.default.resolve(coreRoot, "src/index.ts"),
78
72
  "@opentui/react": import_path.default.resolve(reactRoot, "src/index.ts"),
79
73
  "@opentui/ui": import_path.default.resolve(uiRoot, "src/index.ts")
80
74
  } : {},
@@ -86,8 +80,7 @@ function withGridland(nextConfig = {}) {
86
80
  "tree-sitter-styled-text": shimPath("src/shims/tree-sitter-styled-text-stub.ts"),
87
81
  "web-tree-sitter": shimPath("src/shims/tree-sitter-stub.ts"),
88
82
  "hast-styled-text": shimPath("src/shims/hast-stub.ts"),
89
- // Source-mode-only aliases: opentui source directories and file shims.
90
- // In npm mode, these are already compiled into the core-shims bundle.
83
+ // Source-mode-only aliases
91
84
  ...hasSource ? {
92
85
  [import_path.default.resolve(coreRoot, "src/lib/tree-sitter-styled-text")]: shimPath("src/shims/tree-sitter-styled-text-stub.ts"),
93
86
  [import_path.default.resolve(coreRoot, "src/lib/tree-sitter")]: shimPath("src/shims/tree-sitter-stub.ts"),
@@ -105,6 +98,12 @@ function withGridland(nextConfig = {}) {
105
98
  ...config.resolve.alias,
106
99
  ...sharedAliases
107
100
  };
101
+ config.resolve.modules = [
102
+ ...config.resolve.modules || [],
103
+ import_path.default.resolve(process.cwd(), "node_modules"),
104
+ import_path.default.resolve(pkgRoot, "node_modules"),
105
+ import_path.default.resolve(pkgRoot, "../../node_modules")
106
+ ];
108
107
  if (hasSource) {
109
108
  const renderablesDir = import_path.default.resolve(coreRoot, "src/renderables");
110
109
  config.plugins.push(
@@ -131,11 +130,6 @@ function withGridland(nextConfig = {}) {
131
130
  ...config.resolve.alias,
132
131
  ...clientAliases
133
132
  };
134
- config.resolve.modules = [
135
- ...config.resolve.modules || [],
136
- import_path.default.resolve(pkgRoot, "node_modules"),
137
- import_path.default.resolve(pkgRoot, "../../node_modules")
138
- ];
139
133
  config.plugins.push(
140
134
  new webpack.NormalModuleReplacementPlugin(/^node:/, (resource) => {
141
135
  resource.request = resource.request.replace(/^node:/, "");
@@ -1 +1 @@
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,QAAK,QAAQ,aAAa,aAAa;AAGtD,QAAM,gBAAY,sBAAW,YAAAA,QAAK,QAAQ,WAAW,cAAc,CAAC;AAEpE,QAAM,oBAAoB,YAAAA,QAAK,QAAQ,SAAS,oBAAoB;AAEpE,WAAS,SAAS,GAAW;AAC3B,WAAO,YAAAA,QAAK,QAAQ,SAAS,CAAC;AAAA,EAChC;AAGA,QAAM,gBAAwC;AAAA,IAC5C,KAAK;AAAA,IACL,QAAQ;AAAA,IACR,eAAe;AAAA,IACf,oBAAoB;AAAA,IACpB,gBAAgB;AAAA,IAChB,UAAU;AAAA,IACV,SAAS;AAAA,IACT,eAAe;AAAA,IACf,eAAe;AAAA,IACf,gBAAgB;AAAA,IAChB,gBAAgB;AAAA,IAChB,sBAAsB;AAAA,EACxB;AAEA,QAAM,cAAc,WAAW;AAE/B,SAAO;AAAA,IACL,GAAG;AAAA,IACH,SAAS,CAAC,QAAuB,YAA6D;AAC5F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,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 * In **npm mode**, @gridland/core resolves via package.json conditional exports\n * (\"import\" → dist/browser.js). No aliasing needed.\n *\n * In **source mode**, the plugin handles @opentui/* resolution and file-level\n * browser shims for native-backed classes.\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\n function shimPath(p: string) {\n return path.resolve(pkgRoot, p)\n }\n\n // File-level shims — browser replacements for native-backed classes.\n // NOT needed for: zig (zig-registry.ts is browser-safe), renderer, console,\n // NativeSpanFeed (no longer in browser barrel).\n const coreFileShims: Record<string, string> = {\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 \"edit-buffer\": \"src/shims/edit-buffer-stub.ts\",\n \"editor-view\": \"src/shims/editor-view-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 const sharedAliases: Record<string, string> = {\n // npm mode: @gridland/core resolves via package.json conditional exports.\n // No alias needed.\n\n // @opentui packages — source mode only (monorepo dev)\n ...(hasSource ? {\n \"@opentui/core\": path.resolve(coreRoot, \"src/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\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 // Allow webpack to resolve workspace packages\n config.resolve.modules = [\n ...(config.resolve.modules || []),\n path.resolve(process.cwd(), \"node_modules\"),\n path.resolve(pkgRoot, \"node_modules\"),\n path.resolve(pkgRoot, \"../../node_modules\"),\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 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 // Strip `node:` and `bun:` prefixes from imports\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;AAsBpB,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,QAAK,QAAQ,aAAa,aAAa;AAGtD,QAAM,gBAAY,sBAAW,YAAAA,QAAK,QAAQ,WAAW,cAAc,CAAC;AAEpE,WAAS,SAAS,GAAW;AAC3B,WAAO,YAAAA,QAAK,QAAQ,SAAS,CAAC;AAAA,EAChC;AAKA,QAAM,gBAAwC;AAAA,IAC5C,QAAQ;AAAA,IACR,eAAe;AAAA,IACf,oBAAoB;AAAA,IACpB,gBAAgB;AAAA,IAChB,eAAe;AAAA,IACf,eAAe;AAAA,IACf,gBAAgB;AAAA,IAChB,sBAAsB;AAAA,EACxB;AAEA,QAAM,cAAc,WAAW;AAE/B,SAAO;AAAA,IACL,GAAG;AAAA,IACH,SAAS,CAAC,QAAuB,YAA6D;AAC5F,YAAM,EAAE,UAAU,QAAQ,IAAI;AAG9B,UAAI,aAAa;AACf,iBAAS,YAAY,QAAQ,OAAO;AAAA,MACtC;AAEA,YAAM,gBAAwC;AAAA;AAAA;AAAA;AAAA,QAK5C,GAAI,YAAY;AAAA,UACd,iBAAiB,YAAAA,QAAK,QAAQ,UAAU,cAAc;AAAA,UACtD,kBAAkB,YAAAA,QAAK,QAAQ,WAAW,cAAc;AAAA,UACxD,eAAe,YAA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AAiB,YAAAA,QAAK,QAAQ,UAAU,iBAAiB;AAC/D,eAAO,QAAQ;AAAA,UACb,IAAI,QAAQ,8BAA8B,iBAAiB,CAAC,aAAkB;AAC5E,gBAAI,SAAS,YAAY,gBAAgB;AACvC,uBAAS,UAAU,SAAS,0BAA0B;AAAA,YACxD;AAAA,UACF,CAAC;AAAA,QACH;AAAA,MACF;AAEA,UAAI,CAAC,UAAU;AAEb,cAAM,gBAAwC;AAAA,UAC5C,gBAAgB,SAAS,sBAAsB;AAAA,UAC/C,WAAW,SAAS,0BAA0B;AAAA,UAC9C,eAAe,SAAS,sBAAsB;AAAA,UAC9C,OAAO,SAAS,sBAAsB;AAAA,UACtC,SAAS,SAAS,wBAAwB;AAAA,UAC1C,SAAS,SAAS,wBAAwB;AAAA,UAC1C,OAAO,SAAS,sBAAsB;AAAA,UACtC,WAAW,SAAS,0BAA0B;AAAA,UAC9C,QAAQ,SAAS,uBAAuB;AAAA,QAC1C;AAEA,eAAO,QAAQ,QAAQ;AAAA,UACrB,GAAG,OAAO,QAAQ;AAAA,UAClB,GAAG;AAAA,QACL;AAGA,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"]}
@@ -13,9 +13,11 @@ interface NextConfig {
13
13
  * FFI shims, tree-sitter stubs, Node.js built-in stubs, and circular
14
14
  * dependency fixes.
15
15
  *
16
- * Requires @opentui/core, @opentui/react, and @opentui/ui as peer dependencies.
16
+ * In **npm mode**, @gridland/core resolves via package.json conditional exports
17
+ * ("import" → dist/browser.js). No aliasing needed.
17
18
  *
18
- * @param nextConfig - Optional additional Next.js config to merge
19
+ * In **source mode**, the plugin handles @opentui/* resolution and file-level
20
+ * browser shims for native-backed classes.
19
21
  */
20
22
  declare function withGridland(nextConfig?: NextConfig): NextConfig;
21
23
 
@@ -13,9 +13,11 @@ interface NextConfig {
13
13
  * FFI shims, tree-sitter stubs, Node.js built-in stubs, and circular
14
14
  * dependency fixes.
15
15
  *
16
- * Requires @opentui/core, @opentui/react, and @opentui/ui as peer dependencies.
16
+ * In **npm mode**, @gridland/core resolves via package.json conditional exports
17
+ * ("import" → dist/browser.js). No aliasing needed.
17
18
  *
18
- * @param nextConfig - Optional additional Next.js config to merge
19
+ * In **source mode**, the plugin handles @opentui/* resolution and file-level
20
+ * browser shims for native-backed classes.
19
21
  */
20
22
  declare function withGridland(nextConfig?: NextConfig): NextConfig;
21
23
 
@@ -8,21 +8,16 @@ function withGridland(nextConfig = {}) {
8
8
  const reactRoot = path.resolve(opentuiRoot, "packages/react");
9
9
  const uiRoot = path.resolve(opentuiRoot, "packages/ui");
10
10
  const hasSource = existsSync(path.resolve(reactRoot, "src/index.ts"));
11
- const compiledCoreShims = path.resolve(pkgRoot, "dist/core-shims.js");
12
11
  function shimPath(p) {
13
12
  return path.resolve(pkgRoot, p);
14
13
  }
15
14
  const coreFileShims = {
16
- zig: "src/shims/zig-stub.ts",
17
15
  buffer: "src/browser-buffer.ts",
18
16
  "text-buffer": "src/shims/text-buffer-shim.ts",
19
17
  "text-buffer-view": "src/shims/text-buffer-view-shim.ts",
20
18
  "syntax-style": "src/shims/syntax-style-shim.ts",
21
- renderer: "src/shims/renderer-stub.ts",
22
- console: "src/shims/console-stub.ts",
23
19
  "edit-buffer": "src/shims/edit-buffer-stub.ts",
24
20
  "editor-view": "src/shims/editor-view-stub.ts",
25
- NativeSpanFeed: "src/shims/native-span-feed-stub.ts",
26
21
  "post/filters": "src/shims/filters-stub.ts",
27
22
  "animation/Timeline": "src/shims/timeline-stub.ts"
28
23
  };
@@ -35,12 +30,11 @@ function withGridland(nextConfig = {}) {
35
30
  config = userWebpack(config, context);
36
31
  }
37
32
  const sharedAliases = {
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 } : {},
33
+ // npm mode: @gridland/core resolves via package.json conditional exports.
34
+ // No alias needed.
41
35
  // @opentui packages — source mode only (monorepo dev)
42
36
  ...hasSource ? {
43
- "@opentui/core": shimPath("src/core-shims/index.ts"),
37
+ "@opentui/core": path.resolve(coreRoot, "src/index.ts"),
44
38
  "@opentui/react": path.resolve(reactRoot, "src/index.ts"),
45
39
  "@opentui/ui": path.resolve(uiRoot, "src/index.ts")
46
40
  } : {},
@@ -52,8 +46,7 @@ function withGridland(nextConfig = {}) {
52
46
  "tree-sitter-styled-text": shimPath("src/shims/tree-sitter-styled-text-stub.ts"),
53
47
  "web-tree-sitter": shimPath("src/shims/tree-sitter-stub.ts"),
54
48
  "hast-styled-text": shimPath("src/shims/hast-stub.ts"),
55
- // Source-mode-only aliases: opentui source directories and file shims.
56
- // In npm mode, these are already compiled into the core-shims bundle.
49
+ // Source-mode-only aliases
57
50
  ...hasSource ? {
58
51
  [path.resolve(coreRoot, "src/lib/tree-sitter-styled-text")]: shimPath("src/shims/tree-sitter-styled-text-stub.ts"),
59
52
  [path.resolve(coreRoot, "src/lib/tree-sitter")]: shimPath("src/shims/tree-sitter-stub.ts"),
@@ -71,6 +64,12 @@ function withGridland(nextConfig = {}) {
71
64
  ...config.resolve.alias,
72
65
  ...sharedAliases
73
66
  };
67
+ config.resolve.modules = [
68
+ ...config.resolve.modules || [],
69
+ path.resolve(process.cwd(), "node_modules"),
70
+ path.resolve(pkgRoot, "node_modules"),
71
+ path.resolve(pkgRoot, "../../node_modules")
72
+ ];
74
73
  if (hasSource) {
75
74
  const renderablesDir = path.resolve(coreRoot, "src/renderables");
76
75
  config.plugins.push(
@@ -97,11 +96,6 @@ function withGridland(nextConfig = {}) {
97
96
  ...config.resolve.alias,
98
97
  ...clientAliases
99
98
  };
100
- config.resolve.modules = [
101
- ...config.resolve.modules || [],
102
- path.resolve(pkgRoot, "node_modules"),
103
- path.resolve(pkgRoot, "../../node_modules")
104
- ];
105
99
  config.plugins.push(
106
100
  new webpack.NormalModuleReplacementPlugin(/^node:/, (resource) => {
107
101
  resource.request = resource.request.replace(/^node:/, "");
@@ -1 +1 @@
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,aAAa;AAGtD,QAAM,YAAY,WAAW,KAAK,QAAQ,WAAW,cAAc,CAAC;AAEpE,QAAM,oBAAoB,KAAK,QAAQ,SAAS,oBAAoB;AAEpE,WAAS,SAAS,GAAW;AAC3B,WAAO,KAAK,QAAQ,SAAS,CAAC;AAAA,EAChC;AAGA,QAAM,gBAAwC;AAAA,IAC5C,KAAK;AAAA,IACL,QAAQ;AAAA,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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 * In **npm mode**, @gridland/core resolves via package.json conditional exports\n * (\"import\" → dist/browser.js). No aliasing needed.\n *\n * In **source mode**, the plugin handles @opentui/* resolution and file-level\n * browser shims for native-backed classes.\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\n function shimPath(p: string) {\n return path.resolve(pkgRoot, p)\n }\n\n // File-level shims — browser replacements for native-backed classes.\n // NOT needed for: zig (zig-registry.ts is browser-safe), renderer, console,\n // NativeSpanFeed (no longer in browser barrel).\n const coreFileShims: Record<string, string> = {\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 \"edit-buffer\": \"src/shims/edit-buffer-stub.ts\",\n \"editor-view\": \"src/shims/editor-view-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 const sharedAliases: Record<string, string> = {\n // npm mode: @gridland/core resolves via package.json conditional exports.\n // No alias needed.\n\n // @opentui packages — source mode only (monorepo dev)\n ...(hasSource ? {\n \"@opentui/core\": path.resolve(coreRoot, \"src/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\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 // Allow webpack to resolve workspace packages\n config.resolve.modules = [\n ...(config.resolve.modules || []),\n path.resolve(process.cwd(), \"node_modules\"),\n path.resolve(pkgRoot, \"node_modules\"),\n path.resolve(pkgRoot, \"../../node_modules\"),\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 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 // Strip `node:` and `bun:` prefixes from imports\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;AAsBpB,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,aAAa;AAGtD,QAAM,YAAY,WAAW,KAAK,QAAQ,WAAW,cAAc,CAAC;AAEpE,WAAS,SAAS,GAAW;AAC3B,WAAO,KAAK,QAAQ,SAAS,CAAC;AAAA,EAChC;AAKA,QAAM,gBAAwC;AAAA,IAC5C,QAAQ;AAAA,IACR,eAAe;AAAA,IACf,oBAAoB;AAAA,IACpB,gBAAgB;AAAA,IAChB,eAAe;AAAA,IACf,eAAe;AAAA,IACf,gBAAgB;AAAA,IAChB,sBAAsB;AAAA,EACxB;AAEA,QAAM,cAAc,WAAW;AAE/B,SAAO;AAAA,IACL,GAAG;AAAA,IACH,SAAS,CAAC,QAAuB,YAA6D;AAC5F,YAAM,EAAE,UAAU,QAAQ,IAAI;AAG9B,UAAI,aAAa;AACf,iBAAS,YAAY,QAAQ,OAAO;AAAA,MACtC;AAEA,YAAM,gBAAwC;AAAA;AAAA;AAAA;AAAA,QAK5C,GAAI,YAAY;AAAA,UACd,iBAAiB,K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RGBA.fromHex("#252527");
5805
5805
 
5806
+ // ../../opentui/packages/core/src/zig-registry.ts
5807
+ if (typeof globalThis.Bun !== "undefined") {
5808
+ const zigPath = "./zig";
5809
+ try {
5810
+ await import(zigPath);
5811
+ } catch {
5812
+ }
5813
+ }
5814
+
5806
5815
  // ../../opentui/packages/core/src/lib/selection.ts
5807
5816
  function convertGlobalToLocalSelection(globalSelection, localX, localY) {
5808
5817
  if (!globalSelection?.isActive) {
@@ -9037,9 +9046,7 @@ import { createContext, useContext } from "react";
9037
9046
  var BrowserContext = createContext(null);
9038
9047
 
9039
9048
  // src/create-browser-root.tsx
9040
- import { _render } from "@gridland/core";
9041
- import { AppContext } from "@gridland/core";
9042
- import { ErrorBoundary as _ErrorBoundary } from "@gridland/core";
9049
+ import { _render, AppContext, ErrorBoundary as _ErrorBoundary } from "@gridland/core";
9043
9050
  import { jsx } from "react/jsx-runtime";
9044
9051
  var ErrorBoundary = _ErrorBoundary;
9045
9052
  function createBrowserRoot(renderer) {
@@ -9114,9 +9121,7 @@ var HeadlessRenderer = class {
9114
9121
  };
9115
9122
 
9116
9123
  // src/create-headless-root.tsx
9117
- import { _render as _render2, reconciler } from "@gridland/core";
9118
- import { AppContext as AppContext2 } from "@gridland/core";
9119
- import { ErrorBoundary as _ErrorBoundary2 } from "@gridland/core";
9124
+ import { _render as _render2, reconciler, AppContext as AppContext2, ErrorBoundary as _ErrorBoundary2 } from "@gridland/core";
9120
9125
  import { jsx as jsx2 } from "react/jsx-runtime";
9121
9126
  var ErrorBoundary2 = _ErrorBoundary2;
9122
9127
  var _r = reconciler;