@hyperfrontend/features 0.1.0 → 0.2.0
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/CHANGELOG.md +17 -0
- package/_dependencies/@hyperfrontend/builder/bundle/dependencies/index.cjs.js +1 -0
- package/_dependencies/@hyperfrontend/builder/bundle/dependencies/index.esm.js +1 -0
- package/_dependencies/@hyperfrontend/builder/bundle/dependencies/worker/index.cjs.js +1 -0
- package/_dependencies/@hyperfrontend/builder/bundle/dependencies/worker/index.esm.js +1 -0
- package/_dependencies/@hyperfrontend/builder/bundle/index.cjs.js +12 -10
- package/_dependencies/@hyperfrontend/builder/bundle/index.esm.js +14 -12
- package/_dependencies/@hyperfrontend/builder/bundle/rollup/index.cjs.js +2 -0
- package/_dependencies/@hyperfrontend/builder/bundle/rollup/index.esm.js +2 -0
- package/_dependencies/@hyperfrontend/builder/bundle/rollup/worker/index.cjs.js +2 -0
- package/_dependencies/@hyperfrontend/builder/bundle/rollup/worker/index.esm.js +2 -0
- package/_dependencies/@hyperfrontend/builder/index.cjs.js +87 -53
- package/_dependencies/@hyperfrontend/builder/index.esm.js +89 -55
- package/_dependencies/@hyperfrontend/immutable-api-utils/built-in-copy/promise/index.cjs.js +4 -0
- package/_dependencies/@hyperfrontend/immutable-api-utils/built-in-copy/promise/index.esm.js +3 -1
- package/_dependencies/@hyperfrontend/immutable-api-utils/built-in-copy/reflect/index.cjs.js +10 -0
- package/_dependencies/@hyperfrontend/immutable-api-utils/built-in-copy/reflect/index.esm.js +6 -0
- package/_dependencies/@hyperfrontend/immutable-api-utils/built-in-copy/timers/index.cjs.js +5 -0
- package/_dependencies/@hyperfrontend/immutable-api-utils/built-in-copy/timers/index.esm.js +5 -1
- package/_dependencies/@hyperfrontend/immutable-api-utils/built-in-copy/typed-arrays/index.cjs.js +2 -2
- package/_dependencies/@hyperfrontend/immutable-api-utils/built-in-copy/typed-arrays/index.esm.js +2 -2
- package/_dependencies/@hyperfrontend/network-protocol/browser/channel/index.cjs.js +5 -19
- package/_dependencies/@hyperfrontend/network-protocol/browser/channel/index.esm.js +1 -15
- package/_dependencies/@hyperfrontend/network-protocol/browser/data/index.cjs.js +15 -23
- package/_dependencies/@hyperfrontend/network-protocol/browser/data/index.esm.js +7 -15
- package/_dependencies/@hyperfrontend/network-protocol/browser/packet/index.cjs.js +6 -14
- package/_dependencies/@hyperfrontend/network-protocol/browser/packet/index.esm.js +7 -15
- package/_dependencies/@hyperfrontend/network-protocol/browser/receiver/index.cjs.js +4 -18
- package/_dependencies/@hyperfrontend/network-protocol/browser/receiver/index.esm.js +1 -15
- package/_dependencies/@hyperfrontend/network-protocol/browser/sender/index.cjs.js +5 -19
- package/_dependencies/@hyperfrontend/network-protocol/browser/sender/index.esm.js +2 -16
- package/_dependencies/@hyperfrontend/network-protocol/browser/v1/index.cjs.js +16 -24
- package/_dependencies/@hyperfrontend/network-protocol/browser/v1/index.esm.js +7 -15
- package/_dependencies/@hyperfrontend/network-protocol/browser/v2/index.cjs.js +16 -24
- package/_dependencies/@hyperfrontend/network-protocol/browser/v2/index.esm.js +7 -15
- package/_dependencies/@hyperfrontend/network-protocol/node/channel/index.cjs.js +3 -17
- package/_dependencies/@hyperfrontend/network-protocol/node/channel/index.esm.js +1 -15
- package/_dependencies/@hyperfrontend/network-protocol/node/data/index.cjs.js +6 -14
- package/_dependencies/@hyperfrontend/network-protocol/node/data/index.esm.js +7 -15
- package/_dependencies/@hyperfrontend/network-protocol/node/packet/index.cjs.js +6 -14
- package/_dependencies/@hyperfrontend/network-protocol/node/packet/index.esm.js +7 -15
- package/_dependencies/@hyperfrontend/network-protocol/node/receiver/index.cjs.js +3 -17
- package/_dependencies/@hyperfrontend/network-protocol/node/receiver/index.esm.js +1 -15
- package/_dependencies/@hyperfrontend/network-protocol/node/sender/index.cjs.js +2 -16
- package/_dependencies/@hyperfrontend/network-protocol/node/sender/index.esm.js +2 -16
- package/_dependencies/@hyperfrontend/network-protocol/node/v1/index.cjs.js +6 -14
- package/_dependencies/@hyperfrontend/network-protocol/node/v1/index.esm.js +7 -15
- package/_dependencies/@hyperfrontend/network-protocol/node/v2/index.cjs.js +6 -14
- package/_dependencies/@hyperfrontend/network-protocol/node/v2/index.esm.js +7 -15
- package/_dependencies/@hyperfrontend/nexus/index.cjs.js +49 -19
- package/_dependencies/@hyperfrontend/nexus/index.esm.js +49 -19
- package/_dependencies/@hyperfrontend/project-scope/core/fs/index.cjs.js +62 -0
- package/_dependencies/@hyperfrontend/project-scope/core/fs/index.esm.js +60 -2
- package/_shared/generators/feature/generate-feature-module/index.esm.js +11 -6
- package/_shared/generators/metadata/generate-metadata/index.esm.js +1 -0
- package/_shared/shared/control/index.cjs.js +12 -2
- package/_shared/shared/control/index.esm.js +12 -2
- package/_shared/shared/request/index.cjs.js +91 -0
- package/_shared/shared/request/index.esm.js +88 -0
- package/_shared/shared/shutdown/index.esm.js +12 -0
- package/bin/hf.js +643 -70
- package/bundle/host/index.iife.js +290 -4041
- package/bundle/host/index.iife.min.js +1 -1
- package/bundle/host/index.umd.js +290 -4041
- package/bundle/host/index.umd.min.js +1 -1
- package/bundle/hostee/index.iife.js +215 -2893
- package/bundle/hostee/index.iife.min.js +1 -1
- package/bundle/hostee/index.umd.js +215 -2893
- package/bundle/hostee/index.umd.min.js +1 -1
- package/cli/args.d.ts +2 -0
- package/cli/args.d.ts.map +1 -1
- package/cli/commands/build.d.ts +8 -5
- package/cli/commands/build.d.ts.map +1 -1
- package/cli/commands/dev.d.ts +7 -2
- package/cli/commands/dev.d.ts.map +1 -1
- package/cli/config/resolve.d.ts +3 -1
- package/cli/config/resolve.d.ts.map +1 -1
- package/cli/index.cjs.js +643 -70
- package/cli/index.d.ts +21 -10
- package/cli/index.esm.js +591 -60
- package/cli/usage.d.ts +1 -1
- package/cli/usage.d.ts.map +1 -1
- package/generators/feature/generate-feature-module.d.ts.map +1 -1
- package/generators/index.cjs.js +435 -42
- package/generators/index.d.ts +9 -8
- package/generators/index.esm.js +404 -30
- package/generators/metadata/generate-metadata.d.ts +4 -4
- package/generators/metadata/generate-metadata.d.ts.map +1 -1
- package/generators/shell/connector-types.d.ts +19 -0
- package/generators/shell/connector-types.d.ts.map +1 -0
- package/generators/shell/generate-shell.d.ts +5 -4
- package/generators/shell/generate-shell.d.ts.map +1 -1
- package/generators/shell/schema-type.d.ts +20 -0
- package/generators/shell/schema-type.d.ts.map +1 -0
- package/generators/shell/source-literal.d.ts +28 -0
- package/generators/shell/source-literal.d.ts.map +1 -1
- package/host/create-shell.d.ts +4 -1
- package/host/create-shell.d.ts.map +1 -1
- package/host/display-modes/dialog.d.ts +1 -1
- package/host/display-modes/dialog.d.ts.map +1 -1
- package/host/display-modes/embedded.d.ts +1 -1
- package/host/display-modes/embedded.d.ts.map +1 -1
- package/host/index.cjs.js +150 -30
- package/host/index.d.ts +53 -38
- package/host/index.d.ts.map +1 -1
- package/host/index.esm.js +129 -9
- package/host/lifecycle.d.ts.map +1 -1
- package/host/plugins.d.ts +1 -34
- package/host/plugins.d.ts.map +1 -1
- package/host/types.d.ts +49 -0
- package/host/types.d.ts.map +1 -1
- package/hostee/index.cjs.js +54 -9
- package/hostee/index.d.ts +41 -1
- package/hostee/index.d.ts.map +1 -1
- package/hostee/index.esm.js +51 -6
- package/hostee/lifecycle.d.ts.map +1 -1
- package/hostee/types.d.ts +40 -0
- package/hostee/types.d.ts.map +1 -1
- package/index.cjs.js +32 -1
- package/index.d.ts +89 -3
- package/index.d.ts.map +1 -1
- package/index.esm.js +32 -1
- package/nx/executors/build/index.cjs.js +14975 -137
- package/nx/executors/build/index.esm.js +14935 -115
- package/nx/executors/serve/executor.d.ts.map +1 -1
- package/nx/executors/serve/index.cjs.js +6594 -80
- package/nx/executors/serve/index.esm.js +6529 -44
- package/nx/generators/feature/index.cjs.js +8751 -108
- package/nx/generators/feature/index.esm.js +8711 -81
- package/package.json +15 -5
- package/server/debug-ui/index.d.ts +2 -0
- package/server/debug-ui/index.d.ts.map +1 -0
- package/server/debug-ui/index.html +15 -0
- package/server/debug-ui/index.iife.js +427 -0
- package/server/debug-ui/index.iife.min.js +1 -0
- package/server/dev-server.d.ts.map +1 -1
- package/server/index.cjs.js +78 -10
- package/server/index.esm.js +78 -11
- package/server/module-dir.d.ts +17 -0
- package/server/module-dir.d.ts.map +1 -0
- package/server/module-dir.stub.d.ts +15 -0
- package/server/module-dir.stub.d.ts.map +1 -0
- package/shared/contract.d.ts +1 -1
- package/shared/contract.d.ts.map +1 -1
- package/shared/control.d.ts +4 -0
- package/shared/control.d.ts.map +1 -1
- package/shared/invert-contract.d.ts +20 -0
- package/shared/invert-contract.d.ts.map +1 -0
- package/shared/request.d.ts +68 -0
- package/shared/request.d.ts.map +1 -0
- package/{nx/shared → shared}/shutdown.d.ts +3 -2
- package/shared/shutdown.d.ts.map +1 -0
- package/shared/types.d.ts +72 -1
- package/shared/types.d.ts.map +1 -1
- package/_shared/nx/shared/context/index.cjs.js +0 -18
- package/_shared/nx/shared/context/index.esm.js +0 -16
- package/nx/shared/shutdown.d.ts.map +0 -1
- package/server/debug-ui/bootstrap.d.ts +0 -2
- package/server/debug-ui/bootstrap.d.ts.map +0 -1
package/generators/index.d.ts
CHANGED
|
@@ -41,16 +41,16 @@ declare function generateFeatureModule(config: ResolvedFeatureConfig, contract:
|
|
|
41
41
|
* Stages the connector's `metadata.json` describing the feature and its contract.
|
|
42
42
|
*
|
|
43
43
|
* Stamps a canonical version string via `@hyperfrontend/versioning` and embeds
|
|
44
|
-
* the contract so humans and the registry can
|
|
45
|
-
* unpacking the bundle.
|
|
44
|
+
* the contract and the baked security protocol so humans and the registry can
|
|
45
|
+
* inspect the feature without unpacking the bundle.
|
|
46
46
|
*
|
|
47
|
-
* @param config - The resolved feature config supplying name, version, and
|
|
47
|
+
* @param config - The resolved feature config supplying name, version, URL, and protocol.
|
|
48
48
|
* @param contract - The validated contract embedded for inspection.
|
|
49
49
|
* @param tree - The VFS tree the metadata file is staged into.
|
|
50
50
|
*
|
|
51
51
|
* @example Staging metadata for the clock feature
|
|
52
52
|
* ```typescript
|
|
53
|
-
* generateMetadata({ name: 'clock', version: '1.0.0', contract: './clock.contract.json', url: '/clock' }, contract, tree)
|
|
53
|
+
* generateMetadata({ name: 'clock', version: '1.0.0', contract: './clock.contract.json', url: '/clock', protocol: 'v2' }, contract, tree)
|
|
54
54
|
* ```
|
|
55
55
|
*/
|
|
56
56
|
declare function generateMetadata(config: ResolvedFeatureConfig, contract: FeatureContract, tree: Tree): void;
|
|
@@ -58,9 +58,10 @@ declare function generateMetadata(config: ResolvedFeatureConfig, contract: Featu
|
|
|
58
58
|
/**
|
|
59
59
|
* Stages the complete host connector package into the supplied VFS tree.
|
|
60
60
|
*
|
|
61
|
-
* Emits the entry source, source-level
|
|
62
|
-
*
|
|
63
|
-
* CLI owns temp-dir
|
|
61
|
+
* Emits the entry source (with contract-projected types), source-level
|
|
62
|
+
* `package.json`, `README.md`, and (via {@link generateMetadata})
|
|
63
|
+
* `metadata.json`. Pure: stages only into `tree` — the CLI owns temp-dir
|
|
64
|
+
* creation, bundling, and commit.
|
|
64
65
|
*
|
|
65
66
|
* @param config - The resolved feature config.
|
|
66
67
|
* @param contract - The validated feature contract, inlined into the connector.
|
|
@@ -68,7 +69,7 @@ declare function generateMetadata(config: ResolvedFeatureConfig, contract: Featu
|
|
|
68
69
|
*
|
|
69
70
|
* @example Staging a connector for the clock feature
|
|
70
71
|
* ```typescript
|
|
71
|
-
* generateShell({ name: 'clock', version: '1.0.0', contract: './clock.contract.json', url: '/clock' }, contract, tree)
|
|
72
|
+
* generateShell({ name: 'clock', version: '1.0.0', contract: './clock.contract.json', url: '/clock', protocol: 'v2' }, contract, tree)
|
|
72
73
|
* ```
|
|
73
74
|
*/
|
|
74
75
|
declare function generateShell(config: ResolvedFeatureConfig, contract: FeatureContract, tree: Tree): void;
|
package/generators/index.esm.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { isArray } from '../_dependencies/@hyperfrontend/immutable-api-utils/built-in-copy/array/index.esm.js';
|
|
2
2
|
import { stringify } from '../_dependencies/@hyperfrontend/immutable-api-utils/built-in-copy/json/index.esm.js';
|
|
3
3
|
import { entries } from '../_dependencies/@hyperfrontend/immutable-api-utils/built-in-copy/object/index.esm.js';
|
|
4
|
+
import { isAbsolute, join, relative, dirname } from 'node:path';
|
|
4
5
|
import { Mode } from '../_dependencies/@hyperfrontend/project-scope/vfs/index.esm.js';
|
|
5
6
|
import { format } from '../_dependencies/@hyperfrontend/versioning/semver/format/index.esm.js';
|
|
6
7
|
import { parseVersionStrict } from '../_dependencies/@hyperfrontend/versioning/semver/parse/index.esm.js';
|
|
7
8
|
import { generateMetadata } from '../_shared/generators/metadata/generate-metadata/index.esm.js';
|
|
8
|
-
import { toSourceLiteral } from '../_shared/generators/shell/source-literal/index.esm.js';
|
|
9
|
+
import { quoteString, formatKey, toSourceLiteral } from '../_shared/generators/shell/source-literal/index.esm.js';
|
|
9
10
|
import { generateFeatureModule } from '../_shared/generators/feature/generate-feature-module/index.esm.js';
|
|
10
11
|
|
|
11
12
|
/**
|
|
@@ -81,43 +82,357 @@ export default contract
|
|
|
81
82
|
tree.write(toDeclarationPath(config.contract), declaration);
|
|
82
83
|
}
|
|
83
84
|
|
|
85
|
+
// note: JSON-schema scalar types mapped straight to their TypeScript equivalents; `integer` narrows to `number`.
|
|
86
|
+
const PRIMITIVES = {
|
|
87
|
+
string: 'string',
|
|
88
|
+
number: 'number',
|
|
89
|
+
integer: 'number',
|
|
90
|
+
boolean: 'boolean',
|
|
91
|
+
null: 'null',
|
|
92
|
+
};
|
|
93
|
+
/**
|
|
94
|
+
* Narrows an unknown value to a plain record.
|
|
95
|
+
*
|
|
96
|
+
* @param value - The value to test.
|
|
97
|
+
* @returns `true` when the value is a non-null, non-array object.
|
|
98
|
+
*/
|
|
99
|
+
function isRecord(value) {
|
|
100
|
+
return typeof value === 'object' && value !== null && !isArray(value);
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Renders a JSON scalar as a TypeScript literal type.
|
|
104
|
+
*
|
|
105
|
+
* @param value - The candidate literal.
|
|
106
|
+
* @returns The literal type source, or `null` for a non-scalar value.
|
|
107
|
+
*/
|
|
108
|
+
function literalType(value) {
|
|
109
|
+
if (value === null) {
|
|
110
|
+
return 'null';
|
|
111
|
+
}
|
|
112
|
+
if (typeof value === 'string') {
|
|
113
|
+
return quoteString(value);
|
|
114
|
+
}
|
|
115
|
+
if (typeof value === 'number' || typeof value === 'boolean') {
|
|
116
|
+
return stringify(value);
|
|
117
|
+
}
|
|
118
|
+
return null;
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Renders an `enum` member list as a union of literal types.
|
|
122
|
+
*
|
|
123
|
+
* @param members - The allowed values listed by the schema.
|
|
124
|
+
* @returns The union source, or `unknown` when any member is not a scalar.
|
|
125
|
+
*/
|
|
126
|
+
function enumType(members) {
|
|
127
|
+
const literals = members.map(literalType);
|
|
128
|
+
// why: One non-scalar member would poison the union with `unknown`, which silently absorbs the useful literals — better to fall back for the whole enum.
|
|
129
|
+
return literals.every((literal) => literal !== null) ? literals.join(' | ') : 'unknown';
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Renders an `object` schema as an inline type literal.
|
|
133
|
+
*
|
|
134
|
+
* @param schema - The schema record with optional `properties` and `required`.
|
|
135
|
+
* @param indent - The current indentation prefix.
|
|
136
|
+
* @returns The object type source; `Record<string, unknown>` without properties.
|
|
137
|
+
*/
|
|
138
|
+
function objectType(schema, indent) {
|
|
139
|
+
const properties = isRecord(schema['properties']) ? entries(schema['properties']) : [];
|
|
140
|
+
if (properties.length === 0) {
|
|
141
|
+
return 'Record<string, unknown>';
|
|
142
|
+
}
|
|
143
|
+
const required = isArray(schema['required']) ? schema['required'] : [];
|
|
144
|
+
const inner = `${indent} `;
|
|
145
|
+
const members = properties.map(([key, member]) => `${inner}${formatKey(key)}${required.includes(key) ? '' : '?'}: ${schemaToType(member, inner)}`);
|
|
146
|
+
return `{\n${members.join('\n')}\n${indent}}`;
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Renders an `array` schema as an element-type array.
|
|
150
|
+
*
|
|
151
|
+
* @param schema - The schema record with an optional single `items` schema.
|
|
152
|
+
* @param indent - The current indentation prefix.
|
|
153
|
+
* @returns The array type source; `unknown[]` without a single `items` schema.
|
|
154
|
+
*/
|
|
155
|
+
function arrayType(schema, indent) {
|
|
156
|
+
const items = schema['items'];
|
|
157
|
+
if (!isRecord(items)) {
|
|
158
|
+
return 'unknown[]';
|
|
159
|
+
}
|
|
160
|
+
const element = schemaToType(items, indent);
|
|
161
|
+
return element.includes('|') ? `(${element})[]` : `${element}[]`;
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Projects a JSON-schema-like payload description into TypeScript type source.
|
|
165
|
+
*
|
|
166
|
+
* Bounded mapping: scalar `type`s, `object` with `properties`/`required`,
|
|
167
|
+
* `array` with a single `items` schema, `enum`, and `const` are projected;
|
|
168
|
+
* anything else (including a missing schema) falls back to `unknown`, so a
|
|
169
|
+
* generated type is never wrong — at worst it is loose.
|
|
170
|
+
*
|
|
171
|
+
* @param schema - The schema value to project.
|
|
172
|
+
* @param indent - Indentation prefix applied to nested object members.
|
|
173
|
+
* @returns The TypeScript type as source text.
|
|
174
|
+
*
|
|
175
|
+
* @example Projecting an action payload schema
|
|
176
|
+
* ```typescript
|
|
177
|
+
* schemaToType({ type: 'object', properties: { tz: { type: 'string' } }, required: ['tz'] })
|
|
178
|
+
* // => '{\n tz: string\n}'
|
|
179
|
+
* ```
|
|
180
|
+
*/
|
|
181
|
+
function schemaToType(schema, indent = '') {
|
|
182
|
+
if (!isRecord(schema)) {
|
|
183
|
+
return 'unknown';
|
|
184
|
+
}
|
|
185
|
+
const enumMembers = schema['enum'];
|
|
186
|
+
if (isArray(enumMembers) && enumMembers.length > 0) {
|
|
187
|
+
return enumType(enumMembers);
|
|
188
|
+
}
|
|
189
|
+
if ('const' in schema) {
|
|
190
|
+
return literalType(schema['const']) ?? 'unknown';
|
|
191
|
+
}
|
|
192
|
+
const type = schema['type'];
|
|
193
|
+
if (typeof type !== 'string') {
|
|
194
|
+
return 'unknown';
|
|
195
|
+
}
|
|
196
|
+
const primitive = PRIMITIVES[type];
|
|
197
|
+
if (primitive !== undefined) {
|
|
198
|
+
return primitive;
|
|
199
|
+
}
|
|
200
|
+
if (type === 'object') {
|
|
201
|
+
return objectType(schema, indent);
|
|
202
|
+
}
|
|
203
|
+
if (type === 'array') {
|
|
204
|
+
return arrayType(schema, indent);
|
|
205
|
+
}
|
|
206
|
+
return 'unknown';
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
// note: The generated declarations are structural (no type imports from the SDK), so the connector's d.ts stays fully usable for consumers who install nothing but the packed tarball.
|
|
210
|
+
const STATIC_TYPES = `/** How the feature is surfaced by the host. */
|
|
211
|
+
export type FeatureDisplayMode = 'embedded' | 'dialog' | 'popup' | 'standalone'
|
|
212
|
+
|
|
213
|
+
/** Security envelope selector negotiated between host and feature. */
|
|
214
|
+
export type FeatureSecurityProtocol = 'none' | 'v1' | 'v2'
|
|
215
|
+
|
|
216
|
+
/** Context handed to an experience plugin around the feature's mount lifecycle. */
|
|
217
|
+
export interface FeaturePluginContext {
|
|
218
|
+
/** In-document root the display mode mounted, or \`null\` for windowed modes. */
|
|
219
|
+
element: HTMLElement | null
|
|
220
|
+
/** The display mode the feature was surfaced in. */
|
|
221
|
+
displayMode: FeatureDisplayMode
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
/** Opt-in extension that decorates the feature's mount lifecycle (e.g. transitions). */
|
|
225
|
+
export interface FeatureExperiencePlugin {
|
|
226
|
+
/** Unique plugin name, surfaced in debug logs. */
|
|
227
|
+
name: string
|
|
228
|
+
/**
|
|
229
|
+
* Runs after the feature mounts; may animate it in and return a teardown.
|
|
230
|
+
*
|
|
231
|
+
* @param context - The mounted element and its display mode.
|
|
232
|
+
* @returns An optional teardown invoked on unmount.
|
|
233
|
+
*/
|
|
234
|
+
onMount?(context: FeaturePluginContext): void | (() => void)
|
|
235
|
+
/**
|
|
236
|
+
* Runs before the feature unmounts; may defer teardown until an exit animation finishes.
|
|
237
|
+
*
|
|
238
|
+
* @param context - The mounted element and its display mode.
|
|
239
|
+
* @returns Optionally a promise the shell awaits before tearing down.
|
|
240
|
+
*/
|
|
241
|
+
onUnmount?(context: FeaturePluginContext): void | Promise<void>
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
/** Details handed to an unresponsive-feature callback when the feature stops responding. */
|
|
245
|
+
export interface FeatureUnresponsiveInfo {
|
|
246
|
+
/** Consecutive missed heartbeats that tripped the watchdog. */
|
|
247
|
+
missedBeats: number
|
|
248
|
+
/** Timestamp (ms) of the last heartbeat received, or \`null\` if none ever arrived. */
|
|
249
|
+
lastBeatAt: number | null
|
|
250
|
+
/** The display mode the unresponsive feature was using. */
|
|
251
|
+
displayMode: FeatureDisplayMode
|
|
252
|
+
/** Closes the feature gracefully. */
|
|
253
|
+
close(): void
|
|
254
|
+
/** Closes the feature and releases all resources. */
|
|
255
|
+
destroy(): void
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
/**
|
|
259
|
+
* Options accepted by \`createFeatureShell\`; anything omitted falls back to the
|
|
260
|
+
* defaults baked in from the feature's build.
|
|
261
|
+
*/
|
|
262
|
+
export interface FeatureShellOptions {
|
|
263
|
+
/** Target element (or CSS selector) the embedded feature mounts into. */
|
|
264
|
+
container: string | HTMLElement
|
|
265
|
+
/** Stable identifier for the feature; seeds the broker name surfaced in debug logs. */
|
|
266
|
+
name?: string
|
|
267
|
+
/** How the feature should be surfaced; defaults to \`embedded\`. */
|
|
268
|
+
displayMode?: FeatureDisplayMode
|
|
269
|
+
/** URL of the feature app to load; defaults to the URL baked in from the feature config. */
|
|
270
|
+
url?: string
|
|
271
|
+
/** How an embedded feature is sized; defaults to \`fill\` (the iframe fills its container). */
|
|
272
|
+
embedSizing?: 'fill' | 'content'
|
|
273
|
+
/** How the host reacts when the feature stops responding; defaults to \`emit\`. */
|
|
274
|
+
onUnresponsive?: 'emit' | 'unmount' | ((info: FeatureUnresponsiveInfo) => void)
|
|
275
|
+
/** Whether pressing Escape closes the shell; defaults to \`true\`. */
|
|
276
|
+
closeOnEscape?: boolean
|
|
277
|
+
/** Dialog width in pixels (dialog mode only). */
|
|
278
|
+
dialogWidth?: number
|
|
279
|
+
/** Dialog height in pixels (dialog mode only). */
|
|
280
|
+
dialogHeight?: number
|
|
281
|
+
/** Whether the dialog renders a dimmed backdrop; defaults to \`true\`. */
|
|
282
|
+
dialogOverlay?: boolean
|
|
283
|
+
/** Security envelope to negotiate; defaults to the protocol baked in from the feature's build. */
|
|
284
|
+
protocol?: FeatureSecurityProtocol
|
|
285
|
+
/** Pre-shared key used by the \`v2\` protocol; always supplied by the host, never baked into the connector. */
|
|
286
|
+
sharedKey?: string
|
|
287
|
+
/** Experience plugins wrapped around each mount/unmount. */
|
|
288
|
+
plugins?: readonly FeatureExperiencePlugin[]
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
/** Handle returned by \`createFeatureShell\`, narrowed to the feature's contract. */
|
|
292
|
+
export interface FeatureShellHandle {
|
|
293
|
+
/**
|
|
294
|
+
* Mounts the feature using the merged baked defaults and call-time options.
|
|
295
|
+
*
|
|
296
|
+
* @param options - Per-open overrides layered over the baked and create-time options.
|
|
297
|
+
*/
|
|
298
|
+
open(options?: Partial<FeatureShellOptions>): void
|
|
299
|
+
/** Closes the feature gracefully, disconnecting the messaging channel. */
|
|
300
|
+
close(): void
|
|
301
|
+
/** Closes the feature and releases all resources (channel and DOM). */
|
|
302
|
+
destroy(): void
|
|
303
|
+
/**
|
|
304
|
+
* Sends a contract action to the feature.
|
|
305
|
+
*
|
|
306
|
+
* @param type - Action type from the feature contract's accepted list.
|
|
307
|
+
* @param data - Payload matching the action's schema.
|
|
308
|
+
*/
|
|
309
|
+
send<T extends HostSendType>(type: T, data?: HostSendPayloads[T]): void
|
|
310
|
+
/**
|
|
311
|
+
* Subscribes to a feature event with its contract-typed payload.
|
|
312
|
+
*
|
|
313
|
+
* @param event - Event type from the feature contract's emitted list.
|
|
314
|
+
* @param handler - Callback invoked with the typed event payload.
|
|
315
|
+
* @returns A function that removes this subscription.
|
|
316
|
+
*/
|
|
317
|
+
on<T extends HostEventType>(event: T, handler: (data: HostEventPayloads[T]) => void): () => void
|
|
318
|
+
/**
|
|
319
|
+
* Subscribes to a shell lifecycle event.
|
|
320
|
+
*
|
|
321
|
+
* @param event - Lifecycle event name.
|
|
322
|
+
* @param handler - Callback invoked when the event fires.
|
|
323
|
+
* @returns A function that removes this subscription.
|
|
324
|
+
*/
|
|
325
|
+
on(event: 'open' | 'close' | 'error', handler: (data?: unknown) => void): () => void
|
|
326
|
+
/** Whether the feature channel is currently open (\`true\` while connected). */
|
|
327
|
+
readonly isOpen: boolean
|
|
328
|
+
}
|
|
329
|
+
`;
|
|
330
|
+
/**
|
|
331
|
+
* Escapes a contract description for safe embedding inside a JSDoc comment.
|
|
332
|
+
*
|
|
333
|
+
* @param description - The raw description text.
|
|
334
|
+
* @returns The text with any comment terminator defused.
|
|
335
|
+
*/
|
|
336
|
+
function escapeDoc(description) {
|
|
337
|
+
return description.split('*/').join('*\\/');
|
|
338
|
+
}
|
|
339
|
+
/**
|
|
340
|
+
* Renders one payload-map member for an action, with its description as JSDoc.
|
|
341
|
+
*
|
|
342
|
+
* @param action - The contract action to render.
|
|
343
|
+
* @returns The interface member source.
|
|
344
|
+
*/
|
|
345
|
+
function buildMember(action) {
|
|
346
|
+
const doc = action.description === undefined ? '' : ` /** ${escapeDoc(action.description)} */\n`;
|
|
347
|
+
return `${doc} ${formatKey(action.type)}: ${schemaToType(action.schema, ' ')}`;
|
|
348
|
+
}
|
|
349
|
+
/**
|
|
350
|
+
* Renders a payload-map interface keyed by action type.
|
|
351
|
+
*
|
|
352
|
+
* @param name - The interface identifier.
|
|
353
|
+
* @param doc - The single-line JSDoc summary.
|
|
354
|
+
* @param actions - The contract actions projected into members.
|
|
355
|
+
* @returns The interface declaration source.
|
|
356
|
+
*/
|
|
357
|
+
function buildPayloadInterface(name, doc, actions) {
|
|
358
|
+
const body = actions.length === 0 ? '' : `\n${actions.map(buildMember).join('\n')}\n`;
|
|
359
|
+
return `/** ${doc} */\nexport interface ${name} {${body}}`;
|
|
360
|
+
}
|
|
361
|
+
/**
|
|
362
|
+
* Builds the connector's full generated type surface for a feature contract.
|
|
363
|
+
*
|
|
364
|
+
* Emits payload maps and literal action-name unions projected from the
|
|
365
|
+
* contract, plus structural shell option and handle types, so the connector's
|
|
366
|
+
* declarations resolve with no dependencies beyond the DOM lib.
|
|
367
|
+
*
|
|
368
|
+
* @param contract - The feature contract driving the projected types.
|
|
369
|
+
* @returns The type declaration block for the connector entry.
|
|
370
|
+
*
|
|
371
|
+
* @example Projecting the clock contract
|
|
372
|
+
* ```typescript
|
|
373
|
+
* buildConnectorTypes({ emitted: [{ type: 'timeUpdated' }], accepted: [{ type: 'setTimezone' }] })
|
|
374
|
+
* // => source containing "export interface HostSendPayloads { setTimezone: unknown }"
|
|
375
|
+
* ```
|
|
376
|
+
*/
|
|
377
|
+
function buildConnectorTypes(contract) {
|
|
378
|
+
return `${buildPayloadInterface('HostSendPayloads', 'Payloads for actions the host can send, keyed by action type from the feature contract.', contract.accepted)}
|
|
379
|
+
|
|
380
|
+
${buildPayloadInterface('HostEventPayloads', 'Payloads for events the feature emits to the host, keyed by event type from the feature contract.', contract.emitted)}
|
|
381
|
+
|
|
382
|
+
/** Action types the host can send to the feature. */
|
|
383
|
+
export type HostSendType = keyof HostSendPayloads
|
|
384
|
+
|
|
385
|
+
/** Event types the feature emits to the host. */
|
|
386
|
+
export type HostEventType = keyof HostEventPayloads
|
|
387
|
+
|
|
388
|
+
${STATIC_TYPES}`;
|
|
389
|
+
}
|
|
390
|
+
|
|
84
391
|
const ENTRY_PATH = 'src/index.ts';
|
|
85
392
|
const PACKAGE_PATH = 'package.json';
|
|
86
393
|
const README_PATH = 'README.md';
|
|
87
394
|
/**
|
|
88
395
|
* Builds the baked-in default shell options from the resolved config.
|
|
89
396
|
*
|
|
90
|
-
* @param config - The resolved feature config supplying the URL and display defaults.
|
|
397
|
+
* @param config - The resolved feature config supplying the URL, protocol, and display defaults.
|
|
91
398
|
* @returns A record of options the connector merges under host-supplied overrides.
|
|
92
399
|
*/
|
|
93
400
|
function buildDefaults(config) {
|
|
94
|
-
return {
|
|
401
|
+
return {
|
|
402
|
+
url: config.url,
|
|
403
|
+
...(config.protocol !== undefined && { protocol: config.protocol }),
|
|
404
|
+
...(config.display ?? {}),
|
|
405
|
+
};
|
|
95
406
|
}
|
|
96
407
|
/**
|
|
97
|
-
* Builds the connector's TypeScript entry source with the contract inlined
|
|
408
|
+
* Builds the connector's TypeScript entry source with the contract inlined and
|
|
409
|
+
* the contract-projected types exported.
|
|
98
410
|
*
|
|
99
411
|
* @param config - The resolved feature config naming the feature and its URL.
|
|
100
412
|
* @param contract - The validated contract inlined into the connector.
|
|
101
413
|
* @returns The entry module source as a string.
|
|
102
414
|
*/
|
|
103
415
|
function buildConnectorEntry(config, contract) {
|
|
104
|
-
return `import
|
|
105
|
-
import { createShell } from '@hyperfrontend/features/host'
|
|
416
|
+
return `import { createShell } from '@hyperfrontend/features/host'
|
|
106
417
|
|
|
107
|
-
|
|
418
|
+
${buildConnectorTypes(contract)}
|
|
419
|
+
/** Inlined contract describing the ${config.name} feature's actions, exactly as the feature authored it. */
|
|
108
420
|
const contract = ${toSourceLiteral(contract)}
|
|
109
421
|
|
|
110
|
-
/** Default shell options baked in from the feature
|
|
111
|
-
const defaults =
|
|
422
|
+
/** Default shell options baked in from the feature's build. */
|
|
423
|
+
const defaults = <const>${toSourceLiteral(buildDefaults(config))}
|
|
112
424
|
|
|
113
425
|
/**
|
|
114
426
|
* Creates a host-side shell for the ${config.name} feature.
|
|
115
427
|
*
|
|
428
|
+
* The feature's contract and build-time defaults are baked in, and \`send\`/\`on\`
|
|
429
|
+
* are typed from the contract's actions.
|
|
430
|
+
*
|
|
116
431
|
* @param options - Host-supplied options (at minimum a \`container\`); these override the baked defaults.
|
|
117
|
-
* @returns A shell handle exposing \`open\`, \`close\`, \`destroy\`, \`send\`, \`on\`, and \`isOpen\`.
|
|
432
|
+
* @returns A typed shell handle exposing \`open\`, \`close\`, \`destroy\`, \`send\`, \`on\`, and \`isOpen\`.
|
|
118
433
|
*/
|
|
119
|
-
export function createFeatureShell(options:
|
|
120
|
-
return createShell({ ...defaults, ...options, contract })
|
|
434
|
+
export function createFeatureShell(options: FeatureShellOptions): FeatureShellHandle {
|
|
435
|
+
return <FeatureShellHandle>createShell({ ...defaults, ...options, contract })
|
|
121
436
|
}
|
|
122
437
|
`;
|
|
123
438
|
}
|
|
@@ -140,49 +455,108 @@ function buildConnectorPackageJson(config) {
|
|
|
140
455
|
};
|
|
141
456
|
return `${stringify(manifest, null, 2)}\n`;
|
|
142
457
|
}
|
|
458
|
+
/**
|
|
459
|
+
* Builds the open-connector warning block for a protocol-`none` build.
|
|
460
|
+
*
|
|
461
|
+
* @param config - The resolved feature config carrying the baked protocol.
|
|
462
|
+
* @returns The warning block, or an empty string for secured builds.
|
|
463
|
+
*/
|
|
464
|
+
function buildReadmeWarning(config) {
|
|
465
|
+
if (config.protocol !== 'none') {
|
|
466
|
+
return '';
|
|
467
|
+
}
|
|
468
|
+
return `> **Warning: open connector.** This build uses protocol \`none\`: messages between host and feature travel with no security envelope, so any page that can reach the feature URL can embed and drive it. For production, rebuild the feature with \`--protocol v1\` or \`--protocol v2\`.
|
|
469
|
+
|
|
470
|
+
`;
|
|
471
|
+
}
|
|
472
|
+
/**
|
|
473
|
+
* Builds the security paragraph matching the baked protocol.
|
|
474
|
+
*
|
|
475
|
+
* @param config - The resolved feature config carrying the baked protocol.
|
|
476
|
+
* @returns The security guidance paragraph.
|
|
477
|
+
*/
|
|
478
|
+
function buildReadmeSecurity(config) {
|
|
479
|
+
if (config.protocol === 'v2') {
|
|
480
|
+
return "The `v2` security envelope is baked in from the feature's build — do not pass `protocol` yourself. Supply your own pre-shared key via `sharedKey`; a key is never baked into the artifact.";
|
|
481
|
+
}
|
|
482
|
+
if (config.protocol === 'v1') {
|
|
483
|
+
return "The `v1` security envelope is baked in from the feature's build — do not pass `protocol` yourself.";
|
|
484
|
+
}
|
|
485
|
+
if (config.protocol === 'none') {
|
|
486
|
+
return 'This connector was deliberately built open (see the warning above); harden it by rebuilding the feature with a security protocol.';
|
|
487
|
+
}
|
|
488
|
+
return "No security envelope is baked into this connector; pass `protocol: 'v1'` or `protocol: 'v2'` (with your own `sharedKey` for `v2`) when creating the shell.";
|
|
489
|
+
}
|
|
490
|
+
/**
|
|
491
|
+
* Builds the option lines shown inside the quick-start `createFeatureShell` call.
|
|
492
|
+
*
|
|
493
|
+
* @param config - The resolved feature config carrying the baked protocol.
|
|
494
|
+
* @returns Extra option lines, each newline-prefixed, or an empty string.
|
|
495
|
+
*/
|
|
496
|
+
function buildReadmeOptions(config) {
|
|
497
|
+
if (config.protocol === 'v2') {
|
|
498
|
+
return "\n sharedKey: 'your-pre-shared-key',";
|
|
499
|
+
}
|
|
500
|
+
if (config.protocol === undefined) {
|
|
501
|
+
return "\n protocol: 'v2',\n sharedKey: 'your-pre-shared-key',";
|
|
502
|
+
}
|
|
503
|
+
return '';
|
|
504
|
+
}
|
|
505
|
+
/**
|
|
506
|
+
* Builds the typed messaging example lines from the contract's first actions.
|
|
507
|
+
*
|
|
508
|
+
* @param contract - The validated feature contract.
|
|
509
|
+
* @returns Messaging example lines ending in a newline, or an empty string.
|
|
510
|
+
*/
|
|
511
|
+
function buildReadmeMessaging(contract) {
|
|
512
|
+
const sent = contract.accepted[0];
|
|
513
|
+
const received = contract.emitted[0];
|
|
514
|
+
const sendLine = sent === undefined ? '' : `shell.send('${sent.type}', data) // typed: the payload shape comes from the feature contract\n`;
|
|
515
|
+
const onLine = received === undefined ? '' : `shell.on('${received.type}', (data) => console.log(data)) // typed: data follows the contract\n`;
|
|
516
|
+
return `${sendLine}${onLine}`;
|
|
517
|
+
}
|
|
143
518
|
/**
|
|
144
519
|
* Builds the connector's `README.md` documenting the generated install + usage.
|
|
145
520
|
*
|
|
146
521
|
* @param config - The resolved feature config naming the feature.
|
|
522
|
+
* @param contract - The validated feature contract driving the typed examples.
|
|
147
523
|
* @returns The README contents as a string.
|
|
148
524
|
*/
|
|
149
|
-
function buildConnectorReadme(config) {
|
|
525
|
+
function buildConnectorReadme(config, contract) {
|
|
150
526
|
return `# ${config.name}-shell
|
|
151
527
|
|
|
152
|
-
Generated host connector for the **${config.name}** feature. Self-contained — install it and embed the feature with one call.
|
|
528
|
+
Generated host connector for the **${config.name}** feature. Self-contained — install it and embed the feature with one call. \`send\` and \`on\` are typed from the feature's contract.
|
|
153
529
|
|
|
154
|
-
\`\`\`typescript
|
|
530
|
+
${buildReadmeWarning(config)}\`\`\`typescript
|
|
155
531
|
import { createFeatureShell } from '${config.name}-shell'
|
|
156
532
|
|
|
157
533
|
const shell = createFeatureShell({
|
|
158
|
-
container: '#${config.name}'
|
|
159
|
-
// Security envelope: 'none' (default) | 'v1' | 'v2'.
|
|
160
|
-
// 'v2' authenticates the channel with a pre-shared key.
|
|
161
|
-
protocol: 'v2',
|
|
162
|
-
sharedKey: 'your-pre-shared-key',
|
|
534
|
+
container: '#${config.name}',${buildReadmeOptions(config)}
|
|
163
535
|
})
|
|
164
536
|
|
|
165
537
|
// Lifecycle events ('open', 'close', 'error'); on() returns an unsubscribe fn.
|
|
166
538
|
const unsubscribe = shell.on('open', () => console.log('connected'))
|
|
167
539
|
|
|
168
|
-
shell.open()
|
|
169
|
-
shell.
|
|
170
|
-
console.log(shell.isOpen) // current connection state
|
|
540
|
+
shell.open() // mount the feature in its display mode
|
|
541
|
+
${buildReadmeMessaging(contract)}console.log(shell.isOpen) // current connection state
|
|
171
542
|
|
|
172
543
|
unsubscribe()
|
|
173
|
-
shell.close()
|
|
174
|
-
shell.destroy()
|
|
544
|
+
shell.close() // disconnect gracefully
|
|
545
|
+
shell.destroy() // disconnect and release all resources
|
|
175
546
|
\`\`\`
|
|
176
547
|
|
|
548
|
+
${buildReadmeSecurity(config)}
|
|
549
|
+
|
|
177
550
|
> Regenerated from scratch on every build; do not edit by hand.
|
|
178
551
|
`;
|
|
179
552
|
}
|
|
180
553
|
/**
|
|
181
554
|
* Stages the complete host connector package into the supplied VFS tree.
|
|
182
555
|
*
|
|
183
|
-
* Emits the entry source, source-level
|
|
184
|
-
*
|
|
185
|
-
* CLI owns temp-dir
|
|
556
|
+
* Emits the entry source (with contract-projected types), source-level
|
|
557
|
+
* `package.json`, `README.md`, and (via {@link generateMetadata})
|
|
558
|
+
* `metadata.json`. Pure: stages only into `tree` — the CLI owns temp-dir
|
|
559
|
+
* creation, bundling, and commit.
|
|
186
560
|
*
|
|
187
561
|
* @param config - The resolved feature config.
|
|
188
562
|
* @param contract - The validated feature contract, inlined into the connector.
|
|
@@ -190,13 +564,13 @@ shell.destroy() // disconnect and release all resource
|
|
|
190
564
|
*
|
|
191
565
|
* @example Staging a connector for the clock feature
|
|
192
566
|
* ```typescript
|
|
193
|
-
* generateShell({ name: 'clock', version: '1.0.0', contract: './clock.contract.json', url: '/clock' }, contract, tree)
|
|
567
|
+
* generateShell({ name: 'clock', version: '1.0.0', contract: './clock.contract.json', url: '/clock', protocol: 'v2' }, contract, tree)
|
|
194
568
|
* ```
|
|
195
569
|
*/
|
|
196
570
|
function generateShell(config, contract, tree) {
|
|
197
571
|
tree.write(ENTRY_PATH, buildConnectorEntry(config, contract));
|
|
198
572
|
tree.write(PACKAGE_PATH, buildConnectorPackageJson(config));
|
|
199
|
-
tree.write(README_PATH, buildConnectorReadme(config));
|
|
573
|
+
tree.write(README_PATH, buildConnectorReadme(config, contract));
|
|
200
574
|
generateMetadata(config, contract, tree);
|
|
201
575
|
}
|
|
202
576
|
|
|
@@ -4,16 +4,16 @@ import type { FeatureContract, ResolvedFeatureConfig } from '../../shared/types'
|
|
|
4
4
|
* Stages the connector's `metadata.json` describing the feature and its contract.
|
|
5
5
|
*
|
|
6
6
|
* Stamps a canonical version string via `@hyperfrontend/versioning` and embeds
|
|
7
|
-
* the contract so humans and the registry can
|
|
8
|
-
* unpacking the bundle.
|
|
7
|
+
* the contract and the baked security protocol so humans and the registry can
|
|
8
|
+
* inspect the feature without unpacking the bundle.
|
|
9
9
|
*
|
|
10
|
-
* @param config - The resolved feature config supplying name, version, and
|
|
10
|
+
* @param config - The resolved feature config supplying name, version, URL, and protocol.
|
|
11
11
|
* @param contract - The validated contract embedded for inspection.
|
|
12
12
|
* @param tree - The VFS tree the metadata file is staged into.
|
|
13
13
|
*
|
|
14
14
|
* @example Staging metadata for the clock feature
|
|
15
15
|
* ```typescript
|
|
16
|
-
* generateMetadata({ name: 'clock', version: '1.0.0', contract: './clock.contract.json', url: '/clock' }, contract, tree)
|
|
16
|
+
* generateMetadata({ name: 'clock', version: '1.0.0', contract: './clock.contract.json', url: '/clock', protocol: 'v2' }, contract, tree)
|
|
17
17
|
* ```
|
|
18
18
|
*/
|
|
19
19
|
export declare function generateMetadata(config: ResolvedFeatureConfig, contract: FeatureContract, tree: Tree): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate-metadata.d.ts","sourceRoot":"","sources":["../../../../../../../../libs/features/src/generators/metadata/generate-metadata.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,kCAAkC,CAAA;AAC5D,OAAO,KAAK,EAAE,eAAe,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAA;AAQhF;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,qBAAqB,EAAE,QAAQ,EAAE,eAAe,EAAE,IAAI,EAAE,IAAI,GAAG,IAAI,
|
|
1
|
+
{"version":3,"file":"generate-metadata.d.ts","sourceRoot":"","sources":["../../../../../../../../libs/features/src/generators/metadata/generate-metadata.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,kCAAkC,CAAA;AAC5D,OAAO,KAAK,EAAE,eAAe,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAA;AAQhF;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,qBAAqB,EAAE,QAAQ,EAAE,eAAe,EAAE,IAAI,EAAE,IAAI,GAAG,IAAI,CAU3G"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { FeatureContract } from '../../shared/types';
|
|
2
|
+
/**
|
|
3
|
+
* Builds the connector's full generated type surface for a feature contract.
|
|
4
|
+
*
|
|
5
|
+
* Emits payload maps and literal action-name unions projected from the
|
|
6
|
+
* contract, plus structural shell option and handle types, so the connector's
|
|
7
|
+
* declarations resolve with no dependencies beyond the DOM lib.
|
|
8
|
+
*
|
|
9
|
+
* @param contract - The feature contract driving the projected types.
|
|
10
|
+
* @returns The type declaration block for the connector entry.
|
|
11
|
+
*
|
|
12
|
+
* @example Projecting the clock contract
|
|
13
|
+
* ```typescript
|
|
14
|
+
* buildConnectorTypes({ emitted: [{ type: 'timeUpdated' }], accepted: [{ type: 'setTimezone' }] })
|
|
15
|
+
* // => source containing "export interface HostSendPayloads { setTimezone: unknown }"
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
export declare function buildConnectorTypes(contract: FeatureContract): string;
|
|
19
|
+
//# sourceMappingURL=connector-types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"connector-types.d.ts","sourceRoot":"","sources":["../../../../../../../../libs/features/src/generators/shell/connector-types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAqB,eAAe,EAAE,MAAM,oBAAoB,CAAA;AAgK5E;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,eAAe,GAAG,MAAM,CAYrE"}
|
|
@@ -3,9 +3,10 @@ import type { FeatureContract, ResolvedFeatureConfig } from '../../shared/types'
|
|
|
3
3
|
/**
|
|
4
4
|
* Stages the complete host connector package into the supplied VFS tree.
|
|
5
5
|
*
|
|
6
|
-
* Emits the entry source, source-level
|
|
7
|
-
*
|
|
8
|
-
* CLI owns temp-dir
|
|
6
|
+
* Emits the entry source (with contract-projected types), source-level
|
|
7
|
+
* `package.json`, `README.md`, and (via {@link generateMetadata})
|
|
8
|
+
* `metadata.json`. Pure: stages only into `tree` — the CLI owns temp-dir
|
|
9
|
+
* creation, bundling, and commit.
|
|
9
10
|
*
|
|
10
11
|
* @param config - The resolved feature config.
|
|
11
12
|
* @param contract - The validated feature contract, inlined into the connector.
|
|
@@ -13,7 +14,7 @@ import type { FeatureContract, ResolvedFeatureConfig } from '../../shared/types'
|
|
|
13
14
|
*
|
|
14
15
|
* @example Staging a connector for the clock feature
|
|
15
16
|
* ```typescript
|
|
16
|
-
* generateShell({ name: 'clock', version: '1.0.0', contract: './clock.contract.json', url: '/clock' }, contract, tree)
|
|
17
|
+
* generateShell({ name: 'clock', version: '1.0.0', contract: './clock.contract.json', url: '/clock', protocol: 'v2' }, contract, tree)
|
|
17
18
|
* ```
|
|
18
19
|
*/
|
|
19
20
|
export declare function generateShell(config: ResolvedFeatureConfig, contract: FeatureContract, tree: Tree): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate-shell.d.ts","sourceRoot":"","sources":["../../../../../../../../libs/features/src/generators/shell/generate-shell.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,kCAAkC,CAAA;AAC5D,OAAO,KAAK,EAAE,eAAe,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAA;
|
|
1
|
+
{"version":3,"file":"generate-shell.d.ts","sourceRoot":"","sources":["../../../../../../../../libs/features/src/generators/shell/generate-shell.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,kCAAkC,CAAA;AAC5D,OAAO,KAAK,EAAE,eAAe,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAA;AAmLhF;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,qBAAqB,EAAE,QAAQ,EAAE,eAAe,EAAE,IAAI,EAAE,IAAI,GAAG,IAAI,CAKxG"}
|