@agimon-ai/po-build 0.0.0-alpha.13 → 0.0.0-alpha.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/constants/layout.cjs +1 -1
- package/dist/constants/layout.cjs.map +1 -1
- package/dist/constants/layout.d.mts +2 -0
- package/dist/constants/layout.d.mts.map +1 -1
- package/dist/constants/layout.mjs +1 -1
- package/dist/constants/layout.mjs.map +1 -1
- package/dist/services/renderClient/index.cjs.map +1 -1
- package/dist/services/renderClient/index.mjs.map +1 -1
- package/dist/services/renderEntry/index.cjs +2 -2
- package/dist/services/renderEntry/index.cjs.map +1 -1
- package/dist/services/renderEntry/index.d.mts +10 -4
- package/dist/services/renderEntry/index.d.mts.map +1 -1
- package/dist/services/renderEntry/index.mjs +2 -2
- package/dist/services/renderEntry/index.mjs.map +1 -1
- package/dist/services/renderEntry/type.d.mts +1 -1
- package/dist/services/resolveTarget/index.cjs +1 -1
- package/dist/services/resolveTarget/index.cjs.map +1 -1
- package/dist/services/resolveTarget/index.mjs +1 -1
- package/dist/services/resolveTarget/index.mjs.map +1 -1
- package/dist/services/resolveTarget/type.d.mts +2 -0
- package/dist/services/resolveTarget/type.d.mts.map +1 -1
- package/dist/services/serverContracts/index.cjs +3 -0
- package/dist/services/serverContracts/index.cjs.map +1 -0
- package/dist/services/serverContracts/index.mjs +3 -0
- package/dist/services/serverContracts/index.mjs.map +1 -0
- package/dist/services/serverContracts/type.d.mts +8 -0
- package/dist/services/serverContracts/type.d.mts.map +1 -0
- package/dist/services/syncManifest/index.cjs +1 -1
- package/dist/services/syncManifest/index.cjs.map +1 -1
- package/dist/services/syncManifest/index.d.mts.map +1 -1
- package/dist/services/syncManifest/index.mjs +1 -1
- package/dist/services/syncManifest/index.mjs.map +1 -1
- package/dist/services/syncManifest/type.d.mts +3 -0
- package/dist/services/syncManifest/type.d.mts.map +1 -1
- package/dist/services/tsdownPreset/index.cjs +1 -1
- package/dist/services/tsdownPreset/index.cjs.map +1 -1
- package/dist/services/tsdownPreset/index.d.mts +1 -1
- package/dist/services/tsdownPreset/index.d.mts.map +1 -1
- package/dist/services/tsdownPreset/index.mjs +1 -1
- package/dist/services/tsdownPreset/index.mjs.map +1 -1
- package/package.json +1 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const e=[`mode`,`domain`],t={server:`server`,web:`web`,native:`native`,mcp:`mcp`},n=[`pi`,`server`,`web`,`native`,`mcp`,`client`,`client.native`],r=[`server`,`mcp`],i=[`web`,`native`,`ios`,`android`,`desktop`],a=[`server`,`web`,`native`,`mcp`],o=[`tool`,`skill`,`tool-restriction`,`command`,`hook`,`api`,`channel`,`method`,`provider`,`resource`],s=[`tool`,`command`,`api`,`channel`,`method`,`tab`,`template`,`dock`,`setting`,`slot`,`fill`,`action`,`store`,`activity-group`,`leader`,`selection-axis`,`lifecycle`,`file-links`,`repository-settings-panel`],c=[`fill`,`action`],l=[`api`],u=[`ts`,`tsx`,`mts`,`cts`],d=[`test`,`spec`,`stories`,`edge`];exports.API_ROUTES_MODULE=`src/types/apiRoutes.ts`,exports.BACKEND_GROUP=`backend`,exports.BACKEND_PLATFORMS=r,exports.BACKEND_SURFACES=o,exports.BUILD_TARGET_PLATFORMS=a,exports.DEFAULT_ROUTING_ROOT=`src/extensions`,exports.EXCLUDED_INFIXES=d,exports.FRONTEND_GROUP=`frontend`,exports.FRONTEND_PLATFORMS=i,exports.FRONTEND_SURFACES=s,exports.GATE_SEGMENTS=e,exports.GENERATED_CLIENT_NAME=`client`,exports.GENERATED_DIR=`generated`,exports.GENERATED_ENTRY_FILENAMES=t,exports.GENERATED_ENTRY_NAMES=n,exports.GENERATED_NATIVE_CLIENT_NAME=`client.native`,exports.NATIVE_PLATFORM=`native`,exports.ROOT_FILE_NAME=`root`,exports.ROUTED_SURFACES=l,exports.ROUTE_FILE_NAME=`route`,exports.ROUTING_ROOT_ALIAS=`src/extension`,exports.SESSION_SEGMENT=`sessions`,exports.SOURCE_EXTENSIONS=u,exports.TARGETED_SURFACES=c,exports.WORKSPACE_SEGMENT=`workspaces`;
|
|
1
|
+
const e=[`mode`,`domain`],t={server:`server`,web:`web`,native:`native`,mcp:`mcp`},n=[`pi`,`server`,`web`,`native`,`mcp`,`client`,`client.native`],r=[`server`,`mcp`],i=[`web`,`native`,`ios`,`android`,`desktop`],a=[`server`,`web`,`native`,`mcp`],o=[`tool`,`skill`,`tool-restriction`,`command`,`hook`,`api`,`channel`,`method`,`provider`,`resource`,`contract`],s=[`tool`,`command`,`api`,`channel`,`method`,`tab`,`template`,`dock`,`setting`,`slot`,`fill`,`action`,`store`,`activity-group`,`leader`,`selection-axis`,`lifecycle`,`file-links`,`repository-settings-panel`],c=[`fill`,`action`],l=[`api`],u=[`ts`,`tsx`,`mts`,`cts`],d=[`test`,`spec`,`stories`,`edge`];exports.API_ROUTES_MODULE=`src/types/apiRoutes.ts`,exports.BACKEND_GROUP=`backend`,exports.BACKEND_PLATFORMS=r,exports.BACKEND_SURFACES=o,exports.BUILD_TARGET_PLATFORMS=a,exports.CONTRACT_SURFACE=`contract`,exports.DEFAULT_ROUTING_ROOT=`src/extensions`,exports.EXCLUDED_INFIXES=d,exports.FRONTEND_GROUP=`frontend`,exports.FRONTEND_PLATFORMS=i,exports.FRONTEND_SURFACES=s,exports.GATE_SEGMENTS=e,exports.GENERATED_CLIENT_NAME=`client`,exports.GENERATED_DIR=`generated`,exports.GENERATED_ENTRY_FILENAMES=t,exports.GENERATED_ENTRY_NAMES=n,exports.GENERATED_NATIVE_CLIENT_NAME=`client.native`,exports.NATIVE_PLATFORM=`native`,exports.ROOT_FILE_NAME=`root`,exports.ROUTED_SURFACES=l,exports.ROUTE_FILE_NAME=`route`,exports.ROUTING_ROOT_ALIAS=`src/extension`,exports.SERVER_DIST=`./dist/extensions/server.mjs`,exports.SESSION_SEGMENT=`sessions`,exports.SOURCE_EXTENSIONS=u,exports.TARGETED_SURFACES=c,exports.WORKSPACE_SEGMENT=`workspaces`;
|
|
2
2
|
//# sourceMappingURL=layout.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"layout.cjs","names":["GATE_SEGMENTS","GENERATED_ENTRY_FILENAMES","GENERATED_ENTRY_NAMES","BACKEND_PLATFORMS","FRONTEND_PLATFORMS","BUILD_TARGET_PLATFORMS","BACKEND_SURFACES","FRONTEND_SURFACES","TARGETED_SURFACES","ROUTED_SURFACES","SOURCE_EXTENSIONS","EXCLUDED_INFIXES"],"sources":["../../src/constants/layout.ts"],"sourcesContent":["/**\n * The folder-convention vocabulary, in one place.\n *\n * Every name here is part of the authoring contract in\n * docs/extension-layout.md. Adding a surface means adding it to both.\n */\n\n/** Where the scan starts, package-relative. */\nexport const DEFAULT_ROUTING_ROOT = 'src/extensions';\n/** Accepted spelling of the same root, for packages that prefer the singular. */\nexport const ROUTING_ROOT_ALIAS = 'src/extension';\n\n/** Group folders that also select a build side. */\nexport const BACKEND_GROUP = 'backend';\nexport const FRONTEND_GROUP = 'frontend';\n\n/** Scope segments, in nesting order below the routing root. */\nexport const WORKSPACE_SEGMENT = 'workspaces';\nexport const SESSION_SEGMENT = 'sessions';\n\n/** Gate folders. Each is followed by exactly one id segment. */\nexport const GATE_SEGMENTS: readonly string[] = ['mode', 'domain'];\n\n/** The leaf filename of an HTTP route, as Next.js spells it. */\nexport const ROUTE_FILE_NAME = 'route';\n\n/**\n * The reserved filename that constructs a scope, as Next.js spells a layout.\n *\n * One per scope and side. It runs before every contribution beneath it, and\n * whatever it returns is handed to each of them as part of the mount context,\n * which is how a package with one shared per-mount object graph decomposes\n * into a file per surface instead of one closure.\n */\nexport const ROOT_FILE_NAME = 'root';\n\n/**\n * Where generated entries are written, package-relative.\n *\n * Not `src`. That directory is authored code, and a build that writes into it\n * makes every package carry output its author did not write and must not edit.\n * This one is gitignored per package, and the repository's formatter already\n * skips a directory by this name.\n */\nexport const GENERATED_DIR = 'generated';\n\n/**\n * The generated entry each build target writes, keyed by the target it serves.\n *\n * Keyed rather than positional, so adding a generated file never rotates which\n * host each entry belongs to.\n */\nexport const GENERATED_ENTRY_FILENAMES = { server: 'server', web: 'web', native: 'native', mcp: 'mcp' } as const;\n\n/**\n * The generated typed client, which is not a build target.\n *\n * Nothing bundles it as an entry: a `(frontend)` file imports it and the\n * cockpit's browser build pulls it in from there. It is listed among the\n * managed names so that a package which drops its route table has the stale\n * client deleted rather than left behind.\n */\nexport const GENERATED_CLIENT_NAME = 'client';\n\n/**\n * The same client for a `.native` file, which may import neither the browser\n * contract nor the browser's sealed transport. Imported by its full name: the\n * native build is not Metro and resolves no platform suffix.\n */\nexport const GENERATED_NATIVE_CLIENT_NAME = 'client.native';\n\n/**\n * The route table a package authors, and the switch that asks for a client.\n *\n * Its presence is what opts a package in, the way `src/exports/apiContracts.ts`\n * is what asks for a contracts entry. It lives under `src/types` because that\n * is one of the two source roots a browser bundle may read.\n */\nexport const API_ROUTES_MODULE = 'src/types/apiRoutes.ts';\n\n/**\n * Every generated basename. Never scanned, never hand-edited.\n *\n * Spelled out rather than derived from the two declarations above, because a\n * constants module holds data a reader can see without running it. The cost is\n * that the names appear twice; the generate tests assert the two agree.\n *\n * `pi` is the retired terminal entry. It stays managed so a regenerate deletes\n * the stale file a package built before the terminal host was removed.\n */\nexport const GENERATED_ENTRY_NAMES: readonly string[] = [\n 'pi',\n 'server',\n 'web',\n 'native',\n 'mcp',\n 'client',\n 'client.native',\n];\n\n/** The retired terminal platform suffix. A routed file naming it is rejected. */\nexport const RETIRED_PLATFORM = 'cli';\n\n/**\n * Platform suffixes, scoped to their side. A target may not reuse one of these words.\n *\n * Every public routed file names one of these, so which host reads it is read\n * off the filename rather than inferred. A file that names none is a notice.\n */\nexport const BACKEND_PLATFORMS: readonly string[] = ['server', 'mcp'];\nexport const FRONTEND_PLATFORMS: readonly string[] = ['web', 'native', 'ios', 'android', 'desktop'];\n\n/**\n * The React Native frontend, for the iOS and Android app alike.\n *\n * Only a file naming it reaches the native host. An unsuffixed frontend file is\n * never a fallback here, because the web half is free to use the DOM.\n */\nexport const NATIVE_PLATFORM = 'native';\n\n/** The hosts this build emits. A frontend platform outside this set is authorable but unbuildable. */\nexport const BUILD_TARGET_PLATFORMS: readonly string[] = ['server', 'web', 'native', 'mcp'];\n\n/**\n * Surfaces that produce contributions on the backend side.\n *\n * `mode` is absent on purpose: it is a gate folder, so it is consumed before\n * the surface check and its declaration file synthesises the surface instead.\n */\nexport const BACKEND_SURFACES: readonly string[] = [\n 'tool',\n 'skill',\n 'tool-restriction',\n 'command',\n 'hook',\n 'api',\n 'channel',\n 'method',\n 'provider',\n 'resource',\n];\n\n/**\n * Surfaces that produce contributions on the frontend side.\n */\nexport const FRONTEND_SURFACES: readonly string[] = [\n 'tool',\n 'command',\n 'api',\n 'channel',\n 'method',\n 'tab',\n 'template',\n 'dock',\n 'setting',\n 'slot',\n 'fill',\n 'action',\n 'store',\n 'activity-group',\n 'leader',\n 'selection-axis',\n 'lifecycle',\n 'file-links',\n 'repository-settings-panel',\n];\n\n/** Surfaces whose filename carries a relationship target. */\nexport const TARGETED_SURFACES: readonly string[] = ['fill', 'action'];\n\n/** Surfaces whose folders below the surface spell a route path. */\nexport const ROUTED_SURFACES: readonly string[] = ['api'];\n\n/** Source extensions the scan accepts. */\nexport const SOURCE_EXTENSIONS: readonly string[] = ['ts', 'tsx', 'mts', 'cts'];\n\n/**\n * Filename infixes excluded everywhere, whatever their position. `edge` marks a\n * workerd variant of its base sibling, resolved only by the private Worker build.\n */\nexport const EXCLUDED_INFIXES: readonly string[] = ['test', 'spec', 'stories', 'edge'];\n\n/** Marks a folder as organisational: not a path segment, contents still scanned. */\nexport const GROUP_PREFIX = '(';\nexport const GROUP_SUFFIX = ')';\n/** Marks a folder as private: never scanned, never built. */\nexport const PRIVATE_PREFIX = '_';\n/** Marks a folder as a dynamic route segment. */\nexport const DYNAMIC_PREFIX = '[';\nexport const DYNAMIC_SUFFIX = ']';\n/** Marks a dynamic segment as catch-all. */\nexport const CATCH_ALL_MARKER = '...';\n"],"mappings":"AAQA,MAaaA,EAAmC,CAAC,OAAQ,QAAQ,
|
|
1
|
+
{"version":3,"file":"layout.cjs","names":["GATE_SEGMENTS","GENERATED_ENTRY_FILENAMES","GENERATED_ENTRY_NAMES","BACKEND_PLATFORMS","FRONTEND_PLATFORMS","BUILD_TARGET_PLATFORMS","BACKEND_SURFACES","FRONTEND_SURFACES","TARGETED_SURFACES","ROUTED_SURFACES","SOURCE_EXTENSIONS","EXCLUDED_INFIXES"],"sources":["../../src/constants/layout.ts"],"sourcesContent":["/**\n * The folder-convention vocabulary, in one place.\n *\n * Every name here is part of the authoring contract in\n * docs/extension-layout.md. Adding a surface means adding it to both.\n */\n\n/** Where the scan starts, package-relative. */\nexport const DEFAULT_ROUTING_ROOT = 'src/extensions';\n/** Accepted spelling of the same root, for packages that prefer the singular. */\nexport const ROUTING_ROOT_ALIAS = 'src/extension';\n\n/** Group folders that also select a build side. */\nexport const BACKEND_GROUP = 'backend';\nexport const FRONTEND_GROUP = 'frontend';\n\n/** Scope segments, in nesting order below the routing root. */\nexport const WORKSPACE_SEGMENT = 'workspaces';\nexport const SESSION_SEGMENT = 'sessions';\n\n/** Gate folders. Each is followed by exactly one id segment. */\nexport const GATE_SEGMENTS: readonly string[] = ['mode', 'domain'];\n\n/** The leaf filename of an HTTP route, as Next.js spells it. */\nexport const ROUTE_FILE_NAME = 'route';\n\n/**\n * The reserved filename that constructs a scope, as Next.js spells a layout.\n *\n * One per scope and side. It runs before every contribution beneath it, and\n * whatever it returns is handed to each of them as part of the mount context,\n * which is how a package with one shared per-mount object graph decomposes\n * into a file per surface instead of one closure.\n */\nexport const ROOT_FILE_NAME = 'root';\n\n/**\n * Where generated entries are written, package-relative.\n *\n * Not `src`. That directory is authored code, and a build that writes into it\n * makes every package carry output its author did not write and must not edit.\n * This one is gitignored per package, and the repository's formatter already\n * skips a directory by this name.\n */\nexport const GENERATED_DIR = 'generated';\n\n/** The built server entry a host imports, package-relative, as `poServer.dist` names it. */\nexport const SERVER_DIST = './dist/extensions/server.mjs';\n\n/**\n * The generated entry each build target writes, keyed by the target it serves.\n *\n * Keyed rather than positional, so adding a generated file never rotates which\n * host each entry belongs to.\n */\nexport const GENERATED_ENTRY_FILENAMES = { server: 'server', web: 'web', native: 'native', mcp: 'mcp' } as const;\n\n/**\n * The generated typed client, which is not a build target.\n *\n * Nothing bundles it as an entry: a `(frontend)` file imports it and the\n * cockpit's browser build pulls it in from there. It is listed among the\n * managed names so that a package which drops its route table has the stale\n * client deleted rather than left behind.\n */\nexport const GENERATED_CLIENT_NAME = 'client';\n\n/**\n * The same client for a `.native` file, which may import neither the browser\n * contract nor the browser's sealed transport. Imported by its full name: the\n * native build is not Metro and resolves no platform suffix.\n */\nexport const GENERATED_NATIVE_CLIENT_NAME = 'client.native';\n\n/**\n * The route table a package authors, and the switch that asks for a client.\n *\n * Its presence is what opts a package in, the way `src/exports/apiContracts.ts`\n * is what asks for a contracts entry. It lives under `src/types` because that\n * is one of the two source roots a browser bundle may read.\n */\nexport const API_ROUTES_MODULE = 'src/types/apiRoutes.ts';\n\n/**\n * Every generated basename. Never scanned, never hand-edited.\n *\n * Spelled out rather than derived from the two declarations above, because a\n * constants module holds data a reader can see without running it. The cost is\n * that the names appear twice; the generate tests assert the two agree.\n *\n * `pi` is the retired terminal entry. It stays managed so a regenerate deletes\n * the stale file a package built before the terminal host was removed.\n */\nexport const GENERATED_ENTRY_NAMES: readonly string[] = [\n 'pi',\n 'server',\n 'web',\n 'native',\n 'mcp',\n 'client',\n 'client.native',\n];\n\n/** The retired terminal platform suffix. A routed file naming it is rejected. */\nexport const RETIRED_PLATFORM = 'cli';\n\n/**\n * Platform suffixes, scoped to their side. A target may not reuse one of these words.\n *\n * Every public routed file names one of these, so which host reads it is read\n * off the filename rather than inferred. A file that names none is a notice.\n */\nexport const BACKEND_PLATFORMS: readonly string[] = ['server', 'mcp'];\nexport const FRONTEND_PLATFORMS: readonly string[] = ['web', 'native', 'ios', 'android', 'desktop'];\n\n/**\n * The React Native frontend, for the iOS and Android app alike.\n *\n * Only a file naming it reaches the native host. An unsuffixed frontend file is\n * never a fallback here, because the web half is free to use the DOM.\n */\nexport const NATIVE_PLATFORM = 'native';\n\n/** The hosts this build emits. A frontend platform outside this set is authorable but unbuildable. */\nexport const BUILD_TARGET_PLATFORMS: readonly string[] = ['server', 'web', 'native', 'mcp'];\n\n/**\n * Surfaces that produce contributions on the backend side.\n *\n * `mode` is absent on purpose: it is a gate folder, so it is consumed before\n * the surface check and its declaration file synthesises the surface instead.\n * `contract` is not a contribution either: each file declares one service\n * contract its level provides, which the plugin lists as `provides`.\n */\nexport const BACKEND_SURFACES: readonly string[] = [\n 'tool',\n 'skill',\n 'tool-restriction',\n 'command',\n 'hook',\n 'api',\n 'channel',\n 'method',\n 'provider',\n 'resource',\n 'contract',\n];\n\n/** The backend surface whose files declare the service contracts a level provides. */\nexport const CONTRACT_SURFACE = 'contract';\n\n/**\n * Surfaces that produce contributions on the frontend side.\n */\nexport const FRONTEND_SURFACES: readonly string[] = [\n 'tool',\n 'command',\n 'api',\n 'channel',\n 'method',\n 'tab',\n 'template',\n 'dock',\n 'setting',\n 'slot',\n 'fill',\n 'action',\n 'store',\n 'activity-group',\n 'leader',\n 'selection-axis',\n 'lifecycle',\n 'file-links',\n 'repository-settings-panel',\n];\n\n/** Surfaces whose filename carries a relationship target. */\nexport const TARGETED_SURFACES: readonly string[] = ['fill', 'action'];\n\n/** Surfaces whose folders below the surface spell a route path. */\nexport const ROUTED_SURFACES: readonly string[] = ['api'];\n\n/** Source extensions the scan accepts. */\nexport const SOURCE_EXTENSIONS: readonly string[] = ['ts', 'tsx', 'mts', 'cts'];\n\n/**\n * Filename infixes excluded everywhere, whatever their position. `edge` marks a\n * workerd variant of its base sibling, resolved only by the private Worker build.\n */\nexport const EXCLUDED_INFIXES: readonly string[] = ['test', 'spec', 'stories', 'edge'];\n\n/** Marks a folder as organisational: not a path segment, contents still scanned. */\nexport const GROUP_PREFIX = '(';\nexport const GROUP_SUFFIX = ')';\n/** Marks a folder as private: never scanned, never built. */\nexport const PRIVATE_PREFIX = '_';\n/** Marks a folder as a dynamic route segment. */\nexport const DYNAMIC_PREFIX = '[';\nexport const DYNAMIC_SUFFIX = ']';\n/** Marks a dynamic segment as catch-all. */\nexport const CATCH_ALL_MARKER = '...';\n"],"mappings":"AAQA,MAaaA,EAAmC,CAAC,OAAQ,QAAQ,EAkCpDC,EAA4B,CAAE,OAAQ,SAAU,IAAK,MAAO,OAAQ,SAAU,IAAK,KAAM,EAsCzFC,EAA2C,CACtD,KACA,SACA,MACA,SACA,MACA,SACA,eACF,EAWaC,EAAuC,CAAC,SAAU,KAAK,EACvDC,EAAwC,CAAC,MAAO,SAAU,MAAO,UAAW,SAAS,EAWrFC,EAA4C,CAAC,SAAU,MAAO,SAAU,KAAK,EAU7EC,EAAsC,CACjD,OACA,QACA,mBACA,UACA,OACA,MACA,UACA,SACA,WACA,WACA,UACF,EAQaC,EAAuC,CAClD,OACA,UACA,MACA,UACA,SACA,MACA,WACA,OACA,UACA,OACA,OACA,SACA,QACA,iBACA,SACA,iBACA,YACA,aACA,2BACF,EAGaC,EAAuC,CAAC,OAAQ,QAAQ,EAGxDC,EAAqC,CAAC,KAAK,EAG3CC,EAAuC,CAAC,KAAM,MAAO,MAAO,KAAK,EAMjEC,EAAsC,CAAC,OAAQ,OAAQ,UAAW,MAAM"}
|
|
@@ -42,6 +42,8 @@ export declare const NATIVE_PLATFORM = "native";
|
|
|
42
42
|
*
|
|
43
43
|
* `mode` is absent on purpose: it is a gate folder, so it is consumed before
|
|
44
44
|
* the surface check and its declaration file synthesises the surface instead.
|
|
45
|
+
* `contract` is not a contribution either: each file declares one service
|
|
46
|
+
* contract its level provides, which the plugin lists as `provides`.
|
|
45
47
|
*/
|
|
46
48
|
export declare const BACKEND_SURFACES: readonly string[];
|
|
47
49
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"layout.d.mts","names":[],"sources":["../../src/constants/layout.ts"],"mappings":";;;;;;;;qBAQa;;qBAEA;;qBAWA;;qBAGA;;;;;;;;;qBAoBA;;;;;;;
|
|
1
|
+
{"version":3,"file":"layout.d.mts","names":[],"sources":["../../src/constants/layout.ts"],"mappings":";;;;;;;;qBAQa;;qBAEA;;qBAWA;;qBAGA;;;;;;;;;qBAoBA;;;;;;;qBAoEA;qBACA;;;;;;;qBAQA;;;;;;;;;qBAaA;;;;qBAoBA;;qBAuBA;;qBAGA"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const e=`src/extensions`,t=`src/extension`,n=`backend`,r=`frontend`,i=`workspaces`,a=`sessions`,o=[`mode`,`domain`],s=`route`,c=`root`,l=`generated`,u={server:`server`,web:`web`,native:`native`,mcp:`mcp`},
|
|
1
|
+
const e=`src/extensions`,t=`src/extension`,n=`backend`,r=`frontend`,i=`workspaces`,a=`sessions`,o=[`mode`,`domain`],s=`route`,c=`root`,l=`generated`,u=`./dist/extensions/server.mjs`,d={server:`server`,web:`web`,native:`native`,mcp:`mcp`},f=`client`,p=`client.native`,m=`src/types/apiRoutes.ts`,h=[`pi`,`server`,`web`,`native`,`mcp`,`client`,`client.native`],g=[`server`,`mcp`],_=[`web`,`native`,`ios`,`android`,`desktop`],v=`native`,y=[`server`,`web`,`native`,`mcp`],b=[`tool`,`skill`,`tool-restriction`,`command`,`hook`,`api`,`channel`,`method`,`provider`,`resource`,`contract`],x=`contract`,S=[`tool`,`command`,`api`,`channel`,`method`,`tab`,`template`,`dock`,`setting`,`slot`,`fill`,`action`,`store`,`activity-group`,`leader`,`selection-axis`,`lifecycle`,`file-links`,`repository-settings-panel`],C=[`fill`,`action`],w=[`api`],T=[`ts`,`tsx`,`mts`,`cts`],E=[`test`,`spec`,`stories`,`edge`];export{m as API_ROUTES_MODULE,n as BACKEND_GROUP,g as BACKEND_PLATFORMS,b as BACKEND_SURFACES,y as BUILD_TARGET_PLATFORMS,x as CONTRACT_SURFACE,e as DEFAULT_ROUTING_ROOT,E as EXCLUDED_INFIXES,r as FRONTEND_GROUP,_ as FRONTEND_PLATFORMS,S as FRONTEND_SURFACES,o as GATE_SEGMENTS,f as GENERATED_CLIENT_NAME,l as GENERATED_DIR,d as GENERATED_ENTRY_FILENAMES,h as GENERATED_ENTRY_NAMES,p as GENERATED_NATIVE_CLIENT_NAME,v as NATIVE_PLATFORM,c as ROOT_FILE_NAME,w as ROUTED_SURFACES,s as ROUTE_FILE_NAME,t as ROUTING_ROOT_ALIAS,u as SERVER_DIST,a as SESSION_SEGMENT,T as SOURCE_EXTENSIONS,C as TARGETED_SURFACES,i as WORKSPACE_SEGMENT};
|
|
2
2
|
//# sourceMappingURL=layout.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"layout.mjs","names":["DEFAULT_ROUTING_ROOT","ROUTING_ROOT_ALIAS","BACKEND_GROUP","FRONTEND_GROUP","WORKSPACE_SEGMENT","SESSION_SEGMENT","GATE_SEGMENTS","ROUTE_FILE_NAME","ROOT_FILE_NAME","GENERATED_DIR","GENERATED_ENTRY_FILENAMES","GENERATED_CLIENT_NAME","GENERATED_NATIVE_CLIENT_NAME","API_ROUTES_MODULE","GENERATED_ENTRY_NAMES","BACKEND_PLATFORMS","FRONTEND_PLATFORMS","NATIVE_PLATFORM","BUILD_TARGET_PLATFORMS","BACKEND_SURFACES","FRONTEND_SURFACES","TARGETED_SURFACES","ROUTED_SURFACES","SOURCE_EXTENSIONS","EXCLUDED_INFIXES"],"sources":["../../src/constants/layout.ts"],"sourcesContent":["/**\n * The folder-convention vocabulary, in one place.\n *\n * Every name here is part of the authoring contract in\n * docs/extension-layout.md. Adding a surface means adding it to both.\n */\n\n/** Where the scan starts, package-relative. */\nexport const DEFAULT_ROUTING_ROOT = 'src/extensions';\n/** Accepted spelling of the same root, for packages that prefer the singular. */\nexport const ROUTING_ROOT_ALIAS = 'src/extension';\n\n/** Group folders that also select a build side. */\nexport const BACKEND_GROUP = 'backend';\nexport const FRONTEND_GROUP = 'frontend';\n\n/** Scope segments, in nesting order below the routing root. */\nexport const WORKSPACE_SEGMENT = 'workspaces';\nexport const SESSION_SEGMENT = 'sessions';\n\n/** Gate folders. Each is followed by exactly one id segment. */\nexport const GATE_SEGMENTS: readonly string[] = ['mode', 'domain'];\n\n/** The leaf filename of an HTTP route, as Next.js spells it. */\nexport const ROUTE_FILE_NAME = 'route';\n\n/**\n * The reserved filename that constructs a scope, as Next.js spells a layout.\n *\n * One per scope and side. It runs before every contribution beneath it, and\n * whatever it returns is handed to each of them as part of the mount context,\n * which is how a package with one shared per-mount object graph decomposes\n * into a file per surface instead of one closure.\n */\nexport const ROOT_FILE_NAME = 'root';\n\n/**\n * Where generated entries are written, package-relative.\n *\n * Not `src`. That directory is authored code, and a build that writes into it\n * makes every package carry output its author did not write and must not edit.\n * This one is gitignored per package, and the repository's formatter already\n * skips a directory by this name.\n */\nexport const GENERATED_DIR = 'generated';\n\n/**\n * The generated entry each build target writes, keyed by the target it serves.\n *\n * Keyed rather than positional, so adding a generated file never rotates which\n * host each entry belongs to.\n */\nexport const GENERATED_ENTRY_FILENAMES = { server: 'server', web: 'web', native: 'native', mcp: 'mcp' } as const;\n\n/**\n * The generated typed client, which is not a build target.\n *\n * Nothing bundles it as an entry: a `(frontend)` file imports it and the\n * cockpit's browser build pulls it in from there. It is listed among the\n * managed names so that a package which drops its route table has the stale\n * client deleted rather than left behind.\n */\nexport const GENERATED_CLIENT_NAME = 'client';\n\n/**\n * The same client for a `.native` file, which may import neither the browser\n * contract nor the browser's sealed transport. Imported by its full name: the\n * native build is not Metro and resolves no platform suffix.\n */\nexport const GENERATED_NATIVE_CLIENT_NAME = 'client.native';\n\n/**\n * The route table a package authors, and the switch that asks for a client.\n *\n * Its presence is what opts a package in, the way `src/exports/apiContracts.ts`\n * is what asks for a contracts entry. It lives under `src/types` because that\n * is one of the two source roots a browser bundle may read.\n */\nexport const API_ROUTES_MODULE = 'src/types/apiRoutes.ts';\n\n/**\n * Every generated basename. Never scanned, never hand-edited.\n *\n * Spelled out rather than derived from the two declarations above, because a\n * constants module holds data a reader can see without running it. The cost is\n * that the names appear twice; the generate tests assert the two agree.\n *\n * `pi` is the retired terminal entry. It stays managed so a regenerate deletes\n * the stale file a package built before the terminal host was removed.\n */\nexport const GENERATED_ENTRY_NAMES: readonly string[] = [\n 'pi',\n 'server',\n 'web',\n 'native',\n 'mcp',\n 'client',\n 'client.native',\n];\n\n/** The retired terminal platform suffix. A routed file naming it is rejected. */\nexport const RETIRED_PLATFORM = 'cli';\n\n/**\n * Platform suffixes, scoped to their side. A target may not reuse one of these words.\n *\n * Every public routed file names one of these, so which host reads it is read\n * off the filename rather than inferred. A file that names none is a notice.\n */\nexport const BACKEND_PLATFORMS: readonly string[] = ['server', 'mcp'];\nexport const FRONTEND_PLATFORMS: readonly string[] = ['web', 'native', 'ios', 'android', 'desktop'];\n\n/**\n * The React Native frontend, for the iOS and Android app alike.\n *\n * Only a file naming it reaches the native host. An unsuffixed frontend file is\n * never a fallback here, because the web half is free to use the DOM.\n */\nexport const NATIVE_PLATFORM = 'native';\n\n/** The hosts this build emits. A frontend platform outside this set is authorable but unbuildable. */\nexport const BUILD_TARGET_PLATFORMS: readonly string[] = ['server', 'web', 'native', 'mcp'];\n\n/**\n * Surfaces that produce contributions on the backend side.\n *\n * `mode` is absent on purpose: it is a gate folder, so it is consumed before\n * the surface check and its declaration file synthesises the surface instead.\n */\nexport const BACKEND_SURFACES: readonly string[] = [\n 'tool',\n 'skill',\n 'tool-restriction',\n 'command',\n 'hook',\n 'api',\n 'channel',\n 'method',\n 'provider',\n 'resource',\n];\n\n/**\n * Surfaces that produce contributions on the frontend side.\n */\nexport const FRONTEND_SURFACES: readonly string[] = [\n 'tool',\n 'command',\n 'api',\n 'channel',\n 'method',\n 'tab',\n 'template',\n 'dock',\n 'setting',\n 'slot',\n 'fill',\n 'action',\n 'store',\n 'activity-group',\n 'leader',\n 'selection-axis',\n 'lifecycle',\n 'file-links',\n 'repository-settings-panel',\n];\n\n/** Surfaces whose filename carries a relationship target. */\nexport const TARGETED_SURFACES: readonly string[] = ['fill', 'action'];\n\n/** Surfaces whose folders below the surface spell a route path. */\nexport const ROUTED_SURFACES: readonly string[] = ['api'];\n\n/** Source extensions the scan accepts. */\nexport const SOURCE_EXTENSIONS: readonly string[] = ['ts', 'tsx', 'mts', 'cts'];\n\n/**\n * Filename infixes excluded everywhere, whatever their position. `edge` marks a\n * workerd variant of its base sibling, resolved only by the private Worker build.\n */\nexport const EXCLUDED_INFIXES: readonly string[] = ['test', 'spec', 'stories', 'edge'];\n\n/** Marks a folder as organisational: not a path segment, contents still scanned. */\nexport const GROUP_PREFIX = '(';\nexport const GROUP_SUFFIX = ')';\n/** Marks a folder as private: never scanned, never built. */\nexport const PRIVATE_PREFIX = '_';\n/** Marks a folder as a dynamic route segment. */\nexport const DYNAMIC_PREFIX = '[';\nexport const DYNAMIC_SUFFIX = ']';\n/** Marks a dynamic segment as catch-all. */\nexport const CATCH_ALL_MARKER = '...';\n"],"mappings":"AAQA,MAAaA,EAAuB,iBAEvBC,EAAqB,gBAGrBC,EAAgB,UAChBC,EAAiB,WAGjBC,EAAoB,aACpBC,EAAkB,WAGlBC,EAAmC,CAAC,OAAQ,QAAQ,EAGpDC,EAAkB,QAUlBC,EAAiB,OAUjBC,EAAgB,
|
|
1
|
+
{"version":3,"file":"layout.mjs","names":["DEFAULT_ROUTING_ROOT","ROUTING_ROOT_ALIAS","BACKEND_GROUP","FRONTEND_GROUP","WORKSPACE_SEGMENT","SESSION_SEGMENT","GATE_SEGMENTS","ROUTE_FILE_NAME","ROOT_FILE_NAME","GENERATED_DIR","SERVER_DIST","GENERATED_ENTRY_FILENAMES","GENERATED_CLIENT_NAME","GENERATED_NATIVE_CLIENT_NAME","API_ROUTES_MODULE","GENERATED_ENTRY_NAMES","BACKEND_PLATFORMS","FRONTEND_PLATFORMS","NATIVE_PLATFORM","BUILD_TARGET_PLATFORMS","BACKEND_SURFACES","CONTRACT_SURFACE","FRONTEND_SURFACES","TARGETED_SURFACES","ROUTED_SURFACES","SOURCE_EXTENSIONS","EXCLUDED_INFIXES"],"sources":["../../src/constants/layout.ts"],"sourcesContent":["/**\n * The folder-convention vocabulary, in one place.\n *\n * Every name here is part of the authoring contract in\n * docs/extension-layout.md. Adding a surface means adding it to both.\n */\n\n/** Where the scan starts, package-relative. */\nexport const DEFAULT_ROUTING_ROOT = 'src/extensions';\n/** Accepted spelling of the same root, for packages that prefer the singular. */\nexport const ROUTING_ROOT_ALIAS = 'src/extension';\n\n/** Group folders that also select a build side. */\nexport const BACKEND_GROUP = 'backend';\nexport const FRONTEND_GROUP = 'frontend';\n\n/** Scope segments, in nesting order below the routing root. */\nexport const WORKSPACE_SEGMENT = 'workspaces';\nexport const SESSION_SEGMENT = 'sessions';\n\n/** Gate folders. Each is followed by exactly one id segment. */\nexport const GATE_SEGMENTS: readonly string[] = ['mode', 'domain'];\n\n/** The leaf filename of an HTTP route, as Next.js spells it. */\nexport const ROUTE_FILE_NAME = 'route';\n\n/**\n * The reserved filename that constructs a scope, as Next.js spells a layout.\n *\n * One per scope and side. It runs before every contribution beneath it, and\n * whatever it returns is handed to each of them as part of the mount context,\n * which is how a package with one shared per-mount object graph decomposes\n * into a file per surface instead of one closure.\n */\nexport const ROOT_FILE_NAME = 'root';\n\n/**\n * Where generated entries are written, package-relative.\n *\n * Not `src`. That directory is authored code, and a build that writes into it\n * makes every package carry output its author did not write and must not edit.\n * This one is gitignored per package, and the repository's formatter already\n * skips a directory by this name.\n */\nexport const GENERATED_DIR = 'generated';\n\n/** The built server entry a host imports, package-relative, as `poServer.dist` names it. */\nexport const SERVER_DIST = './dist/extensions/server.mjs';\n\n/**\n * The generated entry each build target writes, keyed by the target it serves.\n *\n * Keyed rather than positional, so adding a generated file never rotates which\n * host each entry belongs to.\n */\nexport const GENERATED_ENTRY_FILENAMES = { server: 'server', web: 'web', native: 'native', mcp: 'mcp' } as const;\n\n/**\n * The generated typed client, which is not a build target.\n *\n * Nothing bundles it as an entry: a `(frontend)` file imports it and the\n * cockpit's browser build pulls it in from there. It is listed among the\n * managed names so that a package which drops its route table has the stale\n * client deleted rather than left behind.\n */\nexport const GENERATED_CLIENT_NAME = 'client';\n\n/**\n * The same client for a `.native` file, which may import neither the browser\n * contract nor the browser's sealed transport. Imported by its full name: the\n * native build is not Metro and resolves no platform suffix.\n */\nexport const GENERATED_NATIVE_CLIENT_NAME = 'client.native';\n\n/**\n * The route table a package authors, and the switch that asks for a client.\n *\n * Its presence is what opts a package in, the way `src/exports/apiContracts.ts`\n * is what asks for a contracts entry. It lives under `src/types` because that\n * is one of the two source roots a browser bundle may read.\n */\nexport const API_ROUTES_MODULE = 'src/types/apiRoutes.ts';\n\n/**\n * Every generated basename. Never scanned, never hand-edited.\n *\n * Spelled out rather than derived from the two declarations above, because a\n * constants module holds data a reader can see without running it. The cost is\n * that the names appear twice; the generate tests assert the two agree.\n *\n * `pi` is the retired terminal entry. It stays managed so a regenerate deletes\n * the stale file a package built before the terminal host was removed.\n */\nexport const GENERATED_ENTRY_NAMES: readonly string[] = [\n 'pi',\n 'server',\n 'web',\n 'native',\n 'mcp',\n 'client',\n 'client.native',\n];\n\n/** The retired terminal platform suffix. A routed file naming it is rejected. */\nexport const RETIRED_PLATFORM = 'cli';\n\n/**\n * Platform suffixes, scoped to their side. A target may not reuse one of these words.\n *\n * Every public routed file names one of these, so which host reads it is read\n * off the filename rather than inferred. A file that names none is a notice.\n */\nexport const BACKEND_PLATFORMS: readonly string[] = ['server', 'mcp'];\nexport const FRONTEND_PLATFORMS: readonly string[] = ['web', 'native', 'ios', 'android', 'desktop'];\n\n/**\n * The React Native frontend, for the iOS and Android app alike.\n *\n * Only a file naming it reaches the native host. An unsuffixed frontend file is\n * never a fallback here, because the web half is free to use the DOM.\n */\nexport const NATIVE_PLATFORM = 'native';\n\n/** The hosts this build emits. A frontend platform outside this set is authorable but unbuildable. */\nexport const BUILD_TARGET_PLATFORMS: readonly string[] = ['server', 'web', 'native', 'mcp'];\n\n/**\n * Surfaces that produce contributions on the backend side.\n *\n * `mode` is absent on purpose: it is a gate folder, so it is consumed before\n * the surface check and its declaration file synthesises the surface instead.\n * `contract` is not a contribution either: each file declares one service\n * contract its level provides, which the plugin lists as `provides`.\n */\nexport const BACKEND_SURFACES: readonly string[] = [\n 'tool',\n 'skill',\n 'tool-restriction',\n 'command',\n 'hook',\n 'api',\n 'channel',\n 'method',\n 'provider',\n 'resource',\n 'contract',\n];\n\n/** The backend surface whose files declare the service contracts a level provides. */\nexport const CONTRACT_SURFACE = 'contract';\n\n/**\n * Surfaces that produce contributions on the frontend side.\n */\nexport const FRONTEND_SURFACES: readonly string[] = [\n 'tool',\n 'command',\n 'api',\n 'channel',\n 'method',\n 'tab',\n 'template',\n 'dock',\n 'setting',\n 'slot',\n 'fill',\n 'action',\n 'store',\n 'activity-group',\n 'leader',\n 'selection-axis',\n 'lifecycle',\n 'file-links',\n 'repository-settings-panel',\n];\n\n/** Surfaces whose filename carries a relationship target. */\nexport const TARGETED_SURFACES: readonly string[] = ['fill', 'action'];\n\n/** Surfaces whose folders below the surface spell a route path. */\nexport const ROUTED_SURFACES: readonly string[] = ['api'];\n\n/** Source extensions the scan accepts. */\nexport const SOURCE_EXTENSIONS: readonly string[] = ['ts', 'tsx', 'mts', 'cts'];\n\n/**\n * Filename infixes excluded everywhere, whatever their position. `edge` marks a\n * workerd variant of its base sibling, resolved only by the private Worker build.\n */\nexport const EXCLUDED_INFIXES: readonly string[] = ['test', 'spec', 'stories', 'edge'];\n\n/** Marks a folder as organisational: not a path segment, contents still scanned. */\nexport const GROUP_PREFIX = '(';\nexport const GROUP_SUFFIX = ')';\n/** Marks a folder as private: never scanned, never built. */\nexport const PRIVATE_PREFIX = '_';\n/** Marks a folder as a dynamic route segment. */\nexport const DYNAMIC_PREFIX = '[';\nexport const DYNAMIC_SUFFIX = ']';\n/** Marks a dynamic segment as catch-all. */\nexport const CATCH_ALL_MARKER = '...';\n"],"mappings":"AAQA,MAAaA,EAAuB,iBAEvBC,EAAqB,gBAGrBC,EAAgB,UAChBC,EAAiB,WAGjBC,EAAoB,aACpBC,EAAkB,WAGlBC,EAAmC,CAAC,OAAQ,QAAQ,EAGpDC,EAAkB,QAUlBC,EAAiB,OAUjBC,EAAgB,YAGhBC,EAAc,+BAQdC,EAA4B,CAAE,OAAQ,SAAU,IAAK,MAAO,OAAQ,SAAU,IAAK,KAAM,EAUzFC,EAAwB,SAOxBC,EAA+B,gBAS/BC,EAAoB,yBAYpBC,EAA2C,CACtD,KACA,SACA,MACA,SACA,MACA,SACA,eACF,EAWaC,EAAuC,CAAC,SAAU,KAAK,EACvDC,EAAwC,CAAC,MAAO,SAAU,MAAO,UAAW,SAAS,EAQrFC,EAAkB,SAGlBC,EAA4C,CAAC,SAAU,MAAO,SAAU,KAAK,EAU7EC,EAAsC,CACjD,OACA,QACA,mBACA,UACA,OACA,MACA,UACA,SACA,WACA,WACA,UACF,EAGaC,EAAmB,WAKnBC,EAAuC,CAClD,OACA,UACA,MACA,UACA,SACA,MACA,WACA,OACA,UACA,OACA,OACA,SACA,QACA,iBACA,SACA,iBACA,YACA,aACA,2BACF,EAGaC,EAAuC,CAAC,OAAQ,QAAQ,EAGxDC,EAAqC,CAAC,KAAK,EAG3CC,EAAuC,CAAC,KAAM,MAAO,MAAO,KAAK,EAMjEC,EAAsC,CAAC,OAAQ,OAAQ,UAAW,MAAM"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["toKebab","posix","require_index","node_path","SCOPE_ORDER","identifierFor","multiple","camel","basePath","word","index","baseSegmentOf","first","entry","mountsOf","scopesByBase","graph","held","bases","declared","shallowest","scope","routesSpecifier","relative","entryDir","BROWSER_CLIENT","NATIVE_CLIENT","renderMount","scopes","mount","suffix","flavor","renderClient","mounts","options","renderApiClient","renderNativeApiClient"],"sources":["../../../src/services/renderClient/index.ts"],"sourcesContent":["import { posix } from 'node:path';\n\nimport { GENERATED_DIR } from '../../constants/layout';\nimport type { ExtensionEntry, ExtensionGraph, ExtensionScope } from '../../types/extensionGraph';\nimport { toKebab } from '../identity';\nimport type { RenderOptions } from '../renderEntry/type';\n\n/**\n * Renders the typed client a cockpit plugin calls its own API through.\n *\n * The two facts this injects are the two a package kept restating and getting\n * wrong: which scopes its API mounts at, and under which base path. Both are\n * read off the folder tree, so `api/file-edits/route.server.ts` at the session\n * scope is the whole declaration. A package that writes them out again is a\n * package that can disagree with itself, and several did.\n *\n * The route list is not read here. It is authored as plain data in\n * `src/types/apiRoutes.ts`, because this build evaluates no TypeScript and must\n * not learn how: it has no dependencies at all, and every specifier below is\n * emitted as text.\n */\n\nconst HEADER = '// Generated by @agimon-ai/po-build. Do not edit by hand.';\n\n/** Server scopes cascade outward-in, the way the generated server entry mounts them. */\nconst SCOPE_ORDER: readonly ExtensionScope[] = ['global', 'workspace', 'session'];\n\n/** One mount the tree declares: a base path, and the scopes it is reachable at. */\ninterface ClientMount {\n readonly basePath: string;\n readonly scopes: readonly ExtensionScope[];\n /** A valid identifier for the exported factory, when a package has several mounts. */\n readonly identifier: string;\n}\n\nfunction identifierFor(basePath: string, multiple: boolean): string {\n if (!multiple) return 'api';\n const camel = toKebab(basePath)\n .split('-')\n .filter((word) => word.length > 0)\n .map((word, index) => (index === 0 ? word : word[0]?.toUpperCase() + word.slice(1)))\n .join('');\n return /^[A-Za-z_]/u.test(camel) ? camel : `api${camel}`;\n}\n\n/**\n * The base path an api entry mounts at: the first literal segment below `api/`.\n *\n * An entry with no segment is the flat `api/route.server.ts` shape that predates\n * this convention. Its base path lives in a hand-written `PoApi` the build\n * cannot read, so it contributes no client and keeps its hand-built URLs until\n * the folder is renamed.\n */\nfunction baseSegmentOf(entry: ExtensionEntry): string | undefined {\n const first = entry.route[0];\n if (first === undefined || !('literal' in first)) return undefined;\n return first.literal;\n}\n\nfunction mountsOf(graph: ExtensionGraph): ClientMount[] {\n const scopesByBase = new Map<string, Set<ExtensionScope>>();\n for (const entry of graph.entries) {\n if (entry.side !== 'backend' || entry.surface !== 'api' || entry.role !== 'contribution') continue;\n const basePath = baseSegmentOf(entry);\n if (basePath === undefined) continue;\n const held = scopesByBase.get(basePath) ?? new Set<ExtensionScope>();\n held.add(entry.scope);\n scopesByBase.set(basePath, held);\n }\n\n const bases = [...scopesByBase.keys()].sort();\n return bases.map((basePath) => {\n const declared = scopesByBase.get(basePath) as Set<ExtensionScope>;\n // A
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["toKebab","posix","require_index","node_path","SCOPE_ORDER","identifierFor","multiple","camel","basePath","word","index","baseSegmentOf","first","entry","mountsOf","scopesByBase","graph","held","bases","declared","shallowest","scope","routesSpecifier","relative","entryDir","BROWSER_CLIENT","NATIVE_CLIENT","renderMount","scopes","mount","suffix","flavor","renderClient","mounts","options","renderApiClient","renderNativeApiClient"],"sources":["../../../src/services/renderClient/index.ts"],"sourcesContent":["import { posix } from 'node:path';\n\nimport { GENERATED_DIR } from '../../constants/layout';\nimport type { ExtensionEntry, ExtensionGraph, ExtensionScope } from '../../types/extensionGraph';\nimport { toKebab } from '../identity';\nimport type { RenderOptions } from '../renderEntry/type';\n\n/**\n * Renders the typed client a cockpit plugin calls its own API through.\n *\n * The two facts this injects are the two a package kept restating and getting\n * wrong: which scopes its API mounts at, and under which base path. Both are\n * read off the folder tree, so `api/file-edits/route.server.ts` at the session\n * scope is the whole declaration. A package that writes them out again is a\n * package that can disagree with itself, and several did.\n *\n * The route list is not read here. It is authored as plain data in\n * `src/types/apiRoutes.ts`, because this build evaluates no TypeScript and must\n * not learn how: it has no dependencies at all, and every specifier below is\n * emitted as text.\n */\n\nconst HEADER = '// Generated by @agimon-ai/po-build. Do not edit by hand.';\n\n/** Server scopes cascade outward-in, the way the generated server entry mounts them. */\nconst SCOPE_ORDER: readonly ExtensionScope[] = ['global', 'workspace', 'session'];\n\n/** One mount the tree declares: a base path, and the scopes it is reachable at. */\ninterface ClientMount {\n readonly basePath: string;\n readonly scopes: readonly ExtensionScope[];\n /** A valid identifier for the exported factory, when a package has several mounts. */\n readonly identifier: string;\n}\n\nfunction identifierFor(basePath: string, multiple: boolean): string {\n if (!multiple) return 'api';\n const camel = toKebab(basePath)\n .split('-')\n .filter((word) => word.length > 0)\n .map((word, index) => (index === 0 ? word : word[0]?.toUpperCase() + word.slice(1)))\n .join('');\n return /^[A-Za-z_]/u.test(camel) ? camel : `api${camel}`;\n}\n\n/**\n * The base path an api entry mounts at: the first literal segment below `api/`.\n *\n * An entry with no segment is the flat `api/route.server.ts` shape that predates\n * this convention. Its base path lives in a hand-written `PoApi` the build\n * cannot read, so it contributes no client and keeps its hand-built URLs until\n * the folder is renamed.\n */\nfunction baseSegmentOf(entry: ExtensionEntry): string | undefined {\n const first = entry.route[0];\n if (first === undefined || !('literal' in first)) return undefined;\n return first.literal;\n}\n\nfunction mountsOf(graph: ExtensionGraph): ClientMount[] {\n const scopesByBase = new Map<string, Set<ExtensionScope>>();\n for (const entry of graph.entries) {\n if (entry.side !== 'backend' || entry.surface !== 'api' || entry.role !== 'contribution') continue;\n const basePath = baseSegmentOf(entry);\n if (basePath === undefined) continue;\n const held = scopesByBase.get(basePath) ?? new Set<ExtensionScope>();\n held.add(entry.scope);\n scopesByBase.set(basePath, held);\n }\n\n const bases = [...scopesByBase.keys()].sort();\n return bases.map((basePath) => {\n const declared = scopesByBase.get(basePath) as Set<ExtensionScope>;\n // A server plugin offers a contribution at its own scope and every scope below it,\n // so a global API answers workspace and session requests too.\n const shallowest = SCOPE_ORDER.findIndex((scope) => declared.has(scope));\n return {\n basePath,\n scopes: SCOPE_ORDER.slice(shallowest),\n identifier: identifierFor(basePath, bases.length > 1),\n };\n });\n}\n\n/** The extensionless relative specifier from the generated directory to the route table. */\nfunction routesSpecifier(entryDir: string): string {\n const relative = posix.relative(entryDir, 'src/types/apiRoutes');\n return relative.startsWith('.') ? relative : `./${relative}`;\n}\n\n/** What differs between the browser and native clients: where the runtime comes from, and how a call leaves. */\ninterface ClientFlavor {\n readonly imports: readonly string[];\n readonly transport: string;\n}\n\nconst BROWSER_CLIENT: ClientFlavor = {\n imports: [\n \"import { createApiClient, sessionApiAddress } from '@agimon-ai/po-core/web';\",\n \"import { sealedTransport } from '@agimon-ai/po-web-security/browser';\",\n ],\n transport: '(input, init) => sealedTransport.fetch(input, init)',\n};\n\n/**\n * Only `@agimon-ai/po-core/native`, the one Po module on the native host list.\n * The phone's sealed channel and step-up live in the app shell, which binds\n * them behind `nativeApiTransport`.\n */\nconst NATIVE_CLIENT: ClientFlavor = {\n imports: [\"import { createApiClient, nativeApiTransport, sessionApiAddress } from '@agimon-ai/po-core/native';\"],\n transport: 'nativeApiTransport',\n};\n\nfunction renderMount(mount: ClientMount, flavor: ClientFlavor): string[] {\n const scopes = mount.scopes.map((scope) => `'${scope}'`).join(', ');\n const suffix = mount.identifier === 'api' ? '' : ` for the ${mount.basePath} mount`;\n return [\n `/** Scopes the tree mounts '${mount.basePath}' at${suffix}. */`,\n `export const ${mount.identifier}Scopes = [${scopes}] as const;`,\n '',\n `export const ${mount.identifier} = createApiClient(routes, {`,\n ` scopes: ${mount.identifier}Scopes,`,\n ` basePath: '${mount.basePath}',`,\n ` transport: ${flavor.transport},`,\n ' sessionAddress: sessionApiAddress,',\n '});',\n '',\n ];\n}\n\nfunction renderClient(graph: ExtensionGraph, options: RenderOptions, flavor: ClientFlavor): string | undefined {\n const mounts = mountsOf(graph);\n if (mounts.length === 0) return undefined;\n\n const lines = [\n HEADER,\n ...flavor.imports,\n '',\n `import routes from '${routesSpecifier(options.entryDir ?? GENERATED_DIR)}';`,\n '',\n ...mounts.flatMap((mount) => renderMount(mount, flavor)),\n ];\n return `${lines.join('\\n').replace(/\\n+$/u, '')}\\n`;\n}\n\n/**\n * The client source, or undefined when the tree declares no `api/<base-path>/`.\n *\n * `options.entryDir` is where the file will be written, so the relative import\n * of the route table is computed against it rather than assumed.\n */\nexport function renderApiClient(graph: ExtensionGraph, options: RenderOptions): string | undefined {\n return renderClient(graph, options, BROWSER_CLIENT);\n}\n\n/**\n * The same mounts and the same route table for a `.native` file.\n *\n * The route table is imported, never restated, so it must itself import only\n * what the native host provides: a table that imports `@agimon-ai/po-core/web`\n * is refused by the native composition build, which is the intended failure.\n */\nexport function renderNativeApiClient(graph: ExtensionGraph, options: RenderOptions): string | undefined {\n return renderClient(graph, options, NATIVE_CLIENT);\n}\n"],"mappings":"0GAsBA,MAGMI,EAAyC,CAAC,SAAU,YAAa,SAAS,EAUhF,SAASC,EAAc,EAAkB,EAA2B,CAClE,GAAI,CAACC,EAAU,MAAO,MACtB,IAAMC,EAAQP,EAAAA,QAAQQ,CAAQ,CAAC,CAC5B,MAAM,GAAG,CAAC,CACV,OAAQ,GAASC,EAAK,OAAS,CAAC,CAAC,CACjC,KAAK,EAAM,IAAWC,IAAU,EAAID,EAAOA,EAAK,EAAE,EAAE,YAAY,EAAIA,EAAK,MAAM,CAAC,CAAE,CAAC,CACnF,KAAK,EAAE,EACV,MAAO,cAAc,KAAKF,CAAK,EAAIA,EAAQ,MAAMA,GACnD,CAUA,SAASI,EAAc,EAA2C,CAChE,IAAMC,EAAQC,EAAM,MAAM,GAC1B,GAAID,IAAU,IAAA,IAAe,YAAaA,EAC1C,OAAOA,EAAM,OACf,CAEA,SAASE,EAAS,EAAsC,CACtD,IAAMC,kBAAe,IAAI,IACzB,IAAK,IAAMF,KAASG,EAAM,QAAS,CACjC,GAAIH,EAAM,OAAS,WAAaA,EAAM,UAAY,OAASA,EAAM,OAAS,eAAgB,SAC1F,IAAML,EAAWG,EAAcE,CAAK,EACpC,GAAIL,IAAa,IAAA,GAAW,SAC5B,IAAMS,EAAOF,EAAa,IAAIP,CAAQ,mBAAK,IAAI,IAC/CS,EAAK,IAAIJ,EAAM,KAAK,EACpBE,EAAa,IAAIP,EAAUS,CAAI,CACjC,CAEA,IAAMC,EAAQ,CAAC,GAAGH,EAAa,KAAK,CAAC,CAAC,CAAC,KAAK,EAC5C,OAAOG,EAAM,IAA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S,EAAE,EAAE,GAClD,CAQA,SAAgBI,EAAgB,EAAuB,EAA4C,CACjG,OAAOH,EAAahB,EAAOkB,EAAST,CAAc,CACpD,CASA,SAAgBW,EAAsB,EAAuB,EAA4C,CACvG,OAAOJ,EAAahB,EAAOkB,EAASR,CAAa,CACnD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":["SCOPE_ORDER","identifierFor","multiple","camel","toKebab","basePath","word","index","baseSegmentOf","first","entry","mountsOf","scopesByBase","graph","held","bases","declared","shallowest","scope","routesSpecifier","relative","posix","entryDir","BROWSER_CLIENT","NATIVE_CLIENT","renderMount","scopes","mount","suffix","flavor","renderClient","mounts","options","renderApiClient","renderNativeApiClient"],"sources":["../../../src/services/renderClient/index.ts"],"sourcesContent":["import { posix } from 'node:path';\n\nimport { GENERATED_DIR } from '../../constants/layout';\nimport type { ExtensionEntry, ExtensionGraph, ExtensionScope } from '../../types/extensionGraph';\nimport { toKebab } from '../identity';\nimport type { RenderOptions } from '../renderEntry/type';\n\n/**\n * Renders the typed client a cockpit plugin calls its own API through.\n *\n * The two facts this injects are the two a package kept restating and getting\n * wrong: which scopes its API mounts at, and under which base path. Both are\n * read off the folder tree, so `api/file-edits/route.server.ts` at the session\n * scope is the whole declaration. A package that writes them out again is a\n * package that can disagree with itself, and several did.\n *\n * The route list is not read here. It is authored as plain data in\n * `src/types/apiRoutes.ts`, because this build evaluates no TypeScript and must\n * not learn how: it has no dependencies at all, and every specifier below is\n * emitted as text.\n */\n\nconst HEADER = '// Generated by @agimon-ai/po-build. Do not edit by hand.';\n\n/** Server scopes cascade outward-in, the way the generated server entry mounts them. */\nconst SCOPE_ORDER: readonly ExtensionScope[] = ['global', 'workspace', 'session'];\n\n/** One mount the tree declares: a base path, and the scopes it is reachable at. */\ninterface ClientMount {\n readonly basePath: string;\n readonly scopes: readonly ExtensionScope[];\n /** A valid identifier for the exported factory, when a package has several mounts. */\n readonly identifier: string;\n}\n\nfunction identifierFor(basePath: string, multiple: boolean): string {\n if (!multiple) return 'api';\n const camel = toKebab(basePath)\n .split('-')\n .filter((word) => word.length > 0)\n .map((word, index) => (index === 0 ? word : word[0]?.toUpperCase() + word.slice(1)))\n .join('');\n return /^[A-Za-z_]/u.test(camel) ? camel : `api${camel}`;\n}\n\n/**\n * The base path an api entry mounts at: the first literal segment below `api/`.\n *\n * An entry with no segment is the flat `api/route.server.ts` shape that predates\n * this convention. Its base path lives in a hand-written `PoApi` the build\n * cannot read, so it contributes no client and keeps its hand-built URLs until\n * the folder is renamed.\n */\nfunction baseSegmentOf(entry: ExtensionEntry): string | undefined {\n const first = entry.route[0];\n if (first === undefined || !('literal' in first)) return undefined;\n return first.literal;\n}\n\nfunction mountsOf(graph: ExtensionGraph): ClientMount[] {\n const scopesByBase = new Map<string, Set<ExtensionScope>>();\n for (const entry of graph.entries) {\n if (entry.side !== 'backend' || entry.surface !== 'api' || entry.role !== 'contribution') continue;\n const basePath = baseSegmentOf(entry);\n if (basePath === undefined) continue;\n const held = scopesByBase.get(basePath) ?? new Set<ExtensionScope>();\n held.add(entry.scope);\n scopesByBase.set(basePath, held);\n }\n\n const bases = [...scopesByBase.keys()].sort();\n return bases.map((basePath) => {\n const declared = scopesByBase.get(basePath) as Set<ExtensionScope>;\n // A
|
|
1
|
+
{"version":3,"file":"index.mjs","names":["SCOPE_ORDER","identifierFor","multiple","camel","toKebab","basePath","word","index","baseSegmentOf","first","entry","mountsOf","scopesByBase","graph","held","bases","declared","shallowest","scope","routesSpecifier","relative","posix","entryDir","BROWSER_CLIENT","NATIVE_CLIENT","renderMount","scopes","mount","suffix","flavor","renderClient","mounts","options","renderApiClient","renderNativeApiClient"],"sources":["../../../src/services/renderClient/index.ts"],"sourcesContent":["import { posix } from 'node:path';\n\nimport { GENERATED_DIR } from '../../constants/layout';\nimport type { ExtensionEntry, ExtensionGraph, ExtensionScope } from '../../types/extensionGraph';\nimport { toKebab } from '../identity';\nimport type { RenderOptions } from '../renderEntry/type';\n\n/**\n * Renders the typed client a cockpit plugin calls its own API through.\n *\n * The two facts this injects are the two a package kept restating and getting\n * wrong: which scopes its API mounts at, and under which base path. Both are\n * read off the folder tree, so `api/file-edits/route.server.ts` at the session\n * scope is the whole declaration. A package that writes them out again is a\n * package that can disagree with itself, and several did.\n *\n * The route list is not read here. It is authored as plain data in\n * `src/types/apiRoutes.ts`, because this build evaluates no TypeScript and must\n * not learn how: it has no dependencies at all, and every specifier below is\n * emitted as text.\n */\n\nconst HEADER = '// Generated by @agimon-ai/po-build. Do not edit by hand.';\n\n/** Server scopes cascade outward-in, the way the generated server entry mounts them. */\nconst SCOPE_ORDER: readonly ExtensionScope[] = ['global', 'workspace', 'session'];\n\n/** One mount the tree declares: a base path, and the scopes it is reachable at. */\ninterface ClientMount {\n readonly basePath: string;\n readonly scopes: readonly ExtensionScope[];\n /** A valid identifier for the exported factory, when a package has several mounts. */\n readonly identifier: string;\n}\n\nfunction identifierFor(basePath: string, multiple: boolean): string {\n if (!multiple) return 'api';\n const camel = toKebab(basePath)\n .split('-')\n .filter((word) => word.length > 0)\n .map((word, index) => (index === 0 ? word : word[0]?.toUpperCase() + word.slice(1)))\n .join('');\n return /^[A-Za-z_]/u.test(camel) ? camel : `api${camel}`;\n}\n\n/**\n * The base path an api entry mounts at: the first literal segment below `api/`.\n *\n * An entry with no segment is the flat `api/route.server.ts` shape that predates\n * this convention. Its base path lives in a hand-written `PoApi` the build\n * cannot read, so it contributes no client and keeps its hand-built URLs until\n * the folder is renamed.\n */\nfunction baseSegmentOf(entry: ExtensionEntry): string | undefined {\n const first = entry.route[0];\n if (first === undefined || !('literal' in first)) return undefined;\n return first.literal;\n}\n\nfunction mountsOf(graph: ExtensionGraph): ClientMount[] {\n const scopesByBase = new Map<string, Set<ExtensionScope>>();\n for (const entry of graph.entries) {\n if (entry.side !== 'backend' || entry.surface !== 'api' || entry.role !== 'contribution') continue;\n const basePath = baseSegmentOf(entry);\n if (basePath === undefined) continue;\n const held = scopesByBase.get(basePath) ?? new Set<ExtensionScope>();\n held.add(entry.scope);\n scopesByBase.set(basePath, held);\n }\n\n const bases = [...scopesByBase.keys()].sort();\n return bases.map((basePath) => {\n const declared = scopesByBase.get(basePath) as Set<ExtensionScope>;\n // A server plugin offers a contribution at its own scope and every scope below it,\n // so a global API answers workspace and session requests too.\n const shallowest = SCOPE_ORDER.findIndex((scope) => declared.has(scope));\n return {\n basePath,\n scopes: SCOPE_ORDER.slice(shallowest),\n identifier: identifierFor(basePath, bases.length > 1),\n };\n });\n}\n\n/** The extensionless relative specifier from the generated directory to the route table. */\nfunction routesSpecifier(entryDir: string): string {\n const relative = posix.relative(entryDir, 'src/types/apiRoutes');\n return relative.startsWith('.') ? relative : `./${relative}`;\n}\n\n/** What differs between the browser and native clients: where the runtime comes from, and how a call leaves. */\ninterface ClientFlavor {\n readonly imports: readonly string[];\n readonly transport: string;\n}\n\nconst BROWSER_CLIENT: ClientFlavor = {\n imports: [\n \"import { createApiClient, sessionApiAddress } from '@agimon-ai/po-core/web';\",\n \"import { sealedTransport } from '@agimon-ai/po-web-security/browser';\",\n ],\n transport: '(input, init) => sealedTransport.fetch(input, init)',\n};\n\n/**\n * Only `@agimon-ai/po-core/native`, the one Po module on the native host list.\n * The phone's sealed channel and step-up live in the app shell, which binds\n * them behind `nativeApiTransport`.\n */\nconst NATIVE_CLIENT: ClientFlavor = {\n imports: [\"import { createApiClient, nativeApiTransport, sessionApiAddress } from '@agimon-ai/po-core/native';\"],\n transport: 'nativeApiTransport',\n};\n\nfunction renderMount(mount: ClientMount, flavor: ClientFlavor): string[] {\n const scopes = mount.scopes.map((scope) => `'${scope}'`).join(', ');\n const suffix = mount.identifier === 'api' ? '' : ` for the ${mount.basePath} mount`;\n return [\n `/** Scopes the tree mounts '${mount.basePath}' at${suffix}. */`,\n `export const ${mount.identifier}Scopes = [${scopes}] as const;`,\n '',\n `export const ${mount.identifier} = createApiClient(routes, {`,\n ` scopes: ${mount.identifier}Scopes,`,\n ` basePath: '${mount.basePath}',`,\n ` transport: ${flavor.transport},`,\n ' sessionAddress: sessionApiAddress,',\n '});',\n '',\n ];\n}\n\nfunction renderClient(graph: ExtensionGraph, options: RenderOptions, flavor: ClientFlavor): string | undefined {\n const mounts = mountsOf(graph);\n if (mounts.length === 0) return undefined;\n\n const lines = [\n HEADER,\n ...flavor.imports,\n '',\n `import routes from '${routesSpecifier(options.entryDir ?? GENERATED_DIR)}';`,\n '',\n ...mounts.flatMap((mount) => renderMount(mount, flavor)),\n ];\n return `${lines.join('\\n').replace(/\\n+$/u, '')}\\n`;\n}\n\n/**\n * The client source, or undefined when the tree declares no `api/<base-path>/`.\n *\n * `options.entryDir` is where the file will be written, so the relative import\n * of the route table is computed against it rather than assumed.\n */\nexport function renderApiClient(graph: ExtensionGraph, options: RenderOptions): string | undefined {\n return renderClient(graph, options, BROWSER_CLIENT);\n}\n\n/**\n * The same mounts and the same route table for a `.native` file.\n *\n * The route table is imported, never restated, so it must itself import only\n * what the native host provides: a table that imports `@agimon-ai/po-core/web`\n * is refused by the native composition build, which is the intended failure.\n */\nexport function renderNativeApiClient(graph: ExtensionGraph, options: RenderOptions): string | undefined {\n return renderClient(graph, options, NATIVE_CLIENT);\n}\n"],"mappings":"qHAsBA,MAGMA,EAAyC,CAAC,SAAU,YAAa,SAAS,EAUhF,SAASC,EAAc,EAAkB,EAA2B,CAClE,GAAI,CAACC,EAAU,MAAO,MACtB,IAAMC,EAAQC,EAAQC,CAAQ,CAAC,CAC5B,MAAM,GAAG,CAAC,CACV,OAAQ,GAASC,EAAK,OAAS,CAAC,CAAC,CACjC,KAAK,EAAM,IAAWC,IAAU,EAAID,EAAOA,EAAK,EAAE,EAAE,YAAY,EAAIA,EAAK,MAAM,CAAC,CAAE,CAAC,CACnF,KAAK,EAAE,EACV,MAAO,cAAc,KAAKH,CAAK,EAAIA,EAAQ,MAAMA,GACnD,CAUA,SAASK,EAAc,EAA2C,CAChE,IAAMC,EAAQC,EAAM,MAAM,GAC1B,GAAID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AgBD,EAAM,WAAW,YAAYD,EAAO,aACpD,GACA,gBAAgBC,EAAM,WAAW,8BACjC,aAAaA,EAAM,WAAW,SAC9B,gBAAgBA,EAAM,SAAS,IAC/B,gBAAgBE,EAAO,UAAU,GACjC,uCACA,MACA,EACF,CACF,CAEA,SAASC,EAAa,EAAuB,EAAwB,EAA0C,CAC7G,IAAMC,EAASpB,EAASE,CAAK,EAC7B,GAAIkB,EAAO,SAAW,EAUtB,MAAO,GAAG,CAPR,4DACA,GAAGF,EAAO,QACV,GACA,uBAAuBV,EAAgBa,EAAQ,UAAA,WAAyB,EAAE,IAC1E,GACA,GAAGD,EAAO,QAAS,GAAUN,EAAYE,EAAOE,CAAM,CAAC,CAE3C,CAAC,CAAC,KAAK;CAAI,CAAC,CAAC,QAAQ,QAAS,EAAE,EAAE,GAClD,CAQA,SAAgBI,EAAgB,EAAuB,EAA4C,CACjG,OAAOH,EAAajB,EAAOmB,EAAST,CAAc,CACpD,CASA,SAAgBW,EAAsB,EAAuB,EAA4C,CACvG,OAAOJ,EAAajB,EAAOmB,EAASR,CAAa,CACnD"}
|
|
@@ -2,6 +2,6 @@ const e=require("../resolveTarget/index.cjs"),t=require("../identity/index.cjs")
|
|
|
2
2
|
`)}function u(){return[`type ManyFactory<T, C> = (context: C) => T | readonly T[];`,`const many = <T, C>(value: T | readonly T[] | ManyFactory<T, C>, context: C): readonly T[] => {`,` const resolved = typeof value === 'function' ? (value as ManyFactory<T, C>)(context) : value;`,` return Array.isArray(resolved) ? resolved : [resolved as T];`,`};`].join(`
|
|
3
3
|
`)}function d(){return[`/* v8 ignore next -- generated normalization branch */`,`const defined = <T>(values: readonly (T | undefined)[]): T[] =>`,` values.filter((value): value is T => value !== undefined);`].join(`
|
|
4
4
|
`)}const f=[`const via = <T>(identity: Record<string, unknown>, value: unknown): T =>`,` (value === undefined ? undefined : { ...identity, ...(value as object) }) as T;`].join(`
|
|
5
|
-
`);function p(e,n){return n===void 0?{id:t.toKebab(e)}:{slot:n,id:t.toKebab(e)}}const m={tool:e=>({name:t.toSnake(e)}),command:e=>({name:t.toKebab(e)}),channel:e=>({frameType:t.toSnake(e)}),hook:e=>({event:t.toSnake(e)}),mode:e=>({name:t.toKebab(e)})},h={tool:e=>({tools:[t.toSnake(e)]}),channel:e=>({channel:t.toSnake(e)}),slot:(e,n)=>({slot:`${n.pluginId}.${t.toKebab(e)}`}),command:e=>({id:t.toKebab(e)}),tab:e=>({id:t.toKebab(e)}),template:e=>({id:t.toKebab(e)}),dock:e=>({id:t.toKebab(e)}),setting:e=>({id:t.toKebab(e)}),action:e=>({id:t.toKebab(e)}),mode:e=>({name:t.toKebab(e)}),"activity-group":e=>({name:t.toKebab(e)}),"selection-axis":e=>({name:t.toKebab(e)}),leader:(e,n)=>({id:`${n.pluginId}.${t.toKebab(e)}`})};function g(t,n,r){let{entry:i}=t,a=i.surface;if(a!==void 0)return e.isFrontendTarget(n)?a===`fill`?p(i.name,i.target):h[a]?.(i.name,r):m[a]?.(i.name)}function _(e,t){let n=e.join(`-`).split(/[^A-Za-z0-9]+/u).filter(e=>e.length>0).map((e,t)=>t===0?e:e[0]?.toUpperCase()+e.slice(1)).join(``),r=/^[A-Za-z_]/u.test(n)?n:`x${n}`,i=r,a=2;for(;t.has(i);)i=`${r}${a++}`;return t.add(i),i}function v(e,t){return _([e.entry.surface??`extra`,e.entry.name],t)}function y(e,t){let r=e.replace(/\.[^.]+$/u,``),i=n.posix.relative(t,r);return i.startsWith(`.`)?i:`./${i}`}function b(e){return JSON.stringify(e).replaceAll(`<`,`\\u003c`).replaceAll(`\u2028`,`\\u2028`).replaceAll(`\u2029`,`\\u2029`)}function x(e,t){let n=/* @__PURE__ */ new Set;return[...e.contributions].sort((e,t)=>e.entry.file.localeCompare(t.entry.file)).map(r=>{let i=v(r,n),a=e.target===`mcp`?t.mcpWidgets?.[r.entry.file]:void 0;if(a!==void 0&&!/^(?:@[a-z0-9][a-z0-9._-]*\/)?[a-z0-9][a-z0-9._-]*\/[a-z0-9_]+$/u.test(a))throw Error(`Invalid MCP widget key '${a}'`);return{identifier:i,contribution:r,identity:g(r,e.target,t),mcpWidget:a}})}const S={global:0,workspace:1,session:2};function C(e){return e.map(e=>{let t=e.scope[0]?.toUpperCase()+e.scope.slice(1);return{identifier:`root${t}`,declaration:`scope${t}`,context:`context${t}`,entry:e}})}function w(e,t,n){let r=[],i=t;for(let[
|
|
6
|
-
`)}function
|
|
5
|
+
`);function p(e,n){return n===void 0?{id:t.toKebab(e)}:{slot:n,id:t.toKebab(e)}}const m={tool:e=>({name:t.toSnake(e)}),command:e=>({name:t.toKebab(e)}),channel:e=>({frameType:t.toSnake(e)}),hook:e=>({event:t.toSnake(e)}),mode:e=>({name:t.toKebab(e)})},h={tool:e=>({tools:[t.toSnake(e)]}),channel:e=>({channel:t.toSnake(e)}),slot:(e,n)=>({slot:`${n.pluginId}.${t.toKebab(e)}`}),command:e=>({id:t.toKebab(e)}),tab:e=>({id:t.toKebab(e)}),template:e=>({id:t.toKebab(e)}),dock:e=>({id:t.toKebab(e)}),setting:e=>({id:t.toKebab(e)}),action:e=>({id:t.toKebab(e)}),mode:e=>({name:t.toKebab(e)}),"activity-group":e=>({name:t.toKebab(e)}),"selection-axis":e=>({name:t.toKebab(e)}),leader:(e,n)=>({id:`${n.pluginId}.${t.toKebab(e)}`})};function g(t,n,r){let{entry:i}=t,a=i.surface;if(a!==void 0)return e.isFrontendTarget(n)?a===`fill`?p(i.name,i.target):h[a]?.(i.name,r):m[a]?.(i.name)}function _(e,t){let n=e.join(`-`).split(/[^A-Za-z0-9]+/u).filter(e=>e.length>0).map((e,t)=>t===0?e:e[0]?.toUpperCase()+e.slice(1)).join(``),r=/^[A-Za-z_]/u.test(n)?n:`x${n}`,i=r,a=2;for(;t.has(i);)i=`${r}${a++}`;return t.add(i),i}function v(e,t){return _([e.entry.surface??`extra`,e.entry.name],t)}function y(e,t){let r=e.replace(/\.[^.]+$/u,``),i=n.posix.relative(t,r);return i.startsWith(`.`)?i:`./${i}`}function b(e){return JSON.stringify(e).replaceAll(`<`,`\\u003c`).replaceAll(`\u2028`,`\\u2028`).replaceAll(`\u2029`,`\\u2029`)}function x(e,t){let n=/* @__PURE__ */ new Set;return[...e.contributions].sort((e,t)=>e.entry.file.localeCompare(t.entry.file)).map(r=>{let i=v(r,n),a=e.target===`mcp`?t.mcpWidgets?.[r.entry.file]:void 0;if(a!==void 0&&!/^(?:@[a-z0-9][a-z0-9._-]*\/)?[a-z0-9][a-z0-9._-]*\/[a-z0-9_]+$/u.test(a))throw Error(`Invalid MCP widget key '${a}'`);return{identifier:i,contribution:r,identity:g(r,e.target,t),mcpWidget:a}})}const S={global:0,workspace:1,session:2};function C(e){return e.map(e=>{let t=e.scope[0]?.toUpperCase()+e.scope.slice(1);return{identifier:`root${t}`,declaration:`scope${t}`,context:`context${t}`,entry:e}})}function w(e,t,n){let r=[],i=t;for(let[a,o]of e.entries())r.push(`const ${o.declaration} = await ${t}.scopeRoot('${o.entry.scope}', ${o.identifier}, ${i});`),(a<e.length-1||n.some(e=>e.includes(o.context)))&&r.push(`const ${o.context} = { ...${i}, root: ${o.declaration}.value };`),i=o.context;return r}function T(e,t,n){let r=n;for(let n of e)S[n.entry.scope]<=S[t]&&(r=n.context);return r}function E(e,t,n){let r=e.contribution.entry.scope;if(S[r]>=S[n])return;let{field:i}=e.contribution;return i===`channels`||t.some(e=>S[e.entry.scope]<=S[r])&&(i===`api`||i===`methods`)?r:void 0}function D(e,t){if(t===void 0)return e;let n=`context.hosted('${t}')`;return e.startsWith(`...`)?`...(${n} ? [] : ${e.slice(3)})`:`${n} ? undefined : ${e}`}function O(e){let{entry:n,field:r}=e.contribution;if(r===`hooks`)return;let i=n.gates.map(e=>`${e.kind}:${e.id}`).join(`/`);return r===`api`?`${i}|api|${n.route.map(e=>`literal`in e?e.literal:`[${e.param.name}]`).join(`/`)}`:e.identity===void 0?void 0:`${i}|${r}|${t.renderIdentity(e.identity)}`}function k(e){let t=/* @__PURE__ */ new Map;for(let n of e){let e=O(n);e!==void 0&&t.set(e,Math.max(t.get(e)??-1,S[n.contribution.entry.scope]))}return e.filter(e=>{let n=O(e);return n===void 0||t.get(n)===S[e.contribution.entry.scope]})}function A(e){return[...e].sort((e,t)=>e.file.localeCompare(t.file)).map((e,t)=>({identifier:`extra${t===0?``:t+1}`,entry:e}))}function j(e){let t=/* @__PURE__ */ new Set;return e.map(e=>({identifier:_([`contract`,e.name],t),entry:e}))}function M(n,r,i){if(o.includes(n.contribution.field))return`${n.identifier}(${r})`;let s=e.isFrontendTarget(i)?n.identifier:`at(${n.identifier}, ${r})`,c=a[i].includes(n.contribution.field);if(n.contribution.entry.cardinality===`collection`)return s;if(n.identity===void 0)return c?n.identifier:s;let l=t.renderIdentity(n.identity);if(c)return`() => via({ ${l} }, ${n.identifier}())`;let u=`via({ ${l} }, ${s})`;return n.mcpWidget===void 0?u:`withWidget(${b(n.mcpWidget)}, ${u})`}function N(e){return`import { ${[`defineServerPlugin`,...e.some(e=>e.includes(`get `))?[`type PoServerSessionPlugin`]:[]].join(`, `)} } from '@agimon-ai/po-core/serverPlugin';`}function P(e,t,n){if(e===`services`||t.startsWith(`...`))return t;let[r,...i]=t.split(`: `);return`get ${r}(): ${`${c[n]}['${r}']`} { return ${i.join(`: `).replace(/,$/u,``)}; },`}function F(e,t,n,r,a=()=>void 0){let o=/* @__PURE__ */ new Map;for(let t of e){let e=o.get(t.contribution.field);e===void 0?o.set(t.contribution.field,[t]):e.push(t)}let s=[];for(let e of[...o.keys()].sort()){let c=o.get(e);if(i.includes(e)){let i=c[0];if(i){let a=M(i,n(i),r);s.push(`${t}${P(e,`${e}: ${a},`,r)}`)}continue}let l=`[${c.map(e=>D(e.contribution.entry.cardinality===`many`?`...many(${e.identifier}, ${n(e)})${e.mcpWidget===void 0?``:`.map((tool) => withWidget(${b(e.mcpWidget)}, tool))`}`:M(e,n(e),r),a(e))).join(`, `)}]`,u=c.some(e=>e.contribution.entry.cardinality===`optional`||e.contribution.entry.cardinality!==`many`&&a(e)!==void 0)?`defined(${l})`:l;s.push(`${t}${P(e,`${e}: ${u},`,r)}`)}return s}function I(e,t,n,r,i){if(t.length===0)return[...e];let a=[...e],o=a.findIndex(e=>e.startsWith(`${r}services: [`)),s=o<0?``:a.splice(o,1)[0]?.match(/services: \[(.*)\],$/u)?.[1]??``,c=[...t.map(e=>`...(${e.declaration}.services ?? [])`),s].filter(Boolean).join(`, `);if(a.push(`${r}services: [${c}],`),n===`server`&&i===`session`){let e=a.findIndex(e=>e.startsWith(`${r}get activities()`)),n=e<0?``:a.splice(e,1)[0]?.match(/return \[(.*)\]; \},$/u)?.[1]??``,i=[...t.map(e=>`...(${e.declaration}.activities ?? [])`),n].filter(Boolean).join(`, `);a.push(`${r}get activities(): PoServerSessionPlugin['activities'] { return [${i}]; },`)}return a}function L(e,t,n,r,i=[]){return[...n.map(e=>`import ${e.identifier} from '${y(e.entry.file,r)}';`),...i.map(e=>`import ${e.identifier} from '${y(e.entry.file,r)}';`),...e.map(e=>`import ${e.identifier} from '${y(e.contribution.entry.file,r)}';`),...t.map(e=>`import ${e.identifier} from '${y(e.entry.file,r)}';`)]}function R(e){return e.filter((e,t,n)=>e!==``||n[t-1]!==``).join(`
|
|
6
|
+
`)}function z(e){let t=[];return e.some(e=>e.includes(`at(`))&&t.push(l()),e.some(e=>e.includes(`many(`))&&t.push(u()),e.some(e=>e.includes(`defined(`))&&t.push(d()),e.some(e=>e.includes(`via(`))&&t.push(f),t.length>0?[...t,``]:[]}function B(e){return e.some(e=>/\bcontext[.,)]/u.test(e))?`(context)`:`()`}function V(e,t,n,r){let i=[...t===void 0?[]:[`${r} ${t}`],...n],a=[...e,...n].some(e=>e.includes(`await `))?`async `:``;return e.length===0?[`${a}${B(n)} => ({`,...i,`${r}}),`]:[`${a}${B([...e,...n])} => {`,...e.map(e=>`${r} ${e}`),`${r} return {`,...i.map(e=>` ${e}`),`${r} };`,`${r}},`]}function H(e){if(e.length!==0)return`...composeRootHooks(${e.map(e=>e.declaration).join(`, `)}),`}function U(e,t){let n=x(e,t),i=A(e.escapeHatches),a=C(e.roots),o=j(e.contracts),c=[],l=[],u=!1;for(let[e,t]of s.entries()){let r=k(n.filter(t=>s.indexOf(t.contribution.entry.scope)<=e)),o=i.filter(t=>s.indexOf(t.entry.scope)<=e),d=a.filter(t=>s.indexOf(t.entry.scope)<=e),f=d[d.length-1]?.context??`context`,p=[...I(F(r,` `,e=>T(d,e.contribution.entry.scope,`context`),`server`,e=>E(e,d,t)),d,`server`,` `,t),...o.map(e=>` ...await at(${e.identifier}, ${f}),`)];if(p.length===0&&d.length===0)continue;d.length>0&&(u=!0,l.push(`${t}: [${d.map(e=>e.identifier).join(`, `)}]`));let m=V(w(d,`context`,p),H(d),p,` `);c.push(` ${t}: ${m[0]}`,...m.slice(1))}let d=s.flatMap(e=>{let t=o.filter(t=>t.entry.scope===e);return t.length===0?[]:[` ${e}: [${t.map(e=>e.identifier).join(`, `)}],`]});return R([r,N(c),...a.length?[`import { composeServerProviderOverrides } from '@agimon-ai/po-core/serverPlugin';`]:[],...u?[`import { composeRootHooks, composeRootInjects } from '@agimon-ai/po-core/extensionFile';`]:[],``,...L(n,i,a,t.entryDir,o),``,...z(c),`export const serverPlugin = defineServerPlugin({`,` name: '${t.packageName}',`,...a.length?[` providerOverrides: composeServerProviderOverrides(${a.map(e=>e.identifier).join(`, `)}),`]:[],...d.length>0?[` provides: {`,...d,` },`]:[],...l.length>0?[` injects: composeRootInjects({ ${l.join(`, `)} }),`]:[],...c,`});`,``,`export default serverPlugin;`,``])}function W(e,t){let n=x(e,t),i=F(n,` `,()=>`context`,`mcp`);return R([r,`import { defineMcpPlugin, type PoMcpSessionPlugin } from '@agimon-ai/po-core/mcpFacet';`,``,...L(n,[],[],t.entryDir),``,...z(i),...n.some(e=>e.mcpWidget!==void 0)?[`const withWidget = <T>(key: string, value: T): T => value === undefined ? value : ({`,` ...value, _meta: { ...(value as { _meta?: object })._meta, ["po/widget"]: key },`,`});`,``]:[],`export const mcp = defineMcpPlugin({`,` name: '${t.packageName}',`,` session: (context) => ({`,...i,` }) satisfies PoMcpSessionPlugin,`,`});`,``,`export default mcp;`,``])}const G={web:{module:`@agimon-ai/po-core/web`,define:`defineWebPlugin`,exportName:`webPlugin`},native:{module:`@agimon-ai/po-core/native`,define:`defineNativePlugin`,exportName:`nativePlugin`}};function K(e,t,n){let i=G[n],a=x(e,t),o=A(e.escapeHatches),l=[];for(let e of s){let t=a.filter(t=>t.contribution.entry.scope===e),r=o.filter(t=>t.entry.scope===e),i=[...F(t,` `,()=>`undefined`,n),...r.map(e=>` ...${e.identifier},`)];i.length!==0&&l.push(` ${e}: {`,...i,` },`)}let u=l.some(e=>e.includes(`get `))?`${i.define}, type ${c[n]}`:i.define;return R([r,`import { ${u} } from '${i.module}';`,``,...L(a,o,[],t.entryDir),``,...z(l),`export const ${i.exportName} = ${i.define}({`,` id: '${t.pluginId}',`,...l,`});`,``])}function q(e,t){return K(e,t,`web`)}function J(e,t){return K(e,t,`native`)}exports.renderMcpEntry=W,exports.renderNativeEntry=J,exports.renderServerEntry=U,exports.renderWebEntry=q;
|
|
7
7
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["toKebab","toSnake","isFrontendTarget","posix","renderIdentity","require_index","require_index$1","node_path","HEADER","SINGLETON_FIELDS","FACTORY_FIELDS","ALWAYS_FACTORY_FIELDS","SCOPE_ORDER","CONTRIBUTIONS_TYPE","resolver","manyResolver","definedResolver","IDENTITY_HELPER","fillIdentity","target","name","BACKEND_IDENTITY","FRONTEND_IDENTITY","options","identityFor","contribution","surface","entry","uniqueIdentifier","head","parts","word","index","base","candidate","suffix","taken","identifierFor","specifierFor","file","relative","entryDir","widgetLiteral","key","bind","resolution","left","right","identifier","mcpWidget","DEPTH","rootBindings","entries","rootPrologue","lines","enclosing","root","roots","body","line","contextForScope","found","scope","hatchBindings","member","binding","contextExpression","resolved","isFactory","identity","value","serverImport","scopes","defer","field","rendered","bodyFor","grouped","bindings","held","members","contextOf","indent","withRootRegistrations","servicesIndex","routedServices","services","activitiesIndex","routedActivities","activities","importsFor","r","b","hatches","h","compact","all","resolverFor","parameterFor","scopeBody","object","hooks","prefix","prologue","rootHooks","renderServerEntry","allRoots","usesRoots","visible","here","innermost","hatch","factory","renderMcpEntry","FRONTEND_ENTRY","renderFrontendEntry","shape","names","renderWebEntry","renderNativeEntry"],"sources":["../../../src/services/renderEntry/index.ts"],"sourcesContent":["import { posix } from 'node:path';\n\nimport type { ExtensionEntry, ExtensionScope } from '../../types/extensionGraph';\nimport { type Identity, renderIdentity, toKebab, toSnake } from '../identity';\nimport { isFrontendTarget } from '../resolveTarget';\nimport type { BuildTarget, FrontendTarget, ResolvedContribution, TargetResolution } from '../resolveTarget/type';\nimport type { RenderOptions } from './type';\n\nconst HEADER = '// Generated by @agimon-ai/po-build. Do not edit by hand.';\n\n/** Fields that accept one declaration rather than an array of declarations. */\nconst SINGLETON_FIELDS: readonly string[] = ['fileLinks', 'repositorySettingsPanel', 'start'];\n\n/**\n * Fields whose members are factories rather than declarations.\n *\n * Keyed by target, not by field name alone, because `channels` means two\n * different things. A server facet's array holds `() => PoHubChannel`, so\n * the host can build one per mount. The cockpit's holds the contribution\n * itself. Treating them alike called a plain object as a function.\n */\nconst FACTORY_FIELDS: Readonly<Record<BuildTarget, readonly string[]>> = {\n server: ['channels'],\n web: [],\n native: [],\n mcp: [],\n};\n\n/**\n * Fields whose member is always a factory of the value, never the value.\n *\n * A Cordis plugin is itself a function, so nothing at runtime separates one\n * from a `(context) => plugin` factory. Rather than guess, the service surface\n * is uniformly a factory and is always called. That is also what lets a\n * package with shared per-mount state decompose: the service builds the graph\n * from the mount and publishes it, and every other contribution is a getter,\n * so it is built after the service fibers are up and can inject it.\n */\nconst ALWAYS_FACTORY_FIELDS: readonly string[] = ['services'];\n\nconst SCOPE_ORDER: readonly ExtensionScope[] = ['global', 'workspace', 'session'];\n\n/**\n * Resolves a routed file's default export, which may be the declaration or a\n * factory of one. Both host helpers already accept either shape, so a\n * generated entry has to as well. Emitted rather than imported, so a generated\n * entry carries no runtime dependency beyond the helper it is calling.\n */\n/** The contribution set each host reads, used to annotate the emitted getters. */\nconst CONTRIBUTIONS_TYPE: Readonly<Record<BuildTarget, string>> = {\n server: 'PoServerSessionPlugin',\n web: 'WebPluginContributions',\n // The native app reuses the cockpit's plugin registry, so its contributions\n // are the same type, re-exported from the native SDK.\n native: 'WebPluginContributions',\n mcp: 'PoMcpSessionPlugin',\n};\n\n/**\n * Resolves a routed file's default export without imposing one host context on\n * every factory. The generated mount supplies the concrete context, and `at`\n * preserves that type while still accepting declaration objects.\n */\nfunction resolver(): string {\n return [\n 'type Factory<T, C> = (context: C) => T;',\n 'const at = <T, C>(value: T | Factory<T, C>, context: C): T =>',\n \" typeof value === 'function' ? (value as Factory<T, C>)(context) : value;\",\n ].join('\\n');\n}\n\n/** Resolves a zero-many catalog contribution without flattening tuple declarations. */\nfunction manyResolver(): string {\n return [\n 'type ManyFactory<T, C> = (context: C) => T | readonly T[];',\n 'const many = <T, C>(value: T | readonly T[] | ManyFactory<T, C>, context: C): readonly T[] => {',\n \" const resolved = typeof value === 'function' ? (value as ManyFactory<T, C>)(context) : value;\",\n ' return Array.isArray(resolved) ? resolved : [resolved as T];',\n '};',\n ].join('\\n');\n}\n\nfunction definedResolver(): string {\n return [\n '/* v8 ignore next -- generated normalization branch */',\n 'const defined = <T>(values: readonly (T | undefined)[]): T[] =>',\n ' values.filter((value): value is T => value !== undefined);',\n ].join('\\n');\n}\n\n/**\n * Applies the identity the path derived, letting the authored value win.\n *\n * A call rather than an object literal on purpose. `{ name: 'x', ...value }`\n * is what this means, but TypeScript reports TS2783 whenever the spread's type\n * also declares the key, which is the common case here.\n *\n * The parameters are deliberately untyped so `T` is inferred from the\n * contribution array this sits in rather than from either argument: the\n * authored file supplies only the half the path cannot. The cost is that the\n * merged shape is not checked against `T`, only its position is.\n */\n// Preserve absence before applying a path-derived name. Otherwise optional routes\n// become incomplete placeholder tools or hooks that the `defined` filter cannot remove.\nconst IDENTITY_HELPER = [\n 'const via = <T>(identity: Record<string, unknown>, value: unknown): T =>',\n ' (value === undefined ? undefined : { ...identity, ...(value as object) }) as T;',\n].join('\\n');\n\n/**\n * Every fill is a slot fill. There is no host-region special case.\n *\n * The cockpit's own regions are slots like any other: an activity section\n * already renders into `activity.<group>`, which is why naming the target\n * directly works for a host region and a plugin's slot alike. Keeping this\n * uniform is what lets a layout package declare new regions without the build\n * tooling learning about them.\n */\nfunction fillIdentity(name: string, target: string | undefined): Identity {\n if (target === undefined) return { id: toKebab(name) };\n return { slot: target, id: toKebab(name) };\n}\n\n/** What the path can tell each host, keyed by the folder the author typed. */\nconst BACKEND_IDENTITY: Readonly<Record<string, (name: string) => Identity>> = {\n tool: (name) => ({ name: toSnake(name) }),\n // Kebab, unlike a tool. A command name is what the user types after the\n // slash and it reaches registerCommand verbatim, so `subagents-doctor` must\n // stay `/subagents-doctor` rather than becoming `/subagents_doctor`.\n command: (name) => ({ name: toKebab(name) }),\n channel: (name) => ({ frameType: toSnake(name) }),\n hook: (name) => ({ event: toSnake(name) }),\n mode: (name) => ({ name: toKebab(name) }),\n};\n\nconst FRONTEND_IDENTITY: Readonly<Record<string, (name: string, options: RenderOptions) => Identity>> = {\n tool: (name) => ({ tools: [toSnake(name)] }),\n channel: (name) => ({ channel: toSnake(name) }),\n slot: (name, options) => ({ slot: `${options.pluginId}.${toKebab(name)}` }),\n command: (name) => ({ id: toKebab(name) }),\n tab: (name) => ({ id: toKebab(name) }),\n template: (name) => ({ id: toKebab(name) }),\n dock: (name) => ({ id: toKebab(name) }),\n setting: (name) => ({ id: toKebab(name) }),\n action: (name) => ({ id: toKebab(name) }),\n mode: (name) => ({ name: toKebab(name) }),\n 'activity-group': (name) => ({ name: toKebab(name) }),\n 'selection-axis': (name) => ({ name: toKebab(name) }),\n // A leader binding's id is namespaced like a slot, because the key tree is\n // shared and two plugins must not collide on one path's identity.\n leader: (name, options) => ({ id: `${options.pluginId}.${toKebab(name)}` }),\n};\n\n/**\n * What the path knows about a contribution's identity.\n *\n * Keyed by surface, because the folder is what the author types. A surface\n * absent from the table, or an identity the path cannot supply such as a tab's\n * human label, is left entirely to the authored file.\n */\nfunction identityFor(\n contribution: ResolvedContribution,\n target: BuildTarget,\n options: RenderOptions,\n): Identity | undefined {\n const { entry } = contribution;\n const surface = entry.surface;\n if (surface === undefined) return undefined;\n\n if (!isFrontendTarget(target)) return BACKEND_IDENTITY[surface]?.(entry.name);\n if (surface === 'fill') return fillIdentity(entry.name, entry.target);\n return FRONTEND_IDENTITY[surface]?.(entry.name, options);\n}\n\n/** A stable, unique, valid identifier built from path words. */\nfunction uniqueIdentifier(parts: readonly string[], taken: Set<string>): string {\n const words = parts\n .join('-')\n .split(/[^A-Za-z0-9]+/u)\n .filter((word) => word.length > 0);\n const head = words.map((word, index) => (index === 0 ? word : word[0]?.toUpperCase() + word.slice(1))).join('');\n const base = /^[A-Za-z_]/u.test(head) ? head : `x${head}`;\n let candidate = base;\n let suffix = 2;\n while (taken.has(candidate)) candidate = `${base}${suffix++}`;\n taken.add(candidate);\n return candidate;\n}\n\n/** A stable, unique, valid identifier: surface and name, disambiguated by scope when needed. */\nfunction identifierFor(contribution: ResolvedContribution, taken: Set<string>): string {\n return uniqueIdentifier([contribution.entry.surface ?? 'extra', contribution.entry.name], taken);\n}\n\n/** The extensionless relative specifier from a generated entry to a routed file. */\nfunction specifierFor(file: string, entryDir: string): string {\n const target = file.replace(/\\.[^.]+$/u, '');\n const relative = posix.relative(entryDir, target);\n return relative.startsWith('.') ? relative : `./${relative}`;\n}\n\ninterface Binding {\n readonly identifier: string;\n readonly contribution: ResolvedContribution;\n readonly identity: Identity | undefined;\n readonly mcpWidget: string | undefined;\n}\n\n/** Encode data for generated JavaScript, including the HTML script boundary. */\nfunction widgetLiteral(key: string): string {\n return JSON.stringify(key).replaceAll('<', '\\\\u003c').replaceAll('\\u2028', '\\\\u2028').replaceAll('\\u2029', '\\\\u2029');\n}\n\nfunction bind(resolution: TargetResolution, options: RenderOptions): Binding[] {\n const taken = new Set<string>();\n return [...resolution.contributions]\n .sort((left, right) => left.entry.file.localeCompare(right.entry.file))\n .map((contribution) => {\n // The contribution takes its identifier first, so the plain name stays\n // with the tool rather than going to whichever file sorted earlier.\n const identifier = identifierFor(contribution, taken);\n const mcpWidget = resolution.target === 'mcp' ? options.mcpWidgets?.[contribution.entry.file] : undefined;\n if (mcpWidget !== undefined && !/^(?:@[a-z0-9][a-z0-9._-]*\\/)?[a-z0-9][a-z0-9._-]*\\/[a-z0-9_]+$/u.test(mcpWidget))\n throw new Error(`Invalid MCP widget key '${mcpWidget}'`);\n return {\n identifier,\n contribution,\n identity: identityFor(contribution, resolution.target, options),\n mcpWidget,\n };\n });\n}\n\n/** Scope nesting depth, so a contribution can find the root that encloses it. */\nconst DEPTH: Readonly<Record<ExtensionScope, number>> = { global: 0, workspace: 1, session: 2 };\n\ninterface RootBinding {\n /** The imported factory. */\n readonly identifier: string;\n /** The declaration it returned: `value` plus this scope's lifecycle hooks. */\n readonly declaration: string;\n /** The mount context contributions beneath this root receive. */\n readonly context: string;\n readonly entry: ExtensionEntry;\n}\n\nfunction rootBindings(entries: readonly ExtensionEntry[]): RootBinding[] {\n return entries.map((entry) => {\n const suffix = entry.scope[0]?.toUpperCase() + entry.scope.slice(1);\n return { identifier: `root${suffix}`, declaration: `scope${suffix}`, context: `context${suffix}`, entry };\n });\n}\n\n/**\n * Constructs each scope before anything it contains, outermost first.\n *\n * Every root is handed the context its enclosing root produced. Root factories\n * may be async, so the generated host factory awaits each one before exposing\n * its value to narrower contributions.\n */\nfunction rootPrologue(roots: readonly RootBinding[], base: string, body: readonly string[]): string[] {\n const lines: string[] = [];\n let enclosing = base;\n for (const [index, root] of roots.entries()) {\n lines.push(`const ${root.declaration} = await ${root.identifier}(${enclosing});`);\n const contextIsUsed = index < roots.length - 1 || body.some((line) => line.includes(root.context));\n if (contextIsUsed) lines.push(`const ${root.context} = { ...${enclosing}, root: ${root.declaration}.value };`);\n enclosing = root.context;\n }\n return lines;\n}\n\n/** The context a contribution sees: the nearest enclosing root's, or the mount's. */\nfunction contextForScope(roots: readonly RootBinding[], scope: ExtensionScope, base: string): string {\n let found = base;\n for (const root of roots) {\n if (DEPTH[root.entry.scope] <= DEPTH[scope]) found = root.context;\n }\n return found;\n}\n\nfunction hatchBindings(entries: readonly ExtensionEntry[]): { identifier: string; entry: ExtensionEntry }[] {\n return [...entries]\n .sort((left, right) => left.file.localeCompare(right.file))\n .map((entry, index) => ({ identifier: `extra${index === 0 ? '' : index + 1}`, entry }));\n}\n\n/**\n * One contribution as it appears inside its array, identity first so the file wins.\n *\n * The browser half is never resolved. The cockpit builds its definition as\n * data and starts it separately, so a frontend file has no mount context to\n * receive, and resolving anyway would call any export that happens to be a\n * function. A React component is a function, so that is not hypothetical.\n */\nfunction member(binding: Binding, contextExpression: string, target: BuildTarget): string {\n if (ALWAYS_FACTORY_FIELDS.includes(binding.contribution.field)) {\n return `${binding.identifier}(${contextExpression})`;\n }\n\n const resolved = isFrontendTarget(target) ? binding.identifier : `at(${binding.identifier}, ${contextExpression})`;\n const isFactory = FACTORY_FIELDS[target].includes(binding.contribution.field);\n // A live collection is the contribution container itself. Applying a path\n // identity would spread class instances into plain objects and can erase\n // prototype-backed snapshot/subscribe methods.\n if (binding.contribution.entry.cardinality === 'collection') return resolved;\n if (binding.identity === undefined) return isFactory ? binding.identifier : resolved;\n\n const identity = renderIdentity(binding.identity);\n // A channel array holds factories, so the identity is applied inside one.\n if (isFactory) return `() => via({ ${identity} }, ${binding.identifier}())`;\n const value = `via({ ${identity} }, ${resolved})`;\n return binding.mcpWidget === undefined ? value : `withWidget(${widgetLiteral(binding.mcpWidget)}, ${value})`;\n}\n\n/** The server entry imports only the types its scopes actually use. */\nfunction serverImport(scopes: readonly string[]): string {\n const types = scopes.some((line) => line.includes('get ')) ? ['type PoServerSessionPlugin'] : [];\n return `import { ${['defineServerPlugin', ...types].join(', ')} } from '@agimon-ai/po-core/serverFacet';`;\n}\n\n/**\n * Emits a contribution as a getter, so it is built after services mount.\n *\n * Both host helpers register `services` first and read every other field\n * afterwards. A plain property would be evaluated when the entry's factory\n * returns, which is before any service exists, so a routed file could never\n * inject one at construction and every package with shared per-mount state\n * would be stuck in one closure.\n *\n * `services` itself stays a plain property: it is what the helper reads first,\n * and a getter for it would buy nothing.\n */\nfunction defer(field: string, rendered: string, target: BuildTarget): string {\n if (field === 'services' || rendered.startsWith('...')) return rendered;\n const [name, ...value] = rendered.split(': ');\n // Annotated, because a getter gets no contextual type from the object\n // literal it sits in, so the identity helper's T would widen to unknown and\n // the contribution would stop type checking against the array it joins.\n const type = `${CONTRIBUTIONS_TYPE[target]}['${name}']`;\n return `get ${name}(): ${type} { return ${value.join(': ').replace(/,$/u, '')}; },`;\n}\n\n/**\n * The contributions object's body.\n *\n * The mount context is resolved per contribution rather than once, because a\n * root rebinds it for everything beneath it and two contributions at different\n * scopes can therefore see different contexts in the same object.\n */\nfunction bodyFor(\n bindings: readonly Binding[],\n indent: string,\n contextOf: (binding: Binding) => string,\n target: BuildTarget,\n): string[] {\n const grouped = new Map<string, Binding[]>();\n for (const binding of bindings) {\n const held = grouped.get(binding.contribution.field);\n if (held === undefined) grouped.set(binding.contribution.field, [binding]);\n else held.push(binding);\n }\n\n const lines: string[] = [];\n for (const field of [...grouped.keys()].sort()) {\n const members = grouped.get(field) as Binding[];\n if (SINGLETON_FIELDS.includes(field)) {\n const entry = members[0];\n if (entry) {\n const rendered = member(entry, contextOf(entry), target);\n lines.push(`${indent}${defer(field, `${field}: ${rendered},`, target)}`);\n }\n continue;\n }\n const renderedMembers = members.map((entry) =>\n entry.contribution.entry.cardinality === 'many'\n ? `...many(${entry.identifier}, ${contextOf(entry)})${entry.mcpWidget === undefined ? '' : `.map((tool) => withWidget(${widgetLiteral(entry.mcpWidget)}, tool))`}`\n : member(entry, contextOf(entry), target),\n );\n const entries = `[${renderedMembers.join(', ')}]`;\n const rendered = members.some((entry) => entry.contribution.entry.cardinality === 'optional')\n ? `defined(${entries})`\n : entries;\n lines.push(`${indent}${defer(field, `${field}: ${rendered},`, target)}`);\n }\n return lines;\n}\n\n/** Root-owned registrations join routed registrations in the host's usual fields. */\nfunction withRootRegistrations(\n body: readonly string[],\n roots: readonly RootBinding[],\n target: 'server',\n indent: string,\n scope: ExtensionScope,\n): string[] {\n if (roots.length === 0) return [...body];\n const lines = [...body];\n const servicesIndex = lines.findIndex((line) => line.startsWith(`${indent}services: [`));\n const routedServices =\n servicesIndex < 0 ? '' : (lines.splice(servicesIndex, 1)[0]?.match(/services: \\[(.*)\\],$/u)?.[1] ?? '');\n const services = [...roots.map((root) => `...(${root.declaration}.services ?? [])`), routedServices]\n .filter(Boolean)\n .join(', ');\n lines.push(`${indent}services: [${services}],`);\n\n if (target === 'server' && scope === 'session') {\n const activitiesIndex = lines.findIndex((line) => line.startsWith(`${indent}get activities()`));\n const routedActivities =\n activitiesIndex < 0 ? '' : (lines.splice(activitiesIndex, 1)[0]?.match(/return \\[(.*)\\]; \\},$/u)?.[1] ?? '');\n const activities = [...roots.map((root) => `...(${root.declaration}.activities ?? [])`), routedActivities]\n .filter(Boolean)\n .join(', ');\n lines.push(`${indent}get activities(): PoServerSessionPlugin['activities'] { return [${activities}]; },`);\n }\n return lines;\n}\n\nfunction importsFor(\n bindings: readonly Binding[],\n hatches: readonly { identifier: string; entry: ExtensionEntry }[],\n roots: readonly RootBinding[],\n entryDir: string,\n): string[] {\n return [\n ...roots.map((r) => `import ${r.identifier} from '${specifierFor(r.entry.file, entryDir)}';`),\n ...bindings.map((b) => `import ${b.identifier} from '${specifierFor(b.contribution.entry.file, entryDir)}';`),\n ...hatches.map((h) => `import ${h.identifier} from '${specifierFor(h.entry.file, entryDir)}';`),\n ];\n}\n\nfunction compact(lines: readonly string[]): string {\n return lines.filter((line, index, all) => !(line === '' && all[index - 1] === '')).join('\\n');\n}\n\n/**\n * Emits the resolver only when something calls it.\n *\n * Extension packages compile with noUnusedLocals, so a generated entry whose\n * every contribution is a factory would otherwise fail to typecheck on an\n * unused helper.\n */\nfunction resolverFor(body: readonly string[]): string[] {\n const lines: string[] = [];\n if (body.some((line) => line.includes('at('))) lines.push(resolver());\n if (body.some((line) => line.includes('many('))) lines.push(manyResolver());\n if (body.some((line) => line.includes('defined('))) lines.push(definedResolver());\n if (body.some((line) => line.includes('via('))) lines.push(IDENTITY_HELPER);\n return lines.length > 0 ? [...lines, ''] : [];\n}\n\n/** `noUnusedParameters` means a scope that never threads context takes none. */\nfunction parameterFor(lines: readonly string[]): string {\n return lines.some((line) => line.includes(', context)') || line.includes('(context)')) ? '(context)' : '()';\n}\n\n/**\n * The scope's factory: an expression body, or a block when roots come first.\n *\n * A root has to be constructed before the object that reads it, so a scope\n * that has one becomes statements followed by a return rather than a bare\n * object literal.\n */\nfunction scopeBody(\n prologue: readonly string[],\n hooks: string | undefined,\n body: readonly string[],\n indent: string,\n): string[] {\n const object = [...(hooks === undefined ? [] : [`${indent} ${hooks}`]), ...body];\n const asynchronous = [...prologue, ...body].some((line) => line.includes('await '));\n const prefix = asynchronous ? 'async ' : '';\n if (prologue.length === 0) return [`${prefix}${parameterFor(body)} => ({`, ...object, `${indent}}),`];\n return [\n `${prefix}${parameterFor([...prologue, ...body])} => {`,\n ...prologue.map((line) => `${indent} ${line}`),\n `${indent} return {`,\n ...object.map((line) => ` ${line}`),\n `${indent} };`,\n `${indent}},`,\n ];\n}\n\n/** Folds every enclosing root's lifecycle hooks into the one set the host reads. */\nfunction rootHooks(roots: readonly RootBinding[]): string | undefined {\n if (roots.length === 0) return undefined;\n return `...composeRootHooks(${roots.map((root) => root.declaration).join(', ')}),`;\n}\n\n/**\n * The headless entry, one declaration per scope.\n *\n * Contributions cascade downward here because the server does not do it\n * itself: a facet reads exactly one `plugin[host.scope]` and nothing from the\n * scopes above it. Emitting the repetition is what lets an author declare a\n * channel once and have it mount at all three scopes.\n */\nexport function renderServerEntry(resolution: TargetResolution, options: RenderOptions): string {\n const bindings = bind(resolution, options);\n const hatches = hatchBindings(resolution.escapeHatches);\n const allRoots = rootBindings(resolution.roots);\n\n const scopes: string[] = [];\n let usesRoots = false;\n for (const [index, scope] of SCOPE_ORDER.entries()) {\n const visible = bindings.filter((b) => SCOPE_ORDER.indexOf(b.contribution.entry.scope) <= index);\n const here = hatches.filter((h) => SCOPE_ORDER.indexOf(h.entry.scope) <= index);\n // Each scope is an independent mount, so it constructs the roots that\n // enclose it from scratch rather than sharing the deeper scope's.\n const roots = allRoots.filter((root) => SCOPE_ORDER.indexOf(root.entry.scope) <= index);\n const innermost = roots[roots.length - 1]?.context ?? 'context';\n const body = [\n ...withRootRegistrations(\n bodyFor(visible, ' ', (b) => contextForScope(roots, b.contribution.entry.scope, 'context'), 'server'),\n roots,\n 'server',\n ' ',\n scope,\n ),\n ...here.map((hatch) => ` ...await at(${hatch.identifier}, ${innermost}),`),\n ];\n if (body.length === 0 && roots.length === 0) continue;\n if (roots.length > 0) usesRoots = true;\n const factory = scopeBody(rootPrologue(roots, 'context', body), rootHooks(roots), body, ' ');\n scopes.push(` ${scope}: ${factory[0]}`, ...factory.slice(1));\n }\n\n return compact([\n HEADER,\n serverImport(scopes),\n ...(allRoots.length ? [\"import { composeServerProviderOverrides } from '@agimon-ai/po-core/serverFacet';\"] : []),\n ...(usesRoots ? [\"import { composeRootHooks } from '@agimon-ai/po-core/extensionFile';\"] : []),\n '',\n ...importsFor(bindings, hatches, allRoots, options.entryDir),\n '',\n ...resolverFor(scopes),\n 'export const facet = defineServerPlugin({',\n ` name: '${options.packageName}',`,\n ...(allRoots.length\n ? [` providerOverrides: composeServerProviderOverrides(${allRoots.map((root) => root.identifier).join(', ')}),`]\n : []),\n ...scopes,\n '});',\n '',\n 'export default facet;',\n '',\n ]);\n}\n\n/** The explicit remote-MCP entry. It intentionally imports only .mcp declarations. */\nexport function renderMcpEntry(resolution: TargetResolution, options: RenderOptions): string {\n const bindings = bind(resolution, options);\n const body = bodyFor(bindings, ' ', () => 'context', 'mcp');\n return compact([\n HEADER,\n \"import { defineMcpPlugin, type PoMcpSessionPlugin } from '@agimon-ai/po-core/mcpFacet';\",\n '',\n ...importsFor(bindings, [], [], options.entryDir),\n '',\n ...resolverFor(body),\n ...(bindings.some((binding) => binding.mcpWidget !== undefined)\n ? [\n 'const withWidget = <T>(key: string, value: T): T => value === undefined ? value : ({',\n ' ...value, _meta: { ...(value as { _meta?: object })._meta, [\"po/widget\"]: key },',\n '});',\n '',\n ]\n : []),\n 'export const mcp = defineMcpPlugin({',\n ` name: '${options.packageName}',`,\n ' session: (context) => ({',\n ...body,\n ' }) satisfies PoMcpSessionPlugin,',\n '});',\n '',\n 'export default mcp;',\n '',\n ]);\n}\n\n/** What differs between the two frontend entries: the SDK they import and the name they export. */\ninterface FrontendEntryShape {\n readonly module: string;\n readonly define: string;\n readonly exportName: string;\n}\n\nconst FRONTEND_ENTRY: Readonly<Record<FrontendTarget, FrontendEntryShape>> = {\n web: { module: '@agimon-ai/po-core/web', define: 'defineWebPlugin', exportName: 'webPlugin' },\n native: { module: '@agimon-ai/po-core/native', define: 'defineNativePlugin', exportName: 'nativePlugin' },\n};\n\n/**\n * A frontend entry, one contributions object per scope.\n *\n * No cascade here, unlike the server: the registry already folds global into\n * workspace into session before install, so repeating a contribution would\n * install it twice.\n */\nfunction renderFrontendEntry(resolution: TargetResolution, options: RenderOptions, target: FrontendTarget): string {\n const shape = FRONTEND_ENTRY[target];\n const bindings = bind(resolution, options);\n const hatches = hatchBindings(resolution.escapeHatches);\n\n const scopes: string[] = [];\n for (const scope of SCOPE_ORDER) {\n const visible = bindings.filter((b) => b.contribution.entry.scope === scope);\n const here = hatches.filter((h) => h.entry.scope === scope);\n const body = [\n ...bodyFor(visible, ' ', () => 'undefined', target),\n // Frontend escape hatches are contribution data. Calling them would also\n // call React components, so merge the authored object directly.\n ...here.map((hatch) => ` ...${hatch.identifier},`),\n ];\n if (body.length === 0) continue;\n scopes.push(` ${scope}: {`, ...body, ' },');\n }\n\n const names = scopes.some((line) => line.includes('get '))\n ? `${shape.define}, type ${CONTRIBUTIONS_TYPE[target]}`\n : shape.define;\n return compact([\n HEADER,\n `import { ${names} } from '${shape.module}';`,\n '',\n ...importsFor(bindings, hatches, [], options.entryDir),\n '',\n ...resolverFor(scopes),\n `export const ${shape.exportName} = ${shape.define}({`,\n ` id: '${options.pluginId}',`,\n ...scopes,\n '});',\n '',\n ]);\n}\n\n/** The cockpit entry, built from `.web` files and their unsuffixed fallbacks. */\nexport function renderWebEntry(resolution: TargetResolution, options: RenderOptions): string {\n return renderFrontendEntry(resolution, options, 'web');\n}\n\n/** The native app entry, built from `.native` files only. */\nexport function renderNativeEntry(resolution: TargetResolution, options: RenderOptions): string {\n return renderFrontendEntry(resolution, options, 'native');\n}\n"],"mappings":"4GAQA,MAAMQ,EAAS,4DAGTC,EAAsC,CAAC,YAAa,0BAA2B,OAAO,EAUtFC,EAAmE,CACvE,OAAQ,CAAC,UAAU,EACnB,IAAK,CAAC,EACN,OAAQ,CAAC,EACT,IAAK,CAAC,CACR,EAYMC,EAA2C,CAAC,UAAU,EAEtDC,EAAyC,CAAC,SAAU,YAAa,SAAS,EAS1EC,EAA4D,CAChE,OAAQ,wBACR,IAAK,yBAGL,OAAQ,yBACR,IAAK,oBACP,EAOA,SAASC,GAAmB,CAC1B,MAAO,CACL,0CACA,gEACA,4EACF,CAAC,CAAC,KAAK;CAAI,CACb,CAGA,SAASC,GAAuB,CAC9B,MAAO,CACL,6DACA,kGACA,kGACA,iEACA,IACF,CAAC,CAAC,KAAK;CAAI,CACb,CAEA,SAASC,GAA0B,CACjC,MAAO,CACL,yDACA,kEACA,8DACF,CAAC,CAAC,KAAK;CAAI,CACb,CAgBA,MAAMC,EAAkB,CACtB,2EACA,mFACF,CAAC,CAAC,KAAK;CAAI,EAWX,SAASC,EAAa,EAAc,EAAsC,CAExE,OADIC,IAA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,YAAY6G,EAAM,WAAWD,EAAM,OAAO,IAC1C,GACA,GAAG1B,EAAWZ,EAAUe,EAAS,CAAC,EAAGtE,EAAQ,QAAQ,EACrD,GACA,GAAG0E,EAAYzB,CAAM,EACrB,gBAAgB4C,EAAM,WAAW,KAAKA,EAAM,OAAO,IACnD,UAAU7F,EAAQ,SAAS,IAC3B,GAAGiD,EACH,MACA,EACF,CAAC,CACH,CAGA,SAAgB8C,EAAe,EAA8B,EAAgC,CAC3F,OAAOH,EAAoBtE,EAAYtB,EAAS,KAAK,CACvD,CAGA,SAAgBgG,EAAkB,EAA8B,EAAgC,CAC9F,OAAOJ,EAAoBtE,EAAYtB,EAAS,QAAQ,CAC1D"}
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["toKebab","toSnake","isFrontendTarget","posix","renderIdentity","require_index","require_index$1","node_path","HEADER","SINGLETON_FIELDS","FACTORY_FIELDS","ALWAYS_FACTORY_FIELDS","SCOPE_ORDER","CONTRIBUTIONS_TYPE","resolver","manyResolver","definedResolver","IDENTITY_HELPER","fillIdentity","target","name","BACKEND_IDENTITY","FRONTEND_IDENTITY","options","identityFor","contribution","surface","entry","uniqueIdentifier","head","parts","word","index","base","candidate","suffix","taken","identifierFor","specifierFor","file","relative","entryDir","widgetLiteral","key","bind","resolution","left","right","identifier","mcpWidget","DEPTH","rootBindings","entries","rootPrologue","lines","enclosing","root","roots","body","line","contextForScope","found","scope","servedFrom","declared","binding","field","unlessHosted","served","rendered","hosted","shadowKey","gates","gate","segment","withoutShadowed","nearest","bindings","hatchBindings","contractBindings","member","contextExpression","resolved","isFactory","identity","value","serverImport","scopes","defer","bodyFor","grouped","held","members","contextOf","indent","servedOf","withRootRegistrations","servicesIndex","routedServices","services","activitiesIndex","routedActivities","activities","importsFor","r","contracts","c","b","hatches","h","compact","all","resolverFor","parameterFor","scopeBody","object","hooks","prefix","prologue","rootHooks","renderServerEntry","allRoots","injects","usesRoots","visible","here","innermost","hatch","factory","provides","contract","renderMcpEntry","FRONTEND_ENTRY","renderFrontendEntry","shape","names","renderWebEntry","renderNativeEntry"],"sources":["../../../src/services/renderEntry/index.ts"],"sourcesContent":["import { posix } from 'node:path';\n\nimport type { ExtensionEntry, ExtensionScope } from '../../types/extensionGraph';\nimport { type Identity, renderIdentity, toKebab, toSnake } from '../identity';\nimport { isFrontendTarget } from '../resolveTarget';\nimport type { BuildTarget, FrontendTarget, ResolvedContribution, TargetResolution } from '../resolveTarget/type';\nimport type { RenderOptions } from './type';\n\nconst HEADER = '// Generated by @agimon-ai/po-build. Do not edit by hand.';\n\n/** Fields that accept one declaration rather than an array of declarations. */\nconst SINGLETON_FIELDS: readonly string[] = ['fileLinks', 'repositorySettingsPanel', 'start'];\n\n/**\n * Fields whose members are factories rather than declarations.\n *\n * Keyed by target, not by field name alone, because `channels` means two\n * different things. A server plugin's array holds `() => PoHubChannel`, so\n * the host can build one per mount. The cockpit's holds the contribution\n * itself. Treating them alike called a plain object as a function.\n */\nconst FACTORY_FIELDS: Readonly<Record<BuildTarget, readonly string[]>> = {\n server: ['channels'],\n web: [],\n native: [],\n mcp: [],\n};\n\n/**\n * Fields whose member is always a factory of the value, never the value.\n *\n * A Cordis plugin is itself a function, so nothing at runtime separates one\n * from a `(context) => plugin` factory. Rather than guess, the service surface\n * is uniformly a factory and is always called. That is also what lets a\n * package with shared per-mount state decompose: the service builds the graph\n * from the mount and publishes it, and every other contribution is a getter,\n * so it is built after the service fibers are up and can inject it.\n */\nconst ALWAYS_FACTORY_FIELDS: readonly string[] = ['services'];\n\nconst SCOPE_ORDER: readonly ExtensionScope[] = ['global', 'workspace', 'session'];\n\n/**\n * Resolves a routed file's default export, which may be the declaration or a\n * factory of one. Both host helpers already accept either shape, so a\n * generated entry has to as well. Emitted rather than imported, so a generated\n * entry carries no runtime dependency beyond the helper it is calling.\n */\n/** The contribution set each host reads, used to annotate the emitted getters. */\nconst CONTRIBUTIONS_TYPE: Readonly<Record<BuildTarget, string>> = {\n server: 'PoServerSessionPlugin',\n web: 'WebPluginContributions',\n // The native app reuses the cockpit's plugin registry, so its contributions\n // are the same type, re-exported from the native SDK.\n native: 'WebPluginContributions',\n mcp: 'PoMcpSessionPlugin',\n};\n\n/**\n * Resolves a routed file's default export without imposing one host context on\n * every factory. The generated mount supplies the concrete context, and `at`\n * preserves that type while still accepting declaration objects.\n */\nfunction resolver(): string {\n return [\n 'type Factory<T, C> = (context: C) => T;',\n 'const at = <T, C>(value: T | Factory<T, C>, context: C): T =>',\n \" typeof value === 'function' ? (value as Factory<T, C>)(context) : value;\",\n ].join('\\n');\n}\n\n/** Resolves a zero-many catalog contribution without flattening tuple declarations. */\nfunction manyResolver(): string {\n return [\n 'type ManyFactory<T, C> = (context: C) => T | readonly T[];',\n 'const many = <T, C>(value: T | readonly T[] | ManyFactory<T, C>, context: C): readonly T[] => {',\n \" const resolved = typeof value === 'function' ? (value as ManyFactory<T, C>)(context) : value;\",\n ' return Array.isArray(resolved) ? resolved : [resolved as T];',\n '};',\n ].join('\\n');\n}\n\nfunction definedResolver(): string {\n return [\n '/* v8 ignore next -- generated normalization branch */',\n 'const defined = <T>(values: readonly (T | undefined)[]): T[] =>',\n ' values.filter((value): value is T => value !== undefined);',\n ].join('\\n');\n}\n\n/**\n * Applies the identity the path derived, letting the authored value win.\n *\n * A call rather than an object literal on purpose. `{ name: 'x', ...value }`\n * is what this means, but TypeScript reports TS2783 whenever the spread's type\n * also declares the key, which is the common case here.\n *\n * The parameters are deliberately untyped so `T` is inferred from the\n * contribution array this sits in rather than from either argument: the\n * authored file supplies only the half the path cannot. The cost is that the\n * merged shape is not checked against `T`, only its position is.\n */\n// Preserve absence before applying a path-derived name. Otherwise optional routes\n// become incomplete placeholder tools or hooks that the `defined` filter cannot remove.\nconst IDENTITY_HELPER = [\n 'const via = <T>(identity: Record<string, unknown>, value: unknown): T =>',\n ' (value === undefined ? undefined : { ...identity, ...(value as object) }) as T;',\n].join('\\n');\n\n/**\n * Every fill is a slot fill. There is no host-region special case.\n *\n * The cockpit's own regions are slots like any other: an activity section\n * already renders into `activity.<group>`, which is why naming the target\n * directly works for a host region and a plugin's slot alike. Keeping this\n * uniform is what lets a layout package declare new regions without the build\n * tooling learning about them.\n */\nfunction fillIdentity(name: string, target: string | undefined): Identity {\n if (target === undefined) return { id: toKebab(name) };\n return { slot: target, id: toKebab(name) };\n}\n\n/** What the path can tell each host, keyed by the folder the author typed. */\nconst BACKEND_IDENTITY: Readonly<Record<string, (name: string) => Identity>> = {\n tool: (name) => ({ name: toSnake(name) }),\n // Kebab, unlike a tool. A command name is what the user types after the\n // slash and it reaches registerCommand verbatim, so `subagents-doctor` must\n // stay `/subagents-doctor` rather than becoming `/subagents_doctor`.\n command: (name) => ({ name: toKebab(name) }),\n channel: (name) => ({ frameType: toSnake(name) }),\n hook: (name) => ({ event: toSnake(name) }),\n mode: (name) => ({ name: toKebab(name) }),\n};\n\nconst FRONTEND_IDENTITY: Readonly<Record<string, (name: string, options: RenderOptions) => Identity>> = {\n tool: (name) => ({ tools: [toSnake(name)] }),\n channel: (name) => ({ channel: toSnake(name) }),\n slot: (name, options) => ({ slot: `${options.pluginId}.${toKebab(name)}` }),\n command: (name) => ({ id: toKebab(name) }),\n tab: (name) => ({ id: toKebab(name) }),\n template: (name) => ({ id: toKebab(name) }),\n dock: (name) => ({ id: toKebab(name) }),\n setting: (name) => ({ id: toKebab(name) }),\n action: (name) => ({ id: toKebab(name) }),\n mode: (name) => ({ name: toKebab(name) }),\n 'activity-group': (name) => ({ name: toKebab(name) }),\n 'selection-axis': (name) => ({ name: toKebab(name) }),\n // A leader binding's id is namespaced like a slot, because the key tree is\n // shared and two plugins must not collide on one path's identity.\n leader: (name, options) => ({ id: `${options.pluginId}.${toKebab(name)}` }),\n};\n\n/**\n * What the path knows about a contribution's identity.\n *\n * Keyed by surface, because the folder is what the author types. A surface\n * absent from the table, or an identity the path cannot supply such as a tab's\n * human label, is left entirely to the authored file.\n */\nfunction identityFor(\n contribution: ResolvedContribution,\n target: BuildTarget,\n options: RenderOptions,\n): Identity | undefined {\n const { entry } = contribution;\n const surface = entry.surface;\n if (surface === undefined) return undefined;\n\n if (!isFrontendTarget(target)) return BACKEND_IDENTITY[surface]?.(entry.name);\n if (surface === 'fill') return fillIdentity(entry.name, entry.target);\n return FRONTEND_IDENTITY[surface]?.(entry.name, options);\n}\n\n/** A stable, unique, valid identifier built from path words. */\nfunction uniqueIdentifier(parts: readonly string[], taken: Set<string>): string {\n const words = parts\n .join('-')\n .split(/[^A-Za-z0-9]+/u)\n .filter((word) => word.length > 0);\n const head = words.map((word, index) => (index === 0 ? word : word[0]?.toUpperCase() + word.slice(1))).join('');\n const base = /^[A-Za-z_]/u.test(head) ? head : `x${head}`;\n let candidate = base;\n let suffix = 2;\n while (taken.has(candidate)) candidate = `${base}${suffix++}`;\n taken.add(candidate);\n return candidate;\n}\n\n/** A stable, unique, valid identifier: surface and name, disambiguated by scope when needed. */\nfunction identifierFor(contribution: ResolvedContribution, taken: Set<string>): string {\n return uniqueIdentifier([contribution.entry.surface ?? 'extra', contribution.entry.name], taken);\n}\n\n/** The extensionless relative specifier from a generated entry to a routed file. */\nfunction specifierFor(file: string, entryDir: string): string {\n const target = file.replace(/\\.[^.]+$/u, '');\n const relative = posix.relative(entryDir, target);\n return relative.startsWith('.') ? relative : `./${relative}`;\n}\n\ninterface Binding {\n readonly identifier: string;\n readonly contribution: ResolvedContribution;\n readonly identity: Identity | undefined;\n readonly mcpWidget: string | undefined;\n}\n\n/** Encode data for generated JavaScript, including the HTML script boundary. */\nfunction widgetLiteral(key: string): string {\n return JSON.stringify(key).replaceAll('<', '\\\\u003c').replaceAll('\\u2028', '\\\\u2028').replaceAll('\\u2029', '\\\\u2029');\n}\n\nfunction bind(resolution: TargetResolution, options: RenderOptions): Binding[] {\n const taken = new Set<string>();\n return [...resolution.contributions]\n .sort((left, right) => left.entry.file.localeCompare(right.entry.file))\n .map((contribution) => {\n // The contribution takes its identifier first, so the plain name stays\n // with the tool rather than going to whichever file sorted earlier.\n const identifier = identifierFor(contribution, taken);\n const mcpWidget = resolution.target === 'mcp' ? options.mcpWidgets?.[contribution.entry.file] : undefined;\n if (mcpWidget !== undefined && !/^(?:@[a-z0-9][a-z0-9._-]*\\/)?[a-z0-9][a-z0-9._-]*\\/[a-z0-9_]+$/u.test(mcpWidget))\n throw new Error(`Invalid MCP widget key '${mcpWidget}'`);\n return {\n identifier,\n contribution,\n identity: identityFor(contribution, resolution.target, options),\n mcpWidget,\n };\n });\n}\n\n/** Scope nesting depth, so a contribution can find the root that encloses it. */\nconst DEPTH: Readonly<Record<ExtensionScope, number>> = { global: 0, workspace: 1, session: 2 };\n\ninterface RootBinding {\n /** The imported factory. */\n readonly identifier: string;\n /** The declaration it returned: `value` plus this scope's lifecycle hooks. */\n readonly declaration: string;\n /** The mount context contributions beneath this root receive. */\n readonly context: string;\n readonly entry: ExtensionEntry;\n}\n\nfunction rootBindings(entries: readonly ExtensionEntry[]): RootBinding[] {\n return entries.map((entry) => {\n const suffix = entry.scope[0]?.toUpperCase() + entry.scope.slice(1);\n return { identifier: `root${suffix}`, declaration: `scope${suffix}`, context: `context${suffix}`, entry };\n });\n}\n\n/**\n * Constructs each scope before anything it contains, outermost first.\n *\n * Every root is handed the context its enclosing root produced. Root factories\n * may be async, so the generated host factory awaits each one before exposing\n * its value to narrower contributions. Each goes through the host's\n * `scopeRoot`, so a root an outer level already built is reused, not rebuilt.\n */\nfunction rootPrologue(roots: readonly RootBinding[], base: string, body: readonly string[]): string[] {\n const lines: string[] = [];\n let enclosing = base;\n for (const [index, root] of roots.entries()) {\n lines.push(\n `const ${root.declaration} = await ${base}.scopeRoot('${root.entry.scope}', ${root.identifier}, ${enclosing});`,\n );\n const contextIsUsed = index < roots.length - 1 || body.some((line) => line.includes(root.context));\n if (contextIsUsed) lines.push(`const ${root.context} = { ...${enclosing}, root: ${root.declaration}.value };`);\n enclosing = root.context;\n }\n return lines;\n}\n\n/** The context a contribution sees: the nearest enclosing root's, or the mount's. */\nfunction contextForScope(roots: readonly RootBinding[], scope: ExtensionScope, base: string): string {\n let found = base;\n for (const root of roots) {\n if (DEPTH[root.entry.scope] <= DEPTH[scope]) found = root.context;\n }\n return found;\n}\n\n/**\n * The outer scope that already serves a cascaded contribution, when one can.\n *\n * Only a scope-wide registration is served from outside. A channel reaches\n * every session beneath the level that mounted it, and an API or method bound\n * to an outer root is mounted where that root lives. Root-free APIs and\n * methods still cascade, because each level mounts them under its own path,\n * and session registrations such as tools exist only on a session's agent.\n */\nfunction servedFrom(\n binding: Binding,\n roots: readonly RootBinding[],\n scope: ExtensionScope,\n): ExtensionScope | undefined {\n const declared = binding.contribution.entry.scope;\n if (DEPTH[declared] >= DEPTH[scope]) return undefined;\n const { field } = binding.contribution;\n if (field === 'channels') return declared;\n const rootBound = roots.some((root) => DEPTH[root.entry.scope] <= DEPTH[declared]);\n return rootBound && (field === 'api' || field === 'methods') ? declared : undefined;\n}\n\n/**\n * Drops a member while the outer level `served` runs the package and serves it there.\n *\n * A single member leaves a hole for `defined` to remove rather than spreading a\n * conditional array, because TypeScript gives a spread no contextual type and\n * the identity helper's T would widen to unknown.\n */\nfunction unlessHosted(rendered: string, served: ExtensionScope | undefined): string {\n if (served === undefined) return rendered;\n const hosted = `context.hosted('${served}')`;\n if (rendered.startsWith('...')) return `...(${hosted} ? [] : ${rendered.slice('...'.length)})`;\n return `${hosted} ? undefined : ${rendered}`;\n}\n\n/**\n * What makes two routed contributions the same one: its gates, its field, and the identity the host\n * reads, which for an API is its route path. Hooks have none, because two handlers of one event both run.\n */\nfunction shadowKey(binding: Binding): string | undefined {\n const { entry, field } = binding.contribution;\n if (field === 'hooks') return undefined;\n const gates = entry.gates.map((gate) => `${gate.kind}:${gate.id}`).join('/');\n if (field === 'api') {\n const route = entry.route.map((segment) => ('literal' in segment ? segment.literal : `[${segment.param.name}]`));\n return `${gates}|api|${route.join('/')}`;\n }\n return binding.identity === undefined ? undefined : `${gates}|${field}|${renderIdentity(binding.identity)}`;\n}\n\n/**\n * Leaves out a contribution cascaded from an outer level when a level nearer this one declares the\n * same contribution again, as the cockpit replaces a parent's contribution when its key matches. Both\n * would otherwise claim one name, and the host keeps whichever registered first.\n */\nfunction withoutShadowed(bindings: readonly Binding[]): Binding[] {\n const nearest = new Map<string, number>();\n for (const binding of bindings) {\n const key = shadowKey(binding);\n if (key !== undefined) nearest.set(key, Math.max(nearest.get(key) ?? -1, DEPTH[binding.contribution.entry.scope]));\n }\n return bindings.filter((binding) => {\n const key = shadowKey(binding);\n return key === undefined || nearest.get(key) === DEPTH[binding.contribution.entry.scope];\n });\n}\n\nfunction hatchBindings(entries: readonly ExtensionEntry[]): { identifier: string; entry: ExtensionEntry }[] {\n return [...entries]\n .sort((left, right) => left.file.localeCompare(right.file))\n .map((entry, index) => ({ identifier: `extra${index === 0 ? '' : index + 1}`, entry }));\n}\n\n/** Each `contract/` file under an identifier of its own. */\nfunction contractBindings(entries: readonly ExtensionEntry[]): { identifier: string; entry: ExtensionEntry }[] {\n const taken = new Set<string>();\n return entries.map((entry) => ({ identifier: uniqueIdentifier(['contract', entry.name], taken), entry }));\n}\n\n/**\n * One contribution as it appears inside its array, identity first so the file wins.\n *\n * The browser half is never resolved. The cockpit builds its definition as\n * data and starts it separately, so a frontend file has no mount context to\n * receive, and resolving anyway would call any export that happens to be a\n * function. A React component is a function, so that is not hypothetical.\n */\nfunction member(binding: Binding, contextExpression: string, target: BuildTarget): string {\n if (ALWAYS_FACTORY_FIELDS.includes(binding.contribution.field)) {\n return `${binding.identifier}(${contextExpression})`;\n }\n\n const resolved = isFrontendTarget(target) ? binding.identifier : `at(${binding.identifier}, ${contextExpression})`;\n const isFactory = FACTORY_FIELDS[target].includes(binding.contribution.field);\n // A live collection is the contribution container itself. Applying a path\n // identity would spread class instances into plain objects and can erase\n // prototype-backed snapshot/subscribe methods.\n if (binding.contribution.entry.cardinality === 'collection') return resolved;\n if (binding.identity === undefined) return isFactory ? binding.identifier : resolved;\n\n const identity = renderIdentity(binding.identity);\n // A channel array holds factories, so the identity is applied inside one.\n if (isFactory) return `() => via({ ${identity} }, ${binding.identifier}())`;\n const value = `via({ ${identity} }, ${resolved})`;\n return binding.mcpWidget === undefined ? value : `withWidget(${widgetLiteral(binding.mcpWidget)}, ${value})`;\n}\n\n/** The server entry imports only the types its scopes actually use. */\nfunction serverImport(scopes: readonly string[]): string {\n const types = scopes.some((line) => line.includes('get ')) ? ['type PoServerSessionPlugin'] : [];\n return `import { ${['defineServerPlugin', ...types].join(', ')} } from '@agimon-ai/po-core/serverPlugin';`;\n}\n\n/**\n * Emits a contribution as a getter, so it is built after services mount.\n *\n * Both host helpers register `services` first and read every other field\n * afterwards. A plain property would be evaluated when the entry's factory\n * returns, which is before any service exists, so a routed file could never\n * inject one at construction and every package with shared per-mount state\n * would be stuck in one closure.\n *\n * `services` itself stays a plain property: it is what the helper reads first,\n * and a getter for it would buy nothing.\n */\nfunction defer(field: string, rendered: string, target: BuildTarget): string {\n if (field === 'services' || rendered.startsWith('...')) return rendered;\n const [name, ...value] = rendered.split(': ');\n // Annotated, because a getter gets no contextual type from the object\n // literal it sits in, so the identity helper's T would widen to unknown and\n // the contribution would stop type checking against the array it joins.\n const type = `${CONTRIBUTIONS_TYPE[target]}['${name}']`;\n return `get ${name}(): ${type} { return ${value.join(': ').replace(/,$/u, '')}; },`;\n}\n\n/**\n * The contributions object's body.\n *\n * The mount context is resolved per contribution rather than once, because a\n * root rebinds it for everything beneath it and two contributions at different\n * scopes can therefore see different contexts in the same object.\n */\nfunction bodyFor(\n bindings: readonly Binding[],\n indent: string,\n contextOf: (binding: Binding) => string,\n target: BuildTarget,\n servedOf: (binding: Binding) => ExtensionScope | undefined = () => undefined,\n): string[] {\n const grouped = new Map<string, Binding[]>();\n for (const binding of bindings) {\n const held = grouped.get(binding.contribution.field);\n if (held === undefined) grouped.set(binding.contribution.field, [binding]);\n else held.push(binding);\n }\n\n const lines: string[] = [];\n for (const field of [...grouped.keys()].sort()) {\n const members = grouped.get(field) as Binding[];\n if (SINGLETON_FIELDS.includes(field)) {\n const entry = members[0];\n if (entry) {\n const rendered = member(entry, contextOf(entry), target);\n lines.push(`${indent}${defer(field, `${field}: ${rendered},`, target)}`);\n }\n continue;\n }\n const renderedMembers = members.map((entry) =>\n unlessHosted(\n entry.contribution.entry.cardinality === 'many'\n ? `...many(${entry.identifier}, ${contextOf(entry)})${entry.mcpWidget === undefined ? '' : `.map((tool) => withWidget(${widgetLiteral(entry.mcpWidget)}, tool))`}`\n : member(entry, contextOf(entry), target),\n servedOf(entry),\n ),\n );\n const entries = `[${renderedMembers.join(', ')}]`;\n const holes = members.some(\n (entry) =>\n entry.contribution.entry.cardinality === 'optional' ||\n (entry.contribution.entry.cardinality !== 'many' && servedOf(entry) !== undefined),\n );\n const rendered = holes ? `defined(${entries})` : entries;\n lines.push(`${indent}${defer(field, `${field}: ${rendered},`, target)}`);\n }\n return lines;\n}\n\n/** Root-owned registrations join routed registrations in the host's usual fields. */\nfunction withRootRegistrations(\n body: readonly string[],\n roots: readonly RootBinding[],\n target: 'server',\n indent: string,\n scope: ExtensionScope,\n): string[] {\n if (roots.length === 0) return [...body];\n const lines = [...body];\n const servicesIndex = lines.findIndex((line) => line.startsWith(`${indent}services: [`));\n const routedServices =\n servicesIndex < 0 ? '' : (lines.splice(servicesIndex, 1)[0]?.match(/services: \\[(.*)\\],$/u)?.[1] ?? '');\n const services = [...roots.map((root) => `...(${root.declaration}.services ?? [])`), routedServices]\n .filter(Boolean)\n .join(', ');\n lines.push(`${indent}services: [${services}],`);\n\n if (target === 'server' && scope === 'session') {\n const activitiesIndex = lines.findIndex((line) => line.startsWith(`${indent}get activities()`));\n const routedActivities =\n activitiesIndex < 0 ? '' : (lines.splice(activitiesIndex, 1)[0]?.match(/return \\[(.*)\\]; \\},$/u)?.[1] ?? '');\n const activities = [...roots.map((root) => `...(${root.declaration}.activities ?? [])`), routedActivities]\n .filter(Boolean)\n .join(', ');\n lines.push(`${indent}get activities(): PoServerSessionPlugin['activities'] { return [${activities}]; },`);\n }\n return lines;\n}\n\nfunction importsFor(\n bindings: readonly Binding[],\n hatches: readonly { identifier: string; entry: ExtensionEntry }[],\n roots: readonly RootBinding[],\n entryDir: string,\n contracts: readonly { identifier: string; entry: ExtensionEntry }[] = [],\n): string[] {\n return [\n ...roots.map((r) => `import ${r.identifier} from '${specifierFor(r.entry.file, entryDir)}';`),\n ...contracts.map((c) => `import ${c.identifier} from '${specifierFor(c.entry.file, entryDir)}';`),\n ...bindings.map((b) => `import ${b.identifier} from '${specifierFor(b.contribution.entry.file, entryDir)}';`),\n ...hatches.map((h) => `import ${h.identifier} from '${specifierFor(h.entry.file, entryDir)}';`),\n ];\n}\n\nfunction compact(lines: readonly string[]): string {\n return lines.filter((line, index, all) => !(line === '' && all[index - 1] === '')).join('\\n');\n}\n\n/**\n * Emits the resolver only when something calls it.\n *\n * Extension packages compile with noUnusedLocals, so a generated entry whose\n * every contribution is a factory would otherwise fail to typecheck on an\n * unused helper.\n */\nfunction resolverFor(body: readonly string[]): string[] {\n const lines: string[] = [];\n if (body.some((line) => line.includes('at('))) lines.push(resolver());\n if (body.some((line) => line.includes('many('))) lines.push(manyResolver());\n if (body.some((line) => line.includes('defined('))) lines.push(definedResolver());\n if (body.some((line) => line.includes('via('))) lines.push(IDENTITY_HELPER);\n return lines.length > 0 ? [...lines, ''] : [];\n}\n\n/** `noUnusedParameters` means a scope that never threads context takes none. */\nfunction parameterFor(lines: readonly string[]): string {\n return lines.some((line) => /\\bcontext[.,)]/u.test(line)) ? '(context)' : '()';\n}\n\n/**\n * The scope's factory: an expression body, or a block when roots come first.\n *\n * A root has to be constructed before the object that reads it, so a scope\n * that has one becomes statements followed by a return rather than a bare\n * object literal.\n */\nfunction scopeBody(\n prologue: readonly string[],\n hooks: string | undefined,\n body: readonly string[],\n indent: string,\n): string[] {\n const object = [...(hooks === undefined ? [] : [`${indent} ${hooks}`]), ...body];\n const asynchronous = [...prologue, ...body].some((line) => line.includes('await '));\n const prefix = asynchronous ? 'async ' : '';\n if (prologue.length === 0) return [`${prefix}${parameterFor(body)} => ({`, ...object, `${indent}}),`];\n return [\n `${prefix}${parameterFor([...prologue, ...body])} => {`,\n ...prologue.map((line) => `${indent} ${line}`),\n `${indent} return {`,\n ...object.map((line) => ` ${line}`),\n `${indent} };`,\n `${indent}},`,\n ];\n}\n\n/** Folds every enclosing root's lifecycle hooks into the one set the host reads. */\nfunction rootHooks(roots: readonly RootBinding[]): string | undefined {\n if (roots.length === 0) return undefined;\n return `...composeRootHooks(${roots.map((root) => root.declaration).join(', ')}),`;\n}\n\n/**\n * The headless entry, one declaration per scope.\n *\n * Contributions cascade downward here because each level reads exactly one\n * `plugin[host.scope]` and nothing from the scopes above it. Emitting the\n * repetition is what lets an author declare a channel once and have it reach\n * every session, whether or not an outer level runs the package. When one does,\n * the host says so through `context.hosted`, and the inner level leaves to it\n * the roots, channels and root-bound registrations it already serves.\n *\n * `provides` lists each level's `contract/` files, and `injects` what the roots\n * a level builds or reuses ask for, so the host can make the level wait for\n * them and the build can write both into the manifest.\n */\nexport function renderServerEntry(resolution: TargetResolution, options: RenderOptions): string {\n const bindings = bind(resolution, options);\n const hatches = hatchBindings(resolution.escapeHatches);\n const allRoots = rootBindings(resolution.roots);\n const contracts = contractBindings(resolution.contracts);\n\n const scopes: string[] = [];\n const injects: string[] = [];\n let usesRoots = false;\n for (const [index, scope] of SCOPE_ORDER.entries()) {\n const visible = withoutShadowed(bindings.filter((b) => SCOPE_ORDER.indexOf(b.contribution.entry.scope) <= index));\n const here = hatches.filter((h) => SCOPE_ORDER.indexOf(h.entry.scope) <= index);\n // Each scope names every root that encloses it. The host hands back the\n // one an outer level already built, and builds it here when none did.\n const roots = allRoots.filter((root) => SCOPE_ORDER.indexOf(root.entry.scope) <= index);\n const innermost = roots[roots.length - 1]?.context ?? 'context';\n const body = [\n ...withRootRegistrations(\n bodyFor(\n visible,\n ' ',\n (b) => contextForScope(roots, b.contribution.entry.scope, 'context'),\n 'server',\n (b) => servedFrom(b, roots, scope),\n ),\n roots,\n 'server',\n ' ',\n scope,\n ),\n ...here.map((hatch) => ` ...await at(${hatch.identifier}, ${innermost}),`),\n ];\n if (body.length === 0 && roots.length === 0) continue;\n if (roots.length > 0) {\n usesRoots = true;\n injects.push(`${scope}: [${roots.map((root) => root.identifier).join(', ')}]`);\n }\n const factory = scopeBody(rootPrologue(roots, 'context', body), rootHooks(roots), body, ' ');\n scopes.push(` ${scope}: ${factory[0]}`, ...factory.slice(1));\n }\n const provides = SCOPE_ORDER.flatMap((scope) => {\n const declared = contracts.filter((contract) => contract.entry.scope === scope);\n return declared.length === 0\n ? []\n : [` ${scope}: [${declared.map((contract) => contract.identifier).join(', ')}],`];\n });\n\n return compact([\n HEADER,\n serverImport(scopes),\n ...(allRoots.length ? [\"import { composeServerProviderOverrides } from '@agimon-ai/po-core/serverPlugin';\"] : []),\n ...(usesRoots ? [\"import { composeRootHooks, composeRootInjects } from '@agimon-ai/po-core/extensionFile';\"] : []),\n '',\n ...importsFor(bindings, hatches, allRoots, options.entryDir, contracts),\n '',\n ...resolverFor(scopes),\n 'export const serverPlugin = defineServerPlugin({',\n ` name: '${options.packageName}',`,\n ...(allRoots.length\n ? [` providerOverrides: composeServerProviderOverrides(${allRoots.map((root) => root.identifier).join(', ')}),`]\n : []),\n ...(provides.length > 0 ? [' provides: {', ...provides, ' },'] : []),\n ...(injects.length > 0 ? [` injects: composeRootInjects({ ${injects.join(', ')} }),`] : []),\n ...scopes,\n '});',\n '',\n 'export default serverPlugin;',\n '',\n ]);\n}\n\n/** The explicit remote-MCP entry. It intentionally imports only .mcp declarations. */\nexport function renderMcpEntry(resolution: TargetResolution, options: RenderOptions): string {\n const bindings = bind(resolution, options);\n const body = bodyFor(bindings, ' ', () => 'context', 'mcp');\n return compact([\n HEADER,\n \"import { defineMcpPlugin, type PoMcpSessionPlugin } from '@agimon-ai/po-core/mcpFacet';\",\n '',\n ...importsFor(bindings, [], [], options.entryDir),\n '',\n ...resolverFor(body),\n ...(bindings.some((binding) => binding.mcpWidget !== undefined)\n ? [\n 'const withWidget = <T>(key: string, value: T): T => value === undefined ? value : ({',\n ' ...value, _meta: { ...(value as { _meta?: object })._meta, [\"po/widget\"]: key },',\n '});',\n '',\n ]\n : []),\n 'export const mcp = defineMcpPlugin({',\n ` name: '${options.packageName}',`,\n ' session: (context) => ({',\n ...body,\n ' }) satisfies PoMcpSessionPlugin,',\n '});',\n '',\n 'export default mcp;',\n '',\n ]);\n}\n\n/** What differs between the two frontend entries: the SDK they import and the name they export. */\ninterface FrontendEntryShape {\n readonly module: string;\n readonly define: string;\n readonly exportName: string;\n}\n\nconst FRONTEND_ENTRY: Readonly<Record<FrontendTarget, FrontendEntryShape>> = {\n web: { module: '@agimon-ai/po-core/web', define: 'defineWebPlugin', exportName: 'webPlugin' },\n native: { module: '@agimon-ai/po-core/native', define: 'defineNativePlugin', exportName: 'nativePlugin' },\n};\n\n/**\n * A frontend entry, one contributions object per scope.\n *\n * No cascade here, unlike the server: the registry already folds global into\n * workspace into session before install, so repeating a contribution would\n * install it twice.\n */\nfunction renderFrontendEntry(resolution: TargetResolution, options: RenderOptions, target: FrontendTarget): string {\n const shape = FRONTEND_ENTRY[target];\n const bindings = bind(resolution, options);\n const hatches = hatchBindings(resolution.escapeHatches);\n\n const scopes: string[] = [];\n for (const scope of SCOPE_ORDER) {\n const visible = bindings.filter((b) => b.contribution.entry.scope === scope);\n const here = hatches.filter((h) => h.entry.scope === scope);\n const body = [\n ...bodyFor(visible, ' ', () => 'undefined', target),\n // Frontend escape hatches are contribution data. Calling them would also\n // call React components, so merge the authored object directly.\n ...here.map((hatch) => ` ...${hatch.identifier},`),\n ];\n if (body.length === 0) continue;\n scopes.push(` ${scope}: {`, ...body, ' },');\n }\n\n const names = scopes.some((line) => line.includes('get '))\n ? `${shape.define}, type ${CONTRIBUTIONS_TYPE[target]}`\n : shape.define;\n return compact([\n HEADER,\n `import { ${names} } from '${shape.module}';`,\n '',\n ...importsFor(bindings, hatches, [], options.entryDir),\n '',\n ...resolverFor(scopes),\n `export const ${shape.exportName} = ${shape.define}({`,\n ` id: '${options.pluginId}',`,\n ...scopes,\n '});',\n '',\n ]);\n}\n\n/** The cockpit entry, built from `.web` files and their unsuffixed fallbacks. */\nexport function renderWebEntry(resolution: TargetResolution, options: RenderOptions): string {\n return renderFrontendEntry(resolution, options, 'web');\n}\n\n/** The native app entry, built from `.native` files only. */\nexport function renderNativeEntry(resolution: TargetResolution, options: RenderOptions): string {\n return renderFrontendEntry(resolution, options, 'native');\n}\n"],"mappings":"4GAQA,MAAMQ,EAAS,4DAGTC,EAAsC,CAAC,YAAa,0BAA2B,OAAO,EAUtFC,EAAmE,CACvE,OAAQ,CAAC,UAAU,EACnB,IAAK,CAAC,EACN,OAAQ,CAAC,EACT,IAAK,CAAC,CACR,EAYMC,EAA2C,CAAC,UAAU,EAEtDC,EAAyC,CAAC,SAAU,YAAa,SAAS,EAS1EC,EAA4D,CAChE,OAAQ,wBACR,IAAK,yBAGL,OAAQ,yBACR,IAAK,oBACP,EAOA,SAASC,GAAmB,CAC1B,MAAO,CACL,0CACA,gEACA,4EACF,CAAC,CAAC,KAAK;CAAI,CACb,CAGA,SAASC,GAAuB,CAC9B,MAAO,CACL,6DACA,kGACA,kGACA,iEACA,IACF,CAAC,CAAC,KAAK;CAAI,CACb,CAEA,SAASC,GAA0B,CACjC,MAAO,CACL,yDACA,kEACA,8DACF,CAAC,CAAC,KAAK;CAAI,CACb,CAgBA,MAAMC,EAAkB,CACtB,2EACA,mFACF,CAAC,CAAC,KAAK;CAAI,EAWX,SAASC,EAAa,EAAc,EAAsC,CAExE,OADIC,IAAW,IAAA,GAAkB,CAAE,GAAInB,EAAAA,QAAQoB,CAAI,CAAE,EAC9C,CAAE,KAAMD,EAAQ,GAAInB,EAAAA,QAAQoB,CAAI,CAAE,CAC3C,CAGA,MAAMC,EAAyE,CAC7E,KAAO,IAAU,CAAE,KAAMpB,EAAAA,QAAQmB,CAAI,CA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AQ,QAAQ,EACrD,GACA,GAAGyF,EAAYzB,CAAM,EACrB,gBAAgB+C,EAAM,WAAW,KAAKA,EAAM,OAAO,IACnD,UAAU/G,EAAQ,SAAS,IAC3B,GAAGgE,EACH,MACA,EACF,CAAC,CACH,CAGA,SAAgBiD,EAAe,EAA8B,EAAgC,CAC3F,OAAOH,EAAoBxF,EAAYtB,EAAS,KAAK,CACvD,CAGA,SAAgBkH,EAAkB,EAA8B,EAAgC,CAC9F,OAAOJ,EAAoBxF,EAAYtB,EAAS,QAAQ,CAC1D"}
|
|
@@ -4,10 +4,16 @@ import { RenderOptions } from "./type.mjs";
|
|
|
4
4
|
/**
|
|
5
5
|
* The headless entry, one declaration per scope.
|
|
6
6
|
*
|
|
7
|
-
* Contributions cascade downward here because
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
7
|
+
* Contributions cascade downward here because each level reads exactly one
|
|
8
|
+
* `plugin[host.scope]` and nothing from the scopes above it. Emitting the
|
|
9
|
+
* repetition is what lets an author declare a channel once and have it reach
|
|
10
|
+
* every session, whether or not an outer level runs the package. When one does,
|
|
11
|
+
* the host says so through `context.hosted`, and the inner level leaves to it
|
|
12
|
+
* the roots, channels and root-bound registrations it already serves.
|
|
13
|
+
*
|
|
14
|
+
* `provides` lists each level's `contract/` files, and `injects` what the roots
|
|
15
|
+
* a level builds or reuses ask for, so the host can make the level wait for
|
|
16
|
+
* them and the build can write both into the manifest.
|
|
11
17
|
*/
|
|
12
18
|
export declare function renderServerEntry(resolution: TargetResolution, options: RenderOptions): string;
|
|
13
19
|
/** The cockpit entry, built from `.web` files and their unsuffixed fallbacks. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../../../src/services/renderEntry/index.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../../../src/services/renderEntry/index.ts"],"mappings":";;;;;;;;;;;;;;;;;wBA6kBgB,kBAAkB,YAAY,kBAAkB,SAAS;;wBA+JzD,eAAe,YAAY,kBAAkB,SAAS;;wBAKtD,kBAAkB,YAAY,kBAAkB,SAAS"}
|