@vyriy/create 0.5.4 → 0.5.6

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/preset/mfe.js CHANGED
@@ -21,7 +21,52 @@ const projectFiles = {
21
21
  'packages/api/package.json': '{\n "name": "@p/api",\n "type": "module",\n "private": true\n}\n',
22
22
  'packages/api/prerender.test.tsx': "import { afterEach, describe, expect, it } from '@jest/globals';\n\nimport { prerender } from './prerender.js';\n\ndescribe('prerender', () => {\n afterEach(() => {\n delete process.env.MODE;\n delete process.env.TAG;\n delete process.env.UI;\n });\n\n it('renders profile card props as custom element attributes', () => {\n process.env.MODE = 'open';\n process.env.TAG = 'vyriy-profile-card';\n process.env.UI = 'http://localhost:3002';\n\n expect(\n prerender({\n avatarUrl: 'https://example.com/avatar.png',\n description: 'A \"quoted\" <description>',\n name: 'Name',\n tags: ['one', 'two'],\n title: 'Title',\n }),\n ).toContain(\n '<vyriy-profile-card name=\"Name\" title=\"Title\" description=\"A &quot;quoted&quot; &lt;description&gt;\" avatarUrl=\"https://example.com/avatar.png\" tags=\"[&quot;one&quot;,&quot;two&quot;]\" rendered>',\n );\n expect(\n prerender({\n name: 'Name',\n }),\n ).toContain('<div data-vyriy-root>');\n });\n\n it('removes React generated resource hints from the hydration root', () => {\n process.env.MODE = 'open';\n process.env.TAG = 'vyriy-profile-card';\n process.env.UI = 'http://localhost:3002';\n\n expect(\n prerender({\n avatarUrl: 'https://example.com/avatar.png',\n name: 'Name',\n }),\n ).not.toContain('rel=\"preload\"');\n });\n});\n",
23
23
  'packages/api/prerender.tsx': "import { html } from '@vyriy/render';\n\nimport { ProfileCard } from '@p/components/profile-card';\n\nimport { getTag, getMode, getUi } from '@p/env';\n\nimport type { Prerender } from './types.js';\n\ntype AttributeValue = string | string[] | undefined;\n\nconst escapeAttribute = (value: string): string => {\n return value.replaceAll('&', '&amp;').replaceAll('\"', '&quot;').replaceAll('<', '&lt;').replaceAll('>', '&gt;');\n};\n\nconst getAttributeValue = (value: AttributeValue): string | undefined => {\n if (value === undefined) {\n return undefined;\n }\n\n return Array.isArray(value) ? JSON.stringify(value) : value;\n};\n\nconst getAttribute = (name: string, value: AttributeValue): string => {\n const attributeValue = getAttributeValue(value);\n\n if (attributeValue === undefined) {\n return '';\n }\n\n return ` ${name}=\"${escapeAttribute(attributeValue)}\"`;\n};\n\nconst getProfileCardAttributes = (props: Parameters<Prerender>[0]): string => {\n return [\n getAttribute('name', props.name),\n getAttribute('title', props.title),\n getAttribute('description', props.description),\n getAttribute('avatarUrl', props.avatarUrl),\n getAttribute('tags', props.tags),\n ].join('');\n};\n\nconst removeReactResourceHints = (value: string): string => {\n return value.replaceAll(/<link\\b(?=[^>]*\\brel=\"preload\")[^>]*>/g, '');\n};\n\n/** Renders a profile card custom element with declarative shadow DOM for hydration. */\nexport const prerender: Prerender = (props) => {\n const tag = getTag();\n const mode = getMode();\n const body = removeReactResourceHints(html(<ProfileCard {...props} />));\n\n return [\n `<${tag}${getProfileCardAttributes(props)} rendered>`,\n `<template shadowrootmode=\"${mode}\">`,\n `<link rel=\"stylesheet\" href=\"${getUi()}/main.css\" />`,\n `<div data-vyriy-root>${body}</div>`,\n `</template>`,\n `</${tag}>`,\n ].join('');\n};\n",
24
- 'packages/api/README.md': "# @p/api\n\nServer-side document builders for the profile-card microfrontend.\n\n## Exports\n\n- `demo()` returns a standalone HTML demo document.\n- `prerender(props)` returns SSR custom element markup with declarative shadow DOM.\n- `semantic(props)` returns Schema.org Person JSON-LD.\n- `manifest()` returns the OpenMFE manifest YAML.\n\n## Example\n\n```ts\nimport { prerender } from '@p/api';\n\nconst html = prerender({\n name: 'Ada Lovelace',\n title: 'Mathematician',\n});\n```\n",
24
+ 'packages/api/README.md': `# API
25
+
26
+ Server-side document builders for the profile-card microfrontend.
27
+
28
+ ## Exports
29
+
30
+ - \`demo()\` returns a standalone HTML demo document.
31
+ - \`prerender(props)\` returns SSR custom element markup with declarative shadow DOM.
32
+ - \`semantic(props)\` returns Schema.org Person JSON-LD.
33
+ - \`manifest()\` returns the OpenMFE manifest YAML.
34
+ - \`Demo\`, \`Prerender\`, \`Semantic\`, and \`Manifest\` describe the public builder signatures.
35
+
36
+ ## Props
37
+
38
+ The renderers accept the shared profile-card data model from \`@p/components\`:
39
+
40
+ - \`name\` is required.
41
+ - \`title\`, \`description\`, \`avatarUrl\`, and \`tags\` are optional.
42
+
43
+ \`prerender(props)\` serializes those values onto the configured custom element tag and includes the UI stylesheet inside the declarative shadow root.
44
+
45
+ ## Environment
46
+
47
+ The builders read required runtime configuration through \`@p/env\`:
48
+
49
+ - \`TAG\` custom element tag name.
50
+ - \`MODE\` shadow root mode.
51
+ - \`API\` API origin used in the manifest.
52
+ - \`CDN\` static asset origin used in the manifest.
53
+ - \`UI\` UI asset origin used by demo and prerender output.
54
+
55
+ ## Example
56
+
57
+ \`\`\`ts
58
+ import { prerender, semantic } from '@p/api';
59
+
60
+ const props = {
61
+ name: 'Ada Lovelace',
62
+ title: 'Mathematician',
63
+ tags: ['math', 'computing'],
64
+ };
65
+
66
+ const html = prerender(props);
67
+ const jsonLd = semantic(props);
68
+ \`\`\`
69
+ `,
25
70
  'packages/api/semantic.test.ts': "import { describe, expect, it } from '@jest/globals';\n\nimport { semantic } from './semantic.js';\n\ndescribe('semantic', () => {\n it('serializes profile-card props as Schema.org JSON-LD', () => {\n expect(\n JSON.parse(\n semantic({\n avatarUrl: 'https://example.com/avatar.png',\n name: 'Ada Lovelace',\n title: 'Mathematician',\n }),\n ),\n ).toEqual({\n '@context': 'https://schema.org',\n '@type': 'Person',\n image: 'https://example.com/avatar.png',\n jobTitle: 'Mathematician',\n name: 'Ada Lovelace',\n });\n });\n});\n",
26
71
  'packages/api/semantic.ts': "import type { Semantic } from './types.js';\n\n/** Serializes profile-card props as Schema.org Person JSON-LD. */\nexport const semantic: Semantic = (params) =>\n JSON.stringify({\n '@context': 'https://schema.org',\n '@type': 'Person',\n name: params.name,\n jobTitle: params.title,\n image: params.avatarUrl,\n });\n",
27
72
  'packages/api/types.ts': "import type { ProfileCard } from '@p/components/profile-card/types.js';\n\n/** Builds the standalone HTML demo document. */\nexport type Demo = () => string;\n\n/** Builds server-rendered custom element markup from profile-card props. */\nexport type Prerender = (props: ProfileCard) => string;\n\n/** Builds semantic JSON-LD from profile-card props. */\nexport type Semantic = (props: ProfileCard) => string;\n\n/** Builds the OpenMFE manifest YAML document. */\nexport type Manifest = () => string;\n",
@@ -31,7 +76,39 @@ const projectFiles = {
31
76
  'packages/env/index.test.ts': "import { afterEach, describe, expect, it } from '@jest/globals';\n\nimport * as publicApi from './index.js';\n\nconst ENV_NAMES = [\n 'TAG',\n 'MODE',\n 'API',\n 'CDN',\n 'UI',\n] as const;\n\nconst clearEnv = () => {\n for (const name of ENV_NAMES) {\n delete process.env[name];\n }\n};\n\ndescribe('env public API', () => {\n afterEach(() => {\n clearEnv();\n });\n\n it('exports env getters', () => {\n expect(publicApi.getTag).toBeDefined();\n expect(publicApi.getMode).toBeDefined();\n expect(publicApi.getApi).toBeDefined();\n expect(publicApi.getCdn).toBeDefined();\n expect(publicApi.getUi).toBeDefined();\n });\n\n it('reads environment variables by public getter name', () => {\n process.env.TAG = 'vyriy-profile-card';\n process.env.MODE = 'open';\n process.env.API = 'http://localhost:3000';\n process.env.CDN = 'http://localhost:3001';\n process.env.UI = 'http://localhost:3002';\n\n expect(publicApi.getTag()).toBe('vyriy-profile-card');\n expect(publicApi.getMode()).toBe('open');\n expect(publicApi.getApi()).toBe('http://localhost:3000');\n expect(publicApi.getCdn()).toBe('http://localhost:3001');\n expect(publicApi.getUi()).toBe('http://localhost:3002');\n });\n\n it('throws when a required environment variable is missing', () => {\n clearEnv();\n\n expect(() => publicApi.getApi()).toThrow('Environment variable API is not defined!');\n });\n});\n",
32
77
  'packages/env/index.ts': "export * from './env.js';\n",
33
78
  'packages/env/package.json': '{\n "name": "@p/env",\n "type": "module",\n "private": true\n}\n',
34
- 'packages/env/README.md': '# @p/env\n\nRequired environment readers shared by API and UI workspaces.\n\n## Exports\n\n- `getTag()` reads `TAG`.\n- `getMode()` reads `MODE`.\n- `getApi()` reads `API`.\n- `getCdn()` reads `CDN`.\n- `getUi()` reads `UI`.\n\nEach getter throws when its environment variable is missing.\n',
79
+ 'packages/env/README.md': `# Env
80
+
81
+ Required environment readers shared by API and UI workspaces.
82
+
83
+ ## Exports
84
+
85
+ - \`getTag()\` reads \`TAG\`.
86
+ - \`getMode()\` reads \`MODE\`.
87
+ - \`getApi()\` reads \`API\`.
88
+ - \`getCdn()\` reads \`CDN\`.
89
+ - \`getUi()\` reads \`UI\`.
90
+
91
+ Each getter delegates to \`@vyriy/env\` and throws when its environment variable is missing.
92
+
93
+ ## Local Defaults
94
+
95
+ \`workspaces/env.sh\` provides the local development defaults:
96
+
97
+ - \`API=http://localhost:3000\`
98
+ - \`CDN=http://localhost:3001\`
99
+ - \`UI=http://localhost:3002\`
100
+ - \`TAG=vyriy-profile-card\`
101
+ - \`MODE=open\`
102
+
103
+ ## Example
104
+
105
+ \`\`\`ts
106
+ import { getCdn, getUi } from '@p/env';
107
+
108
+ const stylesheet = \`\${getUi()}/main.css\`;
109
+ const avatar = \`\${getCdn()}/avatar.svg\`;
110
+ \`\`\`
111
+ `,
35
112
  'packages/event/constants.test.ts': "import { describe, expect, it } from '@jest/globals';\n\nimport { PROFILE_CARD_ANALYTICS_EVENT_NAME, PROFILE_CARD_SELECT_EVENT_NAME } from './constants.js';\n\ndescribe('event constants', () => {\n it('matches the manifest event names', () => {\n expect(PROFILE_CARD_ANALYTICS_EVENT_NAME).toBe('openmfe.analytics');\n expect(PROFILE_CARD_SELECT_EVENT_NAME).toBe('vyriy-profile-card.select');\n });\n});\n",
36
113
  'packages/event/constants.ts': "/** Custom event emitted when the profile card is selected. */\nexport const PROFILE_CARD_SELECT_EVENT_NAME = 'vyriy-profile-card.select';\n\n/** Standard OpenMFE analytics event emitted for profile-card interactions. */\nexport const PROFILE_CARD_ANALYTICS_EVENT_NAME = 'openmfe.analytics';\n",
37
114
  'packages/event/doc.mdx': "import { Meta, Markdown } from '@storybook/addon-docs/blocks';\nimport ReadMe from './README.md?raw';\n\n<Meta title=\"Packages/Event\" />\n\n<Markdown>{ReadMe}</Markdown>\n",
@@ -41,7 +118,45 @@ const projectFiles = {
41
118
  'packages/event/profile-card-analytics.ts': "import { dispatchAnalyticsEvent } from '@vyriy/event';\n\nimport type { ProfileCardAnalyticsData } from './types.js';\n\n/** Dispatches the standard OpenMFE analytics event for a profile-card selection. */\nexport const dispatchProfileCardAnalyticsEvent = (target: HTMLElement, data: ProfileCardAnalyticsData): CustomEvent => {\n return dispatchAnalyticsEvent(\n target,\n {\n action: 'select',\n category: 'profile-card',\n data,\n name: 'profile_card_select',\n },\n {\n bubbles: true,\n composed: true,\n },\n );\n};\n",
42
119
  'packages/event/profile-card-select.test.ts': "import { describe, expect, it, jest } from '@jest/globals';\n\nimport { PROFILE_CARD_SELECT_EVENT_NAME } from './constants.js';\nimport { dispatchProfileCardSelectEvent } from './profile-card-select.js';\n\ndescribe('dispatchProfileCardSelectEvent', () => {\n it('dispatches the profile card select event from the custom element', () => {\n const target = document.createElement('vyriy-profile-card');\n const listener = jest.fn();\n\n target.addEventListener(PROFILE_CARD_SELECT_EVENT_NAME, listener);\n\n const event = dispatchProfileCardSelectEvent(target, {\n avatarUrl: 'https://example.com/avatar.png',\n name: 'Ada Lovelace',\n role: 'Mathematician',\n });\n\n expect(event.type).toBe(PROFILE_CARD_SELECT_EVENT_NAME);\n expect(event.bubbles).toBe(true);\n expect(event.composed).toBe(true);\n expect(event.detail).toEqual({\n avatarUrl: 'https://example.com/avatar.png',\n name: 'Ada Lovelace',\n role: 'Mathematician',\n });\n expect(listener).toHaveBeenCalledWith(event);\n });\n});\n",
43
120
  'packages/event/profile-card-select.ts': "import { dispatchCustomEvent } from '@vyriy/event';\n\nimport { PROFILE_CARD_SELECT_EVENT_NAME } from './constants.js';\nimport type { ProfileCardSelectDetail } from './types.js';\n\n/** Dispatches the profile-card select custom event from the web component host. */\nexport const dispatchProfileCardSelectEvent = (\n target: HTMLElement,\n detail: ProfileCardSelectDetail,\n): CustomEvent<ProfileCardSelectDetail> => {\n return dispatchCustomEvent(target, PROFILE_CARD_SELECT_EVENT_NAME, detail, {\n bubbles: true,\n composed: true,\n });\n};\n",
44
- 'packages/event/README.md': "# @p/event\n\nTyped profile-card event helpers.\n\n## Usage\n\n```ts\nimport { dispatchProfileCardAnalyticsEvent, dispatchProfileCardSelectEvent } from '@p/event';\n\nconst target = document.querySelector('vyriy-profile-card');\n\nif (target instanceof HTMLElement) {\n const detail = {\n name: 'Ada Lovelace',\n role: 'Mathematician',\n avatarUrl: '/avatar.svg',\n };\n\n dispatchProfileCardSelectEvent(target, detail);\n dispatchProfileCardAnalyticsEvent(target, detail);\n}\n```\n\n## Events\n\n- `vyriy-profile-card.select` is emitted when the profile card is selected.\n- `openmfe.analytics` is emitted with the standard OpenMFE analytics payload for the same selection.\n",
121
+ 'packages/event/README.md': `# Event
122
+
123
+ Typed profile-card event helpers.
124
+
125
+ ## Exports
126
+
127
+ - \`PROFILE_CARD_SELECT_EVENT_NAME\` is \`vyriy-profile-card.select\`.
128
+ - \`PROFILE_CARD_ANALYTICS_EVENT_NAME\` is \`openmfe.analytics\`.
129
+ - \`dispatchProfileCardSelectEvent(target, detail)\` dispatches the profile-card selection event.
130
+ - \`dispatchProfileCardAnalyticsEvent(target, data)\` dispatches the standard OpenMFE analytics event for the same selection.
131
+ - \`ProfileCardSelectDetail\` and \`ProfileCardAnalyticsData\` describe the event payloads.
132
+
133
+ Both dispatch helpers emit bubbling, composed custom events so consumers outside the custom element shadow root can observe them.
134
+
135
+ ## Usage
136
+
137
+ \`\`\`ts
138
+ import { dispatchProfileCardAnalyticsEvent, dispatchProfileCardSelectEvent } from '@p/event';
139
+
140
+ const target = document.querySelector('vyriy-profile-card');
141
+
142
+ if (target instanceof HTMLElement) {
143
+ const detail = {
144
+ name: 'Ada Lovelace',
145
+ role: 'Mathematician',
146
+ avatarUrl: '/avatar.svg',
147
+ };
148
+
149
+ dispatchProfileCardSelectEvent(target, detail);
150
+ dispatchProfileCardAnalyticsEvent(target, detail);
151
+ }
152
+ \`\`\`
153
+
154
+ ## Payload
155
+
156
+ \`ProfileCardSelectDetail\` requires \`name\` and accepts optional \`role\` and \`avatarUrl\`.
157
+
158
+ The analytics helper wraps the same data in the standard OpenMFE analytics event with \`action: 'select'\` and \`category: 'profile-card'\`.
159
+ `,
45
160
  'packages/event/types.ts': '/** Detail payload for the profile-card select custom event. */\nexport type ProfileCardSelectDetail = {\n name: string;\n role?: string;\n avatarUrl?: string | null;\n};\n\n/** Analytics data payload emitted for profile-card selections. */\nexport type ProfileCardAnalyticsData = ProfileCardSelectDetail;\n',
46
161
  'packages/query/doc.mdx': "import { Meta, Markdown } from '@storybook/addon-docs/blocks';\nimport ReadMe from './README.md?raw';\n\n<Meta title=\"Packages/Query\" />\n\n<Markdown>{ReadMe}</Markdown>\n",
47
162
  'packages/query/index.test.ts': "import { describe, expect, it } from '@jest/globals';\n\nimport * as publicApi from './index.js';\n\ndescribe('query public API', () => {\n it('exports query parsers', () => {\n expect(publicApi.parseProfileCardQuery).toBeDefined();\n });\n});\n",
@@ -49,7 +164,42 @@ const projectFiles = {
49
164
  'packages/query/package.json': '{\n "name": "@p/query",\n "type": "module",\n "private": true\n}\n',
50
165
  'packages/query/profile-card.test.ts': "import { describe, expect, it } from '@jest/globals';\n\nimport { parseProfileCardQuery } from './profile-card.js';\n\ndescribe('parseProfileCardQuery', () => {\n it('returns undefined when name is missing', () => {\n expect(parseProfileCardQuery(undefined)).toBeUndefined();\n expect(parseProfileCardQuery({})).toBeUndefined();\n expect(parseProfileCardQuery({ name: '' })).toBeUndefined();\n });\n\n it('parses supported profile card fields', () => {\n expect(\n parseProfileCardQuery({\n avatarUrl: 'https://example.com/avatar.png',\n description: 'Profile description',\n name: 'Name',\n tags: 'one, two,, three ',\n title: 'Title',\n }),\n ).toEqual({\n avatarUrl: 'https://example.com/avatar.png',\n description: 'Profile description',\n name: 'Name',\n tags: ['one', 'two', 'three'],\n title: 'Title',\n });\n });\n\n it('omits tags when the query list is empty after trimming', () => {\n expect(\n parseProfileCardQuery({\n name: 'Name',\n tags: ', , ',\n }),\n ).toEqual({\n name: 'Name',\n tags: undefined,\n });\n });\n});\n",
51
166
  'packages/query/profile-card.ts': "import type { ParseProfileCardQuery, Query } from './types.js';\n\nconst getQueryValue = (query: Query, name: string): string | undefined => {\n const value = query?.[name];\n\n return value === '' ? undefined : value;\n};\n\nconst getQueryList = (query: Query, name: string): string[] | undefined => {\n const value = getQueryValue(query, name);\n\n if (!value) {\n return undefined;\n }\n\n const list = value\n .split(',')\n .map((item) => item.trim())\n .filter(Boolean);\n\n return list.length > 0 ? list : undefined;\n};\n\n/** Parses request query parameters into profile-card props. */\nexport const parseProfileCardQuery: ParseProfileCardQuery = (query) => {\n const name = getQueryValue(query, 'name');\n\n if (!name) {\n return undefined;\n }\n\n return {\n name,\n title: getQueryValue(query, 'title'),\n description: getQueryValue(query, 'description'),\n avatarUrl: getQueryValue(query, 'avatarUrl'),\n tags: getQueryList(query, 'tags'),\n };\n};\n",
52
- 'packages/query/README.md': "# @p/query\n\nQuery-string parsers for profile-card API endpoints.\n\n## Exports\n\n- `parseProfileCardQuery(query)` converts router query parameters into profile-card props.\n\n## Example\n\n```ts\nimport { parseProfileCardQuery } from '@p/query';\n\nconst props = parseProfileCardQuery({\n name: 'Ada Lovelace',\n title: 'Mathematician',\n tags: 'math, computing',\n});\n```\n",
167
+ 'packages/query/README.md': `# Query
168
+
169
+ Query-string parsers for profile-card API endpoints.
170
+
171
+ ## Exports
172
+
173
+ - \`parseProfileCardQuery(query)\` converts router query parameters into profile-card props.
174
+ - \`Query\` describes the router query input shape.
175
+ - \`ParseProfileCardQuery\` describes the parser signature.
176
+
177
+ ## Parameters
178
+
179
+ \`name\` is required. When \`name\` is missing or empty, the parser returns \`undefined\`.
180
+
181
+ Supported optional parameters:
182
+
183
+ - \`title\`
184
+ - \`description\`
185
+ - \`avatarUrl\`
186
+ - \`tags\`, as a comma-separated list
187
+
188
+ Empty string values are treated as missing. \`tags\` are split on commas, trimmed, and empty items are removed.
189
+
190
+ ## Example
191
+
192
+ \`\`\`ts
193
+ import { parseProfileCardQuery } from '@p/query';
194
+
195
+ const props = parseProfileCardQuery({
196
+ name: 'Ada Lovelace',
197
+ title: 'Mathematician',
198
+ description: 'First computer programmer.',
199
+ tags: 'math, computing',
200
+ });
201
+ \`\`\`
202
+ `,
53
203
  'packages/query/types.ts': "import type { ProfileCard } from '@p/components/profile-card/types.js';\n\n/** Query string values provided by the API router. */\nexport type Query = Record<string, string | undefined> | undefined;\n\n/** Converts query string values into profile-card props or rejects incomplete input. */\nexport type ParseProfileCardQuery = (query: Query) => ProfileCard | undefined;\n",
54
204
  'stylelint.config.ts': "export { default } from '@vyriy/stylelint-config';\n",
55
205
  'workspaces/api/bin/build.sh': '#!/usr/bin/env sh\n\nset -e\n\nscriptdir="$PWD/workspaces/api";\n\n. "$PWD/workspaces/env.sh"\n\nNODE_ENV=production \\\nnpx webpack --config $scriptdir/webpack.config.ts\n\ncp $scriptdir/package.json dist/api/package.json\nnpm pkg delete "type" --prefix dist/api\nnpm pkg delete "private" --prefix dist/api\n',
@@ -58,25 +208,308 @@ const projectFiles = {
58
208
  'workspaces/api/index.test.ts': "import { describe, expect, it, jest } from '@jest/globals';\nimport type { APIGatewayProxyEvent } from '@vyriy/router';\n\nconst apiMock = jest.fn((handler) => ({\n handler,\n}));\nconst serverMock = jest.fn();\n\njest.mock('@vyriy/handler', () => ({\n api: apiMock,\n}));\n\njest.mock('@vyriy/server', () => ({\n server: serverMock,\n}));\n\ndescribe('workspaces/api/index.ts', () => {\n const getEvent = (\n path: string,\n queryStringParameters: APIGatewayProxyEvent['queryStringParameters'] = null,\n ): APIGatewayProxyEvent =>\n ({\n body: null,\n headers: {},\n httpMethod: 'GET',\n path,\n pathParameters: null,\n queryStringParameters,\n }) as APIGatewayProxyEvent;\n\n it('starts the server with the API router handler', async () => {\n process.env.MODE = 'open';\n process.env.TAG = 'vyriy-profile-card';\n process.env.API = 'http://localhost:3000';\n process.env.CDN = 'http://localhost:3001';\n process.env.UI = 'http://localhost:3002';\n\n await import('./index.js');\n\n expect(apiMock).toHaveBeenCalledTimes(1);\n expect(serverMock).toHaveBeenCalledTimes(1);\n expect(serverMock).toHaveBeenCalledWith(apiMock.mock.results[0]?.value);\n\n const handler = apiMock.mock.calls[0]?.[0] as (event: APIGatewayProxyEvent) => Promise<{\n body: string;\n headers?: Record<string, string>;\n statusCode: number;\n }>;\n\n await expect(handler(getEvent('/'))).resolves.toEqual({\n body: expect.stringContaining('<vyriy-profile-card'),\n headers: {\n 'access-control-allow-origin': '*',\n 'cache-control': 'public, max-age=300, s-maxage=3600, stale-while-revalidate=86400',\n 'content-type': 'text/html; charset=utf-8',\n 'x-content-type-options': 'nosniff',\n },\n isBase64Encoded: undefined,\n multiValueHeaders: undefined,\n statusCode: 200,\n });\n\n await expect(handler(getEvent('/prerender'))).resolves.toEqual({\n body: JSON.stringify({\n message: 'Query parameter \"name\" is required.',\n }),\n headers: undefined,\n isBase64Encoded: undefined,\n multiValueHeaders: undefined,\n statusCode: 400,\n });\n\n const prerenderResponse = await handler(\n getEvent('/prerender', {\n description: 'Profile description',\n name: 'Name',\n tags: 'one, two',\n title: 'Title',\n }),\n );\n\n expect(prerenderResponse).toEqual({\n body: expect.stringContaining('Name'),\n headers: {\n 'access-control-allow-origin': '*',\n 'cache-control': 'public, max-age=300, s-maxage=3600, stale-while-revalidate=86400',\n 'content-type': 'text/html; charset=utf-8',\n 'x-content-type-options': 'nosniff',\n },\n isBase64Encoded: undefined,\n multiValueHeaders: undefined,\n statusCode: 200,\n });\n expect(prerenderResponse.body).toContain('shadowrootmode=\"open\"');\n expect(prerenderResponse.body).toContain('http://localhost:3002/main.css');\n\n await expect(handler(getEvent('/semantic', { name: 'Name' }))).resolves.toEqual({\n body: JSON.stringify({\n '@context': 'https://schema.org',\n '@type': 'Person',\n name: 'Name',\n }),\n headers: {\n 'access-control-allow-origin': '*',\n 'cache-control': 'public, max-age=300, s-maxage=3600, stale-while-revalidate=86400',\n 'content-type': 'application/ld+json; charset=utf-8',\n 'x-content-type-options': 'nosniff',\n },\n isBase64Encoded: undefined,\n multiValueHeaders: undefined,\n statusCode: 200,\n });\n\n await expect(handler(getEvent('/semantic'))).resolves.toEqual({\n body: JSON.stringify({\n message: 'Query parameter \"name\" is required.',\n }),\n headers: undefined,\n isBase64Encoded: undefined,\n multiValueHeaders: undefined,\n statusCode: 400,\n });\n\n await expect(handler(getEvent('/manifest.yml'))).resolves.toEqual({\n body: expect.stringContaining(\"name: 'Vyriy Profile Card'\"),\n headers: {\n 'access-control-allow-origin': '*',\n 'cache-control': 'public, max-age=300, s-maxage=3600, stale-while-revalidate=86400',\n 'content-type': 'text/yaml; charset=utf-8',\n 'x-content-type-options': 'nosniff',\n },\n isBase64Encoded: undefined,\n multiValueHeaders: undefined,\n statusCode: 200,\n });\n\n await expect(handler(getEvent('/healthcheck'))).resolves.toEqual({\n body: JSON.stringify({\n message: 'Not Found',\n }),\n statusCode: 404,\n });\n });\n});\n",
59
209
  'workspaces/api/index.ts': "import { server } from '@vyriy/server';\nimport { api } from '@vyriy/handler';\nimport { createRouter } from '@vyriy/router';\nimport { minify } from '@vyriy/html';\n\nimport { demo, manifest, prerender, semantic } from '@p/api';\nimport { parseProfileCardQuery } from '@p/query';\n\nserver(\n api(async (event) =>\n createRouter()\n .get('/', () => ({\n body: minify(demo()),\n headers: {\n 'content-type': 'text/html; charset=utf-8',\n 'cache-control': 'public, max-age=300, s-maxage=3600, stale-while-revalidate=86400',\n 'access-control-allow-origin': '*',\n 'x-content-type-options': 'nosniff',\n },\n }))\n .get('/prerender', ({ query }) => {\n const profileCard = parseProfileCardQuery(query);\n\n if (!profileCard) {\n return {\n statusCode: 400,\n body: JSON.stringify({ message: 'Query parameter \"name\" is required.' }),\n };\n }\n\n return {\n body: minify(prerender(profileCard)),\n headers: {\n 'content-type': 'text/html; charset=utf-8',\n 'cache-control': 'public, max-age=300, s-maxage=3600, stale-while-revalidate=86400',\n 'access-control-allow-origin': '*',\n 'x-content-type-options': 'nosniff',\n },\n };\n })\n .get('/semantic', ({ query }) => {\n const profileCard = parseProfileCardQuery(query);\n\n if (!profileCard) {\n return {\n statusCode: 400,\n body: JSON.stringify({ message: 'Query parameter \"name\" is required.' }),\n };\n }\n\n return {\n body: semantic(profileCard),\n headers: {\n 'content-type': 'application/ld+json; charset=utf-8',\n 'cache-control': 'public, max-age=300, s-maxage=3600, stale-while-revalidate=86400',\n 'access-control-allow-origin': '*',\n 'x-content-type-options': 'nosniff',\n },\n };\n })\n .get('/manifest.yml', () => ({\n body: manifest(),\n headers: {\n 'content-type': 'text/yaml; charset=utf-8',\n 'cache-control': 'public, max-age=300, s-maxage=3600, stale-while-revalidate=86400',\n 'access-control-allow-origin': '*',\n 'x-content-type-options': 'nosniff',\n },\n }))\n .route(event),\n ),\n);\n",
60
210
  'workspaces/api/package.json': '{\n "name": "@w/api",\n "type": "module",\n "private": true\n}\n',
61
- 'workspaces/api/README.md': '# app API\n\nCalm cloud-ready application\n',
211
+ 'workspaces/api/README.md': `# Api
212
+
213
+ Server workspace for the profile-card microfrontend.
214
+
215
+ ## Routes
216
+
217
+ - \`GET /\` returns a standalone HTML demo page.
218
+ - \`GET /prerender\` returns server-rendered custom element HTML.
219
+ - \`GET /semantic\` returns Schema.org Person JSON-LD.
220
+ - \`GET /manifest.yml\` returns the OpenMFE manifest YAML.
221
+
222
+ \`/prerender\` and \`/semantic\` require the \`name\` query parameter. They also accept \`title\`, \`description\`, \`avatarUrl\`, and comma-separated \`tags\`.
223
+
224
+ ## Local Development
225
+
226
+ \`\`\`bash
227
+ yarn start:api
228
+ \`\`\`
229
+
230
+ The start script loads \`workspaces/env.sh\`, listens on \`API_PORT\`, and prints example URLs for the demo, prerender, semantic, and manifest endpoints.
231
+
232
+ Default local URL:
233
+
234
+ \`\`\`text
235
+ http://localhost:3000
236
+ \`\`\`
237
+
238
+ ## Build
239
+
240
+ \`\`\`bash
241
+ yarn build:api
242
+ \`\`\`
243
+
244
+ The build writes the server bundle to \`dist/api\`.
245
+ `,
62
246
  'workspaces/api/webpack.config.ts': "import { EnvironmentPlugin } from 'webpack';\nimport { path } from '@vyriy/path';\nimport { ssr, external } from '@vyriy/webpack-config';\n\nexport default ssr(\n '@w/api',\n {\n path: path('dist', 'api'),\n filename: 'index.js',\n library: { type: 'commonjs2' },\n },\n (config) => ({\n ...config,\n externals: [external({ allowlist: [/^@p/, /^@w/, /^@vyriy/] })],\n plugins: [\n ...(config.plugins ?? []),\n new EnvironmentPlugin([\n 'API',\n 'CDN',\n 'MODE',\n 'TAG',\n 'UI',\n ]),\n ],\n }),\n);\n",
63
247
  'workspaces/env.sh': '#!/usr/bin/env sh\n\n: "${API_PORT:=3000}"\n: "${CDN_PORT:=3001}"\n: "${UI_PORT:=3002}"\n: "${API:=http://localhost:$API_PORT}"\n: "${CDN:=http://localhost:$CDN_PORT}"\n: "${UI:=http://localhost:$UI_PORT}"\n: "${TAG:=vyriy-profile-card}"\n: "${MODE:=open}"\n\nexport API_PORT\nexport CDN_PORT\nexport UI_PORT\nexport API\nexport CDN\nexport UI\nexport TAG\nexport MODE\n',
64
248
  'workspaces/static/bin/build.sh': '#!/usr/bin/env sh\n\nset -e\n\nscriptdir="$PWD/workspaces/static";\ndistdir="$PWD/dist/cdn";\n\ncp -R $scriptdir/public/* $distdir/\n',
65
- 'workspaces/static/bin/start.sh': '#!/usr/bin/env sh\n\nset -e\n\nscriptdir="$PWD/workspaces/static";\n\n. "$PWD/workspaces/env.sh"\n\nnpx serve --cors -p $CDN_PORT $scriptdir/public\n',
249
+ 'workspaces/static/bin/start.sh': `#!/usr/bin/env sh
250
+
251
+ set -e
252
+
253
+ scriptdir="$PWD/workspaces/static";
254
+
255
+ . "$PWD/workspaces/env.sh"
256
+
257
+ npx vs -p $CDN_PORT $scriptdir/public
258
+ `,
66
259
  'workspaces/static/doc.mdx': "import { Meta, Markdown } from '@storybook/addon-docs/blocks';\nimport ReadMe from './README.md?raw';\n\n<Meta title=\"Workspaces/Static\" />\n\n<Markdown>{ReadMe}</Markdown>\n",
67
260
  'workspaces/static/package.json': '{\n "name": "@w/static",\n "type": "module",\n "private": true\n}\n',
68
261
  'workspaces/static/public/avatar.svg': '<svg xmlns="http://www.w3.org/2000/svg" width="1200" height="800">\r\n<rect width="1200" height="800" fill="#0057B7"/>\r\n<rect width="1200" height="400" y="400" fill="#FFD700"/>\r\n</svg>',
69
262
  'workspaces/static/public/icon.svg': '<svg\n width="256"\n height="256"\n viewBox="0 0 256 256"\n fill="none"\n xmlns="http://www.w3.org/2000/svg"\n role="img"\n aria-labelledby="title description"\n>\n <title id="title">Vyriy Profile Card icon</title>\n <desc id="description">A calm rounded square icon with a profile card symbol.</desc>\n\n <rect width="256" height="256" rx="56" fill="#111827" />\n <rect x="56" y="48" width="144" height="160" rx="24" fill="#F9FAFB" />\n <circle cx="128" cy="104" r="36" fill="#9CA3AF" />\n <rect x="84" y="156" width="88" height="14" rx="7" fill="#111827" />\n <rect x="96" y="180" width="64" height="10" rx="5" fill="#6B7280" />\n <circle cx="184" cy="184" r="20" fill="#10B981" />\n <path\n d="M175 184L181 190L194 176"\n stroke="white"\n stroke-width="6"\n stroke-linecap="round"\n stroke-linejoin="round"\n />\n</svg>\n',
70
263
  'workspaces/static/public/screenshots/compact.svg': '<svg\n width="1280"\n height="720"\n viewBox="0 0 1280 720"\n fill="none"\n xmlns="http://www.w3.org/2000/svg"\n role="img"\n aria-labelledby="title description"\n>\n <title id="title">Default profile card screenshot</title>\n <desc id="description">A profile card microfrontend rendered in a desktop host page.</desc>\n\n <rect width="1280" height="720" fill="#F3F4F6" />\n <rect x="80" y="72" width="1120" height="576" rx="32" fill="white" />\n\n <rect x="128" y="120" width="360" height="480" rx="28" fill="#F9FAFB" stroke="#E5E7EB" />\n <circle cx="308" cy="244" r="72" fill="#9CA3AF" />\n <rect x="188" y="368" width="240" height="28" rx="14" fill="#111827" />\n <rect x="224" y="420" width="168" height="18" rx="9" fill="#6B7280" />\n <rect x="232" y="492" width="152" height="44" rx="22" fill="#10B981" />\n\n <rect x="560" y="152" width="420" height="40" rx="20" fill="#111827" />\n <rect x="560" y="232" width="520" height="20" rx="10" fill="#6B7280" />\n <rect x="560" y="272" width="460" height="20" rx="10" fill="#9CA3AF" />\n <rect x="560" y="312" width="360" height="20" rx="10" fill="#D1D5DB" />\n <rect x="560" y="420" width="520" height="96" rx="24" fill="#F9FAFB" stroke="#E5E7EB" />\n</svg>\n',
71
264
  'workspaces/static/public/screenshots/default.svg': '<svg\n width="1280"\n height="720"\n viewBox="0 0 1280 720"\n fill="none"\n xmlns="http://www.w3.org/2000/svg"\n role="img"\n aria-labelledby="title description"\n>\n <title id="title">Default profile card screenshot</title>\n <desc id="description">A profile card microfrontend rendered in a desktop host page.</desc>\n\n <rect width="1280" height="720" fill="#F3F4F6" />\n <rect x="80" y="72" width="1120" height="576" rx="32" fill="white" />\n\n <rect x="128" y="120" width="360" height="480" rx="28" fill="#F9FAFB" stroke="#E5E7EB" />\n <circle cx="308" cy="244" r="72" fill="#9CA3AF" />\n <rect x="188" y="368" width="240" height="28" rx="14" fill="#111827" />\n <rect x="224" y="420" width="168" height="18" rx="9" fill="#6B7280" />\n <rect x="232" y="492" width="152" height="44" rx="22" fill="#10B981" />\n\n <rect x="560" y="152" width="420" height="40" rx="20" fill="#111827" />\n <rect x="560" y="232" width="520" height="20" rx="10" fill="#6B7280" />\n <rect x="560" y="272" width="460" height="20" rx="10" fill="#9CA3AF" />\n <rect x="560" y="312" width="360" height="20" rx="10" fill="#D1D5DB" />\n <rect x="560" y="420" width="520" height="96" rx="24" fill="#F9FAFB" stroke="#E5E7EB" />\n</svg>\n',
72
- 'workspaces/static/README.md': '# @w/static\n\nStatic asset workspace for the profile-card microfrontend.\n\n## Assets\n\n- `avatar.svg` is the default demo avatar.\n- `icon.svg` is the manifest icon.\n- `screenshots/default.svg` and `screenshots/compact.svg` document visible profile-card states.\n\nThe workspace is served as the CDN origin during local development.\n',
265
+ 'workspaces/static/README.md': `# Static
266
+
267
+ Static asset workspace for the profile-card microfrontend.
268
+
269
+ This workspace uses \`@vyriy/static\` to serve files during local development. The package exposes the \`vs\` command, which can also be installed globally to serve static data from any directory with a simple command.
270
+
271
+ ## Assets
272
+
273
+ - \`avatar.svg\` is the default demo avatar.
274
+ - \`icon.svg\` is the manifest icon.
275
+ - \`screenshots/default.svg\` documents the default profile-card state.
276
+ - \`screenshots/compact.svg\` documents the compact profile-card state.
277
+
278
+ The workspace is served as the CDN origin during local development and copied into \`dist/cdn\` for production builds.
279
+
280
+ ## Local Development
281
+
282
+ \`\`\`bash
283
+ yarn start:static
284
+ \`\`\`
285
+
286
+ The start script loads \`workspaces/env.sh\` and serves \`workspaces/static/public\` on \`CDN_PORT\`.
287
+
288
+ Internally it runs:
289
+
290
+ \`\`\`bash
291
+ npx vs -p $CDN_PORT workspaces/static/public
292
+ \`\`\`
293
+
294
+ With \`@vyriy/static\` installed globally, the same kind of static preview can be started directly:
295
+
296
+ \`\`\`bash
297
+ vs -p 3001 workspaces/static/public
298
+ \`\`\`
299
+
300
+ Default local URL:
301
+
302
+ \`\`\`text
303
+ http://localhost:3001
304
+ \`\`\`
305
+
306
+ ## Build
307
+
308
+ \`\`\`bash
309
+ yarn build:static
310
+ \`\`\`
311
+ `,
73
312
  'workspaces/ui/bin/build.sh': '#!/usr/bin/env sh\n\nset -e\n\nscriptdir="$PWD/workspaces/ui";\n\n. "$PWD/workspaces/env.sh"\n\nNODE_ENV=production \\\nnpx webpack \\\n--config $scriptdir/webpack.config.ts\n',
74
313
  'workspaces/ui/bin/start.sh': '#!/usr/bin/env sh\n\nset -e\n\nscriptdir="$PWD/workspaces/ui";\n\n. "$PWD/workspaces/env.sh"\n\nnpx webpack serve \\\n--open \\\n--config $scriptdir/webpack.config.ts \\\n--port $UI_PORT\n',
75
314
  'workspaces/ui/doc.mdx': "import { Meta, Markdown } from '@storybook/addon-docs/blocks';\nimport ReadMe from './README.md?raw';\n\n<Meta title=\"Workspaces/UI\" />\n\n<Markdown>{ReadMe}</Markdown>\n",
76
- 'workspaces/ui/index.test.tsx': "import { beforeAll, describe, expect, it, jest } from '@jest/globals';\nimport type { ReactElement } from 'react';\n\ntype CustomElementOptions = {\n tag: string;\n elements: () => {\n elements: HTMLElement[];\n root: HTMLElement;\n };\n render: (el: HTMLElement) => ReactElement<{\n onClick: () => void;\n tags?: string[];\n }>;\n};\n\nconst customElementMock = jest.fn();\nconst dispatchProfileCardAnalyticsEventMock = jest.fn();\nconst dispatchProfileCardSelectEventMock = jest.fn();\nlet options: CustomElementOptions;\n\njest.mock('@vyriy/render/custom-element', () => ({\n customElement: customElementMock,\n}));\n\njest.mock('@p/env', () => ({\n getUi: () => 'http://localhost:3002',\n}));\n\njest.mock('@p/event', () => ({\n dispatchProfileCardAnalyticsEvent: dispatchProfileCardAnalyticsEventMock,\n dispatchProfileCardSelectEvent: dispatchProfileCardSelectEventMock,\n}));\n\ndescribe('workspaces/ui/index.tsx', () => {\n beforeAll(async () => {\n await import('./index.js');\n\n [options] = (customElementMock.mock.calls[0] ?? []) as [CustomElementOptions];\n });\n\n it('registers the profile-card custom element with event dispatching', () => {\n const renderElements = options.elements();\n const host = document.createElement('vyriy-profile-card');\n\n host.setAttribute('avatarUrl', 'https://example.com/avatar.png');\n host.setAttribute('description', 'Profile description');\n host.setAttribute('name', 'Ada Lovelace');\n host.setAttribute('tags', '[\"math\",\"computing\"]');\n host.setAttribute('title', 'Mathematician');\n\n const element = options.render(host);\n\n element.props.onClick();\n\n expect(options.tag).toBe('vyriy-profile-card');\n expect(renderElements.root).toBeInstanceOf(HTMLDivElement);\n expect(renderElements.elements[0]).toBeInstanceOf(HTMLLinkElement);\n expect((renderElements.elements[0] as HTMLLinkElement).href).toBe('http://localhost:3002/main.css');\n expect(element.props.tags).toEqual(['math', 'computing']);\n expect(dispatchProfileCardSelectEventMock).toHaveBeenCalledWith(host, {\n avatarUrl: 'https://example.com/avatar.png',\n name: 'Ada Lovelace',\n role: 'Mathematician',\n });\n expect(dispatchProfileCardAnalyticsEventMock).toHaveBeenCalledWith(host, {\n avatarUrl: 'https://example.com/avatar.png',\n name: 'Ada Lovelace',\n role: 'Mathematician',\n });\n });\n\n it('ignores missing and invalid tags attributes', () => {\n const host = document.createElement('vyriy-profile-card');\n\n expect(options.render(host).props.tags).toBeUndefined();\n\n host.setAttribute('tags', 'not json');\n\n expect(options.render(host).props.tags).toBeUndefined();\n\n host.setAttribute('tags', '{\"tag\":\"math\"}');\n\n expect(options.render(host).props.tags).toBeUndefined();\n });\n\n it('falls back to empty profile values when attributes are missing', () => {\n const host = document.createElement('vyriy-profile-card');\n const element = options.render(host);\n\n element.props.onClick();\n\n expect(dispatchProfileCardSelectEventMock).toHaveBeenLastCalledWith(host, {\n avatarUrl: null,\n name: '',\n role: undefined,\n });\n });\n});\n",
77
- 'workspaces/ui/index.tsx': "import { customElement } from '@vyriy/render/custom-element';\n\nimport { getUi } from '@p/env';\nimport { dispatchProfileCardAnalyticsEvent, dispatchProfileCardSelectEvent } from '@p/event';\n\nimport { ProfileCard } from '@p/components/profile-card';\nimport '@p/components/styles.scss';\n\nconst parseJsonAttribute = (value: string | null): string[] | undefined => {\n if (!value) {\n return undefined;\n }\n\n try {\n const parsedValue: unknown = JSON.parse(value);\n\n if (Array.isArray(parsedValue) && parsedValue.every((item) => typeof item === 'string')) {\n return parsedValue;\n }\n } catch {\n return undefined;\n }\n\n return undefined;\n};\n\nconst getProfileCardSelectDetail = (el: HTMLElement) => ({\n avatarUrl: el.getAttribute('avatarUrl'),\n name: el.getAttribute('name') ?? '',\n role: el.getAttribute('title') ?? undefined,\n});\n\ncustomElement({\n tag: 'vyriy-profile-card',\n elements: () => {\n const link = document.createElement('link');\n const container = document.createElement('div');\n\n link.rel = 'stylesheet';\n link.href = `${getUi()}/main.css`;\n\n return {\n elements: [link, container],\n root: container,\n };\n },\n render: (el) => (\n <ProfileCard\n avatarUrl={el.getAttribute('avatarUrl') ?? ''}\n description={el.getAttribute('description') ?? ''}\n name={el.getAttribute('name') ?? ''}\n onClick={() => {\n const detail = getProfileCardSelectDetail(el);\n\n dispatchProfileCardSelectEvent(el, detail);\n dispatchProfileCardAnalyticsEvent(el, detail);\n }}\n tags={parseJsonAttribute(el.getAttribute('tags'))}\n title={el.getAttribute('title') ?? ''}\n />\n ),\n});\n",
315
+ 'workspaces/ui/index.test.tsx': `import { beforeAll, describe, expect, it, jest } from '@jest/globals';
316
+ import type { ReactElement } from 'react';
317
+
318
+ type CustomElementOptions = {
319
+ tag: string;
320
+ elements: () => {
321
+ elements: HTMLElement[];
322
+ root: HTMLElement;
323
+ };
324
+ render: (el: HTMLElement) => ReactElement<{
325
+ onClick: () => void;
326
+ tags?: string[];
327
+ }>;
328
+ };
329
+
330
+ const customElementMock = jest.fn();
331
+ const dispatchProfileCardAnalyticsEventMock = jest.fn();
332
+ const dispatchProfileCardSelectEventMock = jest.fn();
333
+ let options: CustomElementOptions;
334
+
335
+ jest.mock('@vyriy/render/custom-element', () => ({
336
+ customElement: customElementMock,
337
+ }));
338
+
339
+ jest.mock('@p/event', () => ({
340
+ dispatchProfileCardAnalyticsEvent: dispatchProfileCardAnalyticsEventMock,
341
+ dispatchProfileCardSelectEvent: dispatchProfileCardSelectEventMock,
342
+ }));
343
+
344
+ describe('workspaces/ui/index.tsx', () => {
345
+ beforeAll(async () => {
346
+ process.env.UI = 'http://localhost:3002';
347
+
348
+ await import('./index.js');
349
+
350
+ [options] = (customElementMock.mock.calls[0] ?? []) as [CustomElementOptions];
351
+ });
352
+
353
+ it('registers the profile-card custom element with event dispatching', () => {
354
+ const renderElements = options.elements();
355
+ const host = document.createElement('vyriy-profile-card');
356
+
357
+ host.setAttribute('avatarUrl', 'https://example.com/avatar.png');
358
+ host.setAttribute('description', 'Profile description');
359
+ host.setAttribute('name', 'Ada Lovelace');
360
+ host.setAttribute('tags', '["math","computing"]');
361
+ host.setAttribute('title', 'Mathematician');
362
+
363
+ const element = options.render(host);
364
+
365
+ element.props.onClick();
366
+
367
+ expect(options.tag).toBe('vyriy-profile-card');
368
+ expect(renderElements.root).toBeInstanceOf(HTMLDivElement);
369
+ expect(renderElements.elements[0]).toBeInstanceOf(HTMLLinkElement);
370
+ expect((renderElements.elements[0] as HTMLLinkElement).href).toBe('http://localhost:3002/main.css');
371
+ expect(element.props.tags).toEqual(['math', 'computing']);
372
+ expect(dispatchProfileCardSelectEventMock).toHaveBeenCalledWith(host, {
373
+ avatarUrl: 'https://example.com/avatar.png',
374
+ name: 'Ada Lovelace',
375
+ role: 'Mathematician',
376
+ });
377
+ expect(dispatchProfileCardAnalyticsEventMock).toHaveBeenCalledWith(host, {
378
+ avatarUrl: 'https://example.com/avatar.png',
379
+ name: 'Ada Lovelace',
380
+ role: 'Mathematician',
381
+ });
382
+ });
383
+
384
+ it('ignores missing and invalid tags attributes', () => {
385
+ const host = document.createElement('vyriy-profile-card');
386
+
387
+ expect(options.render(host).props.tags).toBeUndefined();
388
+
389
+ host.setAttribute('tags', 'not json');
390
+
391
+ expect(options.render(host).props.tags).toBeUndefined();
392
+
393
+ host.setAttribute('tags', '{"tag":"math"}');
394
+
395
+ expect(options.render(host).props.tags).toBeUndefined();
396
+ });
397
+
398
+ it('falls back to empty profile values when attributes are missing', () => {
399
+ const host = document.createElement('vyriy-profile-card');
400
+ const element = options.render(host);
401
+
402
+ element.props.onClick();
403
+
404
+ expect(dispatchProfileCardSelectEventMock).toHaveBeenLastCalledWith(host, {
405
+ avatarUrl: null,
406
+ name: '',
407
+ role: undefined,
408
+ });
409
+ });
410
+ });
411
+ `,
412
+ 'workspaces/ui/index.tsx': `import { customElement } from '@vyriy/render/custom-element';
413
+
414
+ import { dispatchProfileCardAnalyticsEvent, dispatchProfileCardSelectEvent } from '@p/event';
415
+
416
+ import { ProfileCard } from '@p/components/profile-card';
417
+ import '@p/components/styles.scss';
418
+
419
+ const parseJsonAttribute = (value: string | null): string[] | undefined => {
420
+ if (!value) {
421
+ return undefined;
422
+ }
423
+
424
+ try {
425
+ const parsedValue: unknown = JSON.parse(value);
426
+
427
+ if (Array.isArray(parsedValue) && parsedValue.every((item) => typeof item === 'string')) {
428
+ return parsedValue;
429
+ }
430
+ } catch {
431
+ return undefined;
432
+ }
433
+
434
+ return undefined;
435
+ };
436
+
437
+ const getProfileCardSelectDetail = (el: HTMLElement) => ({
438
+ avatarUrl: el.getAttribute('avatarUrl'),
439
+ name: el.getAttribute('name') ?? '',
440
+ role: el.getAttribute('title') ?? undefined,
441
+ });
442
+
443
+ customElement({
444
+ tag: 'vyriy-profile-card',
445
+ elements: () => {
446
+ const link = document.createElement('link');
447
+ const container = document.createElement('div');
448
+
449
+ link.rel = 'stylesheet';
450
+ link.href = \`\${process.env.UI}/main.css\`;
451
+
452
+ return {
453
+ elements: [link, container],
454
+ root: container,
455
+ };
456
+ },
457
+ render: (el) => (
458
+ <ProfileCard
459
+ avatarUrl={el.getAttribute('avatarUrl') ?? ''}
460
+ description={el.getAttribute('description') ?? ''}
461
+ name={el.getAttribute('name') ?? ''}
462
+ onClick={() => {
463
+ const detail = getProfileCardSelectDetail(el);
464
+
465
+ dispatchProfileCardSelectEvent(el, detail);
466
+ dispatchProfileCardAnalyticsEvent(el, detail);
467
+ }}
468
+ tags={parseJsonAttribute(el.getAttribute('tags'))}
469
+ title={el.getAttribute('title') ?? ''}
470
+ />
471
+ ),
472
+ });
473
+ `,
78
474
  'workspaces/ui/package.json': '{\n "name": "@w/ui",\n "type": "module",\n "private": true\n}\n',
79
- 'workspaces/ui/README.md': '# @w/ui\n\nDemo entry point.\n',
475
+ 'workspaces/ui/README.md': `# UI
476
+
477
+ Browser workspace for the \`vyriy-profile-card\` custom element.
478
+
479
+ ## Runtime
480
+
481
+ The entry point registers the custom element and renders \`ProfileCard\` inside its shadow root. The element reads these attributes:
482
+
483
+ - \`name\`
484
+ - \`title\`
485
+ - \`description\`
486
+ - \`avatarUrl\`
487
+ - \`tags\`, as a JSON string array
488
+
489
+ Clicking the rendered profile card dispatches \`vyriy-profile-card.select\` and \`openmfe.analytics\`.
490
+
491
+ ## Local Development
492
+
493
+ \`\`\`bash
494
+ yarn start:ui
495
+ \`\`\`
496
+
497
+ The start script loads \`workspaces/env.sh\`, starts webpack dev server on \`UI_PORT\`, and opens the generated demo page.
498
+
499
+ Default local URL:
500
+
501
+ \`\`\`text
502
+ http://localhost:3002
503
+ \`\`\`
504
+
505
+ ## Build
506
+
507
+ \`\`\`bash
508
+ yarn build:ui
509
+ \`\`\`
510
+
511
+ The build writes \`index.js\`, \`main.css\`, and the generated demo HTML into \`dist/cdn\`.
512
+ `,
80
513
  'workspaces/ui/webpack.config.ts': "import { EnvironmentPlugin } from 'webpack';\n\nimport { csr, html } from '@vyriy/webpack-config';\nimport { path } from '@vyriy/path';\n\nexport default csr(\n '@w/ui',\n {\n path: path('dist', 'cdn'),\n filename: 'index.js',\n },\n (config) => ({\n ...config,\n plugins: [\n ...(config.plugins ?? []),\n new EnvironmentPlugin(['API', 'CDN', 'UI']),\n html(\n {\n htmlAttributes: 'lang=\"en\"',\n title: '<title>Demo</title>',\n meta: '<meta charset=\"utf-8\" /><meta name=\"viewport\" content=\"width=device-width, initial-scale=1\" />',\n body: '<vyriy-profile-card name=\"Developer\" title=\"Senior IT Professional\" avatarUrl=\"http://localhost:3001/avatar.svg\"></vyriy-profile-card>',\n script: [\n '<script defer=\"defer\" src=\"/index.js\"></script>',\n [\n '<script type=\"module\">',\n \"const card = document.querySelector('vyriy-profile-card');\",\n \"card.addEventListener('vyriy-profile-card.select', (event) => {\",\n \" console.log('UI demo event:', event.detail);\",\n '});',\n '</scr' + 'ipt>',\n ].join(''),\n ].join(''),\n },\n { inject: false },\n ),\n ],\n }),\n);\n",
81
514
  };
82
515
  export const mfe = (options) => ({
@@ -276,7 +709,49 @@ export default {
276
709
  'packages/components/profile-tags/README.md': "# ProfileTags\n\n`ProfileTags` renders a list of profile tags using `Badge`.\n\n## Usage\n\n```tsx\nimport { ProfileTags } from './profile-tags.js';\n\nexport const Example = () => <ProfileTags tags={['React', 'TypeScript']} />;\n```\n\n## Props\n\n```ts\nexport type ProfileTagsProps = {\n tags: string[];\n tone?: BadgeProps['tone'];\n} & ComponentProps<'ul'>;\n```\n\n## Accessibility\n\nTags are rendered as a semantic `<ul>` with one `<li>` per tag.\n\n## Notes\n\n- Empty tag arrays render `null`.\n- SSR/SSG-safe.\n- Shared SCSS styles.\n",
277
710
  'packages/components/profile-tags/styles.scss': '.profile-tags {\n display: flex;\n flex-wrap: wrap;\n gap: 0.4rem;\n margin: 0;\n padding: 0;\n list-style: none;\n}\n\n.profile-tags__item {\n display: inline-flex;\n}\n',
278
711
  'packages/components/profile-tags/types.ts': "import type { ComponentProps, FC } from 'react';\n\nimport type { BadgeProps } from '../badge/index.js';\n\n/** Props for the ProfileTags component. */\nexport type ProfileTagsProps = {\n tags: string[];\n tone?: BadgeProps['tone'];\n} & ComponentProps<'ul'>;\n\n/** ProfileTags component type. */\nexport type ProfileTagsType = FC<ProfileTagsProps>;\n",
279
- 'packages/components/README.md': '# @p/components\n\nReusable React primitives for the profile-card microfrontend.\n\n## Exports\n\nThe package exports the public profile-card component set:\n\n- `Avatar`\n- `Badge`\n- `ButtonLink`\n- `Card`\n- `IconLink`\n- `ProfileCard`\n- `ProfileDetails`\n- `ProfileHeader`\n- `ProfileLinks`\n- `ProfileMeta`\n- `ProfileTags`\n\nEach component has a focused README, Storybook docs, stories, and unit tests in its own folder.\n',
712
+ 'packages/components/README.md': `# Components
713
+
714
+ Reusable React primitives for the profile-card microfrontend.
715
+
716
+ ## Exports
717
+
718
+ The package exports the public profile-card component set:
719
+
720
+ - \`Avatar\`
721
+ - \`Badge\`
722
+ - \`ButtonLink\`
723
+ - \`Card\`
724
+ - \`IconLink\`
725
+ - \`ProfileCard\`
726
+ - \`ProfileDetails\`
727
+ - \`ProfileHeader\`
728
+ - \`ProfileLinks\`
729
+ - \`ProfileMeta\`
730
+ - \`ProfileTags\`
731
+
732
+ Each component also exports its public prop and component types from its folder entry point.
733
+
734
+ ## Usage
735
+
736
+ \`\`\`tsx
737
+ import { ProfileCard } from '@p/components';
738
+ import '@p/components/styles.scss';
739
+
740
+ export const Example = () => (
741
+ <ProfileCard
742
+ avatarUrl="/avatar.svg"
743
+ description="First computer programmer."
744
+ name="Ada Lovelace"
745
+ tags={['math', 'computing']}
746
+ title="Mathematician"
747
+ />
748
+ );
749
+ \`\`\`
750
+
751
+ ## Component Docs
752
+
753
+ Each component has a focused README, Storybook docs, stories, and unit tests in its own folder. Use those folder READMEs for prop-level details and supported visual states.
754
+ `,
280
755
  'packages/components/styles.d.ts': "declare module '*.scss';\ndeclare module '*.scss?inline' {\n const css: string;\n export default css;\n}\ndeclare module '*.svg' {\n const src: string;\n export default src;\n}\n",
281
756
  'packages/components/styles.scss': "@use './avatar/styles' as avatar;\n@use './badge/styles' as badge;\n@use './button-link/styles' as button-link;\n@use './card/styles' as card;\n@use './icon-link/styles' as icon-link;\n@use './profile-card/styles' as profile-card;\n@use './profile-details/styles' as profile-details;\n@use './profile-header/styles' as profile-header;\n@use './profile-links/styles' as profile-links;\n@use './profile-meta/styles' as profile-meta;\n@use './profile-tags/styles' as profile-tags;\n",
282
757
  'packages/components/package.json': JSON.stringify({
@@ -354,18 +829,21 @@ export default {
354
829
  'npm-run-all2': packageJson.peerDependencies['npm-run-all2'],
355
830
  prettier: packageJson.peerDependencies['prettier'],
356
831
  rimraf: packageJson.peerDependencies['rimraf'],
357
- serve: packageJson.peerDependencies['serve'],
358
832
  storybook: packageJson.peerDependencies['storybook'],
359
833
  stylelint: packageJson.peerDependencies['stylelint'],
360
834
  tsx: packageJson.peerDependencies['tsx'],
361
835
  typescript: packageJson.peerDependencies['typescript'],
362
836
  webpack: packageJson.peerDependencies['webpack'],
363
837
  'webpack-cli': packageJson.peerDependencies['webpack-cli'],
838
+ '@vyriy/static': `^${packageJson.version}`,
364
839
  },
365
840
  }, null, 2) + '\n',
366
- 'README.md': `# ${options.name}
841
+ 'README.md': `# MFE
367
842
 
368
- ${options.description}
843
+ Profile-card microfrontend starter for Vyriy and OpenMFE-oriented development.
844
+
845
+ The repository is split into reusable packages and runnable workspaces. Packages own typed component, API, event, query, and environment behavior.
846
+ Workspaces compose those packages into the local API server, static asset origin, and browser custom element build.
369
847
 
370
848
  ## Setup
371
849
 
@@ -373,6 +851,17 @@ ${options.description}
373
851
  yarn install
374
852
  \`\`\`
375
853
 
854
+ ## Project Structure
855
+
856
+ - \`packages/api\` builds demo HTML, prerendered custom element markup, JSON-LD, and the OpenMFE manifest.
857
+ - \`packages/components\` provides the React profile-card component set.
858
+ - \`packages/env\` reads required runtime environment values.
859
+ - \`packages/event\` dispatches typed profile-card selection and analytics events.
860
+ - \`packages/query\` parses API query strings into profile-card props.
861
+ - \`workspaces/api\` serves the demo, prerender, semantic, and manifest endpoints.
862
+ - \`workspaces/static\` serves CDN assets such as the avatar, manifest icon, and screenshots with \`@vyriy/static\`.
863
+ - \`workspaces/ui\` registers the \`vyriy-profile-card\` custom element and builds browser assets.
864
+
376
865
  ## Start
377
866
 
378
867
  Start the API, static asset server, and UI dev server together:
@@ -391,12 +880,17 @@ yarn start:ui
391
880
 
392
881
  ## Local URLs
393
882
 
394
- Default ports are defined in \`workspaces/env.sh\`:
883
+ Default ports and origins are defined in \`workspaces/env.sh\`:
395
884
 
396
885
  - API: \`http://localhost:3000\`
397
886
  - Static/CDN assets: \`http://localhost:3001\`
398
887
  - UI dev server: \`http://localhost:3002\`
399
888
 
889
+ Default runtime values:
890
+
891
+ - \`TAG=vyriy-profile-card\`
892
+ - \`MODE=open\`
893
+
400
894
  Useful API URLs:
401
895
 
402
896
  - Demo HTML: \`http://localhost:3000/\`
@@ -404,18 +898,54 @@ Useful API URLs:
404
898
  - Semantic JSON-LD: \`http://localhost:3000/semantic?name=Developer&title=Senior%20IT%20Professional&avatarUrl=http://localhost:3001/avatar.svg\`
405
899
  - Manifest: \`http://localhost:3000/manifest.yml\`
406
900
 
901
+ \`/prerender\` and \`/semantic\` require \`name\` and accept optional \`title\`, \`description\`, \`avatarUrl\`, and comma-separated \`tags\`.
902
+
903
+ ## Static Assets
904
+
905
+ Static files are served with \`@vyriy/static\`. The package exposes the \`vs\` command, so a globally installed copy can serve any static directory with a small command:
906
+
907
+ \`\`\`bash
908
+ vs -p 3001 workspaces/static/public
909
+ \`\`\`
910
+
911
+ In this project, \`yarn start:static\` runs the same static server through \`npx vs\` and the \`CDN_PORT\` value from \`workspaces/env.sh\`.
912
+
913
+ ## Build
914
+
915
+ \`\`\`bash
916
+ yarn build
917
+ \`\`\`
918
+
919
+ The build writes server output to \`dist/api\` and browser/static CDN output to \`dist/cdn\`.
920
+
407
921
  ## Validation
408
922
 
923
+ \`\`\`bash
924
+ yarn check
925
+ \`\`\`
926
+
927
+ Focused validation commands:
928
+
409
929
  \`\`\`bash
410
930
  yarn lint
411
931
  yarn test
412
932
  yarn build
413
933
  \`\`\`
934
+
935
+ ## Project Guidance
936
+
937
+ These articles describe the development approach behind this preset and provide practical guidance for evolving a project on top of it:
938
+
939
+ - [Calm Development Environment: Node.js, Corepack, Yarn and Static Preview](https://vyriy.dev/blog/calm-development-setup/) - how to keep the local development environment predictable and easy to reproduce.
940
+ - [Calm App Structure for the Vyriy Ecosystem](https://vyriy.dev/blog/vyriy-calm-app-structure/) - a practical project structure for Vyriy applications: shared configs, small packages, thin workspaces, Storybook docs, tests, and deployable entry points.
941
+ - [One Handler, Many Runtimes](https://vyriy.dev/examples/one-handler-many-runtimes/) - how @vyriy/handler, @vyriy/router, and @vyriy/server compose a calm Lambda-compatible API that can run locally, in Docker, Fargate-style HTTP runtimes, and AWS Lambda.
942
+ - [Calm Component Structure](https://vyriy.dev/blog/calm-component-structure/) - how to organize component code, tests, stories, and public exports.
943
+ - [Storybook as Project Documentation](https://vyriy.dev/blog/storybook-as-project-documentation/) - how to use Storybook as living project documentation and a component playground.
414
944
  `,
415
945
  'doc.mdx': `import { Meta, Markdown } from '@storybook/addon-docs/blocks';
416
946
  import ReadMe from './README.md?raw';
417
947
 
418
- <Meta title="${options.name}" />
948
+ <Meta title="MFE" />
419
949
 
420
950
  <Markdown>{ReadMe}</Markdown>
421
951
  `,