@agimon-ai/po-build 0.0.0-alpha.1 → 0.0.0-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/constants/contributions.cjs +1 -1
- package/dist/constants/contributions.cjs.map +1 -1
- package/dist/constants/contributions.mjs +1 -1
- package/dist/constants/contributions.mjs.map +1 -1
- package/dist/constants/layout.cjs +1 -1
- package/dist/constants/layout.cjs.map +1 -1
- 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/generate/index.cjs +1 -1
- package/dist/services/generate/index.cjs.map +1 -1
- package/dist/services/generate/index.d.mts.map +1 -1
- package/dist/services/generate/index.mjs +2 -2
- package/dist/services/generate/index.mjs.map +1 -1
- package/dist/services/renderClient/index.cjs +2 -2
- package/dist/services/renderClient/index.cjs.map +1 -1
- package/dist/services/renderClient/index.mjs +2 -2
- package/dist/services/renderClient/index.mjs.map +1 -1
- package/dist/services/resolveTarget/index.cjs +1 -1
- package/dist/services/resolveTarget/index.cjs.map +1 -1
- package/dist/services/resolveTarget/index.d.mts.map +1 -1
- package/dist/services/resolveTarget/index.mjs +1 -1
- package/dist/services/resolveTarget/index.mjs.map +1 -1
- package/package.json +1 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const e={tool:`tools`,"tool-restriction":`toolRestrictions`,command:`commands`,hook:`hooks`,mode:`minorModes`,api:`api`,channel:`channels`,method:`methods`,resource:`resources`},t={tool:`tools`,skill:`skills`,resource:`uiResources`},n={tool:`toolRenderers`,command:`paletteCommands`,mode:`minorModes`,channel:`channels`,tab:`tabs`,template:`templates`,dock:`dockFaces`,setting:`settingsSections`,slot:`slots`,fill:`fills`,action:`contextActions`,"activity-group":`activityGroups`,leader:`leaderBindings`,"selection-axis":`selectionAxes`,lifecycle:`start`,"file-links":`fileLinks`,"repository-settings-panel":`repositorySettingsPanel`,api:``,method:``,store:``},r={tool:`toolRenderers`,tab:`tabs`,slot:`slots`,fill:`fills`,channel:`channels`,"activity-group":`activityGroups`,setting:`settingsSections`,lifecycle:`start`,template:`nativeTemplates`,store:``},i={section:`settingsSections`,panel:`settingsPanels`},a={context:`contextActions`,message:`userMessageActions`};exports.ACTION_FIELDS=a,exports.MCP_FIELDS=t,exports.NATIVE_FIELDS=r,exports.SERVER_FIELDS=e,exports.SETTING_FIELDS=i,exports.WEB_FIELDS=n;
|
|
1
|
+
const e={tool:`tools`,"tool-restriction":`toolRestrictions`,command:`commands`,hook:`hooks`,mode:`minorModes`,api:`api`,channel:`channels`,method:`methods`,resource:`resources`},t={tool:`tools`,skill:`skills`,resource:`uiResources`},n={tool:`toolRenderers`,command:`paletteCommands`,mode:`minorModes`,channel:`channels`,tab:`tabs`,template:`templates`,dock:`dockFaces`,setting:`settingsSections`,slot:`slots`,fill:`fills`,action:`contextActions`,"activity-group":`activityGroups`,leader:`leaderBindings`,"selection-axis":`selectionAxes`,lifecycle:`start`,"file-links":`fileLinks`,"repository-settings-panel":`repositorySettingsPanel`,api:``,method:``,store:``},r={tool:`toolRenderers`,tab:`tabs`,slot:`slots`,fill:`fills`,channel:`channels`,"activity-group":`activityGroups`,"selection-axis":`selectionAxes`,setting:`settingsSections`,action:`userMessageActions`,lifecycle:`start`,template:`nativeTemplates`,store:``},i={section:`settingsSections`,panel:`settingsPanels`},a={context:`contextActions`,message:`userMessageActions`},o={message:`userMessageActions`};exports.ACTION_FIELDS=a,exports.MCP_FIELDS=t,exports.NATIVE_ACTION_FIELDS=o,exports.NATIVE_FIELDS=r,exports.SERVER_FIELDS=e,exports.SETTING_FIELDS=i,exports.WEB_FIELDS=n;
|
|
2
2
|
//# sourceMappingURL=contributions.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contributions.cjs","names":["SERVER_FIELDS","MCP_FIELDS","WEB_FIELDS","NATIVE_FIELDS","SETTING_FIELDS","ACTION_FIELDS"],"sources":["../../src/constants/contributions.ts"],"sourcesContent":["/**\n * Which contribution field each surface produces, per host and side.\n *\n * The surface names the concept; the host decides which array carries it.\n * A surface missing from a host's table is legitimately absent there, such\n * as api/ on MCP, and is skipped without complaint.\n */\n\n/** A surface that produces nothing registrable, but is still published. */\nexport const NOT_A_CONTRIBUTION = '';\n\nexport const SERVER_FIELDS: Readonly<Record<string, string>> = {\n tool: 'tools',\n 'tool-restriction': 'toolRestrictions',\n command: 'commands',\n hook: 'hooks',\n mode: 'minorModes',\n api: 'api',\n channel: 'channels',\n method: 'methods',\n resource: 'resources',\n};\n\nexport const MCP_FIELDS: Readonly<Record<string, string>> = {\n tool: 'tools',\n skill: 'skills',\n resource: 'uiResources',\n};\n\nexport const WEB_FIELDS: Readonly<Record<string, string>> = {\n tool: 'toolRenderers',\n command: 'paletteCommands',\n mode: 'minorModes',\n channel: 'channels',\n tab: 'tabs',\n template: 'templates',\n dock: 'dockFaces',\n setting: 'settingsSections',\n slot: 'slots',\n // Every fill is a slot fill. The cockpit declares its own regions as slots\n // (overlay, rail, context, activity and so on), so the build tooling needs\n // to know none of their names.\n fill: 'fills',\n action: 'contextActions',\n 'activity-group': 'activityGroups',\n leader: 'leaderBindings',\n 'selection-axis': 'selectionAxes',\n lifecycle: 'start',\n 'file-links': 'fileLinks',\n 'repository-settings-panel': 'repositorySettingsPanel',\n api: NOT_A_CONTRIBUTION,\n method: NOT_A_CONTRIBUTION,\n store: NOT_A_CONTRIBUTION,\n};\n\n/**\n * The subset of the cockpit's fields the native app installs.\n *\n * The values match WEB_FIELDS because the native app reuses the cockpit's\n * plugin registry: a native plugin is a web plugin definition built from\n * `.native` files.\n */\nexport const NATIVE_FIELDS: Readonly<Record<string, string>> = {\n tool: 'toolRenderers',\n tab: 'tabs',\n slot: 'slots',\n fill: 'fills',\n channel: 'channels',\n 'activity-group': 'activityGroups',\n setting: 'settingsSections',\n lifecycle: 'start',\n // Its own field: a phone layout has a different contract from a cockpit template.\n template: 'nativeTemplates',\n store: NOT_A_CONTRIBUTION,\n};\n\n/** Disambiguates the two shapes a `setting/` file can take. */\nexport const SETTING_FIELDS: Readonly<Record<string, string>> = {\n section: 'settingsSections',\n panel: 'settingsPanels',\n};\n\n/** Disambiguates the two shapes an `action/` file can take. */\nexport const ACTION_FIELDS: Readonly<Record<string, string>> = {\n context: 'contextActions',\n message: 'userMessageActions',\n};\n"],"mappings":"AAWA,MAAaA,EAAkD,CAC7D,KAAM,QACN,mBAAoB,mBACpB,QAAS,WACT,KAAM,QACN,KAAM,aACN,IAAK,MACL,QAAS,WACT,OAAQ,UACR,SAAU,WACZ,EAEaC,EAA+C,CAC1D,KAAM,QACN,MAAO,SACP,SAAU,aACZ,EAEaC,EAA+C,CAC1D,KAAM,gBACN,QAAS,kBACT,KAAM,aACN,QAAS,WACT,IAAK,OACL,SAAU,YACV,KAAM,YACN,QAAS,mBACT,KAAM,QAIN,KAAM,QACN,OAAQ,iBACR,iBAAkB,iBAClB,OAAQ,iBACR,iBAAkB,gBAClB,UAAW,QACX,aAAc,YACd,4BAA6B,0BAC7B,IAAA,GACA,OAAA,GACA,MAAA,EACF,EASaC,EAAkD,CAC7D,KAAM,gBACN,IAAK,OACL,KAAM,QACN,KAAM,QACN,QAAS,WACT,iBAAkB,iBAClB,QAAS,
|
|
1
|
+
{"version":3,"file":"contributions.cjs","names":["SERVER_FIELDS","MCP_FIELDS","WEB_FIELDS","NATIVE_FIELDS","SETTING_FIELDS","ACTION_FIELDS","NATIVE_ACTION_FIELDS"],"sources":["../../src/constants/contributions.ts"],"sourcesContent":["/**\n * Which contribution field each surface produces, per host and side.\n *\n * The surface names the concept; the host decides which array carries it.\n * A surface missing from a host's table is legitimately absent there, such\n * as api/ on MCP, and is skipped without complaint.\n */\n\n/** A surface that produces nothing registrable, but is still published. */\nexport const NOT_A_CONTRIBUTION = '';\n\nexport const SERVER_FIELDS: Readonly<Record<string, string>> = {\n tool: 'tools',\n 'tool-restriction': 'toolRestrictions',\n command: 'commands',\n hook: 'hooks',\n mode: 'minorModes',\n api: 'api',\n channel: 'channels',\n method: 'methods',\n resource: 'resources',\n};\n\nexport const MCP_FIELDS: Readonly<Record<string, string>> = {\n tool: 'tools',\n skill: 'skills',\n resource: 'uiResources',\n};\n\nexport const WEB_FIELDS: Readonly<Record<string, string>> = {\n tool: 'toolRenderers',\n command: 'paletteCommands',\n mode: 'minorModes',\n channel: 'channels',\n tab: 'tabs',\n template: 'templates',\n dock: 'dockFaces',\n setting: 'settingsSections',\n slot: 'slots',\n // Every fill is a slot fill. The cockpit declares its own regions as slots\n // (overlay, rail, context, activity and so on), so the build tooling needs\n // to know none of their names.\n fill: 'fills',\n action: 'contextActions',\n 'activity-group': 'activityGroups',\n leader: 'leaderBindings',\n 'selection-axis': 'selectionAxes',\n lifecycle: 'start',\n 'file-links': 'fileLinks',\n 'repository-settings-panel': 'repositorySettingsPanel',\n api: NOT_A_CONTRIBUTION,\n method: NOT_A_CONTRIBUTION,\n store: NOT_A_CONTRIBUTION,\n};\n\n/**\n * The subset of the cockpit's fields the native app installs.\n *\n * The values match WEB_FIELDS because the native app reuses the cockpit's\n * plugin registry: a native plugin is a web plugin definition built from\n * `.native` files.\n */\nexport const NATIVE_FIELDS: Readonly<Record<string, string>> = {\n tool: 'toolRenderers',\n tab: 'tabs',\n slot: 'slots',\n fill: 'fills',\n channel: 'channels',\n 'activity-group': 'activityGroups',\n 'selection-axis': 'selectionAxes',\n setting: 'settingsSections',\n // Only the message shape: see NATIVE_ACTION_FIELDS.\n action: 'userMessageActions',\n lifecycle: 'start',\n // Its own field: a phone layout has a different contract from a cockpit template.\n template: 'nativeTemplates',\n store: NOT_A_CONTRIBUTION,\n};\n\n/** Disambiguates the two shapes a `setting/` file can take. */\nexport const SETTING_FIELDS: Readonly<Record<string, string>> = {\n section: 'settingsSections',\n panel: 'settingsPanels',\n};\n\n/** Disambiguates the two shapes an `action/` file can take. */\nexport const ACTION_FIELDS: Readonly<Record<string, string>> = {\n context: 'contextActions',\n message: 'userMessageActions',\n};\n\n/**\n * The `action/` shapes the native app installs. A phone has no context items,\n * so a context action, named or defaulted, stays unsupported there.\n */\nexport const NATIVE_ACTION_FIELDS: Readonly<Record<string, string>> = {\n message: 'userMessageActions',\n};\n"],"mappings":"AAWA,MAAaA,EAAkD,CAC7D,KAAM,QACN,mBAAoB,mBACpB,QAAS,WACT,KAAM,QACN,KAAM,aACN,IAAK,MACL,QAAS,WACT,OAAQ,UACR,SAAU,WACZ,EAEaC,EAA+C,CAC1D,KAAM,QACN,MAAO,SACP,SAAU,aACZ,EAEaC,EAA+C,CAC1D,KAAM,gBACN,QAAS,kBACT,KAAM,aACN,QAAS,WACT,IAAK,OACL,SAAU,YACV,KAAM,YACN,QAAS,mBACT,KAAM,QAIN,KAAM,QACN,OAAQ,iBACR,iBAAkB,iBAClB,OAAQ,iBACR,iBAAkB,gBAClB,UAAW,QACX,aAAc,YACd,4BAA6B,0BAC7B,IAAA,GACA,OAAA,GACA,MAAA,EACF,EASaC,EAAkD,CAC7D,KAAM,gBACN,IAAK,OACL,KAAM,QACN,KAAM,QACN,QAAS,WACT,iBAAkB,iBAClB,iBAAkB,gBAClB,QAAS,mBAET,OAAQ,qBACR,UAAW,QAEX,SAAU,kBACV,MAAA,EACF,EAGaC,EAAmD,CAC9D,QAAS,mBACT,MAAO,gBACT,EAGaC,EAAkD,CAC7D,QAAS,iBACT,QAAS,oBACX,EAMaC,EAAyD,CACpE,QAAS,oBACX"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const e={tool:`tools`,"tool-restriction":`toolRestrictions`,command:`commands`,hook:`hooks`,mode:`minorModes`,api:`api`,channel:`channels`,method:`methods`,resource:`resources`},t={tool:`tools`,skill:`skills`,resource:`uiResources`},n={tool:`toolRenderers`,command:`paletteCommands`,mode:`minorModes`,channel:`channels`,tab:`tabs`,template:`templates`,dock:`dockFaces`,setting:`settingsSections`,slot:`slots`,fill:`fills`,action:`contextActions`,"activity-group":`activityGroups`,leader:`leaderBindings`,"selection-axis":`selectionAxes`,lifecycle:`start`,"file-links":`fileLinks`,"repository-settings-panel":`repositorySettingsPanel`,api:``,method:``,store:``},r={tool:`toolRenderers`,tab:`tabs`,slot:`slots`,fill:`fills`,channel:`channels`,"activity-group":`activityGroups`,setting:`settingsSections`,lifecycle:`start`,template:`nativeTemplates`,store:``},i={section:`settingsSections`,panel:`settingsPanels`},a={context:`contextActions`,message:`userMessageActions`};export{a as ACTION_FIELDS,t as MCP_FIELDS,r as NATIVE_FIELDS,e as SERVER_FIELDS,i as SETTING_FIELDS,n as WEB_FIELDS};
|
|
1
|
+
const e={tool:`tools`,"tool-restriction":`toolRestrictions`,command:`commands`,hook:`hooks`,mode:`minorModes`,api:`api`,channel:`channels`,method:`methods`,resource:`resources`},t={tool:`tools`,skill:`skills`,resource:`uiResources`},n={tool:`toolRenderers`,command:`paletteCommands`,mode:`minorModes`,channel:`channels`,tab:`tabs`,template:`templates`,dock:`dockFaces`,setting:`settingsSections`,slot:`slots`,fill:`fills`,action:`contextActions`,"activity-group":`activityGroups`,leader:`leaderBindings`,"selection-axis":`selectionAxes`,lifecycle:`start`,"file-links":`fileLinks`,"repository-settings-panel":`repositorySettingsPanel`,api:``,method:``,store:``},r={tool:`toolRenderers`,tab:`tabs`,slot:`slots`,fill:`fills`,channel:`channels`,"activity-group":`activityGroups`,"selection-axis":`selectionAxes`,setting:`settingsSections`,action:`userMessageActions`,lifecycle:`start`,template:`nativeTemplates`,store:``},i={section:`settingsSections`,panel:`settingsPanels`},a={context:`contextActions`,message:`userMessageActions`},o={message:`userMessageActions`};export{a as ACTION_FIELDS,t as MCP_FIELDS,o as NATIVE_ACTION_FIELDS,r as NATIVE_FIELDS,e as SERVER_FIELDS,i as SETTING_FIELDS,n as WEB_FIELDS};
|
|
2
2
|
//# sourceMappingURL=contributions.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contributions.mjs","names":["SERVER_FIELDS","MCP_FIELDS","WEB_FIELDS","NATIVE_FIELDS","SETTING_FIELDS","ACTION_FIELDS"],"sources":["../../src/constants/contributions.ts"],"sourcesContent":["/**\n * Which contribution field each surface produces, per host and side.\n *\n * The surface names the concept; the host decides which array carries it.\n * A surface missing from a host's table is legitimately absent there, such\n * as api/ on MCP, and is skipped without complaint.\n */\n\n/** A surface that produces nothing registrable, but is still published. */\nexport const NOT_A_CONTRIBUTION = '';\n\nexport const SERVER_FIELDS: Readonly<Record<string, string>> = {\n tool: 'tools',\n 'tool-restriction': 'toolRestrictions',\n command: 'commands',\n hook: 'hooks',\n mode: 'minorModes',\n api: 'api',\n channel: 'channels',\n method: 'methods',\n resource: 'resources',\n};\n\nexport const MCP_FIELDS: Readonly<Record<string, string>> = {\n tool: 'tools',\n skill: 'skills',\n resource: 'uiResources',\n};\n\nexport const WEB_FIELDS: Readonly<Record<string, string>> = {\n tool: 'toolRenderers',\n command: 'paletteCommands',\n mode: 'minorModes',\n channel: 'channels',\n tab: 'tabs',\n template: 'templates',\n dock: 'dockFaces',\n setting: 'settingsSections',\n slot: 'slots',\n // Every fill is a slot fill. The cockpit declares its own regions as slots\n // (overlay, rail, context, activity and so on), so the build tooling needs\n // to know none of their names.\n fill: 'fills',\n action: 'contextActions',\n 'activity-group': 'activityGroups',\n leader: 'leaderBindings',\n 'selection-axis': 'selectionAxes',\n lifecycle: 'start',\n 'file-links': 'fileLinks',\n 'repository-settings-panel': 'repositorySettingsPanel',\n api: NOT_A_CONTRIBUTION,\n method: NOT_A_CONTRIBUTION,\n store: NOT_A_CONTRIBUTION,\n};\n\n/**\n * The subset of the cockpit's fields the native app installs.\n *\n * The values match WEB_FIELDS because the native app reuses the cockpit's\n * plugin registry: a native plugin is a web plugin definition built from\n * `.native` files.\n */\nexport const NATIVE_FIELDS: Readonly<Record<string, string>> = {\n tool: 'toolRenderers',\n tab: 'tabs',\n slot: 'slots',\n fill: 'fills',\n channel: 'channels',\n 'activity-group': 'activityGroups',\n setting: 'settingsSections',\n lifecycle: 'start',\n // Its own field: a phone layout has a different contract from a cockpit template.\n template: 'nativeTemplates',\n store: NOT_A_CONTRIBUTION,\n};\n\n/** Disambiguates the two shapes a `setting/` file can take. */\nexport const SETTING_FIELDS: Readonly<Record<string, string>> = {\n section: 'settingsSections',\n panel: 'settingsPanels',\n};\n\n/** Disambiguates the two shapes an `action/` file can take. */\nexport const ACTION_FIELDS: Readonly<Record<string, string>> = {\n context: 'contextActions',\n message: 'userMessageActions',\n};\n"],"mappings":"AAWA,MAAaA,EAAkD,CAC7D,KAAM,QACN,mBAAoB,mBACpB,QAAS,WACT,KAAM,QACN,KAAM,aACN,IAAK,MACL,QAAS,WACT,OAAQ,UACR,SAAU,WACZ,EAEaC,EAA+C,CAC1D,KAAM,QACN,MAAO,SACP,SAAU,aACZ,EAEaC,EAA+C,CAC1D,KAAM,gBACN,QAAS,kBACT,KAAM,aACN,QAAS,WACT,IAAK,OACL,SAAU,YACV,KAAM,YACN,QAAS,mBACT,KAAM,QAIN,KAAM,QACN,OAAQ,iBACR,iBAAkB,iBAClB,OAAQ,iBACR,iBAAkB,gBAClB,UAAW,QACX,aAAc,YACd,4BAA6B,0BAC7B,IAAA,GACA,OAAA,GACA,MAAA,EACF,EASaC,EAAkD,CAC7D,KAAM,gBACN,IAAK,OACL,KAAM,QACN,KAAM,QACN,QAAS,WACT,iBAAkB,iBAClB,QAAS,
|
|
1
|
+
{"version":3,"file":"contributions.mjs","names":["SERVER_FIELDS","MCP_FIELDS","WEB_FIELDS","NATIVE_FIELDS","SETTING_FIELDS","ACTION_FIELDS","NATIVE_ACTION_FIELDS"],"sources":["../../src/constants/contributions.ts"],"sourcesContent":["/**\n * Which contribution field each surface produces, per host and side.\n *\n * The surface names the concept; the host decides which array carries it.\n * A surface missing from a host's table is legitimately absent there, such\n * as api/ on MCP, and is skipped without complaint.\n */\n\n/** A surface that produces nothing registrable, but is still published. */\nexport const NOT_A_CONTRIBUTION = '';\n\nexport const SERVER_FIELDS: Readonly<Record<string, string>> = {\n tool: 'tools',\n 'tool-restriction': 'toolRestrictions',\n command: 'commands',\n hook: 'hooks',\n mode: 'minorModes',\n api: 'api',\n channel: 'channels',\n method: 'methods',\n resource: 'resources',\n};\n\nexport const MCP_FIELDS: Readonly<Record<string, string>> = {\n tool: 'tools',\n skill: 'skills',\n resource: 'uiResources',\n};\n\nexport const WEB_FIELDS: Readonly<Record<string, string>> = {\n tool: 'toolRenderers',\n command: 'paletteCommands',\n mode: 'minorModes',\n channel: 'channels',\n tab: 'tabs',\n template: 'templates',\n dock: 'dockFaces',\n setting: 'settingsSections',\n slot: 'slots',\n // Every fill is a slot fill. The cockpit declares its own regions as slots\n // (overlay, rail, context, activity and so on), so the build tooling needs\n // to know none of their names.\n fill: 'fills',\n action: 'contextActions',\n 'activity-group': 'activityGroups',\n leader: 'leaderBindings',\n 'selection-axis': 'selectionAxes',\n lifecycle: 'start',\n 'file-links': 'fileLinks',\n 'repository-settings-panel': 'repositorySettingsPanel',\n api: NOT_A_CONTRIBUTION,\n method: NOT_A_CONTRIBUTION,\n store: NOT_A_CONTRIBUTION,\n};\n\n/**\n * The subset of the cockpit's fields the native app installs.\n *\n * The values match WEB_FIELDS because the native app reuses the cockpit's\n * plugin registry: a native plugin is a web plugin definition built from\n * `.native` files.\n */\nexport const NATIVE_FIELDS: Readonly<Record<string, string>> = {\n tool: 'toolRenderers',\n tab: 'tabs',\n slot: 'slots',\n fill: 'fills',\n channel: 'channels',\n 'activity-group': 'activityGroups',\n 'selection-axis': 'selectionAxes',\n setting: 'settingsSections',\n // Only the message shape: see NATIVE_ACTION_FIELDS.\n action: 'userMessageActions',\n lifecycle: 'start',\n // Its own field: a phone layout has a different contract from a cockpit template.\n template: 'nativeTemplates',\n store: NOT_A_CONTRIBUTION,\n};\n\n/** Disambiguates the two shapes a `setting/` file can take. */\nexport const SETTING_FIELDS: Readonly<Record<string, string>> = {\n section: 'settingsSections',\n panel: 'settingsPanels',\n};\n\n/** Disambiguates the two shapes an `action/` file can take. */\nexport const ACTION_FIELDS: Readonly<Record<string, string>> = {\n context: 'contextActions',\n message: 'userMessageActions',\n};\n\n/**\n * The `action/` shapes the native app installs. A phone has no context items,\n * so a context action, named or defaulted, stays unsupported there.\n */\nexport const NATIVE_ACTION_FIELDS: Readonly<Record<string, string>> = {\n message: 'userMessageActions',\n};\n"],"mappings":"AAWA,MAAaA,EAAkD,CAC7D,KAAM,QACN,mBAAoB,mBACpB,QAAS,WACT,KAAM,QACN,KAAM,aACN,IAAK,MACL,QAAS,WACT,OAAQ,UACR,SAAU,WACZ,EAEaC,EAA+C,CAC1D,KAAM,QACN,MAAO,SACP,SAAU,aACZ,EAEaC,EAA+C,CAC1D,KAAM,gBACN,QAAS,kBACT,KAAM,aACN,QAAS,WACT,IAAK,OACL,SAAU,YACV,KAAM,YACN,QAAS,mBACT,KAAM,QAIN,KAAM,QACN,OAAQ,iBACR,iBAAkB,iBAClB,OAAQ,iBACR,iBAAkB,gBAClB,UAAW,QACX,aAAc,YACd,4BAA6B,0BAC7B,IAAA,GACA,OAAA,GACA,MAAA,EACF,EASaC,EAAkD,CAC7D,KAAM,gBACN,IAAK,OACL,KAAM,QACN,KAAM,QACN,QAAS,WACT,iBAAkB,iBAClB,iBAAkB,gBAClB,QAAS,mBAET,OAAQ,qBACR,UAAW,QAEX,SAAU,kBACV,MAAA,EACF,EAGaC,EAAmD,CAC9D,QAAS,mBACT,MAAO,gBACT,EAGaC,EAAkD,CAC7D,QAAS,iBACT,QAAS,oBACX,EAMaC,EAAyD,CACpE,QAAS,oBACX"}
|
|
@@ -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`],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`];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.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`],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`];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`;
|
|
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 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[] = ['pi'
|
|
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/** Filename infixes excluded everywhere, whatever their position. */\nexport const EXCLUDED_INFIXES: readonly string[] = ['test', 'spec', 'stories'];\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,EA+BpDC,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,EAQ7EC,EAAsC,CACjD,OACA,QACA,mBACA,UACA,OACA,MACA,UACA,SACA,WACA,UACF,EAKaC,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,EAGjEC,EAAsC,CAAC,OAAQ,OAAQ,SAAS"}
|
|
@@ -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;;;;;;;qBAiEA;qBACA;;;;;;;qBAQA;;;;;;;qBAWA;;;;qBAgBA;;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`},d=`client`,f=`src/types/apiRoutes.ts`,
|
|
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`},d=`client`,f=`client.native`,p=`src/types/apiRoutes.ts`,m=[`pi`,`server`,`web`,`native`,`mcp`,`client`,`client.native`],h=[`server`,`mcp`],g=[`web`,`native`,`ios`,`android`,`desktop`],_=`native`,v=[`server`,`web`,`native`,`mcp`],y=[`tool`,`skill`,`tool-restriction`,`command`,`hook`,`api`,`channel`,`method`,`provider`,`resource`],b=[`tool`,`command`,`api`,`channel`,`method`,`tab`,`template`,`dock`,`setting`,`slot`,`fill`,`action`,`store`,`activity-group`,`leader`,`selection-axis`,`lifecycle`,`file-links`,`repository-settings-panel`],x=[`fill`,`action`],S=[`api`],C=[`ts`,`tsx`,`mts`,`cts`],w=[`test`,`spec`,`stories`];export{p as API_ROUTES_MODULE,n as BACKEND_GROUP,h as BACKEND_PLATFORMS,y as BACKEND_SURFACES,v as BUILD_TARGET_PLATFORMS,e as DEFAULT_ROUTING_ROOT,w as EXCLUDED_INFIXES,r as FRONTEND_GROUP,g as FRONTEND_PLATFORMS,b as FRONTEND_SURFACES,o as GATE_SEGMENTS,d as GENERATED_CLIENT_NAME,l as GENERATED_DIR,u as GENERATED_ENTRY_FILENAMES,m as GENERATED_ENTRY_NAMES,f as GENERATED_NATIVE_CLIENT_NAME,_ as NATIVE_PLATFORM,c as ROOT_FILE_NAME,S as ROUTED_SURFACES,s as ROUTE_FILE_NAME,t as ROUTING_ROOT_ALIAS,a as SESSION_SEGMENT,C as SOURCE_EXTENSIONS,x 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","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 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[] = ['pi'
|
|
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/** Filename infixes excluded everywhere, whatever their position. */\nexport const EXCLUDED_INFIXES: readonly string[] = ['test', 'spec', 'stories'];\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,YAQhBC,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,EAQ7EC,EAAsC,CACjD,OACA,QACA,mBACA,UACA,OACA,MACA,UACA,SACA,WACA,UACF,EAKaC,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,EAGjEC,EAAsC,CAAC,OAAQ,OAAQ,SAAS"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
const e=require("../../_virtual/_rolldown/runtime.cjs"),t=require("../../constants/layout.cjs"),n=require("../scan/index.cjs"),r=require("../resolveTarget/index.cjs"),i=require("../renderClient/index.cjs"),a=require("../renderEntry/index.cjs"),o=require("../renderMcpWidgets/index.cjs"),s=require("../writeGenerated/index.cjs");let c=require("node:fs");c=e.__toESM(c,1);let l=require("node:path");l=e.__toESM(l,1);function u(e){return e.replace(/^@[^/]+\//u,``).replace(/^po-/u,``)}function d(e){let t=JSON.parse(c.default.readFileSync(l.default.join(e,`package.json`),`utf8`));if(typeof t.name!=`string`)throw Error(`${e}/package.json has no name`);return t.name}const f={server:a.renderServerEntry,web:a.renderWebEntry,native:a.renderNativeEntry,mcp:a.renderMcpEntry},p=t.GENERATED_ENTRY_FILENAMES;function m(e){let a=e.packageName??d(e.packageDir),m=e.pluginId??u(a),h=n.scanExtensions(e),g=[...h.notices],_=/* @__PURE__ */ new Map,v=[],y=e.target===`mcp`?o.renderMcpWidgets(h,a,t.GENERATED_DIR):void 0;y?.source!==void 0&&_.set(`${t.GENERATED_DIR}/mcp-ui.ts`,y.source);for(let e of h.entries)e.platform===void 0||t.BUILD_TARGET_PLATFORMS.includes(e.platform)||g.push({path:e.file,message:`'${e.platform}' is a forward-looking platform with no build target; this file is not emitted for server, web, native or mcp`});let b=h.notices.filter(e=>e.message===n.RETIRED_PLATFORM_NOTICE);if(b.length>0)throw Error(`${a}: ${n.RETIRED_PLATFORM_NOTICE}\n${b.map(e=>` ${e.path}`).join(`
|
|
2
|
-
`)}`);let x=e.target===void 0?[`server`,`web`,`native`]:[e.target];for(let e of x){let n=r.resolveTarget(h,e);if(g.push(...n.notices),n.contributions.length===0&&n.escapeHatches.length===0&&n.roots.length===0)continue;v.push(e);let i=f[e],o=i(n,{packageName:a,pluginId:m,root:h.root,entryDir:t.GENERATED_DIR,mcpWidgets:y?.declarations});_.set(`${t.GENERATED_DIR}/${p[e]}.ts`,o)}let S=e.target===void 0&&c.default.existsSync(l.default.join(e.packageDir,`src/types/apiRoutes.ts`)),C=v.includes(`web`),w=S&&C?i.renderApiClient(h,{packageName:a,pluginId:m,root:h.root,entryDir:t.GENERATED_DIR}):void 0;w!==void 0&&_.set(`${t.GENERATED_DIR}/${t.GENERATED_CLIENT_NAME}.ts`,w),S&&C&&w===void 0&&g.push({path:t.API_ROUTES_MODULE,message:`declares API routes, but no (backend)/api/<base-path>/ folder says where they are mounted`});let
|
|
2
|
+
`)}`);let x=e.target===void 0?[`server`,`web`,`native`]:[e.target];for(let e of x){let n=r.resolveTarget(h,e);if(g.push(...n.notices),n.contributions.length===0&&n.escapeHatches.length===0&&n.roots.length===0)continue;v.push(e);let i=f[e],o=i(n,{packageName:a,pluginId:m,root:h.root,entryDir:t.GENERATED_DIR,mcpWidgets:y?.declarations});_.set(`${t.GENERATED_DIR}/${p[e]}.ts`,o)}let S=e.target===void 0&&c.default.existsSync(l.default.join(e.packageDir,`src/types/apiRoutes.ts`)),C=v.includes(`web`),w=S&&C?i.renderApiClient(h,{packageName:a,pluginId:m,root:h.root,entryDir:t.GENERATED_DIR}):void 0;w!==void 0&&_.set(`${t.GENERATED_DIR}/${t.GENERATED_CLIENT_NAME}.ts`,w);let T=v.includes(`native`),E=S&&T?i.renderNativeApiClient(h,{packageName:a,pluginId:m,root:h.root,entryDir:t.GENERATED_DIR}):void 0;E!==void 0&&_.set(`${t.GENERATED_DIR}/${t.GENERATED_NATIVE_CLIENT_NAME}.ts`,E),S&&(C||T)&&w===void 0&&E===void 0&&g.push({path:t.API_ROUTES_MODULE,message:`declares API routes, but no (backend)/api/<base-path>/ folder says where they are mounted`});let D=e.target===void 0?t.GENERATED_ENTRY_NAMES.filter(t=>t!==`mcp`||!c.default.existsSync(l.default.join(e.packageDir,`tsdown.mcp.config.ts`))).map(e=>`${t.GENERATED_DIR}/${e}.ts`):[`${t.GENERATED_DIR}/${p[e.target]}.ts`,...e.target===`mcp`?[`${t.GENERATED_DIR}/mcp-ui.ts`]:[]],{changed:O}=s.writeGenerated(e.packageDir,_,e.check,D);return{graph:h,packageName:a,pluginId:m,files:_,changed:O,notices:g,targets:v}}exports.defaultPluginId=u,exports.generateExtension=m;
|
|
3
3
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["fs","path","renderServerEntry","renderWebEntry","renderNativeEntry","renderMcpEntry","GENERATED_ENTRY_FILENAMES","scanExtensions","renderMcpWidgets","GENERATED_DIR","BUILD_TARGET_PLATFORMS","RETIRED_PLATFORM_NOTICE","resolveTarget","renderApiClient","GENERATED_CLIENT_NAME","API_ROUTES_MODULE","GENERATED_ENTRY_NAMES","writeGenerated","require_runtime","require_layout","require_index","require_index$1","require_index$2","require_index$3","require_index$4","require_index$5","node_fs","node_path","defaultPluginId","packageName","readPackageName","manifest","packageDir","RENDERERS","ENTRY_FILENAME","generateExtension","options","pluginId","graph","notices","files","targets","mcpWidgets","entry","retired","notice","requestedTargets","target","resolution","render","source","hasRouteTable","hasBrowserHalf","client","managed","name"],"sources":["../../../src/services/generate/index.ts"],"sourcesContent":["import fs from 'node:fs';\nimport path from 'node:path';\n\nimport {\n API_ROUTES_MODULE,\n BUILD_TARGET_PLATFORMS,\n GENERATED_CLIENT_NAME,\n GENERATED_DIR,\n GENERATED_ENTRY_FILENAMES,\n GENERATED_ENTRY_NAMES,\n} from '../../constants/layout';\nimport type { ExtensionGraph, ExtensionNotice } from '../../types/extensionGraph';\nimport { renderApiClient } from '../renderClient';\nimport { renderMcpEntry, renderNativeEntry, renderServerEntry, renderWebEntry } from '../renderEntry';\nimport { renderMcpWidgets } from '../renderMcpWidgets';\nimport { resolveTarget } from '../resolveTarget';\nimport type { BuildTarget } from '../resolveTarget/type';\nimport { RETIRED_PLATFORM_NOTICE, scanExtensions } from '../scan';\nimport { writeGenerated } from '../writeGenerated';\nimport type { GenerateOptions, GenerateResult } from './type';\n\n/** `@agimon-ai/po-plan` becomes `plan`. */\nexport function defaultPluginId(packageName: string): string {\n return packageName.replace(/^@[^/]+\\//u, '').replace(/^po-/u, '');\n}\n\nfunction readPackageName(packageDir: string): string {\n const manifest = JSON.parse(fs.readFileSync(path.join(packageDir, 'package.json'), 'utf8')) as { name?: unknown };\n if (typeof manifest.name !== 'string') throw new Error(`${packageDir}/package.json has no name`);\n return manifest.name;\n}\n\nconst RENDERERS: Readonly<Record<BuildTarget, typeof renderServerEntry>> = {\n server: renderServerEntry,\n web: renderWebEntry,\n native: renderNativeEntry,\n mcp: renderMcpEntry,\n};\n\nconst ENTRY_FILENAME: Readonly<Record<BuildTarget, string>> = GENERATED_ENTRY_FILENAMES;\n\n/**\n * Scans a package and renders every entry its tree calls for.\n *\n * A target with nothing in it produces no file, so a backend-only package\n * never grows an empty cockpit entry. Notices from the scan and from each\n * resolution are gathered rather than thrown: an unrecognised folder costs\n * that folder, never the build.\n */\nexport function generateExtension(options: GenerateOptions): GenerateResult {\n const packageName = options.packageName ?? readPackageName(options.packageDir);\n const pluginId = options.pluginId ?? defaultPluginId(packageName);\n\n const graph: ExtensionGraph = scanExtensions(options);\n const notices: ExtensionNotice[] = [...graph.notices];\n const files = new Map<string, string>();\n const targets: BuildTarget[] = [];\n const mcpWidgets = options.target === 'mcp' ? renderMcpWidgets(graph, packageName, GENERATED_DIR) : undefined;\n if (mcpWidgets?.source !== undefined) files.set(`${GENERATED_DIR}/mcp-ui.ts`, mcpWidgets.source);\n\n // Here rather than in the scan, deliberately. The doomRoutedFilePosition lint\n // rule calls scanExtensions() directly, so a scan notice would make `.ios` a\n // hard preflight failure and cost us the forward-looking platforms we kept on\n // purpose. resolveTarget runs once per target, which would repeat it per target.\n for (const entry of graph.entries) {\n if (entry.platform === undefined || BUILD_TARGET_PLATFORMS.includes(entry.platform)) continue;\n notices.push({\n path: entry.file,\n message: `'${entry.platform}' is a forward-looking platform with no build target; this file is not emitted for server, web, native or mcp`,\n });\n }\n\n const retired = graph.notices.filter((notice) => notice.message === RETIRED_PLATFORM_NOTICE);\n if (retired.length > 0) {\n throw new Error(\n `${packageName}: ${RETIRED_PLATFORM_NOTICE}\\n${retired.map((notice) => ` ${notice.path}`).join('\\n')}`,\n );\n }\n\n const requestedTargets = options.target === undefined ? (['server', 'web', 'native'] as const) : [options.target];\n for (const target of requestedTargets) {\n const resolution = resolveTarget(graph, target);\n notices.push(...resolution.notices);\n if (resolution.contributions.length === 0 && resolution.escapeHatches.length === 0 && resolution.roots.length === 0)\n continue;\n\n targets.push(target);\n const render = RENDERERS[target];\n const source = render(resolution, {\n packageName,\n pluginId,\n root: graph.root,\n entryDir: GENERATED_DIR,\n mcpWidgets: mcpWidgets?.declarations,\n });\n files.set(`${GENERATED_DIR}/${ENTRY_FILENAME[target]}.ts`, source);\n }\n\n // Not another build target: no host loads it as an entry, and adding one to\n // the target loop would mean a resolution pass and a contribution field for\n // something that is only ever imported by a routed frontend file.\n //\n // Only for a package that has a browser half. The client exists to be called\n // from a page and it carries the sealed transport, so emitting one into a\n // node-only package asks that package to depend on a browser runtime it never\n // loads, to satisfy a file nothing imports.\n const hasRouteTable = options.target === undefined && fs.existsSync(path.join(options.packageDir, API_ROUTES_MODULE));\n const hasBrowserHalf = targets.includes('web');\n const client =\n hasRouteTable && hasBrowserHalf\n ? renderApiClient(graph, { packageName, pluginId, root: graph.root, entryDir: GENERATED_DIR })\n : undefined;\n if (client !== undefined) files.set(`${GENERATED_DIR}/${GENERATED_CLIENT_NAME}.ts`, client);\n if (hasRouteTable && hasBrowserHalf && client === undefined) {\n notices.push({\n path: API_ROUTES_MODULE,\n message: 'declares API routes, but no (backend)/api/<base-path>/ folder says where they are mounted',\n });\n }\n\n const managed =\n options.target === undefined\n ? GENERATED_ENTRY_NAMES.filter(\n (name) => name !== 'mcp' || !fs.existsSync(path.join(options.packageDir, 'tsdown.mcp.config.ts')),\n ).map((name) => `${GENERATED_DIR}/${name}.ts`)\n : [\n `${GENERATED_DIR}/${ENTRY_FILENAME[options.target]}.ts`,\n ...(options.target === 'mcp' ? [`${GENERATED_DIR}/mcp-ui.ts`] : []),\n ];\n const { changed } = writeGenerated(options.packageDir, files, options.check, managed);\n return { graph, packageName, pluginId, files, changed, notices, targets };\n}\n"],"mappings":"8ZAsBA,SAAgB4B,EAAgB,EAA6B,CAC3D,OAAOC,EAAY,QAAQ,aAAc,EAAE,CAAC,CAAC,QAAQ,QAAS,EAAE,CAClE,CAEA,SAASC,EAAgB,EAA4B,CACnD,IAAMC,EAAW,KAAK,MAAM/B,EAAAA,QAAG,aAAaC,EAAAA,QAAK,KAAK+B,EAAY,cAAc,EAAG,MAAM,CAAC,EAC1F,GAAI,OAAOD,EAAS,MAAS,SAAU,MAAU,MAAM,GAAGC,EAAW,0BAA0B,EAC/F,OAAOD,EAAS,IAClB,CAEA,MAAME,EAAqE,CACzE,OAAQ/B,EAAAA,kBACR,IAAKC,EAAAA,eACL,OAAQC,EAAAA,kBACR,IAAKC,EAAAA,cACP,EAEM6B,EAAwD5B,EAAAA,0BAU9D,SAAgB6B,EAAkB,EAA0C,CAC1E,IAAMN,EAAcO,EAAQ,aAAeN,EAAgBM,EAAQ,UAAU,EACvEC,EAAWD,EAAQ,UAAYR,EAAgBC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G/B,EAAAA,cAAc,GAAGyB,EAAea,GAAQ,KAAMG,CAAM,CACnE,CAUA,IAAMC,EAAgBf,EAAQ,SAAW,IAAA,IAAapC,EAAAA,QAAG,WAAWC,EAAAA,QAAK,KAAKmC,EAAQ,WAAA,wBAA6B,CAAC,EAC9GgB,EAAiBX,EAAQ,SAAS,KAAK,EACvCY,EACJF,GAAiBC,EACbvC,EAAAA,gBAAgByB,EAAO,CAAE,cAAa,WAAU,KAAMA,EAAM,KAAM,SAAU7B,EAAAA,aAAc,CAAC,EAC3F,IAAA,GACF4C,IAAW,IAAA,IAAWb,EAAM,IAAI,GAAG/B,EAAAA,cAAc,GAAGK,EAAAA,sBAAsB,KAAMuC,CAAM,EACtFF,GAAiBC,GAAkBC,IAAW,IAAA,IAChDd,EAAQ,KAAK,CACX,KAAMxB,EAAAA,kBACN,QAAS,2FACX,CAAC,EAGH,IAAMuC,EACJlB,EAAQ,SAAW,IAAA,GACfpB,EAAAA,sBAAsB,OACnB,GAASuC,IAAS,OAAS,CAACvD,EAAAA,QAAG,WAAWC,EAAAA,QAAK,KAAKmC,EAAQ,WAAY,sBAAsB,CAAC,CAClG,CAAC,CAAC,IAAK,GAAS,GAAG3B,EAAAA,cAAc,GAAG8C,EAAK,IAAI,EAC7C,CACE,GAAG9C,EAAAA,cAAc,GAAGyB,EAAeE,EAAQ,QAAQ,KACnD,GAAIA,EAAQ,SAAW,MAAQ,CAAC,GAAG3B,EAAAA,cAAc,WAAW,EAAI,CAAC,CACnE,EACA,CAAE,WAAYQ,EAAAA,eAAemB,EAAQ,WAAYI,EAAOJ,EAAQ,MAAOkB,CAAO,EACpF,MAAO,CAAE,QAAO,cAAa,WAAU,QAAO,UAAS,UAAS,SAAQ,CAC1E"}
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["fs","path","renderServerEntry","renderWebEntry","renderNativeEntry","renderMcpEntry","GENERATED_ENTRY_FILENAMES","scanExtensions","renderMcpWidgets","GENERATED_DIR","BUILD_TARGET_PLATFORMS","RETIRED_PLATFORM_NOTICE","resolveTarget","renderApiClient","GENERATED_CLIENT_NAME","renderNativeApiClient","GENERATED_NATIVE_CLIENT_NAME","API_ROUTES_MODULE","GENERATED_ENTRY_NAMES","writeGenerated","require_runtime","require_layout","require_index","require_index$1","require_index$2","require_index$3","require_index$4","require_index$5","node_fs","node_path","defaultPluginId","packageName","readPackageName","manifest","packageDir","RENDERERS","ENTRY_FILENAME","generateExtension","options","pluginId","graph","notices","files","targets","mcpWidgets","entry","retired","notice","requestedTargets","target","resolution","render","source","hasRouteTable","hasBrowserHalf","client","hasNativeHalf","nativeClient","managed","name"],"sources":["../../../src/services/generate/index.ts"],"sourcesContent":["import fs from 'node:fs';\nimport path from 'node:path';\n\nimport {\n API_ROUTES_MODULE,\n BUILD_TARGET_PLATFORMS,\n GENERATED_CLIENT_NAME,\n GENERATED_DIR,\n GENERATED_ENTRY_FILENAMES,\n GENERATED_ENTRY_NAMES,\n GENERATED_NATIVE_CLIENT_NAME,\n} from '../../constants/layout';\nimport type { ExtensionGraph, ExtensionNotice } from '../../types/extensionGraph';\nimport { renderApiClient, renderNativeApiClient } from '../renderClient';\nimport { renderMcpEntry, renderNativeEntry, renderServerEntry, renderWebEntry } from '../renderEntry';\nimport { renderMcpWidgets } from '../renderMcpWidgets';\nimport { resolveTarget } from '../resolveTarget';\nimport type { BuildTarget } from '../resolveTarget/type';\nimport { RETIRED_PLATFORM_NOTICE, scanExtensions } from '../scan';\nimport { writeGenerated } from '../writeGenerated';\nimport type { GenerateOptions, GenerateResult } from './type';\n\n/** `@agimon-ai/po-plan` becomes `plan`. */\nexport function defaultPluginId(packageName: string): string {\n return packageName.replace(/^@[^/]+\\//u, '').replace(/^po-/u, '');\n}\n\nfunction readPackageName(packageDir: string): string {\n const manifest = JSON.parse(fs.readFileSync(path.join(packageDir, 'package.json'), 'utf8')) as { name?: unknown };\n if (typeof manifest.name !== 'string') throw new Error(`${packageDir}/package.json has no name`);\n return manifest.name;\n}\n\nconst RENDERERS: Readonly<Record<BuildTarget, typeof renderServerEntry>> = {\n server: renderServerEntry,\n web: renderWebEntry,\n native: renderNativeEntry,\n mcp: renderMcpEntry,\n};\n\nconst ENTRY_FILENAME: Readonly<Record<BuildTarget, string>> = GENERATED_ENTRY_FILENAMES;\n\n/**\n * Scans a package and renders every entry its tree calls for.\n *\n * A target with nothing in it produces no file, so a backend-only package\n * never grows an empty cockpit entry. Notices from the scan and from each\n * resolution are gathered rather than thrown: an unrecognised folder costs\n * that folder, never the build.\n */\nexport function generateExtension(options: GenerateOptions): GenerateResult {\n const packageName = options.packageName ?? readPackageName(options.packageDir);\n const pluginId = options.pluginId ?? defaultPluginId(packageName);\n\n const graph: ExtensionGraph = scanExtensions(options);\n const notices: ExtensionNotice[] = [...graph.notices];\n const files = new Map<string, string>();\n const targets: BuildTarget[] = [];\n const mcpWidgets = options.target === 'mcp' ? renderMcpWidgets(graph, packageName, GENERATED_DIR) : undefined;\n if (mcpWidgets?.source !== undefined) files.set(`${GENERATED_DIR}/mcp-ui.ts`, mcpWidgets.source);\n\n // Here rather than in the scan, deliberately. The doomRoutedFilePosition lint\n // rule calls scanExtensions() directly, so a scan notice would make `.ios` a\n // hard preflight failure and cost us the forward-looking platforms we kept on\n // purpose. resolveTarget runs once per target, which would repeat it per target.\n for (const entry of graph.entries) {\n if (entry.platform === undefined || BUILD_TARGET_PLATFORMS.includes(entry.platform)) continue;\n notices.push({\n path: entry.file,\n message: `'${entry.platform}' is a forward-looking platform with no build target; this file is not emitted for server, web, native or mcp`,\n });\n }\n\n const retired = graph.notices.filter((notice) => notice.message === RETIRED_PLATFORM_NOTICE);\n if (retired.length > 0) {\n throw new Error(\n `${packageName}: ${RETIRED_PLATFORM_NOTICE}\\n${retired.map((notice) => ` ${notice.path}`).join('\\n')}`,\n );\n }\n\n const requestedTargets = options.target === undefined ? (['server', 'web', 'native'] as const) : [options.target];\n for (const target of requestedTargets) {\n const resolution = resolveTarget(graph, target);\n notices.push(...resolution.notices);\n if (resolution.contributions.length === 0 && resolution.escapeHatches.length === 0 && resolution.roots.length === 0)\n continue;\n\n targets.push(target);\n const render = RENDERERS[target];\n const source = render(resolution, {\n packageName,\n pluginId,\n root: graph.root,\n entryDir: GENERATED_DIR,\n mcpWidgets: mcpWidgets?.declarations,\n });\n files.set(`${GENERATED_DIR}/${ENTRY_FILENAME[target]}.ts`, source);\n }\n\n // Not another build target: no host loads it as an entry, and adding one to\n // the target loop would mean a resolution pass and a contribution field for\n // something that is only ever imported by a routed frontend file.\n //\n // Only for a package that has a browser half. The client exists to be called\n // from a page and it carries the sealed transport, so emitting one into a\n // node-only package asks that package to depend on a browser runtime it never\n // loads, to satisfy a file nothing imports.\n const hasRouteTable = options.target === undefined && fs.existsSync(path.join(options.packageDir, API_ROUTES_MODULE));\n const hasBrowserHalf = targets.includes('web');\n const client =\n hasRouteTable && hasBrowserHalf\n ? renderApiClient(graph, { packageName, pluginId, root: graph.root, entryDir: GENERATED_DIR })\n : undefined;\n if (client !== undefined) files.set(`${GENERATED_DIR}/${GENERATED_CLIENT_NAME}.ts`, client);\n\n // The native half gets its own file rather than a shared one, because the\n // browser client's two imports are exactly what the native host refuses.\n const hasNativeHalf = targets.includes('native');\n const nativeClient =\n hasRouteTable && hasNativeHalf\n ? renderNativeApiClient(graph, { packageName, pluginId, root: graph.root, entryDir: GENERATED_DIR })\n : undefined;\n if (nativeClient !== undefined) files.set(`${GENERATED_DIR}/${GENERATED_NATIVE_CLIENT_NAME}.ts`, nativeClient);\n if (hasRouteTable && (hasBrowserHalf || hasNativeHalf) && client === undefined && nativeClient === undefined) {\n notices.push({\n path: API_ROUTES_MODULE,\n message: 'declares API routes, but no (backend)/api/<base-path>/ folder says where they are mounted',\n });\n }\n\n const managed =\n options.target === undefined\n ? GENERATED_ENTRY_NAMES.filter(\n (name) => name !== 'mcp' || !fs.existsSync(path.join(options.packageDir, 'tsdown.mcp.config.ts')),\n ).map((name) => `${GENERATED_DIR}/${name}.ts`)\n : [\n `${GENERATED_DIR}/${ENTRY_FILENAME[options.target]}.ts`,\n ...(options.target === 'mcp' ? [`${GENERATED_DIR}/mcp-ui.ts`] : []),\n ];\n const { changed } = writeGenerated(options.packageDir, files, options.check, managed);\n return { graph, packageName, pluginId, files, changed, notices, targets };\n}\n"],"mappings":"8ZAuBA,SAAgB8B,EAAgB,EAA6B,CAC3D,OAAOC,EAAY,QAAQ,aAAc,EAAE,CAAC,CAAC,QAAQ,QAAS,EAAE,CAClE,CAEA,SAASC,EAAgB,EAA4B,CACnD,IAAMC,EAAW,KAAK,MAAMjC,EAAAA,QAAG,aAAaC,EAAAA,QAAK,KAAKiC,EAAY,cAAc,EAAG,MAAM,CAAC,EAC1F,GAAI,OAAOD,EAAS,MAAS,SAAU,MAAU,MAAM,GAAGC,EAAW,0BAA0B,EAC/F,OAAOD,EAAS,IAClB,CAEA,MAAME,EAAqE,CACzE,OAAQjC,EAAAA,kBACR,IAAKC,EAAAA,eACL,OAAQC,EAAAA,kBACR,IAAKC,EAAAA,cACP,EAEM+B,EAAwD9B,EAAAA,0BAU9D,SAAgB+B,EAAkB,EAA0C,CAC1E,IAAMN,EAAcO,EAAQ,aAAeN,EAAgBM,EAAQ,UAAU,EACvEC,EAAWD,EAAQ,UAAYR,EAAgBC,CAAW,EAE1DS,EAAwBjC,EAAAA,eAAe+B,CAAO,EAC9CG,EAA6B,CAAC,GAAGD,EAAM,OAAO,EAC9CE,kBAAQ,IAAI,IACZC,EAAyB,CAAC,EAC1BC,EAAaN,EAAQ,SAAW,MAAQ9B,EAAAA,iBAAiBgC,EAAOT,EAAatB,EAAAA,aAAa,EAAI,IAAA,GAChGmC,GAAY,SAAW,IAAA,IAAWF,EAAM,IAAI,GAAGjC,EAAAA,cAAc,YAAamC,EAAW,MAAM,EAM/F,IAAK,IAAMC,KAASL,EAAM,QACpBK,EAAM,WAAa,IAAA,IAAanC,EAAAA,uBAAuB,SAASmC,EAAM,QAAQ,GAClFJ,EAAQ,KAAK,CACX,KAAMI,EA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MC,EAAgBb,EAAQ,SAAS,QAAQ,EACzCc,EACJJ,GAAiBG,EACbzC,EAAAA,sBAAsByB,EAAO,CAAE,cAAa,WAAU,KAAMA,EAAM,KAAM,SAAU/B,EAAAA,aAAc,CAAC,EACjG,IAAA,GACFgD,IAAiB,IAAA,IAAWf,EAAM,IAAI,GAAGjC,EAAAA,cAAc,GAAGO,EAAAA,6BAA6B,KAAMyC,CAAY,EACzGJ,IAAkBC,GAAkBE,IAAkBD,IAAW,IAAA,IAAaE,IAAiB,IAAA,IACjGhB,EAAQ,KAAK,CACX,KAAMxB,EAAAA,kBACN,QAAS,2FACX,CAAC,EAGH,IAAMyC,EACJpB,EAAQ,SAAW,IAAA,GACfpB,EAAAA,sBAAsB,OACnB,GAASyC,IAAS,OAAS,CAAC3D,EAAAA,QAAG,WAAWC,EAAAA,QAAK,KAAKqC,EAAQ,WAAY,sBAAsB,CAAC,CAClG,CAAC,CAAC,IAAK,GAAS,GAAG7B,EAAAA,cAAc,GAAGkD,EAAK,IAAI,EAC7C,CACE,GAAGlD,EAAAA,cAAc,GAAG2B,EAAeE,EAAQ,QAAQ,KACnD,GAAIA,EAAQ,SAAW,MAAQ,CAAC,GAAG7B,EAAAA,cAAc,WAAW,EAAI,CAAC,CACnE,EACA,CAAE,WAAYU,EAAAA,eAAemB,EAAQ,WAAYI,EAAOJ,EAAQ,MAAOoB,CAAO,EACpF,MAAO,CAAE,QAAO,cAAa,WAAU,QAAO,UAAS,UAAS,SAAQ,CAC1E"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../../../src/services/generate/index.ts"],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../../../src/services/generate/index.ts"],"mappings":";;;wBAuBgB,gBAAgB;;;;;;;;;wBA2BhB,kBAAkB,SAAS,kBAAkB"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{API_ROUTES_MODULE as e,BUILD_TARGET_PLATFORMS as t,GENERATED_CLIENT_NAME as n,GENERATED_DIR as r,GENERATED_ENTRY_FILENAMES as i,GENERATED_ENTRY_NAMES as a}from"../../constants/layout.mjs";import{RETIRED_PLATFORM_NOTICE as
|
|
2
|
-
`)}`);let
|
|
1
|
+
import{API_ROUTES_MODULE as e,BUILD_TARGET_PLATFORMS as t,GENERATED_CLIENT_NAME as n,GENERATED_DIR as r,GENERATED_ENTRY_FILENAMES as i,GENERATED_ENTRY_NAMES as a,GENERATED_NATIVE_CLIENT_NAME as o}from"../../constants/layout.mjs";import{RETIRED_PLATFORM_NOTICE as s,scanExtensions as c}from"../scan/index.mjs";import{resolveTarget as l}from"../resolveTarget/index.mjs";import{renderApiClient as u,renderNativeApiClient as d}from"../renderClient/index.mjs";import{renderMcpEntry as f,renderNativeEntry as p,renderServerEntry as m,renderWebEntry as h}from"../renderEntry/index.mjs";import{renderMcpWidgets as g}from"../renderMcpWidgets/index.mjs";import{writeGenerated as _}from"../writeGenerated/index.mjs";import v from"node:fs";import y from"node:path";function b(e){return e.replace(/^@[^/]+\//u,``).replace(/^po-/u,``)}function x(e){let t=JSON.parse(v.readFileSync(y.join(e,`package.json`),`utf8`));if(typeof t.name!=`string`)throw Error(`${e}/package.json has no name`);return t.name}const S={server:m,web:h,native:p,mcp:f},C=i;function w(i){let f=i.packageName??x(i.packageDir),p=i.pluginId??b(f),m=c(i),h=[...m.notices],w=/* @__PURE__ */ new Map,T=[],E=i.target===`mcp`?g(m,f,r):void 0;E?.source!==void 0&&w.set(`${r}/mcp-ui.ts`,E.source);for(let e of m.entries)e.platform===void 0||t.includes(e.platform)||h.push({path:e.file,message:`'${e.platform}' is a forward-looking platform with no build target; this file is not emitted for server, web, native or mcp`});let D=m.notices.filter(e=>e.message===s);if(D.length>0)throw Error(`${f}: ${s}\n${D.map(e=>` ${e.path}`).join(`
|
|
2
|
+
`)}`);let O=i.target===void 0?[`server`,`web`,`native`]:[i.target];for(let e of O){let t=l(m,e);if(h.push(...t.notices),t.contributions.length===0&&t.escapeHatches.length===0&&t.roots.length===0)continue;T.push(e);let n=S[e],i=n(t,{packageName:f,pluginId:p,root:m.root,entryDir:r,mcpWidgets:E?.declarations});w.set(`${r}/${C[e]}.ts`,i)}let k=i.target===void 0&&v.existsSync(y.join(i.packageDir,`src/types/apiRoutes.ts`)),A=T.includes(`web`),j=k&&A?u(m,{packageName:f,pluginId:p,root:m.root,entryDir:r}):void 0;j!==void 0&&w.set(`${r}/${n}.ts`,j);let M=T.includes(`native`),N=k&&M?d(m,{packageName:f,pluginId:p,root:m.root,entryDir:r}):void 0;N!==void 0&&w.set(`${r}/${o}.ts`,N),k&&(A||M)&&j===void 0&&N===void 0&&h.push({path:e,message:`declares API routes, but no (backend)/api/<base-path>/ folder says where they are mounted`});let P=i.target===void 0?a.filter(e=>e!==`mcp`||!v.existsSync(y.join(i.packageDir,`tsdown.mcp.config.ts`))).map(e=>`${r}/${e}.ts`):[`${r}/${C[i.target]}.ts`,...i.target===`mcp`?[`${r}/mcp-ui.ts`]:[]],{changed:F}=_(i.packageDir,w,i.check,P);return{graph:m,packageName:f,pluginId:p,files:w,changed:F,notices:h,targets:T}}export{b as defaultPluginId,w as generateExtension};
|
|
3
3
|
//# sourceMappingURL=index.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":["fs","path","defaultPluginId","packageName","readPackageName","manifest","packageDir","RENDERERS","renderServerEntry","renderWebEntry","renderNativeEntry","renderMcpEntry","ENTRY_FILENAME","GENERATED_ENTRY_FILENAMES","generateExtension","options","pluginId","graph","scanExtensions","notices","files","targets","mcpWidgets","renderMcpWidgets","GENERATED_DIR","entry","BUILD_TARGET_PLATFORMS","retired","notice","RETIRED_PLATFORM_NOTICE","requestedTargets","target","resolution","resolveTarget","render","source","hasRouteTable","hasBrowserHalf","client","renderApiClient","GENERATED_CLIENT_NAME","API_ROUTES_MODULE","managed","GENERATED_ENTRY_NAMES","name","writeGenerated"],"sources":["../../../src/services/generate/index.ts"],"sourcesContent":["import fs from 'node:fs';\nimport path from 'node:path';\n\nimport {\n API_ROUTES_MODULE,\n BUILD_TARGET_PLATFORMS,\n GENERATED_CLIENT_NAME,\n GENERATED_DIR,\n GENERATED_ENTRY_FILENAMES,\n GENERATED_ENTRY_NAMES,\n} from '../../constants/layout';\nimport type { ExtensionGraph, ExtensionNotice } from '../../types/extensionGraph';\nimport { renderApiClient } from '../renderClient';\nimport { renderMcpEntry, renderNativeEntry, renderServerEntry, renderWebEntry } from '../renderEntry';\nimport { renderMcpWidgets } from '../renderMcpWidgets';\nimport { resolveTarget } from '../resolveTarget';\nimport type { BuildTarget } from '../resolveTarget/type';\nimport { RETIRED_PLATFORM_NOTICE, scanExtensions } from '../scan';\nimport { writeGenerated } from '../writeGenerated';\nimport type { GenerateOptions, GenerateResult } from './type';\n\n/** `@agimon-ai/po-plan` becomes `plan`. */\nexport function defaultPluginId(packageName: string): string {\n return packageName.replace(/^@[^/]+\\//u, '').replace(/^po-/u, '');\n}\n\nfunction readPackageName(packageDir: string): string {\n const manifest = JSON.parse(fs.readFileSync(path.join(packageDir, 'package.json'), 'utf8')) as { name?: unknown };\n if (typeof manifest.name !== 'string') throw new Error(`${packageDir}/package.json has no name`);\n return manifest.name;\n}\n\nconst RENDERERS: Readonly<Record<BuildTarget, typeof renderServerEntry>> = {\n server: renderServerEntry,\n web: renderWebEntry,\n native: renderNativeEntry,\n mcp: renderMcpEntry,\n};\n\nconst ENTRY_FILENAME: Readonly<Record<BuildTarget, string>> = GENERATED_ENTRY_FILENAMES;\n\n/**\n * Scans a package and renders every entry its tree calls for.\n *\n * A target with nothing in it produces no file, so a backend-only package\n * never grows an empty cockpit entry. Notices from the scan and from each\n * resolution are gathered rather than thrown: an unrecognised folder costs\n * that folder, never the build.\n */\nexport function generateExtension(options: GenerateOptions): GenerateResult {\n const packageName = options.packageName ?? readPackageName(options.packageDir);\n const pluginId = options.pluginId ?? defaultPluginId(packageName);\n\n const graph: ExtensionGraph = scanExtensions(options);\n const notices: ExtensionNotice[] = [...graph.notices];\n const files = new Map<string, string>();\n const targets: BuildTarget[] = [];\n const mcpWidgets = options.target === 'mcp' ? renderMcpWidgets(graph, packageName, GENERATED_DIR) : undefined;\n if (mcpWidgets?.source !== undefined) files.set(`${GENERATED_DIR}/mcp-ui.ts`, mcpWidgets.source);\n\n // Here rather than in the scan, deliberately. The doomRoutedFilePosition lint\n // rule calls scanExtensions() directly, so a scan notice would make `.ios` a\n // hard preflight failure and cost us the forward-looking platforms we kept on\n // purpose. resolveTarget runs once per target, which would repeat it per target.\n for (const entry of graph.entries) {\n if (entry.platform === undefined || BUILD_TARGET_PLATFORMS.includes(entry.platform)) continue;\n notices.push({\n path: entry.file,\n message: `'${entry.platform}' is a forward-looking platform with no build target; this file is not emitted for server, web, native or mcp`,\n });\n }\n\n const retired = graph.notices.filter((notice) => notice.message === RETIRED_PLATFORM_NOTICE);\n if (retired.length > 0) {\n throw new Error(\n `${packageName}: ${RETIRED_PLATFORM_NOTICE}\\n${retired.map((notice) => ` ${notice.path}`).join('\\n')}`,\n );\n }\n\n const requestedTargets = options.target === undefined ? (['server', 'web', 'native'] as const) : [options.target];\n for (const target of requestedTargets) {\n const resolution = resolveTarget(graph, target);\n notices.push(...resolution.notices);\n if (resolution.contributions.length === 0 && resolution.escapeHatches.length === 0 && resolution.roots.length === 0)\n continue;\n\n targets.push(target);\n const render = RENDERERS[target];\n const source = render(resolution, {\n packageName,\n pluginId,\n root: graph.root,\n entryDir: GENERATED_DIR,\n mcpWidgets: mcpWidgets?.declarations,\n });\n files.set(`${GENERATED_DIR}/${ENTRY_FILENAME[target]}.ts`, source);\n }\n\n // Not another build target: no host loads it as an entry, and adding one to\n // the target loop would mean a resolution pass and a contribution field for\n // something that is only ever imported by a routed frontend file.\n //\n // Only for a package that has a browser half. The client exists to be called\n // from a page and it carries the sealed transport, so emitting one into a\n // node-only package asks that package to depend on a browser runtime it never\n // loads, to satisfy a file nothing imports.\n const hasRouteTable = options.target === undefined && fs.existsSync(path.join(options.packageDir, API_ROUTES_MODULE));\n const hasBrowserHalf = targets.includes('web');\n const client =\n hasRouteTable && hasBrowserHalf\n ? renderApiClient(graph, { packageName, pluginId, root: graph.root, entryDir: GENERATED_DIR })\n : undefined;\n if (client !== undefined) files.set(`${GENERATED_DIR}/${GENERATED_CLIENT_NAME}.ts`, client);\n if (hasRouteTable && hasBrowserHalf && client === undefined) {\n notices.push({\n path: API_ROUTES_MODULE,\n message: 'declares API routes, but no (backend)/api/<base-path>/ folder says where they are mounted',\n });\n }\n\n const managed =\n options.target === undefined\n ? GENERATED_ENTRY_NAMES.filter(\n (name) => name !== 'mcp' || !fs.existsSync(path.join(options.packageDir, 'tsdown.mcp.config.ts')),\n ).map((name) => `${GENERATED_DIR}/${name}.ts`)\n : [\n `${GENERATED_DIR}/${ENTRY_FILENAME[options.target]}.ts`,\n ...(options.target === 'mcp' ? [`${GENERATED_DIR}/mcp-ui.ts`] : []),\n ];\n const { changed } = writeGenerated(options.packageDir, files, options.check, managed);\n return { graph, packageName, pluginId, files, changed, notices, targets };\n}\n"],"mappings":"orBAsBA,SAAgBE,EAAgB,EAA6B,CAC3D,OAAOC,EAAY,QAAQ,aAAc,EAAE,CAAC,CAAC,QAAQ,QAAS,EAAE,CAClE,CAEA,SAASC,EAAgB,EAA4B,CACnD,IAAMC,EAAW,KAAK,MAAML,EAAG,aAAaC,EAAK,KAAKK,EAAY,cAAc,EAAG,MAAM,CAAC,EAC1F,GAAI,OAAOD,EAAS,MAAS,SAAU,MAAU,MAAM,GAAGC,EAAW,0BAA0B,EAC/F,OAAOD,EAAS,IAClB,CAEA,MAAME,EAAqE,CACzE,OAAQC,EACR,IAAKC,EACL,OAAQC,EACR,IAAKC,CACP,EAEMC,EAAwDC,EAU9D,SAAgBC,EAAkB,EAA0C,CAC1E,IAAMX,EAAcY,EAAQ,aAAeX,EAAgBW,EAAQ,UAAU,EACvEC,EAAWD,EAAQ,UAAYb,EAAgBC,CAAW,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,IAAA,IAAaf,EAAG,WAAWC,EAAK,KAAKc,EAAQ,WAAA,wBAA6B,CAAC,EAC9GsB,EAAiBhB,EAAQ,SAAS,KAAK,EACvCiB,EACJF,GAAiBC,EACbE,EAAgBtB,EAAO,CAAE,cAAa,WAAU,KAAMA,EAAM,KAAM,SAAUO,CAAc,CAAC,EAC3F,IAAA,GACFc,IAAW,IAAA,IAAWlB,EAAM,IAAI,GAAGI,EAAc,GAAGgB,EAAsB,KAAMF,CAAM,EACtFF,GAAiBC,GAAkBC,IAAW,IAAA,IAChDnB,EAAQ,KAAK,CACX,KAAMsB,EACN,QAAS,2FACX,CAAC,EAGH,IAAMC,EACJ3B,EAAQ,SAAW,IAAA,GACf4B,EAAsB,OACnB,GAASC,IAAS,OAAS,CAAC5C,EAAG,WAAWC,EAAK,KAAKc,EAAQ,WAAY,sBAAsB,CAAC,CAClG,CAAC,CAAC,IAAK,GAAS,GAAGS,EAAc,GAAGoB,EAAK,IAAI,EAC7C,CACE,GAAGpB,EAAc,GAAGZ,EAAeG,EAAQ,QAAQ,KACnD,GAAIA,EAAQ,SAAW,MAAQ,CAAC,GAAGS,EAAc,WAAW,EAAI,CAAC,CACnE,EACA,CAAE,WAAYqB,EAAe9B,EAAQ,WAAYK,EAAOL,EAAQ,MAAO2B,CAAO,EACpF,MAAO,CAAE,QAAO,cAAa,WAAU,QAAO,UAAS,UAAS,SAAQ,CAC1E"}
|
|
1
|
+
{"version":3,"file":"index.mjs","names":["fs","path","defaultPluginId","packageName","readPackageName","manifest","packageDir","RENDERERS","renderServerEntry","renderWebEntry","renderNativeEntry","renderMcpEntry","ENTRY_FILENAME","GENERATED_ENTRY_FILENAMES","generateExtension","options","pluginId","graph","scanExtensions","notices","files","targets","mcpWidgets","renderMcpWidgets","GENERATED_DIR","entry","BUILD_TARGET_PLATFORMS","retired","notice","RETIRED_PLATFORM_NOTICE","requestedTargets","target","resolution","resolveTarget","render","source","hasRouteTable","hasBrowserHalf","client","renderApiClient","GENERATED_CLIENT_NAME","hasNativeHalf","nativeClient","renderNativeApiClient","GENERATED_NATIVE_CLIENT_NAME","API_ROUTES_MODULE","managed","GENERATED_ENTRY_NAMES","name","writeGenerated"],"sources":["../../../src/services/generate/index.ts"],"sourcesContent":["import fs from 'node:fs';\nimport path from 'node:path';\n\nimport {\n API_ROUTES_MODULE,\n BUILD_TARGET_PLATFORMS,\n GENERATED_CLIENT_NAME,\n GENERATED_DIR,\n GENERATED_ENTRY_FILENAMES,\n GENERATED_ENTRY_NAMES,\n GENERATED_NATIVE_CLIENT_NAME,\n} from '../../constants/layout';\nimport type { ExtensionGraph, ExtensionNotice } from '../../types/extensionGraph';\nimport { renderApiClient, renderNativeApiClient } from '../renderClient';\nimport { renderMcpEntry, renderNativeEntry, renderServerEntry, renderWebEntry } from '../renderEntry';\nimport { renderMcpWidgets } from '../renderMcpWidgets';\nimport { resolveTarget } from '../resolveTarget';\nimport type { BuildTarget } from '../resolveTarget/type';\nimport { RETIRED_PLATFORM_NOTICE, scanExtensions } from '../scan';\nimport { writeGenerated } from '../writeGenerated';\nimport type { GenerateOptions, GenerateResult } from './type';\n\n/** `@agimon-ai/po-plan` becomes `plan`. */\nexport function defaultPluginId(packageName: string): string {\n return packageName.replace(/^@[^/]+\\//u, '').replace(/^po-/u, '');\n}\n\nfunction readPackageName(packageDir: string): string {\n const manifest = JSON.parse(fs.readFileSync(path.join(packageDir, 'package.json'), 'utf8')) as { name?: unknown };\n if (typeof manifest.name !== 'string') throw new Error(`${packageDir}/package.json has no name`);\n return manifest.name;\n}\n\nconst RENDERERS: Readonly<Record<BuildTarget, typeof renderServerEntry>> = {\n server: renderServerEntry,\n web: renderWebEntry,\n native: renderNativeEntry,\n mcp: renderMcpEntry,\n};\n\nconst ENTRY_FILENAME: Readonly<Record<BuildTarget, string>> = GENERATED_ENTRY_FILENAMES;\n\n/**\n * Scans a package and renders every entry its tree calls for.\n *\n * A target with nothing in it produces no file, so a backend-only package\n * never grows an empty cockpit entry. Notices from the scan and from each\n * resolution are gathered rather than thrown: an unrecognised folder costs\n * that folder, never the build.\n */\nexport function generateExtension(options: GenerateOptions): GenerateResult {\n const packageName = options.packageName ?? readPackageName(options.packageDir);\n const pluginId = options.pluginId ?? defaultPluginId(packageName);\n\n const graph: ExtensionGraph = scanExtensions(options);\n const notices: ExtensionNotice[] = [...graph.notices];\n const files = new Map<string, string>();\n const targets: BuildTarget[] = [];\n const mcpWidgets = options.target === 'mcp' ? renderMcpWidgets(graph, packageName, GENERATED_DIR) : undefined;\n if (mcpWidgets?.source !== undefined) files.set(`${GENERATED_DIR}/mcp-ui.ts`, mcpWidgets.source);\n\n // Here rather than in the scan, deliberately. The doomRoutedFilePosition lint\n // rule calls scanExtensions() directly, so a scan notice would make `.ios` a\n // hard preflight failure and cost us the forward-looking platforms we kept on\n // purpose. resolveTarget runs once per target, which would repeat it per target.\n for (const entry of graph.entries) {\n if (entry.platform === undefined || BUILD_TARGET_PLATFORMS.includes(entry.platform)) continue;\n notices.push({\n path: entry.file,\n message: `'${entry.platform}' is a forward-looking platform with no build target; this file is not emitted for server, web, native or mcp`,\n });\n }\n\n const retired = graph.notices.filter((notice) => notice.message === RETIRED_PLATFORM_NOTICE);\n if (retired.length > 0) {\n throw new Error(\n `${packageName}: ${RETIRED_PLATFORM_NOTICE}\\n${retired.map((notice) => ` ${notice.path}`).join('\\n')}`,\n );\n }\n\n const requestedTargets = options.target === undefined ? (['server', 'web', 'native'] as const) : [options.target];\n for (const target of requestedTargets) {\n const resolution = resolveTarget(graph, target);\n notices.push(...resolution.notices);\n if (resolution.contributions.length === 0 && resolution.escapeHatches.length === 0 && resolution.roots.length === 0)\n continue;\n\n targets.push(target);\n const render = RENDERERS[target];\n const source = render(resolution, {\n packageName,\n pluginId,\n root: graph.root,\n entryDir: GENERATED_DIR,\n mcpWidgets: mcpWidgets?.declarations,\n });\n files.set(`${GENERATED_DIR}/${ENTRY_FILENAME[target]}.ts`, source);\n }\n\n // Not another build target: no host loads it as an entry, and adding one to\n // the target loop would mean a resolution pass and a contribution field for\n // something that is only ever imported by a routed frontend file.\n //\n // Only for a package that has a browser half. The client exists to be called\n // from a page and it carries the sealed transport, so emitting one into a\n // node-only package asks that package to depend on a browser runtime it never\n // loads, to satisfy a file nothing imports.\n const hasRouteTable = options.target === undefined && fs.existsSync(path.join(options.packageDir, API_ROUTES_MODULE));\n const hasBrowserHalf = targets.includes('web');\n const client =\n hasRouteTable && hasBrowserHalf\n ? renderApiClient(graph, { packageName, pluginId, root: graph.root, entryDir: GENERATED_DIR })\n : undefined;\n if (client !== undefined) files.set(`${GENERATED_DIR}/${GENERATED_CLIENT_NAME}.ts`, client);\n\n // The native half gets its own file rather than a shared one, because the\n // browser client's two imports are exactly what the native host refuses.\n const hasNativeHalf = targets.includes('native');\n const nativeClient =\n hasRouteTable && hasNativeHalf\n ? renderNativeApiClient(graph, { packageName, pluginId, root: graph.root, entryDir: GENERATED_DIR })\n : undefined;\n if (nativeClient !== undefined) files.set(`${GENERATED_DIR}/${GENERATED_NATIVE_CLIENT_NAME}.ts`, nativeClient);\n if (hasRouteTable && (hasBrowserHalf || hasNativeHalf) && client === undefined && nativeClient === undefined) {\n notices.push({\n path: API_ROUTES_MODULE,\n message: 'declares API routes, but no (backend)/api/<base-path>/ folder says where they are mounted',\n });\n }\n\n const managed =\n options.target === undefined\n ? GENERATED_ENTRY_NAMES.filter(\n (name) => name !== 'mcp' || !fs.existsSync(path.join(options.packageDir, 'tsdown.mcp.config.ts')),\n ).map((name) => `${GENERATED_DIR}/${name}.ts`)\n : [\n `${GENERATED_DIR}/${ENTRY_FILENAME[options.target]}.ts`,\n ...(options.target === 'mcp' ? [`${GENERATED_DIR}/mcp-ui.ts`] : []),\n ];\n const { changed } = writeGenerated(options.packageDir, files, options.check, managed);\n return { graph, packageName, pluginId, files, changed, notices, targets };\n}\n"],"mappings":"ivBAuBA,SAAgBE,EAAgB,EAA6B,CAC3D,OAAOC,EAAY,QAAQ,aAAc,EAAE,CAAC,CAAC,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AKc,EAAQ,WAAY,sBAAsB,CAAC,CAClG,CAAC,CAAC,IAAK,GAAS,GAAGS,EAAc,GAAGwB,EAAK,IAAI,EAC7C,CACE,GAAGxB,EAAc,GAAGZ,EAAeG,EAAQ,QAAQ,KACnD,GAAIA,EAAQ,SAAW,MAAQ,CAAC,GAAGS,EAAc,WAAW,EAAI,CAAC,CACnE,EACA,CAAE,WAAYyB,EAAelC,EAAQ,WAAYK,EAAOL,EAAQ,MAAO+B,CAAO,EACpF,MAAO,CAAE,QAAO,cAAa,WAAU,QAAO,UAAS,UAAS,SAAQ,CAC1E"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
require("../../constants/layout.cjs");const e=require("../identity/index.cjs");let t=require("node:path");const n=[`global`,`workspace`,`session`];function r(t,n){if(!n)return`api`;let r=e.toKebab(t).split(`-`).filter(e=>e.length>0).map((e,t)=>t===0?e:e[0]?.toUpperCase()+e.slice(1)).join(``);return/^[A-Za-z_]/u.test(r)?r:`api${r}`}function i(e){let t=e.route[0];if(t!==void 0&&`literal`in t)return t.literal}function a(e){let t=/* @__PURE__ */ new Map;for(let n of e.entries){if(n.side!==`backend`||n.surface!==`api`||n.role!==`contribution`)continue;let e=i(n);if(e===void 0)continue;let r=t.get(e)??/* @__PURE__ */ new Set;r.add(n.scope),t.set(e,r)}let a=[...t.keys()].sort();return a.map(e=>{let i=t.get(e),o=n.findIndex(e=>i.has(e));return{basePath:e,scopes:n.slice(o),identifier:r(e,a.length>1)}})}function o(e){let n=t.posix.relative(e,`src/types/apiRoutes`);return n.startsWith(`.`)?n:`./${n}`}
|
|
2
|
-
`).replace(/\n+$/u,``)}\n`}exports.renderApiClient=
|
|
1
|
+
require("../../constants/layout.cjs");const e=require("../identity/index.cjs");let t=require("node:path");const n=[`global`,`workspace`,`session`];function r(t,n){if(!n)return`api`;let r=e.toKebab(t).split(`-`).filter(e=>e.length>0).map((e,t)=>t===0?e:e[0]?.toUpperCase()+e.slice(1)).join(``);return/^[A-Za-z_]/u.test(r)?r:`api${r}`}function i(e){let t=e.route[0];if(t!==void 0&&`literal`in t)return t.literal}function a(e){let t=/* @__PURE__ */ new Map;for(let n of e.entries){if(n.side!==`backend`||n.surface!==`api`||n.role!==`contribution`)continue;let e=i(n);if(e===void 0)continue;let r=t.get(e)??/* @__PURE__ */ new Set;r.add(n.scope),t.set(e,r)}let a=[...t.keys()].sort();return a.map(e=>{let i=t.get(e),o=n.findIndex(e=>i.has(e));return{basePath:e,scopes:n.slice(o),identifier:r(e,a.length>1)}})}function o(e){let n=t.posix.relative(e,`src/types/apiRoutes`);return n.startsWith(`.`)?n:`./${n}`}const s={imports:[`import { createApiClient, sessionApiAddress } from '@agimon-ai/po-core/web';`,`import { sealedTransport } from '@agimon-ai/po-web-security/browser';`],transport:`(input, init) => sealedTransport.fetch(input, init)`},c={imports:[`import { createApiClient, nativeApiTransport, sessionApiAddress } from '@agimon-ai/po-core/native';`],transport:`nativeApiTransport`};function l(e,t){let n=e.scopes.map(e=>`'${e}'`).join(`, `),r=e.identifier===`api`?``:` for the ${e.basePath} mount`;return[`/** Scopes the tree mounts '${e.basePath}' at${r}. */`,`export const ${e.identifier}Scopes = [${n}] as const;`,``,`export const ${e.identifier} = createApiClient(routes, {`,` scopes: ${e.identifier}Scopes,`,` basePath: '${e.basePath}',`,` transport: ${t.transport},`,` sessionAddress: sessionApiAddress,`,`});`,``]}function u(e,t,n){let r=a(e);if(r.length!==0)return`${[`// Generated by @agimon-ai/po-build. Do not edit by hand.`,...n.imports,``,`import routes from '${o(t.entryDir??`generated`)}';`,``,...r.flatMap(e=>l(e,n))].join(`
|
|
2
|
+
`).replace(/\n+$/u,``)}\n`}function d(e,t){return u(e,t,s)}function f(e,t){return u(e,t,c)}exports.renderApiClient=d,exports.renderNativeApiClient=f;
|
|
3
3
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -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","renderMount","scopes","mount","suffix","
|
|
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 `DoomApi` 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 facet mounts 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,IAAK,GAAa,CAC7B,IAAMC,EAAWJ,EAAa,IAAIP,CAAQ,EAGpCY,EAAahB,EAAY,UAAW,GAAUe,EAAS,IAAIE,CAAK,CAAC,EACvE,MAAO,CACL,WACA,OAAQjB,EAAY,MAAMgB,CAAU,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AOkB,EAASR,CAAa,CACnD"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import"../../constants/layout.mjs";import{toKebab as e}from"../identity/index.mjs";import{posix as t}from"node:path";const n=[`global`,`workspace`,`session`];function r(t,n){if(!n)return`api`;let r=e(t).split(`-`).filter(e=>e.length>0).map((e,t)=>t===0?e:e[0]?.toUpperCase()+e.slice(1)).join(``);return/^[A-Za-z_]/u.test(r)?r:`api${r}`}function i(e){let t=e.route[0];if(t!==void 0&&`literal`in t)return t.literal}function a(e){let t=/* @__PURE__ */ new Map;for(let n of e.entries){if(n.side!==`backend`||n.surface!==`api`||n.role!==`contribution`)continue;let e=i(n);if(e===void 0)continue;let r=t.get(e)??/* @__PURE__ */ new Set;r.add(n.scope),t.set(e,r)}let a=[...t.keys()].sort();return a.map(e=>{let i=t.get(e),o=n.findIndex(e=>i.has(e));return{basePath:e,scopes:n.slice(o),identifier:r(e,a.length>1)}})}function o(e){let n=t.relative(e,`src/types/apiRoutes`);return n.startsWith(`.`)?n:`./${n}`}
|
|
2
|
-
`).replace(/\n+$/u,``)}\n`}export{
|
|
1
|
+
import"../../constants/layout.mjs";import{toKebab as e}from"../identity/index.mjs";import{posix as t}from"node:path";const n=[`global`,`workspace`,`session`];function r(t,n){if(!n)return`api`;let r=e(t).split(`-`).filter(e=>e.length>0).map((e,t)=>t===0?e:e[0]?.toUpperCase()+e.slice(1)).join(``);return/^[A-Za-z_]/u.test(r)?r:`api${r}`}function i(e){let t=e.route[0];if(t!==void 0&&`literal`in t)return t.literal}function a(e){let t=/* @__PURE__ */ new Map;for(let n of e.entries){if(n.side!==`backend`||n.surface!==`api`||n.role!==`contribution`)continue;let e=i(n);if(e===void 0)continue;let r=t.get(e)??/* @__PURE__ */ new Set;r.add(n.scope),t.set(e,r)}let a=[...t.keys()].sort();return a.map(e=>{let i=t.get(e),o=n.findIndex(e=>i.has(e));return{basePath:e,scopes:n.slice(o),identifier:r(e,a.length>1)}})}function o(e){let n=t.relative(e,`src/types/apiRoutes`);return n.startsWith(`.`)?n:`./${n}`}const s={imports:[`import { createApiClient, sessionApiAddress } from '@agimon-ai/po-core/web';`,`import { sealedTransport } from '@agimon-ai/po-web-security/browser';`],transport:`(input, init) => sealedTransport.fetch(input, init)`},c={imports:[`import { createApiClient, nativeApiTransport, sessionApiAddress } from '@agimon-ai/po-core/native';`],transport:`nativeApiTransport`};function l(e,t){let n=e.scopes.map(e=>`'${e}'`).join(`, `),r=e.identifier===`api`?``:` for the ${e.basePath} mount`;return[`/** Scopes the tree mounts '${e.basePath}' at${r}. */`,`export const ${e.identifier}Scopes = [${n}] as const;`,``,`export const ${e.identifier} = createApiClient(routes, {`,` scopes: ${e.identifier}Scopes,`,` basePath: '${e.basePath}',`,` transport: ${t.transport},`,` sessionAddress: sessionApiAddress,`,`});`,``]}function u(e,t,n){let r=a(e);if(r.length!==0)return`${[`// Generated by @agimon-ai/po-build. Do not edit by hand.`,...n.imports,``,`import routes from '${o(t.entryDir??`generated`)}';`,``,...r.flatMap(e=>l(e,n))].join(`
|
|
2
|
+
`).replace(/\n+$/u,``)}\n`}function d(e,t){return u(e,t,s)}function f(e,t){return u(e,t,c)}export{d as renderApiClient,f as renderNativeApiClient};
|
|
3
3
|
//# sourceMappingURL=index.mjs.map
|
|
@@ -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","renderMount","scopes","mount","suffix","
|
|
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 `DoomApi` 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 facet mounts 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,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AAM,OAAO,IAAK,GAAU,IAAIT,EAAM,EAAE,CAAC,CAAC,KAAK,IAAI,EAC5DU,EAASD,EAAM,aAAe,MAAQ,GAAK,YAAYA,EAAM,SAAS,QAC5E,MAAO,CACL,+BAA+BA,EAAM,SAAS,MAAMC,EAAO,MAC3D,gBAAgBD,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"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
require("../../constants/layout.cjs");const e=require("../../constants/contributions.cjs"),t={global:0,workspace:1,session:2};function n(e){return e===`web`||e===`native`}function r(e,t){return n(t)?e.side===`frontend`:e.side===`backend`}function i(e,t){return t===`mcp`||t===`native`?e.platform===t:e.platform===void 0||e.platform===t}const a={server:{backend:e.SERVER_FIELDS,frontend:{}},web:{backend:{},frontend:e.WEB_FIELDS},native:{backend:{},frontend:e.NATIVE_FIELDS},mcp:{backend:e.MCP_FIELDS,frontend:{}}};function o(e){let t=e.gates.map(e=>`${e.kind}:${e.id}`).join(`/`),n=e.route.map(e=>`literal`in e?e.literal:`[${e.param.name}]`).join(`/`);return[e.side,e.scope,t,e.surface??``,n,e.name,e.target??``].join(`|`)}function s(e,t,n){return n===void 0?t:e[n]??t}function c(t,r){let i=t.surface;if(i===void 0)return;let o=a[r][t.side][i];if(o!==void 0&&o!==``&&!(n(r)&&i===`lifecycle`&&t.name!==`start`))return n(r)&&i===`setting`?s(e.SETTING_FIELDS,o,t.target):r===`web`&&i===`action`?s(e.ACTION_FIELDS,o,t.target):o}function l(
|
|
1
|
+
require("../../constants/layout.cjs");const e=require("../../constants/contributions.cjs"),t={global:0,workspace:1,session:2};function n(e){return e===`web`||e===`native`}function r(e,t){return n(t)?e.side===`frontend`:e.side===`backend`}function i(e,t){return t===`mcp`||t===`native`?e.platform===t:e.platform===void 0||e.platform===t}const a={server:{backend:e.SERVER_FIELDS,frontend:{}},web:{backend:{},frontend:e.WEB_FIELDS},native:{backend:{},frontend:e.NATIVE_FIELDS},mcp:{backend:e.MCP_FIELDS,frontend:{}}};function o(e){let t=e.gates.map(e=>`${e.kind}:${e.id}`).join(`/`),n=e.route.map(e=>`literal`in e?e.literal:`[${e.param.name}]`).join(`/`);return[e.side,e.scope,t,e.surface??``,n,e.name,e.target??``].join(`|`)}function s(e,t,n){return n===void 0?t:e[n]??t}function c(t,r){let i=t.surface;if(i===void 0)return;let o=a[r][t.side][i];if(o!==void 0&&o!==``&&!(n(r)&&i===`lifecycle`&&t.name!==`start`))return n(r)&&i===`setting`?s(e.SETTING_FIELDS,o,t.target):r===`web`&&i===`action`?s(e.ACTION_FIELDS,o,t.target):r===`native`&&i===`action`?t.target===void 0?void 0:e.NATIVE_ACTION_FIELDS[t.target]:o}function l(n,a){let s=[],l=[],u=[],d=/* @__PURE__ */ new Map;for(let e of n.entries){if(!r(e,a)||!i(e,a))continue;if(e.role===`escape-hatch`){l.push(e);continue}if(e.role===`root`){if(e.side===`frontend`){s.push({path:e.file,message:`a scope root is a backend file; the cockpit has no mount context`});continue}u.push(e);continue}let t=o(e),n=d.get(t);if(n===void 0){d.set(t,e);continue}if(n.platform===e.platform){s.push({path:e.file,message:`duplicates ${n.file} for ${a}; the first one wins`});continue}e.platform!==void 0&&d.set(t,e)}let f=[];for(let t of d.values()){let n=c(t,a);if(n===void 0){a===`native`&&t.surface!==void 0&&e.NATIVE_FIELDS[t.surface]!==``&&s.push({path:t.file,message:`${t.surface}/${t.name} is not supported by the native host`});continue}f.push({entry:t,field:n})}return{target:a,contributions:f,escapeHatches:l,roots:u.sort((e,n)=>t[e.scope]-t[n.scope]),notices:s}}exports.isFrontendTarget=n,exports.resolveTarget=l;
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["SERVER_FIELDS","WEB_FIELDS","NATIVE_FIELDS","MCP_FIELDS","SETTING_FIELDS","ACTION_FIELDS","require_contributions","SCOPE_DEPTH","isFrontendTarget","target","drawsFrom","entry","servesPlatform","FIELDS_OF","logicalKey","gates","gate","route","segment","variantField","entryTarget","fallback","table","fieldFor","surface","declared","resolveTarget","notices","escapeHatches","roots","winners","graph","key","held","contributions","field","left","right"],"sources":["../../../src/services/resolveTarget/index.ts"],"sourcesContent":["import {\n ACTION_FIELDS,\n MCP_FIELDS,\n NATIVE_FIELDS,\n NOT_A_CONTRIBUTION,\n SERVER_FIELDS,\n SETTING_FIELDS,\n WEB_FIELDS,\n} from '../../constants/contributions';\nimport { NATIVE_PLATFORM } from '../../constants/layout';\nimport type { ExtensionEntry, ExtensionGraph, ExtensionNotice, ExtensionSide } from '../../types/extensionGraph';\nimport type { BuildTarget, FrontendTarget, ResolvedContribution, TargetResolution } from './type';\n\n/** Nesting order, so roots compose outermost first. */\nconst SCOPE_DEPTH: Readonly<Record<string, number>> = { global: 0, workspace: 1, session: 2 };\n\n/** Whether a host draws presentation: the cockpit and the native app do, the server and MCP hosts run logic. */\nexport function isFrontendTarget(target: BuildTarget): target is FrontendTarget {\n return target === 'web' || target === NATIVE_PLATFORM;\n}\n\n/** Which side a host reads. */\nfunction drawsFrom(entry: ExtensionEntry, target: BuildTarget): boolean {\n return isFrontendTarget(target) ? entry.side === 'frontend' : entry.side === 'backend';\n}\n\n/**\n * Whether a file's platform suffix lets it reach a host.\n *\n * MCP and native take only files that name them: an unsuffixed backend file may\n * touch the whole server, and an unsuffixed frontend file may touch the DOM.\n * The server and the cockpit still accept an unsuffixed sibling as a fallback.\n */\nfunction servesPlatform(entry: ExtensionEntry, target: BuildTarget): boolean {\n if (target === 'mcp' || target === NATIVE_PLATFORM) return entry.platform === target;\n return entry.platform === undefined || entry.platform === target;\n}\n\nconst FIELDS_OF: Readonly<Record<BuildTarget, Readonly<Record<ExtensionSide, Readonly<Record<string, string>>>>>> = {\n server: { backend: SERVER_FIELDS, frontend: {} },\n web: { backend: {}, frontend: WEB_FIELDS },\n native: { backend: {}, frontend: NATIVE_FIELDS },\n mcp: { backend: MCP_FIELDS, frontend: {} },\n};\n\n/** Everything but the platform: two files sharing this are the same contribution. */\nfunction logicalKey(entry: ExtensionEntry): string {\n const gates = entry.gates.map((gate) => `${gate.kind}:${gate.id}`).join('/');\n const route = entry.route\n .map((segment) => ('literal' in segment ? segment.literal : `[${segment.param.name}]`))\n .join('/');\n // The side is part of it, so a tool's logic and its cockpit renderer never\n // look like one contribution overriding the other.\n return [entry.side, entry.scope, gates, entry.surface ?? '', route, entry.name, entry.target ?? ''].join('|');\n}\n\n/** Resolves the field for a surface whose filename target picks between two shapes. */\nfunction variantField(\n table: Readonly<Record<string, string>>,\n fallback: string,\n entryTarget: string | undefined,\n): string {\n if (entryTarget === undefined) return fallback;\n return table[entryTarget] ?? fallback;\n}\n\nfunction fieldFor(entry: ExtensionEntry, target: BuildTarget): string | undefined {\n const surface = entry.surface;\n if (surface === undefined) return undefined;\n\n const declared = FIELDS_OF[target][entry.side][surface];\n if (declared === undefined || declared === NOT_A_CONTRIBUTION) return undefined;\n\n if (isFrontendTarget(target) && surface === 'lifecycle' && entry.name !== 'start') return undefined;\n if (isFrontendTarget(target) && surface === 'setting') return variantField(SETTING_FIELDS, declared, entry.target);\n if (target === 'web' && surface === 'action') return variantField(ACTION_FIELDS, declared, entry.target);\n return declared;\n}\n\n/**\n * Picks the winning file per logical contribution for one host.\n *\n * Metro and Expo semantics: a file naming this platform replaces a sibling\n * that names none, and a file naming none serves the server or the cockpit\n * when it has no more specific sibling. The scan reports the unnamed one, so\n * this is a fallback rather than a supported way to author. MCP and native\n * have no fallback at all: they read only the files that name them. Two files\n * naming the same platform for the same contribution is an authoring mistake,\n * so the first wins and the second becomes a notice rather than silently\n * disappearing.\n */\nexport function resolveTarget(graph: ExtensionGraph, target: BuildTarget): TargetResolution {\n const notices: ExtensionNotice[] = [];\n const escapeHatches: ExtensionEntry[] = [];\n const roots: ExtensionEntry[] = [];\n const winners = new Map<string, ExtensionEntry>();\n\n for (const entry of graph.entries) {\n if (!drawsFrom(entry, target)) continue;\n if (!servesPlatform(entry, target)) continue;\n if (entry.role === 'escape-hatch') {\n escapeHatches.push(entry);\n continue;\n }\n\n if (entry.role === 'root') {\n // Backend only. A root is constructed from a mount context, and the\n // cockpit has none: it builds its plugin definition as data and starts\n // it separately, so there is nothing for a frontend root to receive.\n if (entry.side === 'frontend') {\n notices.push({ path: entry.file, message: 'a scope root is a backend file; the cockpit has no mount context' });\n continue;\n }\n roots.push(entry);\n continue;\n }\n\n const key = logicalKey(entry);\n const held = winners.get(key);\n if (held === undefined) {\n winners.set(key, entry);\n continue;\n }\n if (held.platform === entry.platform) {\n notices.push({ path: entry.file, message: `duplicates ${held.file} for ${target}; the first one wins` });\n continue;\n }\n // A platform file always beats the unsuffixed sibling it overrides.\n if (entry.platform !== undefined) winners.set(key, entry);\n }\n\n const contributions: ResolvedContribution[] = [];\n for (const entry of winners.values()) {\n const field = fieldFor(entry, target);\n if (field === undefined) continue;\n contributions.push({ entry, field });\n }\n\n return {\n target,\n contributions,\n escapeHatches,\n roots: roots.sort((left, right) => SCOPE_DEPTH[left.scope] - SCOPE_DEPTH[right.scope]),\n notices,\n };\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["SERVER_FIELDS","WEB_FIELDS","NATIVE_FIELDS","MCP_FIELDS","SETTING_FIELDS","ACTION_FIELDS","NATIVE_ACTION_FIELDS","require_contributions","SCOPE_DEPTH","isFrontendTarget","target","drawsFrom","entry","servesPlatform","FIELDS_OF","logicalKey","gates","gate","route","segment","variantField","entryTarget","fallback","table","fieldFor","surface","declared","resolveTarget","notices","escapeHatches","roots","winners","graph","key","held","contributions","field","left","right"],"sources":["../../../src/services/resolveTarget/index.ts"],"sourcesContent":["import {\n ACTION_FIELDS,\n MCP_FIELDS,\n NATIVE_ACTION_FIELDS,\n NATIVE_FIELDS,\n NOT_A_CONTRIBUTION,\n SERVER_FIELDS,\n SETTING_FIELDS,\n WEB_FIELDS,\n} from '../../constants/contributions';\nimport { NATIVE_PLATFORM } from '../../constants/layout';\nimport type { ExtensionEntry, ExtensionGraph, ExtensionNotice, ExtensionSide } from '../../types/extensionGraph';\nimport type { BuildTarget, FrontendTarget, ResolvedContribution, TargetResolution } from './type';\n\n/** Nesting order, so roots compose outermost first. */\nconst SCOPE_DEPTH: Readonly<Record<string, number>> = { global: 0, workspace: 1, session: 2 };\n\n/** Whether a host draws presentation: the cockpit and the native app do, the server and MCP hosts run logic. */\nexport function isFrontendTarget(target: BuildTarget): target is FrontendTarget {\n return target === 'web' || target === NATIVE_PLATFORM;\n}\n\n/** Which side a host reads. */\nfunction drawsFrom(entry: ExtensionEntry, target: BuildTarget): boolean {\n return isFrontendTarget(target) ? entry.side === 'frontend' : entry.side === 'backend';\n}\n\n/**\n * Whether a file's platform suffix lets it reach a host.\n *\n * MCP and native take only files that name them: an unsuffixed backend file may\n * touch the whole server, and an unsuffixed frontend file may touch the DOM.\n * The server and the cockpit still accept an unsuffixed sibling as a fallback.\n */\nfunction servesPlatform(entry: ExtensionEntry, target: BuildTarget): boolean {\n if (target === 'mcp' || target === NATIVE_PLATFORM) return entry.platform === target;\n return entry.platform === undefined || entry.platform === target;\n}\n\nconst FIELDS_OF: Readonly<Record<BuildTarget, Readonly<Record<ExtensionSide, Readonly<Record<string, string>>>>>> = {\n server: { backend: SERVER_FIELDS, frontend: {} },\n web: { backend: {}, frontend: WEB_FIELDS },\n native: { backend: {}, frontend: NATIVE_FIELDS },\n mcp: { backend: MCP_FIELDS, frontend: {} },\n};\n\n/** Everything but the platform: two files sharing this are the same contribution. */\nfunction logicalKey(entry: ExtensionEntry): string {\n const gates = entry.gates.map((gate) => `${gate.kind}:${gate.id}`).join('/');\n const route = entry.route\n .map((segment) => ('literal' in segment ? segment.literal : `[${segment.param.name}]`))\n .join('/');\n // The side is part of it, so a tool's logic and its cockpit renderer never\n // look like one contribution overriding the other.\n return [entry.side, entry.scope, gates, entry.surface ?? '', route, entry.name, entry.target ?? ''].join('|');\n}\n\n/** Resolves the field for a surface whose filename target picks between two shapes. */\nfunction variantField(\n table: Readonly<Record<string, string>>,\n fallback: string,\n entryTarget: string | undefined,\n): string {\n if (entryTarget === undefined) return fallback;\n return table[entryTarget] ?? fallback;\n}\n\nfunction fieldFor(entry: ExtensionEntry, target: BuildTarget): string | undefined {\n const surface = entry.surface;\n if (surface === undefined) return undefined;\n\n const declared = FIELDS_OF[target][entry.side][surface];\n if (declared === undefined || declared === NOT_A_CONTRIBUTION) return undefined;\n\n if (isFrontendTarget(target) && surface === 'lifecycle' && entry.name !== 'start') return undefined;\n if (isFrontendTarget(target) && surface === 'setting') return variantField(SETTING_FIELDS, declared, entry.target);\n if (target === 'web' && surface === 'action') return variantField(ACTION_FIELDS, declared, entry.target);\n // No fallback shape: an unnamed or context action is reported, never routed.\n if (target === NATIVE_PLATFORM && surface === 'action') {\n return entry.target === undefined ? undefined : NATIVE_ACTION_FIELDS[entry.target];\n }\n return declared;\n}\n\n/**\n * Picks the winning file per logical contribution for one host.\n *\n * Metro and Expo semantics: a file naming this platform replaces a sibling\n * that names none, and a file naming none serves the server or the cockpit\n * when it has no more specific sibling. The scan reports the unnamed one, so\n * this is a fallback rather than a supported way to author. MCP and native\n * have no fallback at all: they read only the files that name them. Two files\n * naming the same platform for the same contribution is an authoring mistake,\n * so the first wins and the second becomes a notice rather than silently\n * disappearing.\n */\nexport function resolveTarget(graph: ExtensionGraph, target: BuildTarget): TargetResolution {\n const notices: ExtensionNotice[] = [];\n const escapeHatches: ExtensionEntry[] = [];\n const roots: ExtensionEntry[] = [];\n const winners = new Map<string, ExtensionEntry>();\n\n for (const entry of graph.entries) {\n if (!drawsFrom(entry, target)) continue;\n if (!servesPlatform(entry, target)) continue;\n if (entry.role === 'escape-hatch') {\n escapeHatches.push(entry);\n continue;\n }\n\n if (entry.role === 'root') {\n // Backend only. A root is constructed from a mount context, and the\n // cockpit has none: it builds its plugin definition as data and starts\n // it separately, so there is nothing for a frontend root to receive.\n if (entry.side === 'frontend') {\n notices.push({ path: entry.file, message: 'a scope root is a backend file; the cockpit has no mount context' });\n continue;\n }\n roots.push(entry);\n continue;\n }\n\n const key = logicalKey(entry);\n const held = winners.get(key);\n if (held === undefined) {\n winners.set(key, entry);\n continue;\n }\n if (held.platform === entry.platform) {\n notices.push({ path: entry.file, message: `duplicates ${held.file} for ${target}; the first one wins` });\n continue;\n }\n // A platform file always beats the unsuffixed sibling it overrides.\n if (entry.platform !== undefined) winners.set(key, entry);\n }\n\n const contributions: ResolvedContribution[] = [];\n for (const entry of winners.values()) {\n const field = fieldFor(entry, target);\n if (field === undefined) {\n if (\n target === NATIVE_PLATFORM &&\n entry.surface !== undefined &&\n NATIVE_FIELDS[entry.surface] !== NOT_A_CONTRIBUTION\n ) {\n notices.push({\n path: entry.file,\n message: `${entry.surface}/${entry.name} is not supported by the native host`,\n });\n }\n continue;\n }\n contributions.push({ entry, field });\n }\n\n return {\n target,\n contributions,\n escapeHatches,\n roots: roots.sort((left, right) => SCOPE_DEPTH[left.scope] - SCOPE_D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EAAO,qBAAsB,CAAC,EACvG,QACF,CAEIE,EAAM,WAAa,IAAA,IAAWmB,EAAQ,IAAIE,EAAKrB,CAAK,CAC1D,CAEA,IAAMuB,EAAwC,CAAC,EAC/C,IAAK,IAAMvB,KAASmB,EAAQ,OAAO,EAAG,CACpC,IAAMK,EAAQZ,EAASZ,EAAOF,CAAM,EACpC,GAAI0B,IAAU,IAAA,GAAW,CAErB1B,IAAA,UACAE,EAAM,UAAY,IAAA,IAClBV,EAAAA,cAAcU,EAAM,WAAA,IAEpBgB,EAAQ,KAAK,CACX,KAAMhB,EAAM,KACZ,QAAS,GAAGA,EAAM,QAAQ,GAAGA,EAAM,KAAK,qCAC1C,CAAC,EAEH,QACF,CACAuB,EAAc,KAAK,CAAE,QAAO,OAAM,CAAC,CACrC,CAEA,MAAO,CACL,SACA,gBACA,gBACA,MAAOL,EAAM,MAAM,EAAM,IAAUtB,EAAY6B,EAAK,OAAS7B,EAAY8B,EAAM,MAAM,EACrF,SACF,CACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../../../src/services/resolveTarget/index.ts"],"mappings":";;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../../../src/services/resolveTarget/index.ts"],"mappings":";;;;;;;;;;;;;;;wBAgGgB,cAAc,OAAO,gBAAgB,QAAQ,cAAc"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import"../../constants/layout.mjs";import{ACTION_FIELDS as e,MCP_FIELDS as t,
|
|
1
|
+
import"../../constants/layout.mjs";import{ACTION_FIELDS as e,MCP_FIELDS as t,NATIVE_ACTION_FIELDS as n,NATIVE_FIELDS as r,SERVER_FIELDS as i,SETTING_FIELDS as a,WEB_FIELDS as o}from"../../constants/contributions.mjs";const s={global:0,workspace:1,session:2};function c(e){return e===`web`||e===`native`}function l(e,t){return c(t)?e.side===`frontend`:e.side===`backend`}function u(e,t){return t===`mcp`||t===`native`?e.platform===t:e.platform===void 0||e.platform===t}const d={server:{backend:i,frontend:{}},web:{backend:{},frontend:o},native:{backend:{},frontend:r},mcp:{backend:t,frontend:{}}};function f(e){let t=e.gates.map(e=>`${e.kind}:${e.id}`).join(`/`),n=e.route.map(e=>`literal`in e?e.literal:`[${e.param.name}]`).join(`/`);return[e.side,e.scope,t,e.surface??``,n,e.name,e.target??``].join(`|`)}function p(e,t,n){return n===void 0?t:e[n]??t}function m(t,r){let i=t.surface;if(i===void 0)return;let o=d[r][t.side][i];if(o!==void 0&&o!==``&&!(c(r)&&i===`lifecycle`&&t.name!==`start`))return c(r)&&i===`setting`?p(a,o,t.target):r===`web`&&i===`action`?p(e,o,t.target):r===`native`&&i===`action`?t.target===void 0?void 0:n[t.target]:o}function h(e,t){let n=[],i=[],a=[],o=/* @__PURE__ */ new Map;for(let r of e.entries){if(!l(r,t)||!u(r,t))continue;if(r.role===`escape-hatch`){i.push(r);continue}if(r.role===`root`){if(r.side===`frontend`){n.push({path:r.file,message:`a scope root is a backend file; the cockpit has no mount context`});continue}a.push(r);continue}let e=f(r),s=o.get(e);if(s===void 0){o.set(e,r);continue}if(s.platform===r.platform){n.push({path:r.file,message:`duplicates ${s.file} for ${t}; the first one wins`});continue}r.platform!==void 0&&o.set(e,r)}let c=[];for(let e of o.values()){let i=m(e,t);if(i===void 0){t===`native`&&e.surface!==void 0&&r[e.surface]!==``&&n.push({path:e.file,message:`${e.surface}/${e.name} is not supported by the native host`});continue}c.push({entry:e,field:i})}return{target:t,contributions:c,escapeHatches:i,roots:a.sort((e,t)=>s[e.scope]-s[t.scope]),notices:n}}export{c as isFrontendTarget,h as resolveTarget};
|
|
2
2
|
//# sourceMappingURL=index.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":["SCOPE_DEPTH","isFrontendTarget","target","drawsFrom","entry","servesPlatform","FIELDS_OF","SERVER_FIELDS","WEB_FIELDS","NATIVE_FIELDS","MCP_FIELDS","logicalKey","gates","gate","route","segment","variantField","entryTarget","fallback","table","fieldFor","surface","declared","SETTING_FIELDS","ACTION_FIELDS","resolveTarget","notices","escapeHatches","roots","winners","graph","key","held","contributions","field","left","right"],"sources":["../../../src/services/resolveTarget/index.ts"],"sourcesContent":["import {\n ACTION_FIELDS,\n MCP_FIELDS,\n NATIVE_FIELDS,\n NOT_A_CONTRIBUTION,\n SERVER_FIELDS,\n SETTING_FIELDS,\n WEB_FIELDS,\n} from '../../constants/contributions';\nimport { NATIVE_PLATFORM } from '../../constants/layout';\nimport type { ExtensionEntry, ExtensionGraph, ExtensionNotice, ExtensionSide } from '../../types/extensionGraph';\nimport type { BuildTarget, FrontendTarget, ResolvedContribution, TargetResolution } from './type';\n\n/** Nesting order, so roots compose outermost first. */\nconst SCOPE_DEPTH: Readonly<Record<string, number>> = { global: 0, workspace: 1, session: 2 };\n\n/** Whether a host draws presentation: the cockpit and the native app do, the server and MCP hosts run logic. */\nexport function isFrontendTarget(target: BuildTarget): target is FrontendTarget {\n return target === 'web' || target === NATIVE_PLATFORM;\n}\n\n/** Which side a host reads. */\nfunction drawsFrom(entry: ExtensionEntry, target: BuildTarget): boolean {\n return isFrontendTarget(target) ? entry.side === 'frontend' : entry.side === 'backend';\n}\n\n/**\n * Whether a file's platform suffix lets it reach a host.\n *\n * MCP and native take only files that name them: an unsuffixed backend file may\n * touch the whole server, and an unsuffixed frontend file may touch the DOM.\n * The server and the cockpit still accept an unsuffixed sibling as a fallback.\n */\nfunction servesPlatform(entry: ExtensionEntry, target: BuildTarget): boolean {\n if (target === 'mcp' || target === NATIVE_PLATFORM) return entry.platform === target;\n return entry.platform === undefined || entry.platform === target;\n}\n\nconst FIELDS_OF: Readonly<Record<BuildTarget, Readonly<Record<ExtensionSide, Readonly<Record<string, string>>>>>> = {\n server: { backend: SERVER_FIELDS, frontend: {} },\n web: { backend: {}, frontend: WEB_FIELDS },\n native: { backend: {}, frontend: NATIVE_FIELDS },\n mcp: { backend: MCP_FIELDS, frontend: {} },\n};\n\n/** Everything but the platform: two files sharing this are the same contribution. */\nfunction logicalKey(entry: ExtensionEntry): string {\n const gates = entry.gates.map((gate) => `${gate.kind}:${gate.id}`).join('/');\n const route = entry.route\n .map((segment) => ('literal' in segment ? segment.literal : `[${segment.param.name}]`))\n .join('/');\n // The side is part of it, so a tool's logic and its cockpit renderer never\n // look like one contribution overriding the other.\n return [entry.side, entry.scope, gates, entry.surface ?? '', route, entry.name, entry.target ?? ''].join('|');\n}\n\n/** Resolves the field for a surface whose filename target picks between two shapes. */\nfunction variantField(\n table: Readonly<Record<string, string>>,\n fallback: string,\n entryTarget: string | undefined,\n): string {\n if (entryTarget === undefined) return fallback;\n return table[entryTarget] ?? fallback;\n}\n\nfunction fieldFor(entry: ExtensionEntry, target: BuildTarget): string | undefined {\n const surface = entry.surface;\n if (surface === undefined) return undefined;\n\n const declared = FIELDS_OF[target][entry.side][surface];\n if (declared === undefined || declared === NOT_A_CONTRIBUTION) return undefined;\n\n if (isFrontendTarget(target) && surface === 'lifecycle' && entry.name !== 'start') return undefined;\n if (isFrontendTarget(target) && surface === 'setting') return variantField(SETTING_FIELDS, declared, entry.target);\n if (target === 'web' && surface === 'action') return variantField(ACTION_FIELDS, declared, entry.target);\n return declared;\n}\n\n/**\n * Picks the winning file per logical contribution for one host.\n *\n * Metro and Expo semantics: a file naming this platform replaces a sibling\n * that names none, and a file naming none serves the server or the cockpit\n * when it has no more specific sibling. The scan reports the unnamed one, so\n * this is a fallback rather than a supported way to author. MCP and native\n * have no fallback at all: they read only the files that name them. Two files\n * naming the same platform for the same contribution is an authoring mistake,\n * so the first wins and the second becomes a notice rather than silently\n * disappearing.\n */\nexport function resolveTarget(graph: ExtensionGraph, target: BuildTarget): TargetResolution {\n const notices: ExtensionNotice[] = [];\n const escapeHatches: ExtensionEntry[] = [];\n const roots: ExtensionEntry[] = [];\n const winners = new Map<string, ExtensionEntry>();\n\n for (const entry of graph.entries) {\n if (!drawsFrom(entry, target)) continue;\n if (!servesPlatform(entry, target)) continue;\n if (entry.role === 'escape-hatch') {\n escapeHatches.push(entry);\n continue;\n }\n\n if (entry.role === 'root') {\n // Backend only. A root is constructed from a mount context, and the\n // cockpit has none: it builds its plugin definition as data and starts\n // it separately, so there is nothing for a frontend root to receive.\n if (entry.side === 'frontend') {\n notices.push({ path: entry.file, message: 'a scope root is a backend file; the cockpit has no mount context' });\n continue;\n }\n roots.push(entry);\n continue;\n }\n\n const key = logicalKey(entry);\n const held = winners.get(key);\n if (held === undefined) {\n winners.set(key, entry);\n continue;\n }\n if (held.platform === entry.platform) {\n notices.push({ path: entry.file, message: `duplicates ${held.file} for ${target}; the first one wins` });\n continue;\n }\n // A platform file always beats the unsuffixed sibling it overrides.\n if (entry.platform !== undefined) winners.set(key, entry);\n }\n\n const contributions: ResolvedContribution[] = [];\n for (const entry of winners.values()) {\n const field = fieldFor(entry, target);\n if (field === undefined) continue;\n contributions.push({ entry, field });\n }\n\n return {\n target,\n contributions,\n escapeHatches,\n roots: roots.sort((left, right) => SCOPE_DEPTH[left.scope] - SCOPE_DEPTH[right.scope]),\n notices,\n };\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.mjs","names":["SCOPE_DEPTH","isFrontendTarget","target","drawsFrom","entry","servesPlatform","FIELDS_OF","SERVER_FIELDS","WEB_FIELDS","NATIVE_FIELDS","MCP_FIELDS","logicalKey","gates","gate","route","segment","variantField","entryTarget","fallback","table","fieldFor","surface","declared","SETTING_FIELDS","ACTION_FIELDS","NATIVE_ACTION_FIELDS","resolveTarget","notices","escapeHatches","roots","winners","graph","key","held","contributions","field","left","right"],"sources":["../../../src/services/resolveTarget/index.ts"],"sourcesContent":["import {\n ACTION_FIELDS,\n MCP_FIELDS,\n NATIVE_ACTION_FIELDS,\n NATIVE_FIELDS,\n NOT_A_CONTRIBUTION,\n SERVER_FIELDS,\n SETTING_FIELDS,\n WEB_FIELDS,\n} from '../../constants/contributions';\nimport { NATIVE_PLATFORM } from '../../constants/layout';\nimport type { ExtensionEntry, ExtensionGraph, ExtensionNotice, ExtensionSide } from '../../types/extensionGraph';\nimport type { BuildTarget, FrontendTarget, ResolvedContribution, TargetResolution } from './type';\n\n/** Nesting order, so roots compose outermost first. */\nconst SCOPE_DEPTH: Readonly<Record<string, number>> = { global: 0, workspace: 1, session: 2 };\n\n/** Whether a host draws presentation: the cockpit and the native app do, the server and MCP hosts run logic. */\nexport function isFrontendTarget(target: BuildTarget): target is FrontendTarget {\n return target === 'web' || target === NATIVE_PLATFORM;\n}\n\n/** Which side a host reads. */\nfunction drawsFrom(entry: ExtensionEntry, target: BuildTarget): boolean {\n return isFrontendTarget(target) ? entry.side === 'frontend' : entry.side === 'backend';\n}\n\n/**\n * Whether a file's platform suffix lets it reach a host.\n *\n * MCP and native take only files that name them: an unsuffixed backend file may\n * touch the whole server, and an unsuffixed frontend file may touch the DOM.\n * The server and the cockpit still accept an unsuffixed sibling as a fallback.\n */\nfunction servesPlatform(entry: ExtensionEntry, target: BuildTarget): boolean {\n if (target === 'mcp' || target === NATIVE_PLATFORM) return entry.platform === target;\n return entry.platform === undefined || entry.platform === target;\n}\n\nconst FIELDS_OF: Readonly<Record<BuildTarget, Readonly<Record<ExtensionSide, Readonly<Record<string, string>>>>>> = {\n server: { backend: SERVER_FIELDS, frontend: {} },\n web: { backend: {}, frontend: WEB_FIELDS },\n native: { backend: {}, frontend: NATIVE_FIELDS },\n mcp: { backend: MCP_FIELDS, frontend: {} },\n};\n\n/** Everything but the platform: two files sharing this are the same contribution. */\nfunction logicalKey(entry: ExtensionEntry): string {\n const gates = entry.gates.map((gate) => `${gate.kind}:${gate.id}`).join('/');\n const route = entry.route\n .map((segment) => ('literal' in segment ? segment.literal : `[${segment.param.name}]`))\n .join('/');\n // The side is part of it, so a tool's logic and its cockpit renderer never\n // look like one contribution overriding the other.\n return [entry.side, entry.scope, gates, entry.surface ?? '', route, entry.name, entry.target ?? ''].join('|');\n}\n\n/** Resolves the field for a surface whose filename target picks between two shapes. */\nfunction variantField(\n table: Readonly<Record<string, string>>,\n fallback: string,\n entryTarget: string | undefined,\n): string {\n if (entryTarget === undefined) return fallback;\n return table[entryTarget] ?? fallback;\n}\n\nfunction fieldFor(entry: ExtensionEntry, target: BuildTarget): string | undefined {\n const surface = entry.surface;\n if (surface === undefined) return undefined;\n\n const declared = FIELDS_OF[target][entry.side][surface];\n if (declared === undefined || declared === NOT_A_CONTRIBUTION) return undefined;\n\n if (isFrontendTarget(target) && surface === 'lifecycle' && entry.name !== 'start') return undefined;\n if (isFrontendTarget(target) && surface === 'setting') return variantField(SETTING_FIELDS, declared, entry.target);\n if (target === 'web' && surface === 'action') return variantField(ACTION_FIELDS, declared, entry.target);\n // No fallback shape: an unnamed or context action is reported, never routed.\n if (target === NATIVE_PLATFORM && surface === 'action') {\n return entry.target === undefined ? undefined : NATIVE_ACTION_FIELDS[entry.target];\n }\n return declared;\n}\n\n/**\n * Picks the winning file per logical contribution for one host.\n *\n * Metro and Expo semantics: a file naming this platform replaces a sibling\n * that names none, and a file naming none serves the server or the cockpit\n * when it has no more specific sibling. The scan reports the unnamed one, so\n * this is a fallback rather than a supported way to author. MCP and native\n * have no fallback at all: they read only the files that name them. Two files\n * naming the same platform for the same contribution is an authoring mistake,\n * so the first wins and the second becomes a notice rather than silently\n * disappearing.\n */\nexport function resolveTarget(graph: ExtensionGraph, target: BuildTarget): TargetResolution {\n const notices: ExtensionNotice[] = [];\n const escapeHatches: ExtensionEntry[] = [];\n const roots: ExtensionEntry[] = [];\n const winners = new Map<string, ExtensionEntry>();\n\n for (const entry of graph.entries) {\n if (!drawsFrom(entry, target)) continue;\n if (!servesPlatform(entry, target)) continue;\n if (entry.role === 'escape-hatch') {\n escapeHatches.push(entry);\n continue;\n }\n\n if (entry.role === 'root') {\n // Backend only. A root is constructed from a mount context, and the\n // cockpit has none: it builds its plugin definition as data and starts\n // it separately, so there is nothing for a frontend root to receive.\n if (entry.side === 'frontend') {\n notices.push({ path: entry.file, message: 'a scope root is a backend file; the cockpit has no mount context' });\n continue;\n }\n roots.push(entry);\n continue;\n }\n\n const key = logicalKey(entry);\n const held = winners.get(key);\n if (held === undefined) {\n winners.set(key, entry);\n continue;\n }\n if (held.platform === entry.platform) {\n notices.push({ path: entry.file, message: `duplicates ${held.file} for ${target}; the first one wins` });\n continue;\n }\n // A platform file always beats the unsuffixed sibling it overrides.\n if (entry.platform !== undefined) winners.set(key, entry);\n }\n\n const contributions: ResolvedContribution[] = [];\n for (const entry of winners.values()) {\n const field = fieldFor(entry, target);\n if (field === undefined) {\n if (\n target === NATIVE_PLATFORM &&\n entry.surface !== undefined &&\n NATIVE_FIELDS[entry.surface] !== NOT_A_CONTRIBUTION\n ) {\n notices.push({\n path: entry.file,\n message: `${entry.surface}/${entry.name} is not supported by the native host`,\n });\n }\n continue;\n }\n contributions.push({ entry, field });\n }\n\n return {\n target,\n contributions,\n escapeHatches,\n roots: roots.sort((left, right) => SCOPE_DEPTH[left.scope] - SCOPE_DEPTH[right.scope]),\n notices,\n };\n}\n"],"mappings":"yNAeA,MAAMA,EAAgD,CAAE,OAAQ,EAAG,UAAW,EAAG,QAAS,CAAE,EAG5F,SAAgBC,EAAiB,EAA+C,CAC9E,OAAOC,IAAW,OAASA,IAAA,QAC7B,CAGA,SAASC,EAAU,EAAuB,EAA8B,CACtE,OAAOF,EAAiBC,CAAM,EAAIE,EAAM,OAAS,WAAaA,EAAM,OAAS,SAC/E,CASA,SAASC,EAAe,EAAuB,EAA8B,CAE3E,OADIH,IAAW,OAASA,IAAA,SAAmCE,EAAM,WAAaF,EACvEE,EAAM,WAAa,IAAA,IAAaA,EAAM,WAAaF,CAC5D,CAEA,MAAMI,EAA8G,CAClH,OAAQ,CAAE,QAASC,EAAe,SAAU,CAAC,CAAE,EAC/C,IAAK,CAAE,QAAS,CAAC,EAAG,SAAUC,CAAW,EACzC,OAAQ,CAAE,QAAS,CAAC,EAAG,SAAUC,CAAc,EAC/C,IAAK,CAAE,QAASC,EAAY,SAAU,CAAC,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