{"schemaVersion":1,"slug":"subapp","kind":"starter","version":"0.1.0","files":[{"path":".gitignore","sha256":"17f54081f1f2833beec41a97a779072c85e9ae928cb236d0fd4ddc141a47894d","content":"node_modules/\n.env\n.env.*\n!.env.example\n.DS_Store\ncoverage/\n"},{"path":"AGENTS.md","sha256":"1d591bd02e91bc5e8c0ab722e9328231ec305f8f53fdd5a9ff3f1f347595de9c","content":"# Sub-application\n\nThis entry owns an activity section. The host owns navigation, global styling, routing and production promotion. Read the [shared engineering guides](engineering/README.md) for the relevant change.\n\nMount the default React component in [src/index.mjs](src/index.mjs) through the host's modules array. It receives the host's resolved productName, theme and locale in a config prop and can render alone using local defaults. Keep child-specific options scoped to this entry and coordinate changes to the config contract with host maintainers.\n\nRun npm install, npm test and npm run preview in this directory for isolated checks. Record the child version and its compatible host contract. To release, hand the reviewed child version to the host, update its import or pinned package version and verify the mounted section in host preview. Revert that selection to roll back the child. The local preview does not promote the host.\n\nThe [child manifest](layq-manifest.json) declares the module path relative to this directory, the React export, capabilities, inherited settings and local commands. From the child root, use `npm run release:check` to run the complete suite and inspect the package file list. Review that list before handing the release candidate to the host.\n"},{"path":"design-tokens.css","sha256":"149e171e5d7301b4c4b93b7174952ecb5e152fb53afe940058e8194fc3e5caa6","content":":root {\n  --layq-ink: #182027;\n  --layq-primary: #1b232b;\n  --layq-primary-hover: #37444f;\n  --layq-paper: #f7f9fa;\n  --layq-line: #d6dce1;\n  --layq-accent: #415e75;\n  --layq-accent-hover: #2e4a61;\n  --layq-accent-soft: #e6edf2;\n  --layq-accent-on-dark: #b7cbdc;\n  --layq-muted: #4a5c69;\n  --layq-border-strong: #8294a4;\n  --layq-focus: #426986;\n}\n"},{"path":"engineering/database.md","sha256":"6c7943a97cfcad8bb5f482c3a671f92fa1f0fbb1ec7a8a0f6aa7774017968037","content":"# Database\n\nThe generated SaaS host uses a local SQLite file for its workspace. The standalone child requires no database. External database services and credentials are optional. When a feature needs persistence, document the schema owner, tables, keys, relationships and constraints. Keep ordered migration files in version control with the code that reads them.\n\nUse independent local, preview and production databases and separate credentials. Validate a migration on a disposable database with representative synthetic data. For destructive changes, use an expand/backfill/contract sequence and record the recovery point. Rehearse rollback through a down migration where safe, a corrective migration, or restoration of a verified backup. Record the compatibility window for older application versions.\n"},{"path":"engineering/git.md","sha256":"d4d3ac96ca43d15c99c333925ce7dbcc454dba62dff029bb7a65f91b645ea767","content":"# Git\n\nBranch from the intended base using a descriptive name such as feature/activity-view. Keep a behavior change and its checks together. Use imperative commit subjects and explain compatibility or migration decisions in the body.\n\nFor review, list the user-visible change, the affected host or child entry, checks actually run and any rollout steps. Keep credentials and local environment files out of commits. Record breaking changes in the version's change notes before tagging.\n"},{"path":"engineering/i18n.md","sha256":"72a7142a8ed0e20f1f651e15d77d9b8d0e0cdc43e2f19eeea20bf2c52e3aa983","content":"# Internationalization\n\nEnglish is the fallback. Ship changes to English, Simplified Chinese, Spanish and Japanese in the same change. Translate field labels, validation, status messages, keyboard instructions and accessible names alongside the visible controls. Keep IDs, field names and commands stable across languages.\n\nFor the portable preview and activity component, edit src/locales.mjs. Use named keys and a full sentence with the {productName} placeholder so each language controls word order. Add language names and update the child manifest when the supported set changes. The Next host's page catalog lives in app/messages.mjs. Pass the resolved locale to each child in config.locale.\n\nRun `npm run test:unit` to check locale key coverage, placeholders and the English fallback. Run `npm run test:smoke` to check language links, localized document titles and missing-route responses through HTTP. Then open the host workspace and verify the mounted section follows its language selector.\n\nUse Intl for dates, currencies and numbers. Test a long translation at a 390 CSS-pixel viewport, an unsupported locale and one validation error. In the host, also exercise a sign-in message and a workspace action in the selected language.\n"},{"path":"engineering/README.md","sha256":"fd1eb85bb633d7f372dc0fab5c3255c441ce67942e5da35c834d05922eae636e","content":"# Engineering skills\n\nThese portable project guides can be read by a developer, Codex, or Claude Code. Open the guide that applies to the change. They are ordinary Markdown and require no agent installation.\n\n- [Spec](spec.md) defines scope and acceptance cases.\n- [Git](git.md) records a reviewable change.\n- [Database](database.md) covers optional persistent storage.\n- [Test](test.md) checks behavior at three levels.\n- [Release](release.md) prepares a version and rollback.\n- [Internationalization](i18n.md) keeps the host and its children consistent across four languages.\n"},{"path":"engineering/release.md","sha256":"6ecd46d8d234e2272956df5d7c1866c2d2d5861faafb3b4c2099796ce0ca5c34","content":"# Release\n\nRun `npm test` from the project root. For a SaaS host, use `npm run dev` for the local workspace, then `npm run build` and `npm start` to inspect the production build locally. For a child, use `npm run preview` for the isolated module. The local servers bind to loopback. Set PORT to choose another port. Keep any future secret values outside source control and document each variable's purpose and required environments.\n\nRecord the version in package.json and note user-visible changes and compatibility requirements. Verify the exact candidate with preview-specific configuration. Keep the previous version, its config contract and any migration recovery steps available.\n\nProduction promotion is a separate operator decision. Deploy the reviewed version through the consuming team's hosting process, smoke-test it and record the version. To roll back, restore the last verified version and compatible configuration, then repeat the smoke check. Coordinate database recovery before rolling back across a schema change.\n\n## Verifiable release receipt\n\nKeep a dated receipt in the consuming team's release records. Identify the component, environment, operator and version (`node -p \"require('./package.json').version\"`). Record the full source commit from `git rev-parse HEAD` and check `git status --short` for uncommitted inputs. Run `npm run release:check` from the project root. For the host this runs the suite and builds the Next application. For a child it runs the suite and lists package contents locally. For an actual release artifact, record its checksum and retain the artifact or immutable retrieval reference.\n\n| State | Evidence to collect |\n| --- | --- |\n| Registered | The candidate version and commit appear together in the chosen release ledger. Read the entry back and record its identifier. |\n| Published | The intended destination serves the selected version. Retrieve its immutable artifact or deployment metadata, compare the checksum or source revision and record the destination and timestamp. |\n| Health passed | Request a real route on that published version. Record the environment, URL, timestamp, HTTP status and expected content or behavior observed. For a child, check its mounted section in the host. |\n\nA local dry run supports preflight only. Mark each state pending until its evidence exists. To roll back, record the previous verified receipt, restore its exact artifact and configuration through the operator's normal process, and verify the live revision and route again. Append the outcome and timestamps to the receipt so the superseded version remains traceable.\n"},{"path":"engineering/spec.md","sha256":"92de7b7c08e6fc078d4ad0588af26c43589a937505feaa009d6ee745b81ed355","content":"# Spec\n\nBefore changing behavior, write the user outcome, current limitation and observable goal in the change description. List non-goals so reviewers can identify work outside the change.\n\nExpress each acceptance case as a starting state, an action and an observable result. Include an ordinary path and a failure or empty state. For a configuration change, pass the host a dark theme and verify the mounted entry inherits it. Record the command or manual steps that demonstrate each case.\n"},{"path":"engineering/test.md","sha256":"b15b1c3782403a1be30e411eef2f392e1d969b53e2c2095e8886b5ee23dfd055","content":"# Test\n\nUse the Node version declared by the generated project's package.json. Run npm ci when a lockfile is present or npm install to create one. Commit the resulting lockfile.\n\n| Check | What to verify |\n| --- | --- |\n| Unit | Run `npm run test:unit` for isolated functions and rejected input. |\n| Integration | Run `npm run test:integration` to verify module boundaries and supplied configuration. |\n| Smoke | Run `npm run test:smoke` to exercise the project entry and its expected response. |\n| Local suite | Run `npm test` from the project root. See the entry's README or AGENTS.md for setup. |\n\nFor a host contract change, mount each affected child under the host and check its rendered output. From the generated host, run `npm --prefix modules/activity test` to isolate the bundled child. Run the host checks and verify its workspace also displays that module. For a child-only change, start with its own unit, integration and smoke suites before checking the host preview.\n\nFollow the [internationalization guide](i18n.md) when a change affects user-facing text.\n"},{"path":"layq-manifest.json","sha256":"bee738816d85351f59104403f537ed83cd09c38313fed705662a128e741cb6ff","content":"{\n  \"manifestVersion\": 1,\n  \"id\": \"subapp\",\n  \"entry\": \"./src/index.mjs\",\n  \"export\": \"default\",\n  \"capabilities\": [\n    \"render-activity-section\"\n  ],\n  \"inherits\": [\n    \"productName\",\n    \"theme\",\n    \"locale\"\n  ],\n  \"locales\": [\n    \"en\",\n    \"zh-CN\",\n    \"es\",\n    \"ja\"\n  ],\n  \"fallbackLocale\": \"en\",\n  \"commands\": {\n    \"test\": \"npm test\",\n    \"releasePreflight\": \"npm run release:check\"\n  }\n}\n"},{"path":"package.json","sha256":"17c28115fb917609d707108aafb8fe31e327ac9d35e240e6821f0b88f79a2176","content":"{\n  \"name\": \"layq-subapp-subapp\",\n  \"version\": \"0.1.0\",\n  \"private\": true,\n  \"type\": \"module\",\n  \"exports\": \"./src/index.mjs\",\n  \"engines\": {\n    \"node\": \">=20\"\n  },\n  \"scripts\": {\n    \"release:check\": \"npm test && npm pack --dry-run --ignore-scripts\",\n    \"preview\": \"node preview.mjs\",\n    \"test\": \"node --test test/*.test.mjs\",\n    \"test:unit\": \"node --test test/unit.test.mjs\",\n    \"test:integration\": \"node --test test/integration.test.mjs\",\n    \"test:smoke\": \"node --test test/smoke.test.mjs\"\n  },\n  \"dependencies\": {\n    \"react\": \"^19.2.0\",\n    \"react-dom\": \"^19.2.0\"\n  }\n}\n"},{"path":"preview.mjs","sha256":"2cb15239733b6e3319112e7951936b29399a30772fd62f70880975557fe40a5a","content":"import { createServer } from 'node:http';\nimport { resolve } from 'node:path';\nimport { pathToFileURL } from 'node:url';\nimport { createElement } from 'react';\nimport { renderToStaticMarkup } from 'react-dom/server';\nimport App from './src/index.mjs';\nimport { languageNames, messages, resolveLocale } from './src/locales.mjs';\n\nexport function createPreview(config = {}) {\n  return createServer((request, response) => {\n    const url = new URL(request.url, 'http://localhost');\n    const locale = resolveLocale(url.searchParams.get('lang') ?? config.locale);\n    const t = messages[locale];\n    if (url.pathname !== '/') {\n      response.writeHead(404, { 'content-type': 'text/plain; charset=utf-8', 'content-language': locale }).end(t.missing);\n      return;\n    }\n    const navigation = createElement('nav', { 'aria-label': t.language },\n      Object.entries(languageNames).map(([key, name]) => createElement('a', {\n        key, href: '?lang=' + key, lang: key, 'aria-current': key === locale ? 'page' : undefined\n      }, name + ' '))\n    );\n    const page = createElement('html', { lang: locale },\n      createElement('head', null,\n        createElement('meta', { charSet: 'utf-8' }),\n        createElement('meta', { name: 'viewport', content: 'width=device-width,initial-scale=1' }),\n        createElement('title', null, t.preview)\n      ),\n      createElement('body', null, navigation, createElement(App, { config: { ...config, locale } }))\n    );\n    response.writeHead(200, { 'content-type': 'text/html; charset=utf-8', 'content-language': locale });\n    response.end('<!doctype html>' + renderToStaticMarkup(page));\n  });\n}\nif (process.argv[1] && pathToFileURL(resolve(process.argv[1])).href === import.meta.url) {\n  const server = createPreview();\n  server.listen(Number(process.env.PORT || 4173), '127.0.0.1', () => {\n    console.log('Preview at http://127.0.0.1:' + server.address().port);\n  });\n}\n"},{"path":"README.md","sha256":"fb30b8fe094fa4d07fabe5a2b7153958138dae87ed60a3dbd3f4781cf512d7ca","content":"# Activity module\n\nMount the default React export from src/index.mjs with a config object containing productName, theme and locale. It supports English (en), Simplified Chinese (zh-CN), Spanish (es) and Japanese (ja). Missing or unsupported locales use English. The optional labels prop can override heading and updates. Use the {productName} placeholder in a full translated sentence to preserve word order.\n\nRun `npm install`, `npm test` and `npm run preview` in this directory. Select a language using the links in the preview, or open /?lang=ja directly. See the [engineering guides](engineering/README.md) and [machine-readable contract](layq-manifest.json).\n"},{"path":"src/config.mjs","sha256":"fbb9e32c0286901e90212980db8fb8c659717f1b67e9e39ff8c9ff8187e15c9e","content":"import { messages, resolveLocale } from './locales.mjs';\n\nexport function resolveConfig(config = {}) {\n  const theme = config.theme ?? 'light';\n  if (!['light', 'dark'].includes(theme)) throw new Error('Theme must be light or dark.');\n  const locale = resolveLocale(config.locale);\n  return { theme, locale, productName: config.productName ?? messages[locale].workspace };\n}\n"},{"path":"src/index.mjs","sha256":"9b08beccf8150c63d0520c8fb4c2b23b43aeaefcd4ae0e9d2eff6ec3ed8dae64","content":"import { createElement as h } from 'react';\nimport { resolveConfig } from './config.mjs';\nimport { messages } from './locales.mjs';\n\nexport default function SubApp({ config: hostConfig, labels } = {}) {\n  const config = resolveConfig(hostConfig);\n  const heading = labels?.heading ?? messages[config.locale].heading;\n  const template = labels?.updates ?? messages[config.locale].updates;\n  const updates = template.includes('{productName}')\n    ? template.replace('{productName}', () => config.productName)\n    : template + ' ' + config.productName;\n  return h('section', { 'aria-label': heading, lang: config.locale, 'data-theme': config.theme },\n    h('h2', null, heading),\n    h('p', null, updates)\n  );\n}\n"},{"path":"src/locales.mjs","sha256":"dda2f7dc391015014320052bc6527d6a9783710875ff2b2c8b62167483064119","content":"export const messages = {\n  en: {\n    heading: 'Activity', updates: 'Updates for {productName}', workspace: 'Workspace',\n    preview: 'App preview', missing: 'Page not found', language: 'Language'\n  },\n  'zh-CN': {\n    heading: '动态', updates: '{productName}的最新动态', workspace: '工作区',\n    preview: '应用预览', missing: '找不到页面', language: '语言'\n  },\n  es: {\n    heading: 'Actividad', updates: 'Novedades de {productName}', workspace: 'Espacio de trabajo',\n    preview: 'Vista previa', missing: 'Página no encontrada', language: 'Idioma'\n  },\n  ja: {\n    heading: 'アクティビティ', updates: '{productName}の最新情報', workspace: 'ワークスペース',\n    preview: 'アプリのプレビュー', missing: 'ページが見つかりません', language: '言語'\n  }\n};\n\nexport const languageNames = { en: 'English', 'zh-CN': '简体中文', es: 'Español', ja: '日本語' };\nexport function resolveLocale(value) {\n  return typeof value === 'string' && Object.hasOwn(messages, value) ? value : 'en';\n}\n"},{"path":"test/integration.test.mjs","sha256":"e886ed1af43ade22a6393bd06eece17937c3f96a9e3153b6b747fb379a8ac0cd","content":"import test from 'node:test';\nimport assert from 'node:assert/strict';\nimport { createElement } from 'react';\nimport { renderToStaticMarkup } from 'react-dom/server';\nimport App from '../src/index.mjs';\ntest('renders the local entry using the supplied configuration', () => {\n  const html = renderToStaticMarkup(createElement(App, { config: { productName: 'Research & Design', theme: 'dark' } }));\n  assert.match(html, /Research &amp; Design/);\n  assert.match(html, /data-theme=\"dark\"/);\n});\n"},{"path":"test/smoke.test.mjs","sha256":"7e0fbb4842800b6d7cc6786c4262e6e0b200309727b354fe37a9838788352f3d","content":"import test from 'node:test';\nimport assert from 'node:assert/strict';\nimport { once } from 'node:events';\nimport { createPreview } from '../preview.mjs';\ntest('serves the application and a missing-route response', async t => {\n  const server = createPreview();\n  t.after(() => new Promise(resolve => server.close(resolve)));\n  server.listen(0, '127.0.0.1');\n  await once(server, 'listening');\n  const url = 'http://127.0.0.1:' + server.address().port;\n  const page = await fetch(url);\n  assert.equal(page.status, 200);\n  assert.match(await page.text(), /Workspace/);\n  assert.equal((await fetch(url + '/missing')).status, 404);\n});\n\ntest('preview links select each supported locale and translate missing routes', async t => {\n  const { messages } = await import('../src/locales.mjs');\n  const server = createPreview();\n  t.after(() => new Promise(resolve => server.close(resolve)));\n  server.listen(0, '127.0.0.1');\n  await once(server, 'listening');\n  const origin = 'http://127.0.0.1:' + server.address().port;\n  for (const [locale, copy] of Object.entries(messages)) {\n    const page = await fetch(origin + '/?lang=' + locale);\n    assert.equal(page.headers.get('content-language'), locale);\n    const html = await page.text();\n    assert.ok(html.includes('<html lang=\"' + locale + '\">'));\n    assert.ok(html.includes('<title>' + copy.preview + '</title>'));\n    assert.ok(html.includes(copy.workspace));\n    for (const key of Object.keys(messages)) assert.ok(html.includes('href=\"?lang=' + key + '\"'));\n    const missing = await fetch(origin + '/missing?lang=' + locale);\n    assert.equal(missing.status, 404);\n    assert.equal(await missing.text(), copy.missing);\n  }\n  const fallback = await fetch(origin + '/?lang=unknown');\n  assert.equal(fallback.headers.get('content-language'), 'en');\n});\n"},{"path":"test/unit.test.mjs","sha256":"09bf88759e8412280650c297332736605d10a52bb0d37003c2bb193037cea861","content":"import test from 'node:test';\nimport assert from 'node:assert/strict';\nimport { resolveConfig } from '../src/config.mjs';\ntest('validates the theme and fills missing defaults', () => {\n  assert.deepEqual(resolveConfig({ theme: 'dark' }), { theme: 'dark', productName: 'Workspace', locale: 'en' });\n  assert.throws(() => resolveConfig({ theme: 'pink' }), /Theme/);\n});\n\ntest('all locales define each English message and one product-name slot', async () => {\n  const { messages, languageNames, resolveLocale } = await import('../src/locales.mjs');\n  assert.deepEqual(Object.keys(messages).sort(), ['en', 'es', 'ja', 'zh-CN']);\n  for (const [locale, values] of Object.entries(messages)) {\n    assert.equal(resolveLocale(locale), locale);\n    assert.ok(languageNames[locale]);\n    assert.deepEqual(Object.keys(values).sort(), Object.keys(messages.en).sort());\n    assert.ok(Object.values(values).every(value => typeof value === 'string' && value.trim()));\n    assert.equal(values.updates.split('{productName}').length, 2);\n  }\n  for (const unsupported of ['de', undefined, 'constructor']) {\n    assert.equal(resolveLocale(unsupported), 'en');\n  }\n});\n"}]}
