@agimon-ai/po-build 0.0.0-alpha.20 → 0.0.0-alpha.201
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/LICENSE +1 -2
- package/README.md +7 -7
- 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 +2 -2
- 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/browserFile/index.cjs.map +1 -1
- package/dist/services/browserFile/index.mjs.map +1 -1
- package/dist/services/contentProvenance/index.cjs +3 -0
- package/dist/services/contentProvenance/index.cjs.map +1 -0
- package/dist/services/contentProvenance/index.d.mts +10 -0
- package/dist/services/contentProvenance/index.d.mts.map +1 -0
- package/dist/services/contentProvenance/index.mjs +3 -0
- package/dist/services/contentProvenance/index.mjs.map +1 -0
- package/dist/services/filename/index.cjs.map +1 -1
- package/dist/services/filename/index.mjs.map +1 -1
- package/dist/services/generate/index.cjs +1 -0
- package/dist/services/generate/index.cjs.map +1 -1
- package/dist/services/generate/index.d.mts +3 -3
- package/dist/services/generate/index.d.mts.map +1 -1
- package/dist/services/generate/index.mjs +1 -0
- package/dist/services/generate/index.mjs.map +1 -1
- package/dist/services/generate/type.d.mts +2 -0
- package/dist/services/generate/type.d.mts.map +1 -1
- package/dist/services/identity/index.cjs.map +1 -1
- package/dist/services/identity/index.mjs.map +1 -1
- package/dist/services/renderClient/index.cjs +1 -1
- package/dist/services/renderClient/index.cjs.map +1 -1
- package/dist/services/renderClient/index.mjs +1 -1
- package/dist/services/renderClient/index.mjs.map +1 -1
- package/dist/services/renderEntry/index.cjs +3 -3
- package/dist/services/renderEntry/index.cjs.map +1 -1
- package/dist/services/renderEntry/index.d.mts.map +1 -1
- package/dist/services/renderEntry/index.mjs +3 -3
- package/dist/services/renderEntry/index.mjs.map +1 -1
- package/dist/services/renderMcpWidgets/index.cjs.map +1 -1
- package/dist/services/renderMcpWidgets/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/dist/services/scan/index.cjs +1 -1
- package/dist/services/scan/index.cjs.map +1 -1
- package/dist/services/scan/index.d.mts.map +1 -1
- package/dist/services/scan/index.mjs +1 -1
- package/dist/services/scan/index.mjs.map +1 -1
- package/dist/services/segments/index.cjs.map +1 -1
- package/dist/services/segments/index.mjs.map +1 -1
- package/dist/services/serverContracts/index.cjs +1 -1
- package/dist/services/serverContracts/index.cjs.map +1 -1
- package/dist/services/serverContracts/index.mjs +1 -1
- package/dist/services/serverContracts/index.mjs.map +1 -1
- package/dist/services/serverContracts/type.d.mts +7 -0
- package/dist/services/serverContracts/type.d.mts.map +1 -1
- package/dist/services/syncManifest/index.cjs +1 -1
- package/dist/services/syncManifest/index.cjs.map +1 -1
- package/dist/services/syncManifest/index.d.mts.map +1 -1
- package/dist/services/syncManifest/index.mjs +1 -1
- package/dist/services/syncManifest/index.mjs.map +1 -1
- package/dist/services/syncManifest/type.d.mts +3 -0
- package/dist/services/syncManifest/type.d.mts.map +1 -1
- package/dist/services/tsdownPreset/index.cjs +1 -1
- package/dist/services/tsdownPreset/index.cjs.map +1 -1
- package/dist/services/tsdownPreset/index.d.mts +8 -2
- package/dist/services/tsdownPreset/index.d.mts.map +1 -1
- package/dist/services/tsdownPreset/index.mjs +1 -1
- package/dist/services/tsdownPreset/index.mjs.map +1 -1
- package/dist/services/unistylesBabel/index.cjs +1 -1
- package/dist/services/unistylesBabel/index.cjs.map +1 -1
- package/dist/services/unistylesBabel/index.mjs +1 -1
- package/dist/services/unistylesBabel/index.mjs.map +1 -1
- package/dist/services/webMetadata/index.cjs +3 -0
- package/dist/services/webMetadata/index.cjs.map +1 -0
- package/dist/services/webMetadata/index.mjs +3 -0
- package/dist/services/webMetadata/index.mjs.map +1 -0
- package/dist/services/webMetadata/type.d.mts +22 -0
- package/dist/services/webMetadata/type.d.mts.map +1 -0
- package/dist/services/writeGenerated/index.cjs.map +1 -1
- package/dist/services/writeGenerated/index.d.mts.map +1 -1
- package/dist/services/writeGenerated/index.mjs.map +1 -1
- package/dist/tsdown.cjs +1 -1
- package/dist/tsdown.d.mts +2 -1
- package/dist/tsdown.mjs +1 -1
- package/dist/types/extensionGraph.d.mts +1 -1
- package/package.json +2 -2
package/LICENSE
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
MIT License
|
|
2
2
|
|
|
3
|
-
Copyright (c) 2026
|
|
4
|
-
Copyright (c) 2026 pulseaiclub
|
|
3
|
+
Copyright (c) 2026 Agimon Pty Ltd
|
|
5
4
|
|
|
6
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
6
|
of this software and associated documentation files (the "Software"), to deal
|
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@ Folder-convention scanner and build presets for Po extensions.
|
|
|
4
4
|
|
|
5
5
|
An extension declares what it contributes by where its files sit. This package reads that tree and hands the result to the generators and bundler presets, so a package keeps no parallel registry of its own contents.
|
|
6
6
|
|
|
7
|
-
See [
|
|
7
|
+
See [Extensions](https://github.com/AgiFlow/po/blob/main/docs/architecture.md#extensions) for authoring and [Lifecycle](https://github.com/AgiFlow/po/blob/main/docs/architecture.md#lifecycle) for ownership after mounting.
|
|
8
8
|
|
|
9
9
|
## Scanning
|
|
10
10
|
|
|
@@ -18,7 +18,7 @@ for (const notice of graph.notices) console.warn(notice.path, notice.message);
|
|
|
18
18
|
|
|
19
19
|
The scan is filesystem in, data out. It walks directories rather than globbing, which is what keeps parenthesised group folders safe: tsdown's globber reads a bare `(name)` as an extglob group, and a walk never sees a pattern at all.
|
|
20
20
|
|
|
21
|
-
|
|
21
|
+
An unrecognized folder becomes a notice and its subtree is skipped. Filesystem errors still propagate; scan notices are not a guarantee that IO cannot fail.
|
|
22
22
|
|
|
23
23
|
## What a path declares
|
|
24
24
|
|
|
@@ -41,7 +41,7 @@ src/extensions/<scope>/(side)/<surface>/<name>[.<target>][.<platform>].<ext>
|
|
|
41
41
|
|
|
42
42
|
## Options
|
|
43
43
|
|
|
44
|
-
|
|
44
|
+
The scan accepts overrides for its root, side names, platforms, and managed generated-entry names:
|
|
45
45
|
|
|
46
46
|
```ts
|
|
47
47
|
scanExtensions({
|
|
@@ -57,7 +57,7 @@ scanExtensions({
|
|
|
57
57
|
|
|
58
58
|
The build emits four hosts: `server` and `mcp` from `(backend)`, and `web` and `native` from `(frontend)`. `ios`, `android`, and `desktop` are authorable but have no build target, so a file naming one produces a notice and is not emitted.
|
|
59
59
|
|
|
60
|
-
The server and
|
|
60
|
+
Author every routed file with an explicit platform suffix. The server and cockpit retain an unsuffixed fallback with a diagnostic; `mcp` and `native` never use that fallback: they read only files that name them, because an unsuffixed backend file may reach the whole server and an unsuffixed frontend file may use the DOM. `native` reads `tool/`, `tab/`, `slot/`, `fill/`, `channel/`, `activity-group/`, `setting/`, `lifecycle/`, and `store/`, and writes the same contribution fields as the cockpit for them, because the Po phone app reuses the cockpit's plugin registry.
|
|
61
61
|
|
|
62
62
|
`isBrowserFile` and `isNativeFile` (from `@agimon-ai/po-build/browserFile`) classify a package-relative path without reading it. A `(frontend)` path whose filename names `native` anywhere between its name and extension, including `.native.stories.tsx`, is native; every other `(frontend)` path is browser code. Lint rules use these to apply browser and native rules to the right files.
|
|
63
63
|
|
|
@@ -87,10 +87,10 @@ export default defineConfig(poExtension());
|
|
|
87
87
|
|
|
88
88
|
The preset generates entries while the config loads because tsdown needs its entry map before building. It builds Node host entries and public `src/exports` modules, then bundles routed frontend contributions separately to `dist/extensions/web.mjs`. The browser bundle keeps bare package imports external so the cockpit supplies shared React and store singletons. It also emits local `?url` assets and `?worker&url` worker chunks.
|
|
89
89
|
|
|
90
|
-
When a package has `.native` contributions, the preset adds a third config that bundles `generated/native.ts` to `dist/extensions/native.mjs`: ESM, `platform: 'neutral'`, every bare import external, typechecked under `tsconfig.native.json`. Its `po-unistyles-babel` transform runs the `react-native-unistyles` Babel plugin (`{ root: 'src' }`) over `.ts` and `.tsx` files under the package's own `src` that mention `react-native`, before rolldown strips the TypeScript. po-build does not depend on Babel or Unistyles: it loads `@babel/core` and `react-native-unistyles/plugin` from the extension package with `createRequire`, and fails with a message naming both when either is missing. This file bundle is not yet a composition; the `po` CLI
|
|
90
|
+
When a package has `.native` contributions, the preset adds a third config that bundles `generated/native.ts` to `dist/extensions/native.mjs`: ESM, `platform: 'neutral'`, every bare import external, typechecked under `tsconfig.native.json`. Its `po-unistyles-babel` transform runs the `react-native-unistyles` Babel plugin (`{ root: 'src' }`) over `.ts` and `.tsx` files under the package's own `src` that mention `react-native`, before rolldown strips the TypeScript. po-build does not depend on Babel or Unistyles: it loads `@babel/core` and `react-native-unistyles/plugin` from the extension package with `createRequire`, and fails with a message naming both when either is missing. This file bundle is not yet a mounted composition; the `po` CLI builds signed native publications and checks their imports against the native host module list (see [Native](https://github.com/AgiFlow/po/blob/main/docs/architecture.md#native)).
|
|
91
91
|
|
|
92
92
|
Native component libraries reuse the same transform: `import { unistylesBabel } from '@agimon-ai/po-build/tsdown'` and add `unistylesBabel(import.meta.dirname)` to their own tsdown `plugins`.
|
|
93
93
|
|
|
94
|
-
The build synchronizes `
|
|
94
|
+
The build synchronizes `poServer`, `poWeb`, `poNative`, explicit MCP metadata, and generated host exports in `package.json`, and removes the retired Pi extension export. `poNative` holds `pluginId`, the frame types its `.native` channels claim, `client: './dist/extensions/native.mjs'`, and the scopes it contributes to; the build also writes the `./extensions/native` export. `poWeb` and `poNative` describe disjoint files, because the cockpit never reads `.native` files. Keep package-specific public entries with the preset `entry` option, use `exportsDir` for a nonstandard public-export root, and set `pluginId` when the historical cockpit id differs from the package-derived default.
|
|
95
95
|
|
|
96
|
-
Packages with a frontend target typecheck it through a root `tsconfig.web.json`. Include `generated` in the Node project, exclude routed `(frontend)` files from it, and include those files plus `generated/web.ts` in the browser project. Packages with a native target also own a `tsconfig.native.json` with no DOM lib that includes `src/extensions/**/(frontend)/**/*.native.*` and `generated/native.ts`; exclude `**/*.native.*` from `tsconfig.web.json` and add `@babel/core`, `react-native`, and `react-native-unistyles` to the package's dev dependencies. `layers/
|
|
96
|
+
Packages with a frontend target typecheck it through a root `tsconfig.web.json`. Include `generated` in the Node project, exclude routed `(frontend)` files from it, and include those files plus `generated/web.ts` in the browser project. Packages with a native target also own a `tsconfig.native.json` with no DOM lib that includes `src/extensions/**/(frontend)/**/*.native.*` and `generated/native.ts`; exclude `**/*.native.*` from `tsconfig.web.json` and add `@babel/core`, `react-native`, and `react-native-unistyles` to the package's dev dependencies. `layers/agent/po-task` is the working example.
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const e={tool:`tools`,"tool-restriction":`toolRestrictions`,command:`commands`,hook:`hooks`,
|
|
1
|
+
const e={tool:`tools`,"tool-restriction":`toolRestrictions`,command:`commands`,hook:`hooks`,api:`api`,channel:`channels`,method:`methods`,resource:`resources`},t={tool:`tools`,skill:`skills`,resource:`uiResources`},n={tool:`toolRenderers`,command:`paletteCommands`,mode:`modes`,channel:`channels`,tab:`tabs`,template:`templates`,onboarding:`onboarding`,dock:`dockFaces`,setting:`settingsSections`,slot:`slots`,fill:`fills`,action:`contextActions`,"activity-group":`activityGroups`,leader:`leaderBindings`,"selection-axis":`selectionAxes`,lifecycle:`start`,"file-links":`fileLinks`,provider:`provider`,theme:`themes`,locale:`locales`,"repository-settings-panel":`repositorySettingsPanel`,api:``,method:``,store:``},r={tool:`toolRenderers`,dock:`dockFaces`,tab:`tabs`,slot:`slots`,fill:`fills`,channel:`channels`,"activity-group":`activityGroups`,"file-links":`fileLinks`,provider:`provider`,theme:`themes`,locale:`locales`,"selection-axis":`selectionAxes`,setting:`settingsSections`,action:`userMessageActions`,lifecycle:`start`,template:`nativeTemplates`,onboarding:`onboarding`,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","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
|
|
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 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: 'modes',\n channel: 'channels',\n tab: 'tabs',\n template: 'templates',\n onboarding: 'onboarding',\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 provider: 'provider',\n theme: 'themes',\n locale: 'locales',\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 dock: 'dockFaces',\n tab: 'tabs',\n slot: 'slots',\n fill: 'fills',\n channel: 'channels',\n 'activity-group': 'activityGroups',\n // Paths in message text and tool cards open the plugin's file view on the phone, as in the cockpit.\n 'file-links': 'fileLinks',\n provider: 'provider',\n // The same named theme feeds the phone's Appearance screen when its colours are hex.\n theme: 'themes',\n locale: 'locales',\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 onboarding: 'onboarding',\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,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,QACN,QAAS,WACT,IAAK,OACL,SAAU,YACV,WAAY,aACZ,KAAM,YACN,QAAS,mBACT,KAAM,QAIN,KAAM,QACN,OAAQ,iBACR,iBAAkB,iBAClB,OAAQ,iBACR,iBAAkB,gBAClB,UAAW,QACX,aAAc,YACd,SAAU,WACV,MAAO,SACP,OAAQ,UACR,4BAA6B,0BAC7B,IAAA,GACA,OAAA,GACA,MAAA,EACF,EASaC,EAAkD,CAC7D,KAAM,gBACN,KAAM,YACN,IAAK,OACL,KAAM,QACN,KAAM,QACN,QAAS,WACT,iBAAkB,iBAElB,aAAc,YACd,SAAU,WAEV,MAAO,SACP,OAAQ,UACR,iBAAkB,gBAClB,QAAS,mBAET,OAAQ,qBACR,UAAW,QAEX,SAAU,kBACV,WAAY,aACZ,MAAA,EACF,EAGaC,EAAmD,CAC9D,QAAS,mBACT,MAAO,gBACT,EAGaC,EAAkD,CAC7D,QAAS,iBACT,QAAS,oBACX,EAMaC,EAAyD,CACpE,QAAS,oBACX,E"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const e={tool:`tools`,"tool-restriction":`toolRestrictions`,command:`commands`,hook:`hooks`,
|
|
1
|
+
const e={tool:`tools`,"tool-restriction":`toolRestrictions`,command:`commands`,hook:`hooks`,api:`api`,channel:`channels`,method:`methods`,resource:`resources`},t={tool:`tools`,skill:`skills`,resource:`uiResources`},n={tool:`toolRenderers`,command:`paletteCommands`,mode:`modes`,channel:`channels`,tab:`tabs`,template:`templates`,onboarding:`onboarding`,dock:`dockFaces`,setting:`settingsSections`,slot:`slots`,fill:`fills`,action:`contextActions`,"activity-group":`activityGroups`,leader:`leaderBindings`,"selection-axis":`selectionAxes`,lifecycle:`start`,"file-links":`fileLinks`,provider:`provider`,theme:`themes`,locale:`locales`,"repository-settings-panel":`repositorySettingsPanel`,api:``,method:``,store:``},r={tool:`toolRenderers`,dock:`dockFaces`,tab:`tabs`,slot:`slots`,fill:`fills`,channel:`channels`,"activity-group":`activityGroups`,"file-links":`fileLinks`,provider:`provider`,theme:`themes`,locale:`locales`,"selection-axis":`selectionAxes`,setting:`settingsSections`,action:`userMessageActions`,lifecycle:`start`,template:`nativeTemplates`,onboarding:`onboarding`,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","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
|
|
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 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: 'modes',\n channel: 'channels',\n tab: 'tabs',\n template: 'templates',\n onboarding: 'onboarding',\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 provider: 'provider',\n theme: 'themes',\n locale: 'locales',\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 dock: 'dockFaces',\n tab: 'tabs',\n slot: 'slots',\n fill: 'fills',\n channel: 'channels',\n 'activity-group': 'activityGroups',\n // Paths in message text and tool cards open the plugin's file view on the phone, as in the cockpit.\n 'file-links': 'fileLinks',\n provider: 'provider',\n // The same named theme feeds the phone's Appearance screen when its colours are hex.\n theme: 'themes',\n locale: 'locales',\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 onboarding: 'onboarding',\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,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,QACN,QAAS,WACT,IAAK,OACL,SAAU,YACV,WAAY,aACZ,KAAM,YACN,QAAS,mBACT,KAAM,QAIN,KAAM,QACN,OAAQ,iBACR,iBAAkB,iBAClB,OAAQ,iBACR,iBAAkB,gBAClB,UAAW,QACX,aAAc,YACd,SAAU,WACV,MAAO,SACP,OAAQ,UACR,4BAA6B,0BAC7B,IAAA,GACA,OAAA,GACA,MAAA,EACF,EASaC,EAAkD,CAC7D,KAAM,gBACN,KAAM,YACN,IAAK,OACL,KAAM,QACN,KAAM,QACN,QAAS,WACT,iBAAkB,iBAElB,aAAc,YACd,SAAU,WAEV,MAAO,SACP,OAAQ,UACR,iBAAkB,gBAClB,QAAS,mBAET,OAAQ,qBACR,UAAW,QAEX,SAAU,kBACV,WAAY,aACZ,MAAA,EACF,EAGaC,EAAmD,CAC9D,QAAS,mBACT,MAAO,gBACT,EAGaC,EAAkD,CAC7D,QAAS,iBACT,QAAS,oBACX,EAMaC,EAAyD,CACpE,QAAS,oBACX,E"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const e=[`mode`,`domain`],t={server:`server`,web:`web`,native:`native`,mcp:`mcp`},n=[`pi`,`server`,`web`,`native`,`mcp`,`client`,`client.native`],r=[`server`,`mcp`],i=[`web`,`native`,`ios`,`android`,`desktop`],a=[`server`,`web`,`native`,`mcp`],o=[`tool`,`skill`,`tool-restriction`,`command`,`hook`,`api`,`channel`,`method`,`provider`,`resource`,`contract`],s=[`tool`,`command`,`api`,`channel`,`method`,`tab`,`template`,`dock`,`setting`,`slot`,`fill`,`action`,`store`,`activity-group`,`leader`,`selection-axis`,`lifecycle`,`file-links`,`repository-settings-panel`],c=[`fill`,`action`],l=[`api`],u=[`ts`,`tsx`,`mts`,`cts`],d=[`test`,`spec`,`stories`,`edge`];exports.API_ROUTES_MODULE=`src/types/apiRoutes.ts`,exports.BACKEND_GROUP=`backend`,exports.BACKEND_PLATFORMS=r,exports.BACKEND_SURFACES=o,exports.BUILD_TARGET_PLATFORMS=a,exports.CONTRACT_SURFACE=`contract`,exports.DEFAULT_ROUTING_ROOT=`src/extensions`,exports.EXCLUDED_INFIXES=d,exports.FRONTEND_GROUP=`frontend`,exports.FRONTEND_PLATFORMS=i,exports.FRONTEND_SURFACES=s,exports.GATE_SEGMENTS=e,exports.GENERATED_CLIENT_NAME=`client`,exports.GENERATED_DIR=`generated`,exports.GENERATED_ENTRY_FILENAMES=t,exports.GENERATED_ENTRY_NAMES=n,exports.GENERATED_NATIVE_CLIENT_NAME=`client.native`,exports.NATIVE_PLATFORM=`native`,exports.ROOT_FILE_NAME=`root`,exports.ROUTED_SURFACES=l,exports.ROUTE_FILE_NAME=`route`,exports.ROUTING_ROOT_ALIAS=`src/extension`,exports.SERVER_DIST=`./dist/extensions/server.mjs`,exports.SESSION_SEGMENT=`sessions`,exports.SOURCE_EXTENSIONS=u,exports.TARGETED_SURFACES=c,exports.WORKSPACE_SEGMENT=`workspaces`;
|
|
1
|
+
const e=[`mode`,`domain`],t={server:`server`,web:`web`,native:`native`,mcp:`mcp`},n=[`pi`,`server`,`web`,`native`,`mcp`,`client`,`client.native`],r=[`server`,`mcp`],i=[`web`,`native`,`ios`,`android`,`desktop`],a=[`server`,`web`,`native`,`mcp`],o=[`tool`,`skill`,`tool-restriction`,`command`,`hook`,`api`,`channel`,`method`,`provider`,`resource`,`contract`],s=[`tool`,`command`,`api`,`channel`,`method`,`tab`,`template`,`onboarding`,`dock`,`setting`,`slot`,`fill`,`action`,`store`,`activity-group`,`leader`,`selection-axis`,`lifecycle`,`file-links`,`provider`,`theme`,`locale`,`repository-settings-panel`],c=[`fill`,`action`],l=[`api`],u=[`ts`,`tsx`,`mts`,`cts`],d=[`test`,`spec`,`stories`,`edge`];exports.API_ROUTES_MODULE=`src/types/apiRoutes.ts`,exports.BACKEND_GROUP=`backend`,exports.BACKEND_PLATFORMS=r,exports.BACKEND_SURFACES=o,exports.BUILD_TARGET_PLATFORMS=a,exports.CONTRACT_SURFACE=`contract`,exports.DEFAULT_ROUTING_ROOT=`src/extensions`,exports.EXCLUDED_INFIXES=d,exports.FRONTEND_GROUP=`frontend`,exports.FRONTEND_PLATFORMS=i,exports.FRONTEND_SURFACES=s,exports.GATE_SEGMENTS=e,exports.GENERATED_CLIENT_NAME=`client`,exports.GENERATED_DIR=`generated`,exports.GENERATED_ENTRY_FILENAMES=t,exports.GENERATED_ENTRY_NAMES=n,exports.GENERATED_NATIVE_CLIENT_NAME=`client.native`,exports.NATIVE_PLATFORM=`native`,exports.ROOT_FILE_NAME=`root`,exports.ROUTED_SURFACES=l,exports.ROUTE_FILE_NAME=`route`,exports.ROUTING_ROOT_ALIAS=`src/extension`,exports.SERVER_DIST=`./dist/extensions/server.mjs`,exports.SESSION_SEGMENT=`sessions`,exports.SOURCE_EXTENSIONS=u,exports.TARGETED_SURFACES=c,exports.WORKSPACE_SEGMENT=`workspaces`;
|
|
2
2
|
//# sourceMappingURL=layout.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"layout.cjs","names":["GATE_SEGMENTS","GENERATED_ENTRY_FILENAMES","GENERATED_ENTRY_NAMES","BACKEND_PLATFORMS","FRONTEND_PLATFORMS","BUILD_TARGET_PLATFORMS","BACKEND_SURFACES","FRONTEND_SURFACES","TARGETED_SURFACES","ROUTED_SURFACES","SOURCE_EXTENSIONS","EXCLUDED_INFIXES"],"sources":["../../src/constants/layout.ts"],"sourcesContent":["/**\n * The folder-convention vocabulary, in one place.\n *\n *
|
|
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 * Authoring overview: docs/architecture.md#extensions.\n * The constants below define the maintained folder vocabulary.\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 (which is the host scope). */\nexport const WORKSPACE_SEGMENT = 'workspaces';\nexport const SESSION_SEGMENT = 'sessions';\n\n/** Gate folders. Each is followed by exactly one id segment. */\nexport const GATE_SEGMENTS: readonly string[] = ['mode', 'domain'];\n\n/** The leaf filename of an HTTP route, as Next.js spells it. */\nexport const ROUTE_FILE_NAME = 'route';\n\n/**\n * The reserved filename that constructs a scope, as Next.js spells a layout.\n *\n * One per scope and side. It runs before every contribution beneath it, and\n * whatever it returns is handed to each of them as part of the mount context,\n * which is how a package with one shared per-mount object graph decomposes\n * into a file per surface instead of one closure.\n */\nexport const ROOT_FILE_NAME = 'root';\n\n/**\n * Where generated entries are written, package-relative.\n *\n * Not `src`. That directory is authored code, and a build that writes into it\n * makes every package carry output its author did not write and must not edit.\n * This one is gitignored per package, and the repository's formatter already\n * skips a directory by this name.\n */\nexport const GENERATED_DIR = 'generated';\n\n/** The built server entry a host imports, package-relative, as `poServer.dist` names it. */\nexport const SERVER_DIST = './dist/extensions/server.mjs';\n\n/**\n * The generated entry each build target writes, keyed by the target it serves.\n *\n * Keyed rather than positional, so adding a generated file never rotates which\n * host each entry belongs to.\n */\nexport const GENERATED_ENTRY_FILENAMES = { server: 'server', web: 'web', native: 'native', mcp: 'mcp' } as const;\n\n/**\n * The generated typed client, which is not a build target.\n *\n * Nothing bundles it as an entry: a `(frontend)` file imports it and the\n * cockpit's browser build pulls it in from there. It is listed among the\n * managed names so that a package which drops its route table has the stale\n * client deleted rather than left behind.\n */\nexport const GENERATED_CLIENT_NAME = 'client';\n\n/**\n * The same client for a `.native` file, which may import neither the browser\n * contract nor the browser's sealed transport. Imported by its full name: the\n * native build is not Metro and resolves no platform suffix.\n */\nexport const GENERATED_NATIVE_CLIENT_NAME = 'client.native';\n\n/**\n * The route table a package authors, and the switch that asks for a client.\n *\n * Its presence is what opts a package in, the way `src/exports/apiContracts.ts`\n * is what asks for a contracts entry. It lives under `src/types` because that\n * is one of the two source roots a browser bundle may read.\n */\nexport const API_ROUTES_MODULE = 'src/types/apiRoutes.ts';\n\n/**\n * Every generated basename. Never scanned, never hand-edited.\n *\n * Spelled out rather than derived from the two declarations above, because a\n * constants module holds data a reader can see without running it. The cost is\n * that the names appear twice; the generate tests assert the two agree.\n *\n * `pi` is the retired terminal entry. It stays managed so a regenerate deletes\n * the stale file a package built before the terminal host was removed.\n */\nexport const GENERATED_ENTRY_NAMES: readonly string[] = [\n 'pi',\n 'server',\n 'web',\n 'native',\n 'mcp',\n 'client',\n 'client.native',\n];\n\n/** The retired terminal platform suffix. A routed file naming it is rejected. */\nexport const RETIRED_PLATFORM = 'cli';\n\n/**\n * Platform suffixes, scoped to their side. A target may not reuse one of these words.\n *\n * Every public routed file names one of these, so which host reads it is read\n * off the filename rather than inferred. A file that names none is a notice.\n */\nexport const BACKEND_PLATFORMS: readonly string[] = ['server', 'mcp'];\nexport const FRONTEND_PLATFORMS: readonly string[] = ['web', 'native', 'ios', 'android', 'desktop'];\n\n/**\n * The React Native frontend, for the iOS and Android app alike.\n *\n * Only a file naming it reaches the native host. An unsuffixed frontend file is\n * never a fallback here, because the web half is free to use the DOM.\n */\nexport const NATIVE_PLATFORM = 'native';\n\n/** The hosts this build emits. A frontend platform outside this set is authorable but unbuildable. */\nexport const BUILD_TARGET_PLATFORMS: readonly string[] = ['server', 'web', 'native', 'mcp'];\n\n/**\n * Surfaces that produce contributions on the backend side.\n *\n * `mode` is absent on purpose: it is a gate folder, so it is consumed before\n * the surface check and its declaration file synthesises the surface instead.\n * `contract` is not a contribution either: each file declares one service\n * contract its level provides, which the plugin lists as `provides`.\n */\nexport const BACKEND_SURFACES: readonly string[] = [\n 'tool',\n 'skill',\n 'tool-restriction',\n 'command',\n 'hook',\n 'api',\n 'channel',\n 'method',\n 'provider',\n 'resource',\n 'contract',\n];\n\n/** The backend surface whose files declare the service contracts a level provides. */\nexport const CONTRACT_SURFACE = 'contract';\n\n/**\n * Surfaces that produce contributions on the frontend side.\n */\nexport const FRONTEND_SURFACES: readonly string[] = [\n 'tool',\n 'command',\n 'api',\n 'channel',\n 'method',\n 'tab',\n 'template',\n 'onboarding',\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 'provider',\n 'theme',\n 'locale',\n 'repository-settings-panel',\n];\n\n/** Surfaces whose filename carries a relationship target. */\nexport const TARGETED_SURFACES: readonly string[] = ['fill', 'action'];\n\n/** Surfaces whose folders below the surface spell a route path. */\nexport const ROUTED_SURFACES: readonly string[] = ['api'];\n\n/** Source extensions the scan accepts. */\nexport const SOURCE_EXTENSIONS: readonly string[] = ['ts', 'tsx', 'mts', 'cts'];\n\n/**\n * Filename infixes excluded everywhere, whatever their position. `edge` marks a\n * workerd variant of its base sibling, resolved only by the private Worker build.\n */\nexport const EXCLUDED_INFIXES: readonly string[] = ['test', 'spec', 'stories', 'edge'];\n\n/** Marks a folder as organisational: not a path segment, contents still scanned. */\nexport const GROUP_PREFIX = '(';\nexport const GROUP_SUFFIX = ')';\n/** Marks a folder as private: never scanned, never built. */\nexport const PRIVATE_PREFIX = '_';\n/** Marks a folder as a dynamic route segment. */\nexport const DYNAMIC_PREFIX = '[';\nexport const DYNAMIC_SUFFIX = ']';\n/** Marks a dynamic segment as catch-all. */\nexport const CATCH_ALL_MARKER = '...';\n"],"mappings":"AAQA,MAaaA,EAAmC,CAAC,OAAQ,QAAQ,EAkCpDC,EAA4B,CAAE,OAAQ,SAAU,IAAK,MAAO,OAAQ,SAAU,IAAK,KAAM,EAsCzFC,EAA2C,CACtD,KACA,SACA,MACA,SACA,MACA,SACA,eACF,EAWaC,EAAuC,CAAC,SAAU,KAAK,EACvDC,EAAwC,CAAC,MAAO,SAAU,MAAO,UAAW,SAAS,EAWrFC,EAA4C,CAAC,SAAU,MAAO,SAAU,KAAK,EAU7EC,EAAsC,CACjD,OACA,QACA,mBACA,UACA,OACA,MACA,UACA,SACA,WACA,WACA,UACF,EAQaC,EAAuC,CAClD,OACA,UACA,MACA,UACA,SACA,MACA,WACA,aACA,OACA,UACA,OACA,OACA,SACA,QACA,iBACA,SACA,iBACA,YACA,aACA,WACA,QACA,SACA,2BACF,EAGaC,EAAuC,CAAC,OAAQ,QAAQ,EAGxDC,EAAqC,CAAC,KAAK,EAG3CC,EAAuC,CAAC,KAAM,MAAO,MAAO,KAAK,EAMjEC,EAAsC,CAAC,OAAQ,OAAQ,UAAW,MAAM,E"}
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
/**
|
|
3
3
|
* The folder-convention vocabulary, in one place.
|
|
4
4
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
5
|
+
* Authoring overview: docs/architecture.md#extensions.
|
|
6
|
+
* The constants below define the maintained folder vocabulary.
|
|
7
7
|
*/
|
|
8
8
|
/** Where the scan starts, package-relative. */
|
|
9
9
|
export declare const DEFAULT_ROUTING_ROOT = "src/extensions";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"layout.d.mts","names":[],"sources":["../../src/constants/layout.ts"],"mappings":";;;;;;;;qBAQa;;qBAEA;;qBAWA;;qBAGA;;;;;;;;;qBAoBA;;;;;;;qBAoEA;qBACA;;;;;;;qBAQA;;;;;;;;;qBAaA;;;;qBAoBA;;
|
|
1
|
+
{"version":3,"file":"layout.d.mts","names":[],"sources":["../../src/constants/layout.ts"],"mappings":";;;;;;;;qBAQa;;qBAEA;;qBAWA;;qBAGA;;;;;;;;;qBAoBA;;;;;;;qBAoEA;qBACA;;;;;;;qBAQA;;;;;;;;;qBAaA;;;;qBAoBA;;qBA2BA;;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=`./dist/extensions/server.mjs`,d={server:`server`,web:`web`,native:`native`,mcp:`mcp`},f=`client`,p=`client.native`,m=`src/types/apiRoutes.ts`,h=[`pi`,`server`,`web`,`native`,`mcp`,`client`,`client.native`],g=[`server`,`mcp`],_=[`web`,`native`,`ios`,`android`,`desktop`],v=`native`,y=[`server`,`web`,`native`,`mcp`],b=[`tool`,`skill`,`tool-restriction`,`command`,`hook`,`api`,`channel`,`method`,`provider`,`resource`,`contract`],x=`contract`,S=[`tool`,`command`,`api`,`channel`,`method`,`tab`,`template`,`dock`,`setting`,`slot`,`fill`,`action`,`store`,`activity-group`,`leader`,`selection-axis`,`lifecycle`,`file-links`,`repository-settings-panel`],C=[`fill`,`action`],w=[`api`],T=[`ts`,`tsx`,`mts`,`cts`],E=[`test`,`spec`,`stories`,`edge`];export{m as API_ROUTES_MODULE,n as BACKEND_GROUP,g as BACKEND_PLATFORMS,b as BACKEND_SURFACES,y as BUILD_TARGET_PLATFORMS,x as CONTRACT_SURFACE,e as DEFAULT_ROUTING_ROOT,E as EXCLUDED_INFIXES,r as FRONTEND_GROUP,_ as FRONTEND_PLATFORMS,S as FRONTEND_SURFACES,o as GATE_SEGMENTS,f as GENERATED_CLIENT_NAME,l as GENERATED_DIR,d as GENERATED_ENTRY_FILENAMES,h as GENERATED_ENTRY_NAMES,p as GENERATED_NATIVE_CLIENT_NAME,v as NATIVE_PLATFORM,c as ROOT_FILE_NAME,w as ROUTED_SURFACES,s as ROUTE_FILE_NAME,t as ROUTING_ROOT_ALIAS,u as SERVER_DIST,a as SESSION_SEGMENT,T as SOURCE_EXTENSIONS,C as TARGETED_SURFACES,i as WORKSPACE_SEGMENT};
|
|
1
|
+
const e=`src/extensions`,t=`src/extension`,n=`backend`,r=`frontend`,i=`workspaces`,a=`sessions`,o=[`mode`,`domain`],s=`route`,c=`root`,l=`generated`,u=`./dist/extensions/server.mjs`,d={server:`server`,web:`web`,native:`native`,mcp:`mcp`},f=`client`,p=`client.native`,m=`src/types/apiRoutes.ts`,h=[`pi`,`server`,`web`,`native`,`mcp`,`client`,`client.native`],g=[`server`,`mcp`],_=[`web`,`native`,`ios`,`android`,`desktop`],v=`native`,y=[`server`,`web`,`native`,`mcp`],b=[`tool`,`skill`,`tool-restriction`,`command`,`hook`,`api`,`channel`,`method`,`provider`,`resource`,`contract`],x=`contract`,S=[`tool`,`command`,`api`,`channel`,`method`,`tab`,`template`,`onboarding`,`dock`,`setting`,`slot`,`fill`,`action`,`store`,`activity-group`,`leader`,`selection-axis`,`lifecycle`,`file-links`,`provider`,`theme`,`locale`,`repository-settings-panel`],C=[`fill`,`action`],w=[`api`],T=[`ts`,`tsx`,`mts`,`cts`],E=[`test`,`spec`,`stories`,`edge`];export{m as API_ROUTES_MODULE,n as BACKEND_GROUP,g as BACKEND_PLATFORMS,b as BACKEND_SURFACES,y as BUILD_TARGET_PLATFORMS,x as CONTRACT_SURFACE,e as DEFAULT_ROUTING_ROOT,E as EXCLUDED_INFIXES,r as FRONTEND_GROUP,_ as FRONTEND_PLATFORMS,S as FRONTEND_SURFACES,o as GATE_SEGMENTS,f as GENERATED_CLIENT_NAME,l as GENERATED_DIR,d as GENERATED_ENTRY_FILENAMES,h as GENERATED_ENTRY_NAMES,p as GENERATED_NATIVE_CLIENT_NAME,v as NATIVE_PLATFORM,c as ROOT_FILE_NAME,w as ROUTED_SURFACES,s as ROUTE_FILE_NAME,t as ROUTING_ROOT_ALIAS,u as SERVER_DIST,a as SESSION_SEGMENT,T as SOURCE_EXTENSIONS,C as TARGETED_SURFACES,i as WORKSPACE_SEGMENT};
|
|
2
2
|
//# sourceMappingURL=layout.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"layout.mjs","names":["DEFAULT_ROUTING_ROOT","ROUTING_ROOT_ALIAS","BACKEND_GROUP","FRONTEND_GROUP","WORKSPACE_SEGMENT","SESSION_SEGMENT","GATE_SEGMENTS","ROUTE_FILE_NAME","ROOT_FILE_NAME","GENERATED_DIR","SERVER_DIST","GENERATED_ENTRY_FILENAMES","GENERATED_CLIENT_NAME","GENERATED_NATIVE_CLIENT_NAME","API_ROUTES_MODULE","GENERATED_ENTRY_NAMES","BACKEND_PLATFORMS","FRONTEND_PLATFORMS","NATIVE_PLATFORM","BUILD_TARGET_PLATFORMS","BACKEND_SURFACES","CONTRACT_SURFACE","FRONTEND_SURFACES","TARGETED_SURFACES","ROUTED_SURFACES","SOURCE_EXTENSIONS","EXCLUDED_INFIXES"],"sources":["../../src/constants/layout.ts"],"sourcesContent":["/**\n * The folder-convention vocabulary, in one place.\n *\n *
|
|
1
|
+
{"version":3,"file":"layout.mjs","names":["DEFAULT_ROUTING_ROOT","ROUTING_ROOT_ALIAS","BACKEND_GROUP","FRONTEND_GROUP","WORKSPACE_SEGMENT","SESSION_SEGMENT","GATE_SEGMENTS","ROUTE_FILE_NAME","ROOT_FILE_NAME","GENERATED_DIR","SERVER_DIST","GENERATED_ENTRY_FILENAMES","GENERATED_CLIENT_NAME","GENERATED_NATIVE_CLIENT_NAME","API_ROUTES_MODULE","GENERATED_ENTRY_NAMES","BACKEND_PLATFORMS","FRONTEND_PLATFORMS","NATIVE_PLATFORM","BUILD_TARGET_PLATFORMS","BACKEND_SURFACES","CONTRACT_SURFACE","FRONTEND_SURFACES","TARGETED_SURFACES","ROUTED_SURFACES","SOURCE_EXTENSIONS","EXCLUDED_INFIXES"],"sources":["../../src/constants/layout.ts"],"sourcesContent":["/**\n * The folder-convention vocabulary, in one place.\n *\n * Authoring overview: docs/architecture.md#extensions.\n * The constants below define the maintained folder vocabulary.\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 (which is the host scope). */\nexport const WORKSPACE_SEGMENT = 'workspaces';\nexport const SESSION_SEGMENT = 'sessions';\n\n/** Gate folders. Each is followed by exactly one id segment. */\nexport const GATE_SEGMENTS: readonly string[] = ['mode', 'domain'];\n\n/** The leaf filename of an HTTP route, as Next.js spells it. */\nexport const ROUTE_FILE_NAME = 'route';\n\n/**\n * The reserved filename that constructs a scope, as Next.js spells a layout.\n *\n * One per scope and side. It runs before every contribution beneath it, and\n * whatever it returns is handed to each of them as part of the mount context,\n * which is how a package with one shared per-mount object graph decomposes\n * into a file per surface instead of one closure.\n */\nexport const ROOT_FILE_NAME = 'root';\n\n/**\n * Where generated entries are written, package-relative.\n *\n * Not `src`. That directory is authored code, and a build that writes into it\n * makes every package carry output its author did not write and must not edit.\n * This one is gitignored per package, and the repository's formatter already\n * skips a directory by this name.\n */\nexport const GENERATED_DIR = 'generated';\n\n/** The built server entry a host imports, package-relative, as `poServer.dist` names it. */\nexport const SERVER_DIST = './dist/extensions/server.mjs';\n\n/**\n * The generated entry each build target writes, keyed by the target it serves.\n *\n * Keyed rather than positional, so adding a generated file never rotates which\n * host each entry belongs to.\n */\nexport const GENERATED_ENTRY_FILENAMES = { server: 'server', web: 'web', native: 'native', mcp: 'mcp' } as const;\n\n/**\n * The generated typed client, which is not a build target.\n *\n * Nothing bundles it as an entry: a `(frontend)` file imports it and the\n * cockpit's browser build pulls it in from there. It is listed among the\n * managed names so that a package which drops its route table has the stale\n * client deleted rather than left behind.\n */\nexport const GENERATED_CLIENT_NAME = 'client';\n\n/**\n * The same client for a `.native` file, which may import neither the browser\n * contract nor the browser's sealed transport. Imported by its full name: the\n * native build is not Metro and resolves no platform suffix.\n */\nexport const GENERATED_NATIVE_CLIENT_NAME = 'client.native';\n\n/**\n * The route table a package authors, and the switch that asks for a client.\n *\n * Its presence is what opts a package in, the way `src/exports/apiContracts.ts`\n * is what asks for a contracts entry. It lives under `src/types` because that\n * is one of the two source roots a browser bundle may read.\n */\nexport const API_ROUTES_MODULE = 'src/types/apiRoutes.ts';\n\n/**\n * Every generated basename. Never scanned, never hand-edited.\n *\n * Spelled out rather than derived from the two declarations above, because a\n * constants module holds data a reader can see without running it. The cost is\n * that the names appear twice; the generate tests assert the two agree.\n *\n * `pi` is the retired terminal entry. It stays managed so a regenerate deletes\n * the stale file a package built before the terminal host was removed.\n */\nexport const GENERATED_ENTRY_NAMES: readonly string[] = [\n 'pi',\n 'server',\n 'web',\n 'native',\n 'mcp',\n 'client',\n 'client.native',\n];\n\n/** The retired terminal platform suffix. A routed file naming it is rejected. */\nexport const RETIRED_PLATFORM = 'cli';\n\n/**\n * Platform suffixes, scoped to their side. A target may not reuse one of these words.\n *\n * Every public routed file names one of these, so which host reads it is read\n * off the filename rather than inferred. A file that names none is a notice.\n */\nexport const BACKEND_PLATFORMS: readonly string[] = ['server', 'mcp'];\nexport const FRONTEND_PLATFORMS: readonly string[] = ['web', 'native', 'ios', 'android', 'desktop'];\n\n/**\n * The React Native frontend, for the iOS and Android app alike.\n *\n * Only a file naming it reaches the native host. An unsuffixed frontend file is\n * never a fallback here, because the web half is free to use the DOM.\n */\nexport const NATIVE_PLATFORM = 'native';\n\n/** The hosts this build emits. A frontend platform outside this set is authorable but unbuildable. */\nexport const BUILD_TARGET_PLATFORMS: readonly string[] = ['server', 'web', 'native', 'mcp'];\n\n/**\n * Surfaces that produce contributions on the backend side.\n *\n * `mode` is absent on purpose: it is a gate folder, so it is consumed before\n * the surface check and its declaration file synthesises the surface instead.\n * `contract` is not a contribution either: each file declares one service\n * contract its level provides, which the plugin lists as `provides`.\n */\nexport const BACKEND_SURFACES: readonly string[] = [\n 'tool',\n 'skill',\n 'tool-restriction',\n 'command',\n 'hook',\n 'api',\n 'channel',\n 'method',\n 'provider',\n 'resource',\n 'contract',\n];\n\n/** The backend surface whose files declare the service contracts a level provides. */\nexport const CONTRACT_SURFACE = 'contract';\n\n/**\n * Surfaces that produce contributions on the frontend side.\n */\nexport const FRONTEND_SURFACES: readonly string[] = [\n 'tool',\n 'command',\n 'api',\n 'channel',\n 'method',\n 'tab',\n 'template',\n 'onboarding',\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 'provider',\n 'theme',\n 'locale',\n 'repository-settings-panel',\n];\n\n/** Surfaces whose filename carries a relationship target. */\nexport const TARGETED_SURFACES: readonly string[] = ['fill', 'action'];\n\n/** Surfaces whose folders below the surface spell a route path. */\nexport const ROUTED_SURFACES: readonly string[] = ['api'];\n\n/** Source extensions the scan accepts. */\nexport const SOURCE_EXTENSIONS: readonly string[] = ['ts', 'tsx', 'mts', 'cts'];\n\n/**\n * Filename infixes excluded everywhere, whatever their position. `edge` marks a\n * workerd variant of its base sibling, resolved only by the private Worker build.\n */\nexport const EXCLUDED_INFIXES: readonly string[] = ['test', 'spec', 'stories', 'edge'];\n\n/** Marks a folder as organisational: not a path segment, contents still scanned. */\nexport const GROUP_PREFIX = '(';\nexport const GROUP_SUFFIX = ')';\n/** Marks a folder as private: never scanned, never built. */\nexport const PRIVATE_PREFIX = '_';\n/** Marks a folder as a dynamic route segment. */\nexport const DYNAMIC_PREFIX = '[';\nexport const DYNAMIC_SUFFIX = ']';\n/** Marks a dynamic segment as catch-all. */\nexport const CATCH_ALL_MARKER = '...';\n"],"mappings":"AAQA,MAAaA,EAAuB,iBAEvBC,EAAqB,gBAGrBC,EAAgB,UAChBC,EAAiB,WAGjBC,EAAoB,aACpBC,EAAkB,WAGlBC,EAAmC,CAAC,OAAQ,QAAQ,EAGpDC,EAAkB,QAUlBC,EAAiB,OAUjBC,EAAgB,YAGhBC,EAAc,+BAQdC,EAA4B,CAAE,OAAQ,SAAU,IAAK,MAAO,OAAQ,SAAU,IAAK,KAAM,EAUzFC,EAAwB,SAOxBC,EAA+B,gBAS/BC,EAAoB,yBAYpBC,EAA2C,CACtD,KACA,SACA,MACA,SACA,MACA,SACA,eACF,EAWaC,EAAuC,CAAC,SAAU,KAAK,EACvDC,EAAwC,CAAC,MAAO,SAAU,MAAO,UAAW,SAAS,EAQrFC,EAAkB,SAGlBC,EAA4C,CAAC,SAAU,MAAO,SAAU,KAAK,EAU7EC,EAAsC,CACjD,OACA,QACA,mBACA,UACA,OACA,MACA,UACA,SACA,WACA,WACA,UACF,EAGaC,EAAmB,WAKnBC,EAAuC,CAClD,OACA,UACA,MACA,UACA,SACA,MACA,WACA,aACA,OACA,UACA,OACA,OACA,SACA,QACA,iBACA,SACA,iBACA,YACA,aACA,WACA,QACA,SACA,2BACF,EAGaC,EAAuC,CAAC,OAAQ,QAAQ,EAGxDC,EAAqC,CAAC,KAAK,EAG3CC,EAAuC,CAAC,KAAM,MAAO,MAAO,KAAK,EAMjEC,EAAsC,CAAC,OAAQ,OAAQ,UAAW,MAAM,E"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["DEFAULT_ROUTING_ROOT","ROUTING_ROOT_ALIAS","classifySegment","FRONTEND_GROUP","NATIVE_PLATFORM","require_layout","require_index","routedSegments","root","relativePath","isFrontendPath","segments","folder","segment","namesNative","isNativeFile","isBrowserFile"],"sources":["../../../src/services/browserFile/index.ts"],"sourcesContent":["import {\n BACKEND_GROUP,\n DEFAULT_ROUTING_ROOT,\n FRONTEND_GROUP,\n NATIVE_PLATFORM,\n ROUTING_ROOT_ALIAS,\n} from '../../constants/layout';\nimport { classifySegment } from '../segments';\n\n/** The segments below the routing root, or undefined when the path is not routed. */\nfunction routedSegments(relativePath: string): readonly string[] | undefined {\n for (const root of [DEFAULT_ROUTING_ROOT, ROUTING_ROOT_ALIAS]) {\n if (relativePath.startsWith(`${root}/`)) return relativePath.slice(root.length + 1).split('/');\n }\n return undefined;\n}\n\n/** Whether a routed path sits on the `(frontend)` side, the way the scan reads it. */\nfunction isFrontendPath(relativePath: string): boolean {\n const segments = routedSegments(relativePath);\n if (segments === undefined || segments.length < 2) return false;\n\n // The first side group decides the side, the way the scan reads it.\n for (const folder of segments.slice(0, -1)) {\n const segment = classifySegment(folder);\n if (segment.kind !== 'group') continue;\n if (segment.name === BACKEND_GROUP || segment.name === FRONTEND_GROUP) return segment.name === FRONTEND_GROUP;\n }\n return false;\n}\n\n/** Whether a filename names the native platform anywhere between its name and extension. */\nfunction namesNative(relativePath: string): boolean {\n const fileName = relativePath.slice(relativePath.lastIndexOf('/') + 1);\n // `.native.stories.tsx` and `.native.test.ts` are native code too, so this\n // reads every middle part rather than only the platform slot.\n return fileName.split('.').slice(1, -1).includes(NATIVE_PLATFORM);\n}\n\n/**\n * Whether a package-relative path holds code the native app bundles.\n *\n * A `(frontend)` file that names `.native`, including the private helpers and\n * stories colocated beside a surface. It imports React Native, never the DOM.\n *\n * Path in, answer out: nothing here reads the file or the filesystem.\n */\nexport function isNativeFile(relativePath: string): boolean {\n return isFrontendPath(relativePath) && namesNative(relativePath);\n}\n\n/**\n * Whether a package-relative path holds code the cockpit bundles.\n *\n * Po has no terminal host, so the `(frontend)` side is browser-bound,\n * including the private folders colocated beside a surface. The one\n * exception is a `.native` file, which only the native app reads.\n *\n * Path in, answer out: nothing here reads the file or the filesystem.\n */\nexport function isBrowserFile(relativePath: string): boolean {\n return isFrontendPath(relativePath) && !namesNative(relativePath);\n}\n"],"mappings":"iFAUA,SAASO,EAAe,EAAqD,CAC3E,IAAK,IAAMC,IAAQ,CAACR,EAAAA,qBAAsBC,EAAAA,kBAAkB,EAC1D,GAAIQ,EAAa,WAAW,GAAGD,EAAK,EAAE,EAAG,OAAOC,EAAa,MAAMD,EAAK,OAAS,CAAC,CAAC,CAAC,MAAM,GAAG,CAGjG,CAGA,SAASE,EAAe,EAA+B,CACrD,IAAMC,EAAWJ,EAAeE,CAAY,EAC5C,GAAIE,IAAa,IAAA,IAAaA,EAAS,OAAS,EAAG,MAAO,GAG1D,IAAK,IAAMC,KAAUD,EAAS,MAAM,EAAG,EAAE,EAAG,CAC1C,IAAME,EAAUX,EAAAA,gBAAgBU,CAAM,EACtC,GAAIC,EAAQ,OAAS,UACjBA,EAAQ,OAAA,WAA0BA,EAAQ,OAAA,YAAyB,OAAOA,EAAQ,OAASV,EAAAA,cACjG,CACA,MAAO,EACT,CAGA,SAASW,EAAY,EAA+B,CAIlD,OAHiBL,EAAa,MAAMA,EAAa,YAAY,GAAG,EAAI,CAGtD,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,MAAM,EAAG,EAAE,CAAC,CAAC,SAASL,EAAAA,eAAe,CAClE,CAUA,SAAgBW,EAAa,EAA+B,CAC1D,OAAOL,EAAeD,CAAY,GAAKK,EAAYL,CAAY,CACjE,CAWA,SAAgBO,EAAc,EAA+B,CAC3D,OAAON,EAAeD,CAAY,GAAK,CAACK,EAAYL,CAAY,CAClE"}
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["DEFAULT_ROUTING_ROOT","ROUTING_ROOT_ALIAS","classifySegment","FRONTEND_GROUP","NATIVE_PLATFORM","require_layout","require_index","routedSegments","root","relativePath","isFrontendPath","segments","folder","segment","namesNative","isNativeFile","isBrowserFile"],"sources":["../../../src/services/browserFile/index.ts"],"sourcesContent":["import {\n BACKEND_GROUP,\n DEFAULT_ROUTING_ROOT,\n FRONTEND_GROUP,\n NATIVE_PLATFORM,\n ROUTING_ROOT_ALIAS,\n} from '../../constants/layout';\nimport { classifySegment } from '../segments';\n\n/** The segments below the routing root, or undefined when the path is not routed. */\nfunction routedSegments(relativePath: string): readonly string[] | undefined {\n for (const root of [DEFAULT_ROUTING_ROOT, ROUTING_ROOT_ALIAS]) {\n if (relativePath.startsWith(`${root}/`)) return relativePath.slice(root.length + 1).split('/');\n }\n return undefined;\n}\n\n/** Whether a routed path sits on the `(frontend)` side, the way the scan reads it. */\nfunction isFrontendPath(relativePath: string): boolean {\n const segments = routedSegments(relativePath);\n if (segments === undefined || segments.length < 2) return false;\n\n // The first side group decides the side, the way the scan reads it.\n for (const folder of segments.slice(0, -1)) {\n const segment = classifySegment(folder);\n if (segment.kind !== 'group') continue;\n if (segment.name === BACKEND_GROUP || segment.name === FRONTEND_GROUP) return segment.name === FRONTEND_GROUP;\n }\n return false;\n}\n\n/** Whether a filename names the native platform anywhere between its name and extension. */\nfunction namesNative(relativePath: string): boolean {\n const fileName = relativePath.slice(relativePath.lastIndexOf('/') + 1);\n // `.native.stories.tsx` and `.native.test.ts` are native code too, so this\n // reads every middle part rather than only the platform slot.\n return fileName.split('.').slice(1, -1).includes(NATIVE_PLATFORM);\n}\n\n/**\n * Whether a package-relative path holds code the native app bundles.\n *\n * A `(frontend)` file that names `.native`, including the private helpers and\n * stories colocated beside a surface. It imports React Native, never the DOM.\n *\n * Path in, answer out: nothing here reads the file or the filesystem.\n */\nexport function isNativeFile(relativePath: string): boolean {\n return isFrontendPath(relativePath) && namesNative(relativePath);\n}\n\n/**\n * Whether a package-relative path holds code the cockpit bundles.\n *\n * Po has no terminal host, so the `(frontend)` side is browser-bound,\n * including the private folders colocated beside a surface. The one\n * exception is a `.native` file, which only the native app reads.\n *\n * Path in, answer out: nothing here reads the file or the filesystem.\n */\nexport function isBrowserFile(relativePath: string): boolean {\n return isFrontendPath(relativePath) && !namesNative(relativePath);\n}\n"],"mappings":"A,iFAUA,SAASO,EAAe,EAAqD,CAC3E,IAAK,IAAMC,IAAQ,CAACR,EAAAA,qBAAsBC,EAAAA,kBAAkB,EAC1D,GAAIQ,EAAa,WAAW,GAAGD,EAAK,EAAE,EAAG,OAAOC,EAAa,MAAMD,EAAK,OAAS,CAAC,CAAC,CAAC,MAAM,GAAG,CAGjG,CAGA,SAASE,EAAe,EAA+B,CACrD,IAAMC,EAAWJ,EAAeE,CAAY,EAC5C,GAAIE,IAAa,IAAA,IAAaA,EAAS,OAAS,EAAG,MAAO,GAG1D,IAAK,IAAMC,KAAUD,EAAS,MAAM,EAAG,EAAE,EAAG,CAC1C,IAAME,EAAUX,EAAAA,gBAAgBU,CAAM,EACtC,GAAIC,EAAQ,OAAS,UACjBA,EAAQ,OAAA,WAA0BA,EAAQ,OAAA,YAAyB,OAAOA,EAAQ,OAASV,EAAAA,cACjG,CACA,MAAO,EACT,CAGA,SAASW,EAAY,EAA+B,CAIlD,OAHiBL,EAAa,MAAMA,EAAa,YAAY,GAAG,EAAI,CAGtD,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,MAAM,EAAG,EAAE,CAAC,CAAC,SAASL,EAAAA,eAAe,CAClE,CAUA,SAAgBW,EAAa,EAA+B,CAC1D,OAAOL,EAAeD,CAAY,GAAKK,EAAYL,CAAY,CACjE,CAWA,SAAgBO,EAAc,EAA+B,CAC3D,OAAON,EAAeD,CAAY,GAAK,CAACK,EAAYL,CAAY,CAClE,C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":["routedSegments","root","DEFAULT_ROUTING_ROOT","ROUTING_ROOT_ALIAS","relativePath","isFrontendPath","segments","folder","segment","classifySegment","FRONTEND_GROUP","namesNative","NATIVE_PLATFORM","isNativeFile","isBrowserFile"],"sources":["../../../src/services/browserFile/index.ts"],"sourcesContent":["import {\n BACKEND_GROUP,\n DEFAULT_ROUTING_ROOT,\n FRONTEND_GROUP,\n NATIVE_PLATFORM,\n ROUTING_ROOT_ALIAS,\n} from '../../constants/layout';\nimport { classifySegment } from '../segments';\n\n/** The segments below the routing root, or undefined when the path is not routed. */\nfunction routedSegments(relativePath: string): readonly string[] | undefined {\n for (const root of [DEFAULT_ROUTING_ROOT, ROUTING_ROOT_ALIAS]) {\n if (relativePath.startsWith(`${root}/`)) return relativePath.slice(root.length + 1).split('/');\n }\n return undefined;\n}\n\n/** Whether a routed path sits on the `(frontend)` side, the way the scan reads it. */\nfunction isFrontendPath(relativePath: string): boolean {\n const segments = routedSegments(relativePath);\n if (segments === undefined || segments.length < 2) return false;\n\n // The first side group decides the side, the way the scan reads it.\n for (const folder of segments.slice(0, -1)) {\n const segment = classifySegment(folder);\n if (segment.kind !== 'group') continue;\n if (segment.name === BACKEND_GROUP || segment.name === FRONTEND_GROUP) return segment.name === FRONTEND_GROUP;\n }\n return false;\n}\n\n/** Whether a filename names the native platform anywhere between its name and extension. */\nfunction namesNative(relativePath: string): boolean {\n const fileName = relativePath.slice(relativePath.lastIndexOf('/') + 1);\n // `.native.stories.tsx` and `.native.test.ts` are native code too, so this\n // reads every middle part rather than only the platform slot.\n return fileName.split('.').slice(1, -1).includes(NATIVE_PLATFORM);\n}\n\n/**\n * Whether a package-relative path holds code the native app bundles.\n *\n * A `(frontend)` file that names `.native`, including the private helpers and\n * stories colocated beside a surface. It imports React Native, never the DOM.\n *\n * Path in, answer out: nothing here reads the file or the filesystem.\n */\nexport function isNativeFile(relativePath: string): boolean {\n return isFrontendPath(relativePath) && namesNative(relativePath);\n}\n\n/**\n * Whether a package-relative path holds code the cockpit bundles.\n *\n * Po has no terminal host, so the `(frontend)` side is browser-bound,\n * including the private folders colocated beside a surface. The one\n * exception is a `.native` file, which only the native app reads.\n *\n * Path in, answer out: nothing here reads the file or the filesystem.\n */\nexport function isBrowserFile(relativePath: string): boolean {\n return isFrontendPath(relativePath) && !namesNative(relativePath);\n}\n"],"mappings":"2LAUA,SAASA,EAAe,EAAqD,CAC3E,IAAK,IAAMC,IAAQ,CAACC,EAAsBC,CAAkB,EAC1D,GAAIC,EAAa,WAAW,GAAGH,EAAK,EAAE,EAAG,OAAOG,EAAa,MAAMH,EAAK,OAAS,CAAC,CAAC,CAAC,MAAM,GAAG,CAGjG,CAGA,SAASI,EAAe,EAA+B,CACrD,IAAMC,EAAWN,EAAeI,CAAY,EAC5C,GAAIE,IAAa,IAAA,IAAaA,EAAS,OAAS,EAAG,MAAO,GAG1D,IAAK,IAAMC,KAAUD,EAAS,MAAM,EAAG,EAAE,EAAG,CAC1C,IAAME,EAAUC,EAAgBF,CAAM,EACtC,GAAIC,EAAQ,OAAS,UACjBA,EAAQ,OAAA,WAA0BA,EAAQ,OAAA,YAAyB,OAAOA,EAAQ,OAASE,CACjG,CACA,MAAO,EACT,CAGA,SAASC,EAAY,EAA+B,CAIlD,OAHiBP,EAAa,MAAMA,EAAa,YAAY,GAAG,EAAI,CAGtD,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,MAAM,EAAG,EAAE,CAAC,CAAC,SAASQ,CAAe,CAClE,CAUA,SAAgBC,EAAa,EAA+B,CAC1D,OAAOR,EAAeD,CAAY,GAAKO,EAAYP,CAAY,CACjE,CAWA,SAAgBU,EAAc,EAA+B,CAC3D,OAAOT,EAAeD,CAAY,GAAK,CAACO,EAAYP,CAAY,CAClE"}
|
|
1
|
+
{"version":3,"file":"index.mjs","names":["routedSegments","root","DEFAULT_ROUTING_ROOT","ROUTING_ROOT_ALIAS","relativePath","isFrontendPath","segments","folder","segment","classifySegment","FRONTEND_GROUP","namesNative","NATIVE_PLATFORM","isNativeFile","isBrowserFile"],"sources":["../../../src/services/browserFile/index.ts"],"sourcesContent":["import {\n BACKEND_GROUP,\n DEFAULT_ROUTING_ROOT,\n FRONTEND_GROUP,\n NATIVE_PLATFORM,\n ROUTING_ROOT_ALIAS,\n} from '../../constants/layout';\nimport { classifySegment } from '../segments';\n\n/** The segments below the routing root, or undefined when the path is not routed. */\nfunction routedSegments(relativePath: string): readonly string[] | undefined {\n for (const root of [DEFAULT_ROUTING_ROOT, ROUTING_ROOT_ALIAS]) {\n if (relativePath.startsWith(`${root}/`)) return relativePath.slice(root.length + 1).split('/');\n }\n return undefined;\n}\n\n/** Whether a routed path sits on the `(frontend)` side, the way the scan reads it. */\nfunction isFrontendPath(relativePath: string): boolean {\n const segments = routedSegments(relativePath);\n if (segments === undefined || segments.length < 2) return false;\n\n // The first side group decides the side, the way the scan reads it.\n for (const folder of segments.slice(0, -1)) {\n const segment = classifySegment(folder);\n if (segment.kind !== 'group') continue;\n if (segment.name === BACKEND_GROUP || segment.name === FRONTEND_GROUP) return segment.name === FRONTEND_GROUP;\n }\n return false;\n}\n\n/** Whether a filename names the native platform anywhere between its name and extension. */\nfunction namesNative(relativePath: string): boolean {\n const fileName = relativePath.slice(relativePath.lastIndexOf('/') + 1);\n // `.native.stories.tsx` and `.native.test.ts` are native code too, so this\n // reads every middle part rather than only the platform slot.\n return fileName.split('.').slice(1, -1).includes(NATIVE_PLATFORM);\n}\n\n/**\n * Whether a package-relative path holds code the native app bundles.\n *\n * A `(frontend)` file that names `.native`, including the private helpers and\n * stories colocated beside a surface. It imports React Native, never the DOM.\n *\n * Path in, answer out: nothing here reads the file or the filesystem.\n */\nexport function isNativeFile(relativePath: string): boolean {\n return isFrontendPath(relativePath) && namesNative(relativePath);\n}\n\n/**\n * Whether a package-relative path holds code the cockpit bundles.\n *\n * Po has no terminal host, so the `(frontend)` side is browser-bound,\n * including the private folders colocated beside a surface. The one\n * exception is a `.native` file, which only the native app reads.\n *\n * Path in, answer out: nothing here reads the file or the filesystem.\n */\nexport function isBrowserFile(relativePath: string): boolean {\n return isFrontendPath(relativePath) && !namesNative(relativePath);\n}\n"],"mappings":"A,2LAUA,SAASA,EAAe,EAAqD,CAC3E,IAAK,IAAMC,IAAQ,CAACC,EAAsBC,CAAkB,EAC1D,GAAIC,EAAa,WAAW,GAAGH,EAAK,EAAE,EAAG,OAAOG,EAAa,MAAMH,EAAK,OAAS,CAAC,CAAC,CAAC,MAAM,GAAG,CAGjG,CAGA,SAASI,EAAe,EAA+B,CACrD,IAAMC,EAAWN,EAAeI,CAAY,EAC5C,GAAIE,IAAa,IAAA,IAAaA,EAAS,OAAS,EAAG,MAAO,GAG1D,IAAK,IAAMC,KAAUD,EAAS,MAAM,EAAG,EAAE,EAAG,CAC1C,IAAME,EAAUC,EAAgBF,CAAM,EACtC,GAAIC,EAAQ,OAAS,UACjBA,EAAQ,OAAA,WAA0BA,EAAQ,OAAA,YAAyB,OAAOA,EAAQ,OAASE,CACjG,CACA,MAAO,EACT,CAGA,SAASC,EAAY,EAA+B,CAIlD,OAHiBP,EAAa,MAAMA,EAAa,YAAY,GAAG,EAAI,CAGtD,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,MAAM,EAAG,EAAE,CAAC,CAAC,SAASQ,CAAe,CAClE,CAUA,SAAgBC,EAAa,EAA+B,CAC1D,OAAOR,EAAeD,CAAY,GAAKO,EAAYP,CAAY,CACjE,CAWA,SAAgBU,EAAc,EAA+B,CAC3D,OAAOT,EAAeD,CAAY,GAAK,CAACO,EAAYP,CAAY,CAClE,C"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
const e=require("../../_virtual/_rolldown/runtime.cjs");let t=require("node:fs");t=e.__toESM(t,1);let n=require("node:path");n=e.__toESM(n,1);let r=require("node:module"),i=require("node:crypto");const a=e=>/^@agimon-ai\/po-runner-(rmux|rtk)-(darwin|linux)-(arm64|x64)$/.test(e),o=`dist/po-runtime-identity.json`,s=[`.map`,`.d.ts`,`.d.mts`,`.d.cts`,`.tsbuildinfo`];function c(e,r){let i=/* @__PURE__ */ new Set,a=r=>{if(r===o||r.split(`/`).includes(`node_modules`))return;let c=n.default.join(e,r);if(t.default.existsSync(c)){if(t.default.statSync(c).isDirectory())for(let e of t.default.readdirSync(c))a(`${r}/${e}`);else s.some(e=>r.endsWith(e))||i.add(r)}};for(let e of r){let t=e.replaceAll(`\\`,`/`).replace(/^\.\//,``).replace(/\/$/,``);!t||t.startsWith(`/`)||/[*?!]/.test(t)||t.split(`/`).includes(`..`)||a(t)}return[...i].sort()}function l(e){let t={...e};delete t.devDependencies;for(let e of[`dependencies`,`optionalDependencies`,`peerDependencies`]){let n=t[e];n&&typeof n==`object`&&(t[e]=Object.fromEntries(Object.keys(n).sort().map(e=>[e,a(e)?n[e]:`<resolved>`])))}return JSON.stringify(Object.fromEntries(Object.entries(t).sort(([e],[t])=>e<t?-1:+(e>t))))}function u(e,r,a=!1){let o=(0,i.createHash)(`sha256`);for(let i of r){o.update(i).update(`\0`);let r=t.default.readFileSync(n.default.join(e,i));o.update(a&&i===`package.json`?l(JSON.parse(r.toString(`utf8`))):r).update(`\0`)}return o.digest(`hex`).slice(0,32)}function d(e){let i=n.default.resolve(e),s=JSON.parse(t.default.readFileSync(n.default.join(i,`package.json`),`utf8`)),l={},d=(0,r.createRequire)(n.default.join(i,`package.json`));for(let e of[`dependencies`,`optionalDependencies`,`peerDependencies`]){let r=s[e];if(r&&typeof r==`object`)for(let[e,s]of Object.entries(r)){if(!a(e)||typeof s!=`string`)continue;if(!s.startsWith(`workspace:`)){l[e]={published:s};continue}let r;for(let i of d.resolve.paths(e)??[]){let a=n.default.join(i,e,`package.json`);if(t.default.existsSync(a)){r=JSON.parse(t.default.readFileSync(a,`utf8`)).version;break}}if(!r){t.default.rmSync(n.default.join(i,o),{force:!0});return}let c=s.slice(10);l[e]={workspaceRange:c,published:c===`*`?r:c===`^`||c===`~`?`${c}${r}`:c}}}let f=Array.isArray(s.files)?s.files.filter(e=>typeof e==`string`):[],p=c(i,[`package.json`,`src`,`generated`,`templates`,`tsdown.config.ts`,`runtimeEntries.json`,...f.filter(e=>!e.replace(/^\.\//,``).startsWith(`dist`))]),m=c(i,[`dist`,...f]).filter(e=>e!==`package.json`);p.length!==0&&m.length!==0&&(t.default.mkdirSync(n.default.join(i,`dist`),{recursive:!0}),t.default.writeFileSync(n.default.join(i,o),JSON.stringify({version:1,platformRequirements:l,sourceFiles:p,sourceRevision:u(i,p,!0),manifestRevision:u(i,[`package.json`],!0),outputFiles:m,outputRevision:u(i,m)})+`
|
|
2
|
+
`))}exports.writeContentProvenance=d;
|
|
3
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["path","fs","createHash","require","createRequire","require_runtime","node_fs","node_path","node_module","node_crypto","isNativePlatformPackage","name","ARTIFACT","SKIPPED","inventory","files","visit","relative","absolute","root","suffix","target","targets","portableManifest","normalized","value","key","entries","a","b","digest","hash","file","bytes","source","writeContentProvenance","packageDir","packageDirectory","manifest","platformRequirements","require$1","requirement","version","directory","workspaceRange","shipped","sourceFiles","outputFiles"],"sources":["../../../src/services/contentProvenance/index.ts"],"sourcesContent":["// sync: Node-only build hook. Runtime verification lives in po-core and does not import build tooling.\nimport { createHash } from 'node:crypto';\nimport fs from 'node:fs';\nimport { createRequire } from 'node:module';\nimport path from 'node:path';\n\nconst isNativePlatformPackage = (name: string) =>\n /^@agimon-ai\\/po-runner-(rmux|rtk)-(darwin|linux)-(arm64|x64)$/.test(name);\n// The authored requirement is `workspace:<workspaceRange>` when present, else `published`. The prefix is never\n// written: shipped files must not contain a workspace protocol string.\ntype PlatformRequirements = Record<string, { workspaceRange?: string; published: string }>;\n\nconst ARTIFACT = 'dist/po-runtime-identity.json';\nconst SKIPPED = ['.map', '.d.ts', '.d.mts', '.d.cts', '.tsbuildinfo'];\n\nfunction inventory(root: string, targets: readonly string[]): string[] {\n const files = new Set<string>();\n const visit = (relative: string) => {\n if (relative === ARTIFACT || relative.split('/').includes('node_modules')) return;\n const absolute = path.join(root, relative);\n if (!fs.existsSync(absolute)) return;\n if (fs.statSync(absolute).isDirectory()) {\n for (const name of fs.readdirSync(absolute)) visit(`${relative}/${name}`);\n } else if (!SKIPPED.some((suffix) => relative.endsWith(suffix))) files.add(relative);\n };\n for (const target of targets) {\n const relative = target.replaceAll('\\\\', '/').replace(/^\\.\\//, '').replace(/\\/$/, '');\n if (!relative || relative.startsWith('/') || /[*?!]/.test(relative) || relative.split('/').includes('..')) continue;\n visit(relative);\n }\n return [...files].sort();\n}\n\nfunction portableManifest(value: Record<string, unknown>): string {\n const normalized = { ...value };\n delete normalized.devDependencies;\n for (const key of ['dependencies', 'optionalDependencies', 'peerDependencies']) {\n const entries = normalized[key];\n if (entries && typeof entries === 'object')\n normalized[key] = Object.fromEntries(\n Object.keys(entries)\n .sort()\n .map((name) => [\n name,\n isNativePlatformPackage(name) ? (entries as Record<string, unknown>)[name] : '<resolved>',\n ]),\n );\n }\n // Preserve nested condition-map order: exports/imports key order affects resolution.\n return JSON.stringify(\n Object.fromEntries(Object.entries(normalized).sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0))),\n );\n}\n\nfunction digest(root: string, files: readonly string[], source = false): string {\n const hash = createHash('sha256');\n for (const file of files) {\n hash.update(file).update('\\0');\n const bytes = fs.readFileSync(path.join(root, file));\n hash\n .update(source && file === 'package.json' ? portableManifest(JSON.parse(bytes.toString('utf8'))) : bytes)\n .update('\\0');\n }\n return hash.digest('hex').slice(0, 32);\n}\n\n/**\n * Additive, versioned provenance inside the already-packaged dist directory.\n * Source covers both platform variants. Output is bound to shipped bytes, excluding\n * this artifact, maps/types, and package.json (publish rewrites workspace ranges).\n * Runtime graph identity separately covers actual manifest name/version/dependencies.\n */\nexport function writeContentProvenance(packageDirectory: string): void {\n const packageDir = path.resolve(packageDirectory);\n const manifest = JSON.parse(fs.readFileSync(path.join(packageDir, 'package.json'), 'utf8')) as Record<\n string,\n unknown\n >;\n const platformRequirements: PlatformRequirements = {};\n const require = createRequire(path.join(packageDir, 'package.json'));\n for (const key of ['dependencies', 'optionalDependencies', 'peerDependencies']) {\n const entries = manifest[key];\n if (!entries || typeof entries !== 'object') continue;\n for (const [name, requirement] of Object.entries(entries)) {\n if (!isNativePlatformPackage(name) || typeof requirement !== 'string') continue;\n if (!requirement.startsWith('workspace:')) {\n platformRequirements[name] = { published: requirement };\n continue;\n }\n let version: string | undefined;\n for (const directory of require.resolve.paths(name) ?? []) {\n const file = path.join(directory, name, 'package.json');\n if (fs.existsSync(file)) {\n version = JSON.parse(fs.readFileSync(file, 'utf8')).version;\n break;\n }\n }\n if (!version) {\n // No reliable publication projection: leave identity explicitly unavailable.\n fs.rmSync(path.join(packageDir, ARTIFACT), { force: true });\n return;\n }\n const workspaceRange = requirement.slice('workspace:'.length);\n const published =\n workspaceRange === '*'\n ? version\n : workspaceRange === '^' || workspaceRange === '~'\n ? `${workspaceRange}${version}`\n : workspaceRange;\n platformRequirements[name] = { workspaceRange, published };\n }\n }\n const shipped = Array.isArray(manifest.files)\n ? manifest.files.filter((file): file is string => typeof file === 'string')\n : [];\n const sourceFiles = inventory(packageDir, [\n 'package.json',\n 'src',\n 'generated',\n 'templates',\n 'tsdown.config.ts',\n 'runtimeEntries.json',\n ...shipped.filter((file) => !file.replace(/^\\.\\//, '').startsWith('dist')),\n ]);\n const outputFiles = inventory(packageDir, ['dist', ...shipped]).filter((file) => file !== 'package.json');\n if (sourceFiles.length === 0 || outputFiles.length === 0) return;\n fs.mkdirSync(path.join(packageDir, 'dist'), { recursive: true });\n fs.writeFileSync(\n path.join(packageDir, ARTIFACT),\n JSON.stringify({\n version: 1,\n platformRequirements,\n sourceFiles,\n sourceRevision: digest(packageDir, sourceFiles, true),\n manifestRevision: digest(packageDir, ['package.json'], true),\n outputFiles,\n outputRevision: digest(packageDir, outputFiles),\n }) + '\\n',\n );\n}\n"],"mappings":"A,oMAMA,MAAMU,EAA2B,GAC/B,gEAAgE,KAAKC,CAAI,EAKrEC,EAAW,gCACXC,EAAU,CAAC,OAAQ,QAAS,SAAU,SAAU,cAAc,EAEpE,SAASC,EAAU,EAAc,EAAsC,CACrE,IAAMC,kBAAQ,IAAI,IACZC,EAAS,GAAqB,CAClC,GAAIC,IAAaL,GAAYK,EAAS,MAAM,GAAG,CAAC,CAAC,SAAS,cAAc,EAAG,OAC3E,IAAMC,EAAWlB,EAAAA,QAAK,KAAKmB,EAAMF,CAAQ,EACzC,GAAKhB,EAAAA,QAAG,WAAWiB,CAAQ,EAC3B,IAAIjB,EAAAA,QAAG,SAASiB,CAAQ,CAAC,CAAC,YAAY,EACpC,IAAK,IAAMP,KAAQV,EAAAA,QAAG,YAAYiB,CAAQ,EAAGF,EAAM,GAAGC,EAAS,GAAGN,GAAM,OAC9DE,EAAQ,KAAM,GAAWI,EAAS,SAASG,CAAM,CAAC,GAAGL,EAAM,IAAIE,CAAQ,CAAA,CACrF,EACA,IAAK,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,IACfF,EACAE,IAAmB,KAAOA,IAAmB,IAC3C,GAAGA,IAAiBF,IACpBE,CACiD,CAC3D,CACF,CACA,IAAMC,EAAU,MAAM,QAAQP,EAAS,KAAK,EACxCA,EAAS,MAAM,OAAQ,GAAyB,OAAON,GAAS,QAAQ,EACxE,CAAC,EACCc,EAAchC,EAAUsB,EAAY,CACxC,eACA,MACA,YACA,YACA,mBACA,sBACA,GAAGS,EAAQ,OAAQ,GAAS,CAACb,EAAK,QAAQ,QAAS,EAAE,CAAC,CAAC,WAAW,MAAM,CAAC,CAC3E,CAAC,EACKe,EAAcjC,EAAUsB,EAAY,CAAC,OAAQ,GAAGS,CAAO,CAAC,CAAC,CAAC,OAAQ,GAASb,IAAS,cAAc,EACpGc,EAAY,SAAW,GAAKC,EAAY,SAAW,IACvDzC,EAAA,QAAG,UAAUN,EAAAA,QAAK,KAAKoC,EAAY,MAAM,EAAG,CAAE,UAAW,EAAK,CAAC,EAC/D9B,EAAA,QAAG,cACDN,EAAAA,QAAK,KAAKoC,EAAYxB,CAAQ,EAC9B,KAAK,UAAU,CACb,QAAS,EACT,uBACA,cACA,eAAgBkB,EAAOM,EAAYU,EAAa,EAAI,EACpD,iBAAkBhB,EAAOM,EAAY,CAAC,cAAc,EAAG,EAAI,EAC3D,cACA,eAAgBN,EAAOM,EAAYW,CAAW,CAChD,CAAC,EAAI;CACP,EACF,C"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
//#region src/services/contentProvenance/index.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Additive, versioned provenance inside the already-packaged dist directory.
|
|
4
|
+
* Source covers both platform variants. Output is bound to shipped bytes, excluding
|
|
5
|
+
* this artifact, maps/types, and package.json (publish rewrites workspace ranges).
|
|
6
|
+
* Runtime graph identity separately covers actual manifest name/version/dependencies.
|
|
7
|
+
*/
|
|
8
|
+
export declare function writeContentProvenance(packageDirectory: string): void;
|
|
9
|
+
//#endregion
|
|
10
|
+
//# sourceMappingURL=index.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../../../src/services/contentProvenance/index.ts"],"mappings":";;;;;;;wBAwEgB,uBAAuB"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import{createRequire as e}from"node:module";import t from"node:fs";import n from"node:path";import{createHash as r}from"node:crypto";const i=e=>/^@agimon-ai\/po-runner-(rmux|rtk)-(darwin|linux)-(arm64|x64)$/.test(e),a=`dist/po-runtime-identity.json`,o=[`.map`,`.d.ts`,`.d.mts`,`.d.cts`,`.tsbuildinfo`];function s(e,r){let i=/* @__PURE__ */ new Set,s=r=>{if(r===a||r.split(`/`).includes(`node_modules`))return;let c=n.join(e,r);if(t.existsSync(c)){if(t.statSync(c).isDirectory())for(let e of t.readdirSync(c))s(`${r}/${e}`);else o.some(e=>r.endsWith(e))||i.add(r)}};for(let e of r){let t=e.replaceAll(`\\`,`/`).replace(/^\.\//,``).replace(/\/$/,``);!t||t.startsWith(`/`)||/[*?!]/.test(t)||t.split(`/`).includes(`..`)||s(t)}return[...i].sort()}function c(e){let t={...e};delete t.devDependencies;for(let e of[`dependencies`,`optionalDependencies`,`peerDependencies`]){let n=t[e];n&&typeof n==`object`&&(t[e]=Object.fromEntries(Object.keys(n).sort().map(e=>[e,i(e)?n[e]:`<resolved>`])))}return JSON.stringify(Object.fromEntries(Object.entries(t).sort(([e],[t])=>e<t?-1:+(e>t))))}function l(e,i,a=!1){let o=r(`sha256`);for(let r of i){o.update(r).update(`\0`);let i=t.readFileSync(n.join(e,r));o.update(a&&r===`package.json`?c(JSON.parse(i.toString(`utf8`))):i).update(`\0`)}return o.digest(`hex`).slice(0,32)}function u(r){let o=n.resolve(r),c=JSON.parse(t.readFileSync(n.join(o,`package.json`),`utf8`)),u={},d=e(n.join(o,`package.json`));for(let e of[`dependencies`,`optionalDependencies`,`peerDependencies`]){let r=c[e];if(r&&typeof r==`object`)for(let[e,s]of Object.entries(r)){if(!i(e)||typeof s!=`string`)continue;if(!s.startsWith(`workspace:`)){u[e]={published:s};continue}let r;for(let i of d.resolve.paths(e)??[]){let a=n.join(i,e,`package.json`);if(t.existsSync(a)){r=JSON.parse(t.readFileSync(a,`utf8`)).version;break}}if(!r){t.rmSync(n.join(o,a),{force:!0});return}let c=s.slice(10);u[e]={workspaceRange:c,published:c===`*`?r:c===`^`||c===`~`?`${c}${r}`:c}}}let f=Array.isArray(c.files)?c.files.filter(e=>typeof e==`string`):[],p=s(o,[`package.json`,`src`,`generated`,`templates`,`tsdown.config.ts`,`runtimeEntries.json`,...f.filter(e=>!e.replace(/^\.\//,``).startsWith(`dist`))]),m=s(o,[`dist`,...f]).filter(e=>e!==`package.json`);p.length!==0&&m.length!==0&&(t.mkdirSync(n.join(o,`dist`),{recursive:!0}),t.writeFileSync(n.join(o,a),JSON.stringify({version:1,platformRequirements:u,sourceFiles:p,sourceRevision:l(o,p,!0),manifestRevision:l(o,[`package.json`],!0),outputFiles:m,outputRevision:l(o,m)})+`
|
|
2
|
+
`))}export{u as writeContentProvenance};
|
|
3
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","names":["fs","path","isNativePlatformPackage","name","ARTIFACT","SKIPPED","inventory","files","visit","relative","absolute","root","suffix","target","targets","portableManifest","normalized","value","key","entries","a","b","digest","hash","createHash","file","bytes","source","writeContentProvenance","packageDir","packageDirectory","manifest","platformRequirements","require","createRequire","requirement","version","directory","workspaceRange","shipped","sourceFiles","outputFiles"],"sources":["../../../src/services/contentProvenance/index.ts"],"sourcesContent":["// sync: Node-only build hook. Runtime verification lives in po-core and does not import build tooling.\nimport { createHash } from 'node:crypto';\nimport fs from 'node:fs';\nimport { createRequire } from 'node:module';\nimport path from 'node:path';\n\nconst isNativePlatformPackage = (name: string) =>\n /^@agimon-ai\\/po-runner-(rmux|rtk)-(darwin|linux)-(arm64|x64)$/.test(name);\n// The authored requirement is `workspace:<workspaceRange>` when present, else `published`. The prefix is never\n// written: shipped files must not contain a workspace protocol string.\ntype PlatformRequirements = Record<string, { workspaceRange?: string; published: string }>;\n\nconst ARTIFACT = 'dist/po-runtime-identity.json';\nconst SKIPPED = ['.map', '.d.ts', '.d.mts', '.d.cts', '.tsbuildinfo'];\n\nfunction inventory(root: string, targets: readonly string[]): string[] {\n const files = new Set<string>();\n const visit = (relative: string) => {\n if (relative === ARTIFACT || relative.split('/').includes('node_modules')) return;\n const absolute = path.join(root, relative);\n if (!fs.existsSync(absolute)) return;\n if (fs.statSync(absolute).isDirectory()) {\n for (const name of fs.readdirSync(absolute)) visit(`${relative}/${name}`);\n } else if (!SKIPPED.some((suffix) => relative.endsWith(suffix))) files.add(relative);\n };\n for (const target of targets) {\n const relative = target.replaceAll('\\\\', '/').replace(/^\\.\\//, '').replace(/\\/$/, '');\n if (!relative || relative.startsWith('/') || /[*?!]/.test(relative) || relative.split('/').includes('..')) continue;\n visit(relative);\n }\n return [...files].sort();\n}\n\nfunction portableManifest(value: Record<string, unknown>): string {\n const normalized = { ...value };\n delete normalized.devDependencies;\n for (const key of ['dependencies', 'optionalDependencies', 'peerDependencies']) {\n const entries = normalized[key];\n if (entries && typeof entries === 'object')\n normalized[key] = Object.fromEntries(\n Object.keys(entries)\n .sort()\n .map((name) => [\n name,\n isNativePlatformPackage(name) ? (entries as Record<string, unknown>)[name] : '<resolved>',\n ]),\n );\n }\n // Preserve nested condition-map order: exports/imports key order affects resolution.\n return JSON.stringify(\n Object.fromEntries(Object.entries(normalized).sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0))),\n );\n}\n\nfunction digest(root: string, files: readonly string[], source = false): string {\n const hash = createHash('sha256');\n for (const file of files) {\n hash.update(file).update('\\0');\n const bytes = fs.readFileSync(path.join(root, file));\n hash\n .update(source && file === 'package.json' ? portableManifest(JSON.parse(bytes.toString('utf8'))) : bytes)\n .update('\\0');\n }\n return hash.digest('hex').slice(0, 32);\n}\n\n/**\n * Additive, versioned provenance inside the already-packaged dist directory.\n * Source covers both platform variants. Output is bound to shipped bytes, excluding\n * this artifact, maps/types, and package.json (publish rewrites workspace ranges).\n * Runtime graph identity separately covers actual manifest name/version/dependencies.\n */\nexport function writeContentProvenance(packageDirectory: string): void {\n const packageDir = path.resolve(packageDirectory);\n const manifest = JSON.parse(fs.readFileSync(path.join(packageDir, 'package.json'), 'utf8')) as Record<\n string,\n unknown\n >;\n const platformRequirements: PlatformRequirements = {};\n const require = createRequire(path.join(packageDir, 'package.json'));\n for (const key of ['dependencies', 'optionalDependencies', 'peerDependencies']) {\n const entries = manifest[key];\n if (!entries || typeof entries !== 'object') continue;\n for (const [name, requirement] of Object.entries(entries)) {\n if (!isNativePlatformPackage(name) || typeof requirement !== 'string') continue;\n if (!requirement.startsWith('workspace:')) {\n platformRequirements[name] = { published: requirement };\n continue;\n }\n let version: string | undefined;\n for (const directory of require.resolve.paths(name) ?? []) {\n const file = path.join(directory, name, 'package.json');\n if (fs.existsSync(file)) {\n version = JSON.parse(fs.readFileSync(file, 'utf8')).version;\n break;\n }\n }\n if (!version) {\n // No reliable publication projection: leave identity explicitly unavailable.\n fs.rmSync(path.join(packageDir, ARTIFACT), { force: true });\n return;\n }\n const workspaceRange = requirement.slice('workspace:'.length);\n const published =\n workspaceRange === '*'\n ? version\n : workspaceRange === '^' || workspaceRange === '~'\n ? `${workspaceRange}${version}`\n : workspaceRange;\n platformRequirements[name] = { workspaceRange, published };\n }\n }\n const shipped = Array.isArray(manifest.files)\n ? manifest.files.filter((file): file is string => typeof file === 'string')\n : [];\n const sourceFiles = inventory(packageDir, [\n 'package.json',\n 'src',\n 'generated',\n 'templates',\n 'tsdown.config.ts',\n 'runtimeEntries.json',\n ...shipped.filter((file) => !file.replace(/^\\.\\//, '').startsWith('dist')),\n ]);\n const outputFiles = inventory(packageDir, ['dist', ...shipped]).filter((file) => file !== 'package.json');\n if (sourceFiles.length === 0 || outputFiles.length === 0) return;\n fs.mkdirSync(path.join(packageDir, 'dist'), { recursive: true });\n fs.writeFileSync(\n path.join(packageDir, ARTIFACT),\n JSON.stringify({\n version: 1,\n platformRequirements,\n sourceFiles,\n sourceRevision: digest(packageDir, sourceFiles, true),\n manifestRevision: digest(packageDir, ['package.json'], true),\n outputFiles,\n outputRevision: digest(packageDir, outputFiles),\n }) + '\\n',\n );\n}\n"],"mappings":"A,qIAMA,MAAME,EAA2B,GAC/B,gEAAgE,KAAKC,CAAI,EAKrEC,EAAW,gCACXC,EAAU,CAAC,OAAQ,QAAS,SAAU,SAAU,cAAc,EAEpE,SAASC,EAAU,EAAc,EAAsC,CACrE,IAAMC,kBAAQ,IAAI,IACZC,EAAS,GAAqB,CAClC,GAAIC,IAAaL,GAAYK,EAAS,MAAM,GAAG,CAAC,CAAC,SAAS,cAAc,EAAG,OAC3E,IAAMC,EAAWT,EAAK,KAAKU,EAAMF,CAAQ,EACzC,GAAKT,EAAG,WAAWU,CAAQ,EAC3B,IAAIV,EAAG,SAASU,CAAQ,CAAC,CAAC,YAAY,EACpC,IAAK,IAAMP,KAAQH,EAAG,YAAYU,CAAQ,EAAGF,EAAM,GAAGC,EAAS,GAAGN,GAAM,OAC9DE,EAAQ,KAAM,GAAWI,EAAS,SAASG,CAAM,CAAC,GAAGL,EAAM,IAAIE,CAAQ,CAAA,CACrF,EACA,IAAK,IAAMI,KAAUC,EAAS,CAC5B,IAAML,EAAWI,EAAO,WAAW,KAAM,GAAG,CAAC,CAAC,QAAQ,QAAS,EAAE,CAAC,CAAC,QAAQ,MAAO,EAAE,EAChF,CAACJ,GAAYA,EAAS,WAAW,GAAG,GAAK,QAAQ,KAAKA,CAAQ,GAAKA,EAAS,MAAM,GAAG,CAAC,CAAC,SAAS,IAAI,GACxGD,EAAMC,CAAQ,CAChB,CACA,MAAO,CAAC,GAAGF,CAAK,CAAC,CAAC,KAAK,CACzB,CAEA,SAASQ,EAAiB,EAAwC,CAChE,IAAMC,EAAa,CAAE,GAAGC,CAAM,EAC9B,OAAOD,EAAW,gBAClB,I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AM,EAAG,CAAE,UAAW,EAAK,CAAC,EAC/D7B,EAAG,cACDC,EAAK,KAAK4B,EAAYzB,CAAQ,EAC9B,KAAK,UAAU,CACb,QAAS,EACT,uBACA,cACA,eAAgBkB,EAAOO,EAAYW,EAAa,EAAI,EACpD,iBAAkBlB,EAAOO,EAAY,CAAC,cAAc,EAAG,EAAI,EAC3D,cACA,eAAgBP,EAAOO,EAAYY,CAAW,CAChD,CAAC,EAAI;CACP,EACF,C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["SOURCE_EXTENSIONS","EXCLUDED_INFIXES","require_layout","parseFilename","lastDot","fileName","extension","parts","name","rest","part","last","platform","platforms"],"sources":["../../../src/services/filename/index.ts"],"sourcesContent":["import { EXCLUDED_INFIXES, SOURCE_EXTENSIONS } from '../../constants/layout';\n\n/** One filename split into the four things the grammar encodes. */\nexport interface ParsedFilename {\n /** The contribution's identity. */\n readonly name: string;\n /** The relationship target, such as the slot a fill names. */\n readonly target: string | undefined;\n /** The platform this file serves, or undefined when the filename names none. */\n readonly platform: string | undefined;\n readonly extension: string;\n}\n\n/**\n * Parses `{name}[.{target}][.{platform}].{ext}`.\n *\n * Right to left, because the platform set is closed and the target is not: a\n * dotted slot name such as `task.detail` would otherwise be ambiguous. A file\n * whose extension is not a source extension, or that carries an excluded\n * infix, returns undefined rather than an entry the caller has to filter.\n *\n * The one word a target may not be is a platform name for its own side, since\n * the last segment is read as a platform whenever it matches.\n *\n * A filename that names no platform still parses, with `platform: undefined`.\n * Requiring one is the scan's job, since only the scan knows whether the file\n * is public: a private `_lib` helper and an `api/` route sibling name none.\n */\nexport function parseFilename(fileName: string, platforms: readonly string[]): ParsedFilename | undefined {\n const lastDot = fileName.lastIndexOf('.');\n if (lastDot <= 0) return undefined;\n\n const extension = fileName.slice(lastDot + 1);\n if (!SOURCE_EXTENSIONS.includes(extension)) return undefined;\n\n const parts = fileName.slice(0, lastDot).split('.');\n const [name, ...rest] = parts;\n if (name === undefined || name === '') return undefined;\n if (parts.some((part) => EXCLUDED_INFIXES.includes(part))) return undefined;\n\n const last = rest[rest.length - 1];\n const platform = last !== undefined && platforms.includes(last) ? rest.pop() : undefined;\n\n return { name, target: rest.length > 0 ? rest.join('.') : undefined, platform, extension };\n}\n"],"mappings":"8CA4BA,SAAgBG,EAAc,EAAkB,EAA0D,CACxG,IAAMC,EAAUC,EAAS,YAAY,GAAG,EACxC,GAAID,GAAW,EAAG,OAElB,IAAME,EAAYD,EAAS,MAAMD,EAAU,CAAC,EAC5C,GAAI,CAACJ,EAAAA,kBAAkB,SAASM,CAAS,EAAG,OAE5C,IAAMC,EAAQF,EAAS,MAAM,EAAGD,CAAO,CAAC,CAAC,MAAM,GAAG,EAC5C,CAACI,EAAM,GAAGC,GAAQF,EAExB,GADIC,IAAS,IAAA,IAAaA,IAAS,IAC/BD,EAAM,KAAM,GAASN,EAAAA,iBAAiB,SAASS,CAAI,CAAC,EAAG,OAE3D,IAAMC,EAAOF,EAAKA,EAAK,OAAS,GAC1BG,EAAWD,IAAS,IAAA,IAAaE,EAAU,SAASF,CAAI,EAAIF,EAAK,IAAI,EAAI,IAAA,GAE/E,MAAO,CAAE,OAAM,OAAQA,EAAK,OAAS,EAAIA,EAAK,KAAK,GAAG,EAAI,IAAA,GAAW,WAAU,WAAU,CAC3F"}
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["SOURCE_EXTENSIONS","EXCLUDED_INFIXES","require_layout","parseFilename","lastDot","fileName","extension","parts","name","rest","part","last","platform","platforms"],"sources":["../../../src/services/filename/index.ts"],"sourcesContent":["import { EXCLUDED_INFIXES, SOURCE_EXTENSIONS } from '../../constants/layout';\n\n/** One filename split into the four things the grammar encodes. */\nexport interface ParsedFilename {\n /** The contribution's identity. */\n readonly name: string;\n /** The relationship target, such as the slot a fill names. */\n readonly target: string | undefined;\n /** The platform this file serves, or undefined when the filename names none. */\n readonly platform: string | undefined;\n readonly extension: string;\n}\n\n/**\n * Parses `{name}[.{target}][.{platform}].{ext}`.\n *\n * Right to left, because the platform set is closed and the target is not: a\n * dotted slot name such as `task.detail` would otherwise be ambiguous. A file\n * whose extension is not a source extension, or that carries an excluded\n * infix, returns undefined rather than an entry the caller has to filter.\n *\n * The one word a target may not be is a platform name for its own side, since\n * the last segment is read as a platform whenever it matches.\n *\n * A filename that names no platform still parses, with `platform: undefined`.\n * Requiring one is the scan's job, since only the scan knows whether the file\n * is public: a private `_lib` helper and an `api/` route sibling name none.\n */\nexport function parseFilename(fileName: string, platforms: readonly string[]): ParsedFilename | undefined {\n const lastDot = fileName.lastIndexOf('.');\n if (lastDot <= 0) return undefined;\n\n const extension = fileName.slice(lastDot + 1);\n if (!SOURCE_EXTENSIONS.includes(extension)) return undefined;\n\n const parts = fileName.slice(0, lastDot).split('.');\n const [name, ...rest] = parts;\n if (name === undefined || name === '') return undefined;\n if (parts.some((part) => EXCLUDED_INFIXES.includes(part))) return undefined;\n\n const last = rest[rest.length - 1];\n const platform = last !== undefined && platforms.includes(last) ? rest.pop() : undefined;\n\n return { name, target: rest.length > 0 ? rest.join('.') : undefined, platform, extension };\n}\n"],"mappings":"A,8CA4BA,SAAgBG,EAAc,EAAkB,EAA0D,CACxG,IAAMC,EAAUC,EAAS,YAAY,GAAG,EACxC,GAAID,GAAW,EAAG,OAElB,IAAME,EAAYD,EAAS,MAAMD,EAAU,CAAC,EAC5C,GAAI,CAACJ,EAAAA,kBAAkB,SAASM,CAAS,EAAG,OAE5C,IAAMC,EAAQF,EAAS,MAAM,EAAGD,CAAO,CAAC,CAAC,MAAM,GAAG,EAC5C,CAACI,EAAM,GAAGC,GAAQF,EAExB,GADIC,IAAS,IAAA,IAAaA,IAAS,IAC/BD,EAAM,KAAM,GAASN,EAAAA,iBAAiB,SAASS,CAAI,CAAC,EAAG,OAE3D,IAAMC,EAAOF,EAAKA,EAAK,OAAS,GAC1BG,EAAWD,IAAS,IAAA,IAAaE,EAAU,SAASF,CAAI,EAAIF,EAAK,IAAI,EAAI,IAAA,GAE/E,MAAO,CAAE,OAAM,OAAQA,EAAK,OAAS,EAAIA,EAAK,KAAK,GAAG,EAAI,IAAA,GAAW,WAAU,WAAU,CAC3F,C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":["parseFilename","lastDot","fileName","extension","SOURCE_EXTENSIONS","parts","name","rest","EXCLUDED_INFIXES","part","last","platform","platforms"],"sources":["../../../src/services/filename/index.ts"],"sourcesContent":["import { EXCLUDED_INFIXES, SOURCE_EXTENSIONS } from '../../constants/layout';\n\n/** One filename split into the four things the grammar encodes. */\nexport interface ParsedFilename {\n /** The contribution's identity. */\n readonly name: string;\n /** The relationship target, such as the slot a fill names. */\n readonly target: string | undefined;\n /** The platform this file serves, or undefined when the filename names none. */\n readonly platform: string | undefined;\n readonly extension: string;\n}\n\n/**\n * Parses `{name}[.{target}][.{platform}].{ext}`.\n *\n * Right to left, because the platform set is closed and the target is not: a\n * dotted slot name such as `task.detail` would otherwise be ambiguous. A file\n * whose extension is not a source extension, or that carries an excluded\n * infix, returns undefined rather than an entry the caller has to filter.\n *\n * The one word a target may not be is a platform name for its own side, since\n * the last segment is read as a platform whenever it matches.\n *\n * A filename that names no platform still parses, with `platform: undefined`.\n * Requiring one is the scan's job, since only the scan knows whether the file\n * is public: a private `_lib` helper and an `api/` route sibling name none.\n */\nexport function parseFilename(fileName: string, platforms: readonly string[]): ParsedFilename | undefined {\n const lastDot = fileName.lastIndexOf('.');\n if (lastDot <= 0) return undefined;\n\n const extension = fileName.slice(lastDot + 1);\n if (!SOURCE_EXTENSIONS.includes(extension)) return undefined;\n\n const parts = fileName.slice(0, lastDot).split('.');\n const [name, ...rest] = parts;\n if (name === undefined || name === '') return undefined;\n if (parts.some((part) => EXCLUDED_INFIXES.includes(part))) return undefined;\n\n const last = rest[rest.length - 1];\n const platform = last !== undefined && platforms.includes(last) ? rest.pop() : undefined;\n\n return { name, target: rest.length > 0 ? rest.join('.') : undefined, platform, extension };\n}\n"],"mappings":"qFA4BA,SAAgBA,EAAc,EAAkB,EAA0D,CACxG,IAAMC,EAAUC,EAAS,YAAY,GAAG,EACxC,GAAID,GAAW,EAAG,OAElB,IAAME,EAAYD,EAAS,MAAMD,EAAU,CAAC,EAC5C,GAAI,CAACG,EAAkB,SAASD,CAAS,EAAG,OAE5C,IAAME,EAAQH,EAAS,MAAM,EAAGD,CAAO,CAAC,CAAC,MAAM,GAAG,EAC5C,CAACK,EAAM,GAAGC,GAAQF,EAExB,GADIC,IAAS,IAAA,IAAaA,IAAS,IAC/BD,EAAM,KAAM,GAASG,EAAiB,SAASC,CAAI,CAAC,EAAG,OAE3D,IAAMC,EAAOH,EAAKA,EAAK,OAAS,GAC1BI,EAAWD,IAAS,IAAA,IAAaE,EAAU,SAASF,CAAI,EAAIH,EAAK,IAAI,EAAI,IAAA,GAE/E,MAAO,CAAE,OAAM,OAAQA,EAAK,OAAS,EAAIA,EAAK,KAAK,GAAG,EAAI,IAAA,GAAW,WAAU,WAAU,CAC3F"}
|
|
1
|
+
{"version":3,"file":"index.mjs","names":["parseFilename","lastDot","fileName","extension","SOURCE_EXTENSIONS","parts","name","rest","EXCLUDED_INFIXES","part","last","platform","platforms"],"sources":["../../../src/services/filename/index.ts"],"sourcesContent":["import { EXCLUDED_INFIXES, SOURCE_EXTENSIONS } from '../../constants/layout';\n\n/** One filename split into the four things the grammar encodes. */\nexport interface ParsedFilename {\n /** The contribution's identity. */\n readonly name: string;\n /** The relationship target, such as the slot a fill names. */\n readonly target: string | undefined;\n /** The platform this file serves, or undefined when the filename names none. */\n readonly platform: string | undefined;\n readonly extension: string;\n}\n\n/**\n * Parses `{name}[.{target}][.{platform}].{ext}`.\n *\n * Right to left, because the platform set is closed and the target is not: a\n * dotted slot name such as `task.detail` would otherwise be ambiguous. A file\n * whose extension is not a source extension, or that carries an excluded\n * infix, returns undefined rather than an entry the caller has to filter.\n *\n * The one word a target may not be is a platform name for its own side, since\n * the last segment is read as a platform whenever it matches.\n *\n * A filename that names no platform still parses, with `platform: undefined`.\n * Requiring one is the scan's job, since only the scan knows whether the file\n * is public: a private `_lib` helper and an `api/` route sibling name none.\n */\nexport function parseFilename(fileName: string, platforms: readonly string[]): ParsedFilename | undefined {\n const lastDot = fileName.lastIndexOf('.');\n if (lastDot <= 0) return undefined;\n\n const extension = fileName.slice(lastDot + 1);\n if (!SOURCE_EXTENSIONS.includes(extension)) return undefined;\n\n const parts = fileName.slice(0, lastDot).split('.');\n const [name, ...rest] = parts;\n if (name === undefined || name === '') return undefined;\n if (parts.some((part) => EXCLUDED_INFIXES.includes(part))) return undefined;\n\n const last = rest[rest.length - 1];\n const platform = last !== undefined && platforms.includes(last) ? rest.pop() : undefined;\n\n return { name, target: rest.length > 0 ? rest.join('.') : undefined, platform, extension };\n}\n"],"mappings":"A,qFA4BA,SAAgBA,EAAc,EAAkB,EAA0D,CACxG,IAAMC,EAAUC,EAAS,YAAY,GAAG,EACxC,GAAID,GAAW,EAAG,OAElB,IAAME,EAAYD,EAAS,MAAMD,EAAU,CAAC,EAC5C,GAAI,CAACG,EAAkB,SAASD,CAAS,EAAG,OAE5C,IAAME,EAAQH,EAAS,MAAM,EAAGD,CAAO,CAAC,CAAC,MAAM,GAAG,EAC5C,CAACK,EAAM,GAAGC,GAAQF,EAExB,GADIC,IAAS,IAAA,IAAaA,IAAS,IAC/BD,EAAM,KAAM,GAASG,EAAiB,SAASC,CAAI,CAAC,EAAG,OAE3D,IAAMC,EAAOH,EAAKA,EAAK,OAAS,GAC1BI,EAAWD,IAAS,IAAA,IAAaE,EAAU,SAASF,CAAI,EAAIH,EAAK,IAAI,EAAI,IAAA,GAE/E,MAAO,CAAE,OAAM,OAAQA,EAAK,OAAS,EAAIA,EAAK,KAAK,GAAG,EAAI,IAAA,GAAW,WAAU,WAAU,CAC3F,C"}
|
|
@@ -1,3 +1,4 @@
|
|
|
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
|
+
`)}`);if(e.strictLayout!==!1&&h.notices.length>0)throw Error(`${a}: misplaced routed files (set strictLayout: false to report them as notices)\n${h.notices.map(e=>` ${e.path}: ${e.message}`).join(`
|
|
2
3
|
`)}`);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
4
|
//# 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","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 poRoutedFilePosition 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,SAA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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
|
+
{"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":["// sync: Public generateExtension contract is synchronous, deferred with its cross-package callers to phase 2.\nimport 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. A misplaced routed file fails the\n * build unless `strictLayout: false`, which gathers scan notices instead.\n * Resolution notices are always gathered rather than thrown.\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 poRoutedFilePosition 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 if (options.strictLayout !== false && graph.notices.length > 0) {\n throw new Error(\n `${packageName}: misplaced routed files (set strictLayout: false to report them as notices)\\n${graph.notices\n .map((notice) => ` ${notice.path}: ${notice.message}`)\n .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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c,GAAGK,EAAAA,sBAAsB,KAAMyC,CAAM,EAI1F,IAAMC,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,C"}
|
|
@@ -6,9 +6,9 @@ export declare function defaultPluginId(packageName: string): string;
|
|
|
6
6
|
* Scans a package and renders every entry its tree calls for.
|
|
7
7
|
*
|
|
8
8
|
* A target with nothing in it produces no file, so a backend-only package
|
|
9
|
-
* never grows an empty cockpit entry.
|
|
10
|
-
*
|
|
11
|
-
*
|
|
9
|
+
* never grows an empty cockpit entry. A misplaced routed file fails the
|
|
10
|
+
* build unless `strictLayout: false`, which gathers scan notices instead.
|
|
11
|
+
* Resolution notices are always gathered rather than thrown.
|
|
12
12
|
*/
|
|
13
13
|
export declare function generateExtension(options: GenerateOptions): GenerateResult;
|
|
14
14
|
//#endregion
|
|
@@ -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":";;;wBAwBgB,gBAAgB;;;;;;;;;wBA2BhB,kBAAkB,SAAS,kBAAkB"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
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
|
+
`)}`);if(i.strictLayout!==!1&&m.notices.length>0)throw Error(`${f}: misplaced routed files (set strictLayout: false to report them as notices)\n${m.notices.map(e=>` ${e.path}: ${e.message}`).join(`
|
|
2
3
|
`)}`);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
4
|
//# sourceMappingURL=index.mjs.map
|