@taggor/contract 0.0.0-stage → 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.
Files changed (343) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +61 -2
  3. package/dist/.tsbuildinfo +1 -0
  4. package/dist/artifact-keys.d.ts +169 -0
  5. package/dist/artifact-keys.d.ts.map +1 -0
  6. package/dist/artifact-keys.js +195 -0
  7. package/dist/artifact-keys.js.map +1 -0
  8. package/dist/assets.d.ts +72 -0
  9. package/dist/assets.d.ts.map +1 -0
  10. package/dist/assets.js +94 -0
  11. package/dist/assets.js.map +1 -0
  12. package/dist/bounded-path.d.ts +29 -0
  13. package/dist/bounded-path.d.ts.map +1 -0
  14. package/dist/bounded-path.js +57 -0
  15. package/dist/bounded-path.js.map +1 -0
  16. package/dist/bounded.d.ts +47 -0
  17. package/dist/bounded.d.ts.map +1 -0
  18. package/dist/bounded.js +93 -0
  19. package/dist/bounded.js.map +1 -0
  20. package/dist/build-diagnostic.d.ts +89 -0
  21. package/dist/build-diagnostic.d.ts.map +1 -0
  22. package/dist/build-diagnostic.js +91 -0
  23. package/dist/build-diagnostic.js.map +1 -0
  24. package/dist/component-types.d.ts +61 -0
  25. package/dist/component-types.d.ts.map +1 -0
  26. package/dist/component-types.js +277 -0
  27. package/dist/component-types.js.map +1 -0
  28. package/dist/consent-text.d.ts +31 -0
  29. package/dist/consent-text.d.ts.map +1 -0
  30. package/dist/consent-text.js +41 -0
  31. package/dist/consent-text.js.map +1 -0
  32. package/dist/contract-version.d.ts +150 -0
  33. package/dist/contract-version.d.ts.map +1 -0
  34. package/dist/contract-version.js +198 -0
  35. package/dist/contract-version.js.map +1 -0
  36. package/dist/credential-fields.d.ts +31 -0
  37. package/dist/credential-fields.d.ts.map +1 -0
  38. package/dist/credential-fields.js +36 -0
  39. package/dist/credential-fields.js.map +1 -0
  40. package/dist/css-tokens.d.ts +46 -0
  41. package/dist/css-tokens.d.ts.map +1 -0
  42. package/dist/css-tokens.js +189 -0
  43. package/dist/css-tokens.js.map +1 -0
  44. package/dist/css-value.d.ts +42 -0
  45. package/dist/css-value.d.ts.map +1 -0
  46. package/dist/css-value.js +78 -0
  47. package/dist/css-value.js.map +1 -0
  48. package/dist/data-api.d.ts +127 -0
  49. package/dist/data-api.d.ts.map +1 -0
  50. package/dist/data-api.js +167 -0
  51. package/dist/data-api.js.map +1 -0
  52. package/dist/denylist-keys.d.ts +19 -0
  53. package/dist/denylist-keys.d.ts.map +1 -0
  54. package/dist/denylist-keys.js +48 -0
  55. package/dist/denylist-keys.js.map +1 -0
  56. package/dist/diagnostic-catalog.d.ts +1402 -0
  57. package/dist/diagnostic-catalog.d.ts.map +1 -0
  58. package/dist/diagnostic-catalog.js +1311 -0
  59. package/dist/diagnostic-catalog.js.map +1 -0
  60. package/dist/dom-members.snapshot.d.ts +33 -0
  61. package/dist/dom-members.snapshot.d.ts.map +1 -0
  62. package/dist/dom-members.snapshot.js +760 -0
  63. package/dist/dom-members.snapshot.js.map +1 -0
  64. package/dist/early-loading.d.ts +27 -0
  65. package/dist/early-loading.d.ts.map +1 -0
  66. package/dist/early-loading.js +44 -0
  67. package/dist/early-loading.js.map +1 -0
  68. package/dist/error-catalog.d.ts +749 -0
  69. package/dist/error-catalog.d.ts.map +1 -0
  70. package/dist/error-catalog.js +720 -0
  71. package/dist/error-catalog.js.map +1 -0
  72. package/dist/executable-config.d.ts +35 -0
  73. package/dist/executable-config.d.ts.map +1 -0
  74. package/dist/executable-config.js +44 -0
  75. package/dist/executable-config.js.map +1 -0
  76. package/dist/freeze.d.ts +17 -0
  77. package/dist/freeze.d.ts.map +1 -0
  78. package/dist/freeze.js +29 -0
  79. package/dist/freeze.js.map +1 -0
  80. package/dist/gunzip.d.ts +33 -0
  81. package/dist/gunzip.d.ts.map +1 -0
  82. package/dist/gunzip.js +330 -0
  83. package/dist/gunzip.js.map +1 -0
  84. package/dist/hostname.d.ts +74 -0
  85. package/dist/hostname.d.ts.map +1 -0
  86. package/dist/hostname.js +215 -0
  87. package/dist/hostname.js.map +1 -0
  88. package/dist/human-actions.d.ts +49 -0
  89. package/dist/human-actions.d.ts.map +1 -0
  90. package/dist/human-actions.js +272 -0
  91. package/dist/human-actions.js.map +1 -0
  92. package/dist/index.d.ts +73 -0
  93. package/dist/index.d.ts.map +1 -0
  94. package/dist/index.js +73 -0
  95. package/dist/index.js.map +1 -0
  96. package/dist/json-schema.d.ts +108 -0
  97. package/dist/json-schema.d.ts.map +1 -0
  98. package/dist/json-schema.js +240 -0
  99. package/dist/json-schema.js.map +1 -0
  100. package/dist/key-checksum.d.ts +33 -0
  101. package/dist/key-checksum.d.ts.map +1 -0
  102. package/dist/key-checksum.js +67 -0
  103. package/dist/key-checksum.js.map +1 -0
  104. package/dist/libraries.d.ts +60 -0
  105. package/dist/libraries.d.ts.map +1 -0
  106. package/dist/libraries.js +120 -0
  107. package/dist/libraries.js.map +1 -0
  108. package/dist/limit-catalog.d.ts +381 -0
  109. package/dist/limit-catalog.d.ts.map +1 -0
  110. package/dist/limit-catalog.js +429 -0
  111. package/dist/limit-catalog.js.map +1 -0
  112. package/dist/limits.d.ts +167 -0
  113. package/dist/limits.d.ts.map +1 -0
  114. package/dist/limits.js +175 -0
  115. package/dist/limits.js.map +1 -0
  116. package/dist/locale-tag.d.ts +21 -0
  117. package/dist/locale-tag.d.ts.map +1 -0
  118. package/dist/locale-tag.js +21 -0
  119. package/dist/locale-tag.js.map +1 -0
  120. package/dist/make-diagnostic.d.ts +74 -0
  121. package/dist/make-diagnostic.d.ts.map +1 -0
  122. package/dist/make-diagnostic.js +100 -0
  123. package/dist/make-diagnostic.js.map +1 -0
  124. package/dist/manifest-compat-diagnostics.d.ts +23 -0
  125. package/dist/manifest-compat-diagnostics.d.ts.map +1 -0
  126. package/dist/manifest-compat-diagnostics.js +150 -0
  127. package/dist/manifest-compat-diagnostics.js.map +1 -0
  128. package/dist/manifest-compat.d.ts +58 -0
  129. package/dist/manifest-compat.d.ts.map +1 -0
  130. package/dist/manifest-compat.js +377 -0
  131. package/dist/manifest-compat.js.map +1 -0
  132. package/dist/manifest.d.ts +1769 -0
  133. package/dist/manifest.d.ts.map +1 -0
  134. package/dist/manifest.js +421 -0
  135. package/dist/manifest.js.map +1 -0
  136. package/dist/metering.d.ts +126 -0
  137. package/dist/metering.d.ts.map +1 -0
  138. package/dist/metering.js +147 -0
  139. package/dist/metering.js.map +1 -0
  140. package/dist/migrate.d.ts +70 -0
  141. package/dist/migrate.d.ts.map +1 -0
  142. package/dist/migrate.js +159 -0
  143. package/dist/migrate.js.map +1 -0
  144. package/dist/money.d.ts +41 -0
  145. package/dist/money.d.ts.map +1 -0
  146. package/dist/money.js +52 -0
  147. package/dist/money.js.map +1 -0
  148. package/dist/names.d.ts +37 -0
  149. package/dist/names.d.ts.map +1 -0
  150. package/dist/names.js +55 -0
  151. package/dist/names.js.map +1 -0
  152. package/dist/overage-pricing.d.ts +89 -0
  153. package/dist/overage-pricing.d.ts.map +1 -0
  154. package/dist/overage-pricing.js +170 -0
  155. package/dist/overage-pricing.js.map +1 -0
  156. package/dist/plan-ids.d.ts +10 -0
  157. package/dist/plan-ids.d.ts.map +1 -0
  158. package/dist/plan-ids.js +8 -0
  159. package/dist/plan-ids.js.map +1 -0
  160. package/dist/plan-limits.d.ts +138 -0
  161. package/dist/plan-limits.d.ts.map +1 -0
  162. package/dist/plan-limits.js +112 -0
  163. package/dist/plan-limits.js.map +1 -0
  164. package/dist/plan-pricing.d.ts +145 -0
  165. package/dist/plan-pricing.d.ts.map +1 -0
  166. package/dist/plan-pricing.js +172 -0
  167. package/dist/plan-pricing.js.map +1 -0
  168. package/dist/plan-usage.d.ts +112 -0
  169. package/dist/plan-usage.d.ts.map +1 -0
  170. package/dist/plan-usage.js +134 -0
  171. package/dist/plan-usage.js.map +1 -0
  172. package/dist/preview-token.d.ts +52 -0
  173. package/dist/preview-token.d.ts.map +1 -0
  174. package/dist/preview-token.js +106 -0
  175. package/dist/preview-token.js.map +1 -0
  176. package/dist/prop-names.d.ts +51 -0
  177. package/dist/prop-names.d.ts.map +1 -0
  178. package/dist/prop-names.js +150 -0
  179. package/dist/prop-names.js.map +1 -0
  180. package/dist/prop-type-docs.d.ts +20 -0
  181. package/dist/prop-type-docs.d.ts.map +1 -0
  182. package/dist/prop-type-docs.js +89 -0
  183. package/dist/prop-type-docs.js.map +1 -0
  184. package/dist/prop-types.d.ts +97 -0
  185. package/dist/prop-types.d.ts.map +1 -0
  186. package/dist/prop-types.js +299 -0
  187. package/dist/prop-types.js.map +1 -0
  188. package/dist/props.d.ts +996 -0
  189. package/dist/props.d.ts.map +1 -0
  190. package/dist/props.js +183 -0
  191. package/dist/props.js.map +1 -0
  192. package/dist/proto-guard.d.ts +29 -0
  193. package/dist/proto-guard.d.ts.map +1 -0
  194. package/dist/proto-guard.js +79 -0
  195. package/dist/proto-guard.js.map +1 -0
  196. package/dist/runtime-errors.d.ts +42 -0
  197. package/dist/runtime-errors.d.ts.map +1 -0
  198. package/dist/runtime-errors.js +42 -0
  199. package/dist/runtime-errors.js.map +1 -0
  200. package/dist/runtime-pointers.d.ts +58 -0
  201. package/dist/runtime-pointers.d.ts.map +1 -0
  202. package/dist/runtime-pointers.js +84 -0
  203. package/dist/runtime-pointers.js.map +1 -0
  204. package/dist/secret-scan.d.ts +191 -0
  205. package/dist/secret-scan.d.ts.map +1 -0
  206. package/dist/secret-scan.js +542 -0
  207. package/dist/secret-scan.js.map +1 -0
  208. package/dist/semver.d.ts +89 -0
  209. package/dist/semver.d.ts.map +1 -0
  210. package/dist/semver.js +400 -0
  211. package/dist/semver.js.map +1 -0
  212. package/dist/server-key.d.ts +68 -0
  213. package/dist/server-key.d.ts.map +1 -0
  214. package/dist/server-key.js +150 -0
  215. package/dist/server-key.js.map +1 -0
  216. package/dist/site-manifest-keys.d.ts +107 -0
  217. package/dist/site-manifest-keys.d.ts.map +1 -0
  218. package/dist/site-manifest-keys.js +146 -0
  219. package/dist/site-manifest-keys.js.map +1 -0
  220. package/dist/site-manifest.d.ts +286 -0
  221. package/dist/site-manifest.d.ts.map +1 -0
  222. package/dist/site-manifest.js +100 -0
  223. package/dist/site-manifest.js.map +1 -0
  224. package/dist/source-archive.d.ts +119 -0
  225. package/dist/source-archive.d.ts.map +1 -0
  226. package/dist/source-archive.js +644 -0
  227. package/dist/source-archive.js.map +1 -0
  228. package/dist/source-package-corpus.d.ts +55 -0
  229. package/dist/source-package-corpus.d.ts.map +1 -0
  230. package/dist/source-package-corpus.js +303 -0
  231. package/dist/source-package-corpus.js.map +1 -0
  232. package/dist/source-package.d.ts +227 -0
  233. package/dist/source-package.d.ts.map +1 -0
  234. package/dist/source-package.js +361 -0
  235. package/dist/source-package.js.map +1 -0
  236. package/dist/source-secrets.d.ts +21 -0
  237. package/dist/source-secrets.d.ts.map +1 -0
  238. package/dist/source-secrets.js +43 -0
  239. package/dist/source-secrets.js.map +1 -0
  240. package/dist/ssr-cap.d.ts +61 -0
  241. package/dist/ssr-cap.d.ts.map +1 -0
  242. package/dist/ssr-cap.js +107 -0
  243. package/dist/ssr-cap.js.map +1 -0
  244. package/dist/ssr-kv.d.ts +18 -0
  245. package/dist/ssr-kv.d.ts.map +1 -0
  246. package/dist/ssr-kv.js +18 -0
  247. package/dist/ssr-kv.js.map +1 -0
  248. package/dist/ssr-version-ledger.d.ts +53 -0
  249. package/dist/ssr-version-ledger.d.ts.map +1 -0
  250. package/dist/ssr-version-ledger.js +88 -0
  251. package/dist/ssr-version-ledger.js.map +1 -0
  252. package/dist/style-references.d.ts +58 -0
  253. package/dist/style-references.d.ts.map +1 -0
  254. package/dist/style-references.js +241 -0
  255. package/dist/style-references.js.map +1 -0
  256. package/dist/tag-name.d.ts +87 -0
  257. package/dist/tag-name.d.ts.map +1 -0
  258. package/dist/tag-name.js +222 -0
  259. package/dist/tag-name.js.map +1 -0
  260. package/dist/tar-writer.d.ts +74 -0
  261. package/dist/tar-writer.d.ts.map +1 -0
  262. package/dist/tar-writer.js +148 -0
  263. package/dist/tar-writer.js.map +1 -0
  264. package/dist/testing.d.ts +11 -0
  265. package/dist/testing.d.ts.map +1 -0
  266. package/dist/testing.js +11 -0
  267. package/dist/testing.js.map +1 -0
  268. package/dist/text-codec.d.ts +36 -0
  269. package/dist/text-codec.d.ts.map +1 -0
  270. package/dist/text-codec.js +32 -0
  271. package/dist/text-codec.js.map +1 -0
  272. package/dist/url-value.d.ts +41 -0
  273. package/dist/url-value.d.ts.map +1 -0
  274. package/dist/url-value.js +147 -0
  275. package/dist/url-value.js.map +1 -0
  276. package/dist/usage-guard.d.ts +99 -0
  277. package/dist/usage-guard.d.ts.map +1 -0
  278. package/dist/usage-guard.js +104 -0
  279. package/dist/usage-guard.js.map +1 -0
  280. package/dist/usage-mirror.d.ts +55 -0
  281. package/dist/usage-mirror.d.ts.map +1 -0
  282. package/dist/usage-mirror.js +52 -0
  283. package/dist/usage-mirror.js.map +1 -0
  284. package/dist/value-check.d.ts +88 -0
  285. package/dist/value-check.d.ts.map +1 -0
  286. package/dist/value-check.js +279 -0
  287. package/dist/value-check.js.map +1 -0
  288. package/dist/value-patterns.d.ts +9 -0
  289. package/dist/value-patterns.d.ts.map +1 -0
  290. package/dist/value-patterns.js +17 -0
  291. package/dist/value-patterns.js.map +1 -0
  292. package/dist/value-schema.d.ts +796 -0
  293. package/dist/value-schema.d.ts.map +1 -0
  294. package/dist/value-schema.js +231 -0
  295. package/dist/value-schema.js.map +1 -0
  296. package/dist/zod-free.d.ts +60 -0
  297. package/dist/zod-free.d.ts.map +1 -0
  298. package/dist/zod-free.js +59 -0
  299. package/dist/zod-free.js.map +1 -0
  300. package/package.json +75 -3
  301. package/schema/DEPLOYED +12 -0
  302. package/schema/build-diagnostic.v1.json +63 -0
  303. package/schema/component-manifest.v1.json +1000 -0
  304. package/schema/data-api.v1.json +194 -0
  305. package/schema/library-manifest.v1.json +60 -0
  306. package/schema/published/SHA256SUMS +36 -0
  307. package/schema/published/build-diagnostic/v1.10.json +83 -0
  308. package/schema/published/build-diagnostic/v1.3.json +83 -0
  309. package/schema/published/build-diagnostic/v1.4.json +83 -0
  310. package/schema/published/build-diagnostic/v1.5.json +83 -0
  311. package/schema/published/build-diagnostic/v1.6.json +83 -0
  312. package/schema/published/build-diagnostic/v1.7.json +83 -0
  313. package/schema/published/build-diagnostic/v1.8.json +83 -0
  314. package/schema/published/build-diagnostic/v1.9.json +83 -0
  315. package/schema/published/component-manifest/v1.10.json +1443 -0
  316. package/schema/published/component-manifest/v1.3.json +1411 -0
  317. package/schema/published/component-manifest/v1.4.json +1419 -0
  318. package/schema/published/component-manifest/v1.5.json +1437 -0
  319. package/schema/published/component-manifest/v1.6.json +1437 -0
  320. package/schema/published/component-manifest/v1.7.json +1437 -0
  321. package/schema/published/component-manifest/v1.8.json +1437 -0
  322. package/schema/published/component-manifest/v1.9.json +1437 -0
  323. package/schema/published/data-api/v1.10.json +282 -0
  324. package/schema/published/data-api/v1.3.json +281 -0
  325. package/schema/published/data-api/v1.4.json +281 -0
  326. package/schema/published/data-api/v1.5.json +281 -0
  327. package/schema/published/data-api/v1.6.json +281 -0
  328. package/schema/published/data-api/v1.7.json +281 -0
  329. package/schema/published/data-api/v1.8.json +282 -0
  330. package/schema/published/data-api/v1.9.json +282 -0
  331. package/schema/published/library-manifest/v1.10.json +68 -0
  332. package/schema/published/library-manifest/v1.5.json +68 -0
  333. package/schema/published/library-manifest/v1.6.json +68 -0
  334. package/schema/published/library-manifest/v1.7.json +68 -0
  335. package/schema/published/library-manifest/v1.8.json +68 -0
  336. package/schema/published/library-manifest/v1.9.json +68 -0
  337. package/schema/published/taggor-config/v1.10.json +56 -0
  338. package/schema/published/taggor-config/v1.5.json +56 -0
  339. package/schema/published/taggor-config/v1.6.json +56 -0
  340. package/schema/published/taggor-config/v1.7.json +56 -0
  341. package/schema/published/taggor-config/v1.8.json +56 -0
  342. package/schema/published/taggor-config/v1.9.json +56 -0
  343. package/schema/taggor-config.v1.json +39 -0
@@ -0,0 +1,61 @@
1
+ /**
2
+ * Per-component TypeScript declarations for the customer's site (TAG-214): from a validated manifest,
3
+ * the text of `<tag>.d.ts` (the element in `HTMLElementTagNameMap`, its props as typed properties,
4
+ * its events on the element and on `document`, and `window.taggor` typed with them) and of
5
+ * `<tag>.react.d.ts` (the element in React 19's JSX, with its props and `on<tag>:<event>`
6
+ * listeners). TAG-324: a form field (`formAssociated: true`) also gets the element's form field
7
+ * API (`value`, `form`, `validity`, `validationMessage`, `checkValidity()`, `reportValidity()`).
8
+ * TAG-236: `<tag>.vue.d.ts`, the element in Vue 3's `GlobalComponents`, with its props and
9
+ * `@<tag>:<event>` listeners for `vue-tsc`'s template checks.
10
+ * `taggor types` (CLI, TAG-1001) writes these files and
11
+ * `GET /v1/components/{id}/types.d.ts` (API) serves them; both only call this module.
12
+ *
13
+ * The types follow what the runtime does, not what an author wrote: a prop's value type comes from
14
+ * its declared `type` (the prop type catalog's `PropValueTypes`, `enum` as the union of its
15
+ * `values`), arrays and objects as the runtime delivers them (read-only at every level, since it
16
+ * deep-freezes them, TAG-304), a getter without `default` may give `undefined` (a `boolean` never:
17
+ * absent is `false`), and a setter also takes `null` and `undefined` (they clear the property).
18
+ *
19
+ * Manifest text never becomes code: names come from the contract's patterns (tag, prop, event and
20
+ * field names are identifiers or kebab-case) and are still written as JSON string literals where a
21
+ * key is quoted; descriptions only go into comments, with every line break and `*` + `/` defused,
22
+ * so a description cannot close the comment. The host API part (`HOST_API_DECLARATIONS`) is the
23
+ * same text in every file, built only from interface merges, so any number of component files
24
+ * compile together.
25
+ */
26
+ import type { ComponentManifest } from "./manifest.js";
27
+ /** The declaration files of one component. */
28
+ export interface ComponentTypeDeclarations {
29
+ /** `<tag>.d.ts`: the DOM element, its events and `window.taggor`. */
30
+ readonly dom: string;
31
+ /** `<tag>.react.d.ts`: the JSX element of React 19; references `<tag>.d.ts` beside it. */
32
+ readonly react: string;
33
+ /** `<tag>.vue.d.ts`: the element in Vue 3's templates; references `<tag>.d.ts` beside it. */
34
+ readonly vue: string;
35
+ }
36
+ /**
37
+ * `window.taggor` (TAG-214) for the site: the API the loader installs (the runtime's
38
+ * `TaggorHostApi`, `packages/runtime/src/host/types.ts`, which the runtime's
39
+ * `host-api-types.test.ts` keeps assignable to this text), with `on` typed by the
40
+ * `TaggorComponentEventMap` the component files fill. Identical in every generated file.
41
+ */
42
+ export declare const HOST_API_DECLARATIONS = " /** The details of each component's declared events, by tag and event name (one entry per component file). */\n interface TaggorComponentEventMap {}\n /** The props of each component, by tag, as properties and JSX attributes (one entry per component file). */\n interface TaggorComponentPropsMap {}\n /** What `taggor.get(el)` says about one connected component element. */\n interface TaggorComponentInfo {\n readonly element: HTMLElement;\n readonly tag: string;\n readonly name: string;\n readonly version: string | undefined;\n readonly contractVersion: string | undefined;\n readonly state: \"mounted\" | \"failed\";\n readonly props: Readonly<Record<string, unknown>>;\n }\n /** `window.taggor`: no method throws; invalid arguments give `undefined`. */\n interface TaggorHostApi {\n readonly version: string;\n /** Resolves once every component of the initial load is registered; a new promise per call. */\n ready(): Promise<void>;\n /** The info of a component element in the document, `undefined` for anything else. */\n get(element: unknown): TaggorComponentInfo | undefined;\n /**\n * Calls `handler` with every `<tag>:<event>` that a live component element dispatches in the\n * document; returns the function that stops it. Page code can still dispatch a forged event on a\n * component element: check `taggor.get(event.composedPath()[0])` and the `detail` before trusting it.\n */\n on<T extends keyof TaggorComponentEventMap, E extends keyof TaggorComponentEventMap[T] & string>(\n tag: T,\n event: E,\n handler: (event: CustomEvent<TaggorComponentEventMap[T][E]>) => void,\n ): (() => void) | undefined;\n /** Any other tag (a component without a declaration file); a declared tag only takes its own events. */\n on<T extends string>(\n tag: T & (T extends keyof TaggorComponentEventMap ? never : string),\n event: string,\n handler: (event: CustomEvent<unknown>) => void,\n ): (() => void) | undefined;\n /** Every connected component element, in connection order. */\n components(): readonly TaggorComponentInfo[];\n }\n interface Window {\n /** Installed by the Taggor snippet; absent until it runs. */\n readonly taggor?: TaggorHostApi;\n }\n";
43
+ /**
44
+ * The name of a component's element interface: `Taggor`, the PascalCase segments of the tag and
45
+ * `Element` (`finance-simulator` → `TaggorFinanceSimulatorElement`). The prefix keeps a tag such as
46
+ * `h-t-m-l-div` from naming a DOM lib interface (`HTMLDivElement`; TAG-214 review, A5). A segment
47
+ * that starts with a digit keeps an underscore (`x-a-1b` → `TaggorXA_1bElement`), so two valid
48
+ * tags never share a name.
49
+ *
50
+ * Inputs: a tag accepted by `TAG_NAME_PATTERN`. Output: a TypeScript identifier. Errors: none.
51
+ * Side effects: none.
52
+ */
53
+ export declare function componentElementTypeName(tag: string): string;
54
+ /**
55
+ * The declaration files of one component.
56
+ *
57
+ * Inputs: a manifest accepted by `parseManifest`. Output: `ComponentTypeDeclarations`, the text of
58
+ * `<tag>.d.ts`, `<tag>.react.d.ts` and `<tag>.vue.d.ts`. Errors: none for a validated manifest. Side effects: none.
59
+ */
60
+ export declare function componentTypeDeclarations(manifest: ComponentManifest): ComponentTypeDeclarations;
61
+ //# sourceMappingURL=component-types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"component-types.d.ts","sourceRoot":"","sources":["../src/component-types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAIvD,8CAA8C;AAC9C,MAAM,WAAW,yBAAyB;IACxC,qEAAqE;IACrE,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,0FAA0F;IAC1F,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,6FAA6F;IAC7F,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;CACtB;AA4DD;;;;;GAKG;AACH,eAAO,MAAM,qBAAqB,ovEA4CjC,CAAC;AAEF;;;;;;;;;GASG;AACH,wBAAgB,wBAAwB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAO5D;AA4DD;;;;;GAKG;AACH,wBAAgB,yBAAyB,CAAC,QAAQ,EAAE,iBAAiB,GAAG,yBAAyB,CAoIhG"}
@@ -0,0 +1,277 @@
1
+ /**
2
+ * The form field API on a form field component's element (TAG-324), as the runtime gives it: the
3
+ * value is the text the component submits (`""` for none), the rest is `undefined` in a browser
4
+ * without form-associated custom elements, where the checks always pass. Keyed by the runtime's
5
+ * lists (`FORM_FIELD_ACCESSORS`, `FORM_FIELD_METHODS`), so a member added there must be typed here.
6
+ */
7
+ const FORM_FIELD_API = {
8
+ value: { type: "string", doc: 'The text the field submits with its form ("" when none).' },
9
+ form: {
10
+ type: "HTMLFormElement | null | undefined",
11
+ doc: "The field's form; undefined in a browser without form-associated custom elements.",
12
+ },
13
+ validationMessage: {
14
+ type: "string | undefined",
15
+ doc: "Why the field is invalid, in the visitor's language; empty while valid.",
16
+ },
17
+ validity: { type: "ValidityState | undefined", doc: "The field's validity flags." },
18
+ checkValidity: {
19
+ type: "boolean",
20
+ method: true,
21
+ doc: "Whether the field is valid; fires invalid on it when not.",
22
+ },
23
+ reportValidity: {
24
+ type: "boolean",
25
+ method: true,
26
+ doc: "Like checkValidity, and the browser shows the message on the component's control.",
27
+ },
28
+ };
29
+ /** A form field member that no prop shares a name with: a method or a read-only property. */
30
+ function fieldMember(name, member) {
31
+ return (doc(member.doc, " ") +
32
+ (member.method === true
33
+ ? ` ${name}(): ${member.type};\n`
34
+ : ` readonly ${name}: ${member.type};\n`));
35
+ }
36
+ /**
37
+ * `window.taggor` (TAG-214) for the site: the API the loader installs (the runtime's
38
+ * `TaggorHostApi`, `packages/runtime/src/host/types.ts`, which the runtime's
39
+ * `host-api-types.test.ts` keeps assignable to this text), with `on` typed by the
40
+ * `TaggorComponentEventMap` the component files fill. Identical in every generated file.
41
+ */
42
+ export const HOST_API_DECLARATIONS = ` /** The details of each component's declared events, by tag and event name (one entry per component file). */
43
+ interface TaggorComponentEventMap {}
44
+ /** The props of each component, by tag, as properties and JSX attributes (one entry per component file). */
45
+ interface TaggorComponentPropsMap {}
46
+ /** What \`taggor.get(el)\` says about one connected component element. */
47
+ interface TaggorComponentInfo {
48
+ readonly element: HTMLElement;
49
+ readonly tag: string;
50
+ readonly name: string;
51
+ readonly version: string | undefined;
52
+ readonly contractVersion: string | undefined;
53
+ readonly state: "mounted" | "failed";
54
+ readonly props: Readonly<Record<string, unknown>>;
55
+ }
56
+ /** \`window.taggor\`: no method throws; invalid arguments give \`undefined\`. */
57
+ interface TaggorHostApi {
58
+ readonly version: string;
59
+ /** Resolves once every component of the initial load is registered; a new promise per call. */
60
+ ready(): Promise<void>;
61
+ /** The info of a component element in the document, \`undefined\` for anything else. */
62
+ get(element: unknown): TaggorComponentInfo | undefined;
63
+ /**
64
+ * Calls \`handler\` with every \`<tag>:<event>\` that a live component element dispatches in the
65
+ * document; returns the function that stops it. Page code can still dispatch a forged event on a
66
+ * component element: check \`taggor.get(event.composedPath()[0])\` and the \`detail\` before trusting it.
67
+ */
68
+ on<T extends keyof TaggorComponentEventMap, E extends keyof TaggorComponentEventMap[T] & string>(
69
+ tag: T,
70
+ event: E,
71
+ handler: (event: CustomEvent<TaggorComponentEventMap[T][E]>) => void,
72
+ ): (() => void) | undefined;
73
+ /** Any other tag (a component without a declaration file); a declared tag only takes its own events. */
74
+ on<T extends string>(
75
+ tag: T & (T extends keyof TaggorComponentEventMap ? never : string),
76
+ event: string,
77
+ handler: (event: CustomEvent<unknown>) => void,
78
+ ): (() => void) | undefined;
79
+ /** Every connected component element, in connection order. */
80
+ components(): readonly TaggorComponentInfo[];
81
+ }
82
+ interface Window {
83
+ /** Installed by the Taggor snippet; absent until it runs. */
84
+ readonly taggor?: TaggorHostApi;
85
+ }
86
+ `;
87
+ /**
88
+ * The name of a component's element interface: `Taggor`, the PascalCase segments of the tag and
89
+ * `Element` (`finance-simulator` → `TaggorFinanceSimulatorElement`). The prefix keeps a tag such as
90
+ * `h-t-m-l-div` from naming a DOM lib interface (`HTMLDivElement`; TAG-214 review, A5). A segment
91
+ * that starts with a digit keeps an underscore (`x-a-1b` → `TaggorXA_1bElement`), so two valid
92
+ * tags never share a name.
93
+ *
94
+ * Inputs: a tag accepted by `TAG_NAME_PATTERN`. Output: a TypeScript identifier. Errors: none.
95
+ * Side effects: none.
96
+ */
97
+ export function componentElementTypeName(tag) {
98
+ const segments = tag
99
+ .split("-")
100
+ .map((segment) => /^\d/.test(segment) ? `_${segment}` : segment.charAt(0).toUpperCase() + segment.slice(1));
101
+ return `Taggor${segments.join("")}Element`;
102
+ }
103
+ /** Comment text: one line, without anything that could end the comment. */
104
+ function commentLine(text) {
105
+ return text.replace(/[\r\n\u2028\u2029]+/g, " ").replaceAll("*/", "* /");
106
+ }
107
+ /** A JSDoc block at `indent`, or nothing without text. */
108
+ function doc(text, indent) {
109
+ return text === undefined ? "" : `${indent}/** ${commentLine(text)} */\n`;
110
+ }
111
+ /** The TypeScript type of a value the runtime delivers for `schema` (read-only containers). */
112
+ function valueType(schema) {
113
+ switch (schema.type) {
114
+ case "number":
115
+ return "number";
116
+ case "boolean":
117
+ return "boolean";
118
+ case "enum":
119
+ return (schema.values ?? []).map((value) => JSON.stringify(value)).join(" | ") || "string";
120
+ case "array":
121
+ return `readonly (${schema.items === undefined ? "unknown" : valueType(schema.items)})[]`;
122
+ case "object": {
123
+ const required = new Set(schema.required);
124
+ const fields = Object.entries(schema.fields ?? {}).map(([name, field]) => `readonly ${JSON.stringify(name)}${required.has(name) ? "" : "?"}: ${valueType(field)}`);
125
+ return fields.length === 0 ? "Record<string, never>" : `{ ${fields.join("; ")} }`;
126
+ }
127
+ // string, color, url, date (an ISO string), and any type of a newer minor.
128
+ default:
129
+ return schema.type === "string" ||
130
+ schema.type === "color" ||
131
+ schema.type === "url" ||
132
+ schema.type === "date"
133
+ ? "string"
134
+ : "unknown";
135
+ }
136
+ }
137
+ /**
138
+ * The prop that Vue's template compiler, and `vue-tsc`, make of `@<type>`: `on` and the
139
+ * capitalized camelCase of the type (`finance-simulator:simulate` → `onFinanceSimulator:simulate`,
140
+ * Vue's `camelize`). `undefined` when Vue's runtime would not listen to `type` itself: it turns the
141
+ * prop back into an event name with `hyphenate`, which loses a hyphen before a digit (`x-a-1b:go`
142
+ * → `onXA1b:go` → `x-a1b:go`), so typing that listener would promise an event that never comes.
143
+ */
144
+ function vueListenerName(type) {
145
+ const camel = type.replace(/-(\w)/g, (_, letter) => letter.toUpperCase());
146
+ const back = camel.replace(/\B([A-Z])/g, "-$1").toLowerCase();
147
+ return back === type ? `on${camel.charAt(0).toUpperCase()}${camel.slice(1)}` : undefined;
148
+ }
149
+ /** Whether the runtime always gives the prop a value (a `boolean`, or a declared `default`). */
150
+ function alwaysSet(prop) {
151
+ return prop.type === "boolean" || prop.default !== undefined;
152
+ }
153
+ /**
154
+ * The declaration files of one component.
155
+ *
156
+ * Inputs: a manifest accepted by `parseManifest`. Output: `ComponentTypeDeclarations`, the text of
157
+ * `<tag>.d.ts`, `<tag>.react.d.ts` and `<tag>.vue.d.ts`. Errors: none for a validated manifest. Side effects: none.
158
+ */
159
+ export function componentTypeDeclarations(manifest) {
160
+ const { tag } = manifest;
161
+ const key = JSON.stringify(tag);
162
+ const element = componentElementTypeName(tag);
163
+ const eventMap = `${element}EventMap`;
164
+ const props = Object.entries(manifest.props ?? {});
165
+ const events = Object.entries(manifest.events ?? {});
166
+ const header = `// Generated by Taggor from the manifest of ${commentLine(manifest.name)} (<${tag}>),` +
167
+ ` contract ${commentLine(manifest.contractVersion)}. Do not edit: run \`taggor types\` again.\n`;
168
+ // TAG-324: a form field's element has the field API, which wins over a prop of the same name
169
+ // for reading (the runtime's getter is the field's); the prop's setter stays, except under a
170
+ // method's name.
171
+ const field = manifest.formAssociated === true ? FORM_FIELD_API : {};
172
+ const declared = manifest.props ?? {};
173
+ const fieldMembers = Object.entries(field)
174
+ .filter(([name]) => !Object.hasOwn(declared, name))
175
+ .map(([name, member]) => (member === undefined ? "" : fieldMember(name, member)))
176
+ .join("");
177
+ const accessors = props
178
+ .map(([name, prop]) => {
179
+ const type = valueType(prop);
180
+ const member = field[name];
181
+ if (member?.method === true)
182
+ return fieldMember(name, member);
183
+ const value = member?.type ?? (alwaysSet(prop) ? type : `${type} | undefined`);
184
+ return (doc(member?.doc ?? prop.description, " ") +
185
+ ` get ${name}(): ${value};\n` +
186
+ ` set ${name}(value: ${type} | null | undefined);\n`);
187
+ })
188
+ .join("");
189
+ const eventEntries = events
190
+ .map(([name, event]) => doc(event.description, " ") +
191
+ ` ${JSON.stringify(`${tag}:${name}`)}: CustomEvent<${valueType(event.detail)}>;\n`)
192
+ .join("");
193
+ const documentEntries = events
194
+ .filter(([, event]) => event.bubbles !== false)
195
+ .map(([name]) => {
196
+ const type = JSON.stringify(`${tag}:${name}`);
197
+ return ` ${type}: ${eventMap}[${type}];\n`;
198
+ })
199
+ .join("");
200
+ const details = events
201
+ .map(([name, event]) => `${JSON.stringify(name)}: ${valueType(event.detail)}`)
202
+ .join("; ");
203
+ const jsxProps = props
204
+ .map(([name, prop]) => `${name}?: ${valueType(prop)}`)
205
+ .join("; ");
206
+ const listener = (type) => `(this: ${element}, event: ${eventMap}[K]) => unknown, options?: boolean | ${type}): void;\n`;
207
+ const dom = header +
208
+ "export {};\n\n" +
209
+ "declare global {\n" +
210
+ doc(`${manifest.title}: ${manifest.description}`, " ") +
211
+ ` interface ${element} extends HTMLElement {\n` +
212
+ accessors +
213
+ fieldMembers +
214
+ ` addEventListener<K extends keyof ${eventMap}>(type: K, listener: ${listener("AddEventListenerOptions")}` +
215
+ " addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;\n" +
216
+ ` removeEventListener<K extends keyof ${eventMap}>(type: K, listener: ${listener("EventListenerOptions")}` +
217
+ " removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void;\n" +
218
+ " }\n" +
219
+ ` interface ${eventMap} extends HTMLElementEventMap {\n${eventEntries} }\n` +
220
+ ` interface HTMLElementTagNameMap {\n ${key}: ${element};\n }\n` +
221
+ (documentEntries === "" ? "" : ` interface DocumentEventMap {\n${documentEntries} }\n`) +
222
+ ` interface TaggorComponentEventMap {\n ${key}: { ${details} };\n }\n` +
223
+ ` interface TaggorComponentPropsMap {\n ${key}: { ${jsxProps} };\n }\n` +
224
+ HOST_API_DECLARATIONS +
225
+ "}\n";
226
+ const reactListeners = events
227
+ .map(([name]) => {
228
+ const type = JSON.stringify(`${tag}:${name}`);
229
+ return ` ${JSON.stringify(`on${tag}:${name}`)}?: (event: ${eventMap}[${type}]) => void;\n`;
230
+ })
231
+ .join("");
232
+ const react = `/// <reference path="./${tag}.d.ts" />\n` +
233
+ header +
234
+ 'import type { DetailedHTMLProps, HTMLAttributes } from "react";\n\n' +
235
+ // React 19 sets a prop as a property when the element has it (every declared prop does) and
236
+ // turns an `on<type>` prop of a custom element into a listener of `<type>`.
237
+ 'declare module "react" {\n' +
238
+ " namespace JSX {\n" +
239
+ " interface IntrinsicElements {\n" +
240
+ ` ${key}: Omit<DetailedHTMLProps<HTMLAttributes<${element}>, ${element}>, keyof TaggorComponentPropsMap[${key}]> &\n` +
241
+ ` TaggorComponentPropsMap[${key}] & {\n` +
242
+ reactListeners +
243
+ " };\n" +
244
+ " }\n" +
245
+ " }\n" +
246
+ "}\n";
247
+ const vueListeners = events
248
+ .map(([name]) => {
249
+ const type = `${tag}:${name}`;
250
+ const prop = vueListenerName(type);
251
+ return prop === undefined
252
+ ? ""
253
+ : ` ${JSON.stringify(prop)}?: (event: ${eventMap}[${JSON.stringify(type)}]) => void;\n`;
254
+ })
255
+ .join("");
256
+ const vue = `/// <reference path="./${tag}.d.ts" />\n` +
257
+ header +
258
+ 'import type { HTMLAttributes, PublicProps } from "vue";\n\n' +
259
+ // Vue's template compiler makes every tag that is not native HTML or SVG a component, also for
260
+ // vue-tsc (`isCustomElement` is a runtime compiler option it never reads), so the element goes
261
+ // in `GlobalComponents`, not in `IntrinsicElementAttributes`, as Vue's guide does for custom
262
+ // elements. The instance type is the element: a template ref to it is the typed element. Vue
263
+ // keeps `key`, `ref`, `class` and `style` for itself, so a prop of those names stays Vue's.
264
+ 'declare module "vue" {\n' +
265
+ " interface GlobalComponents {\n" +
266
+ ` ${key}: new () => ${element} & {\n` +
267
+ ` $props: Omit<HTMLAttributes, keyof TaggorComponentPropsMap[${key}]> &\n` +
268
+ ` Omit<TaggorComponentPropsMap[${key}], keyof PublicProps> &\n` +
269
+ " PublicProps & {\n" +
270
+ vueListeners +
271
+ " };\n" +
272
+ " };\n" +
273
+ " }\n" +
274
+ "}\n";
275
+ return Object.freeze({ dom, react, vue });
276
+ }
277
+ //# sourceMappingURL=component-types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"component-types.js","sourceRoot":"","sources":["../src/component-types.ts"],"names":[],"mappings":"AA+CA;;;;;GAKG;AACH,MAAM,cAAc,GAEhB;IACF,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,GAAG,EAAE,0DAA0D,EAAE;IAC1F,IAAI,EAAE;QACJ,IAAI,EAAE,oCAAoC;QAC1C,GAAG,EAAE,mFAAmF;KACzF;IACD,iBAAiB,EAAE;QACjB,IAAI,EAAE,oBAAoB;QAC1B,GAAG,EAAE,yEAAyE;KAC/E;IACD,QAAQ,EAAE,EAAE,IAAI,EAAE,2BAA2B,EAAE,GAAG,EAAE,6BAA6B,EAAE;IACnF,aAAa,EAAE;QACb,IAAI,EAAE,SAAS;QACf,MAAM,EAAE,IAAI;QACZ,GAAG,EAAE,2DAA2D;KACjE;IACD,cAAc,EAAE;QACd,IAAI,EAAE,SAAS;QACf,MAAM,EAAE,IAAI;QACZ,GAAG,EAAE,mFAAmF;KACzF;CACF,CAAC;AAEF,6FAA6F;AAC7F,SAAS,WAAW,CAAC,IAAY,EAAE,MAAmB;IACpD,OAAO,CACL,GAAG,CAAC,MAAM,CAAC,GAAG,EAAE,MAAM,CAAC;QACvB,CAAC,MAAM,CAAC,MAAM,KAAK,IAAI;YACrB,CAAC,CAAC,OAAO,IAAI,OAAO,MAAM,CA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AAG,2CAA2C,OAAO,MAAM,OAAO,oCAAoC,GAAG,QAAQ;QAC1H,mCAAmC,GAAG,SAAS;QAC/C,cAAc;QACd,YAAY;QACZ,SAAS;QACT,OAAO;QACP,KAAK,CAAC;IAER,MAAM,YAAY,GAAG,MAAM;SACxB,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,EAAE;QACd,MAAM,IAAI,GAAG,GAAG,GAAG,IAAI,IAAI,EAAE,CAAC;QAC9B,MAAM,IAAI,GAAG,eAAe,CAAC,IAAI,CAAC,CAAC;QACnC,OAAO,IAAI,KAAK,SAAS;YACvB,CAAC,CAAC,EAAE;YACJ,CAAC,CAAC,aAAa,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,cAAc,QAAQ,IAAI,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,eAAe,CAAC;IACrG,CAAC,CAAC;SACD,IAAI,CAAC,EAAE,CAAC,CAAC;IACZ,MAAM,GAAG,GACP,0BAA0B,GAAG,aAAa;QAC1C,MAAM;QACN,6DAA6D;QAC7D,+FAA+F;QAC/F,+FAA+F;QAC/F,6FAA6F;QAC7F,6FAA6F;QAC7F,4FAA4F;QAC5F,0BAA0B;QAC1B,kCAAkC;QAClC,OAAO,GAAG,eAAe,OAAO,QAAQ;QACxC,oEAAoE,GAAG,QAAQ;QAC/E,wCAAwC,GAAG,2BAA2B;QACtE,2BAA2B;QAC3B,YAAY;QACZ,cAAc;QACd,UAAU;QACV,OAAO;QACP,KAAK,CAAC;IAER,OAAO,MAAM,CAAC,MAAM,CAAC,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,CAAC;AAC5C,CAAC"}
@@ -0,0 +1,31 @@
1
+ /**
2
+ * The text of the consent a visitor accepts, as the server must rebuild it (TAG-703, `SPEC.md`
3
+ * §5): the checkbox label of `<Consent>` in each language and the string whose SHA-256 is the
4
+ * proof's `text_hash`. The SDK (`packages/component/src/consent.ts`) builds the label and hashes it
5
+ * in the browser; the ingest builds the same text from what it trusts (the language of the proof,
6
+ * the `Origin` host, the policy URL it stores for the site) and compares. A parity test in the
7
+ * component package keeps the two copies equal. Zod-free and pure, so the edge imports it cheaply.
8
+ */
9
+ /** Languages the SDK shows the consent label in (the proof's `locale` is one of these). */
10
+ export declare const CONSENT_LOCALES: readonly ["pt-BR", "en"];
11
+ /** One of `CONSENT_LOCALES`. */
12
+ export type ConsentLocale = (typeof CONSENT_LOCALES)[number];
13
+ /**
14
+ * Whether a value is a language the SDK shows the consent label in.
15
+ * Inputs: any value. Output: a type guard. Errors: none. Side effects: none.
16
+ */
17
+ export declare function isConsentLocale(value: unknown): value is ConsentLocale;
18
+ /**
19
+ * The consent label exactly as the visitor reads it.
20
+ * Inputs: the language and the site's name (the page's host name; empty leaves it out). Output:
21
+ * the joined text, e.g. "I have read and accept the privacy policy of cliente.com.br.". Errors:
22
+ * none. Side effects: none.
23
+ */
24
+ export declare function consentLabelText(locale: ConsentLocale, site: string): string;
25
+ /**
26
+ * The text whose SHA-256 (lowercase hex) is the `text_hash`: the label, a line feed and the policy
27
+ * URL (empty when the site has none). Inputs: the label and the URL. Output: the string to hash as
28
+ * UTF-8. Errors: none. Side effects: none.
29
+ */
30
+ export declare function consentHashInput(label: string, policyUrl: string): string;
31
+ //# sourceMappingURL=consent-text.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"consent-text.d.ts","sourceRoot":"","sources":["../src/consent-text.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,2FAA2F;AAC3F,eAAO,MAAM,eAAe,0BAA0C,CAAC;AAEvE,gCAAgC;AAChC,MAAM,MAAM,aAAa,GAAG,CAAC,OAAO,eAAe,CAAC,CAAC,MAAM,CAAC,CAAC;AAQ7D;;;GAGG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,aAAa,CAEtE;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,aAAa,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAG5E;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,CAEzE"}
@@ -0,0 +1,41 @@
1
+ /**
2
+ * The text of the consent a visitor accepts, as the server must rebuild it (TAG-703, `SPEC.md`
3
+ * §5): the checkbox label of `<Consent>` in each language and the string whose SHA-256 is the
4
+ * proof's `text_hash`. The SDK (`packages/component/src/consent.ts`) builds the label and hashes it
5
+ * in the browser; the ingest builds the same text from what it trusts (the language of the proof,
6
+ * the `Origin` host, the policy URL it stores for the site) and compares. A parity test in the
7
+ * component package keeps the two copies equal. Zod-free and pure, so the edge imports it cheaply.
8
+ */
9
+ /** Languages the SDK shows the consent label in (the proof's `locale` is one of these). */
10
+ export const CONSENT_LOCALES = Object.freeze(["pt-BR", "en"]);
11
+ /** Label pieces: the text before the link, the link's text, the connector before the site name. */
12
+ const LABELS = Object.freeze({
13
+ "pt-BR": ["Li e aceito a ", "política de privacidade", " de "],
14
+ en: ["I have read and accept the ", "privacy policy", " of "],
15
+ });
16
+ /**
17
+ * Whether a value is a language the SDK shows the consent label in.
18
+ * Inputs: any value. Output: a type guard. Errors: none. Side effects: none.
19
+ */
20
+ export function isConsentLocale(value) {
21
+ return value === "pt-BR" || value === "en";
22
+ }
23
+ /**
24
+ * The consent label exactly as the visitor reads it.
25
+ * Inputs: the language and the site's name (the page's host name; empty leaves it out). Output:
26
+ * the joined text, e.g. "I have read and accept the privacy policy of cliente.com.br.". Errors:
27
+ * none. Side effects: none.
28
+ */
29
+ export function consentLabelText(locale, site) {
30
+ const [before, link, of] = LABELS[locale];
31
+ return `${before}${link}${site === "" ? "." : `${of}${site}.`}`;
32
+ }
33
+ /**
34
+ * The text whose SHA-256 (lowercase hex) is the `text_hash`: the label, a line feed and the policy
35
+ * URL (empty when the site has none). Inputs: the label and the URL. Output: the string to hash as
36
+ * UTF-8. Errors: none. Side effects: none.
37
+ */
38
+ export function consentHashInput(label, policyUrl) {
39
+ return `${label}\n${policyUrl}`;
40
+ }
41
+ //# sourceMappingURL=consent-text.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"consent-text.js","sourceRoot":"","sources":["../src/consent-text.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,2FAA2F;AAC3F,MAAM,CAAC,MAAM,eAAe,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,EAAE,IAAI,CAAU,CAAC,CAAC;AAKvE,mGAAmG;AACnG,MAAM,MAAM,GAAuE,MAAM,CAAC,MAAM,CAAC;IAC/F,OAAO,EAAE,CAAC,gBAAgB,EAAE,yBAAyB,EAAE,MAAM,CAAC;IAC9D,EAAE,EAAE,CAAC,6BAA6B,EAAE,gBAAgB,EAAE,MAAM,CAAC;CAC9D,CAAC,CAAC;AAEH;;;GAGG;AACH,MAAM,UAAU,eAAe,CAAC,KAAc;IAC5C,OAAO,KAAK,KAAK,OAAO,IAAI,KAAK,KAAK,IAAI,CAAC;AAC7C,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,gBAAgB,CAAC,MAAqB,EAAE,IAAY;IAClE,MAAM,CAAC,MAAM,EAAE,IAAI,EAAE,EAAE,CAAC,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC;IAC1C,OAAO,GAAG,MAAM,GAAG,IAAI,GAAG,IAAI,KAAK,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,GAAG,IAAI,GAAG,EAAE,CAAC;AAClE,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,gBAAgB,CAAC,KAAa,EAAE,SAAiB;IAC/D,OAAO,GAAG,KAAK,KAAK,SAAS,EAAE,CAAC;AAClC,CAAC"}
@@ -0,0 +1,150 @@
1
+ /**
2
+ * Versions of the component contract and what each consumer does with them (TAG-207, ADR 0019).
3
+ *
4
+ * A manifest declares the contract version it was written for in `contractVersion` (semver).
5
+ * Minor versions are additive, a major is anything that invalidates a manifest that used to be
6
+ * valid. This module is the single source of the current version, of the support window of older
7
+ * majors and of the verdict each consumer gives: the builder refuses (error) what it cannot build,
8
+ * the runtime warns and never throws, so a bad manifest cannot break the host page (golden rule 2).
9
+ *
10
+ * Zod-free and pure: the runtime imports it through `@taggor/contract/zod-free`, and the date is
11
+ * always passed in, never read from a clock.
12
+ */
13
+ /** Major version of the contract this package implements; `contractVersion` is `<major>.x.y`. */
14
+ export declare const CONTRACT_MAJOR = 1;
15
+ /**
16
+ * Newest minor of `CONTRACT_MAJOR` this package implements; newer minors are refused. 1.1
17
+ * (TAG-212): `data.personal` and `data.privacyPolicyUrl`. 1.2 (TAG-211): `locales`. 1.3
18
+ * (TAG-213): `assets`. 1.4 (TAG-314): `formAssociated` and `delegatesFocus`. 1.5 (TAG-210):
19
+ * component `libraries` and the workspace library manifest. 1.6 (TAG-2282): no manifest field;
20
+ * the schema documents and the diagnostics' `docsUrl` move to `taggor.dev` (ADR 0042). 1.7
21
+ * (TAG-242): no manifest field; the `build-diagnostic` text pattern also refuses U+034F, U+115F,
22
+ * U+1160, U+17B4, U+17B5, U+3164 and U+FFA0 (ADR 0043). 1.8 (TAG-730): no manifest field; the
23
+ * data API's `daily_cap_reached` error code (ADR 0050). 1.9 (TAG-1331): no manifest field; the
24
+ * site's environment picks the channel it delivers, and the attachment's own channel is ignored (ADR 0053).
25
+ * 1.10 (TAG-819): `eventSampleRate`, the share of interaction and custom events the browser sends.
26
+ */
27
+ export declare const CONTRACT_MINOR = 10;
28
+ /** Newest contract version this package implements. */
29
+ export declare const CONTRACT_VERSION: string;
30
+ /** Minimum months an older major stays supported after the next major ships (ADR 0019). */
31
+ export declare const SUPPORT_WINDOW_MONTHS = 12;
32
+ /**
33
+ * Support of one contract major.
34
+ *
35
+ * `deprecatedOn` is the day the next major shipped; `supportedUntil` is the last day the builder
36
+ * and the runtime accept this major, at least `SUPPORT_WINDOW_MONTHS` after `deprecatedOn`
37
+ * (checked by contract-version.test.ts). The current major has neither. Dates are ISO `YYYY-MM-DD`.
38
+ */
39
+ export interface ContractMajorSupport {
40
+ readonly major: number;
41
+ readonly deprecatedOn?: string;
42
+ readonly supportedUntil?: string;
43
+ }
44
+ /**
45
+ * What a package release knows about contract versions: the version it implements and the
46
+ * support of every major (oldest first). Injectable so tests can describe a future with v2.
47
+ */
48
+ export interface ContractVersionPolicy {
49
+ readonly major: number;
50
+ readonly minor: number;
51
+ readonly majors: readonly ContractMajorSupport[];
52
+ }
53
+ /**
54
+ * The policy of this release: contract 1.7, with v1 as the only (and current) major.
55
+ *
56
+ * Inputs: none. Output: frozen data. When a major ships, the previous entry gains `deprecatedOn`
57
+ * and `supportedUntil` in the same change that bumps `CONTRACT_MAJOR` (ADR 0019). Errors: none.
58
+ * Side effects: none.
59
+ */
60
+ export declare const CONTRACT_VERSION_POLICY: ContractVersionPolicy;
61
+ /** A parsed `contractVersion`. */
62
+ export interface ContractVersion {
63
+ readonly major: number;
64
+ readonly minor: number;
65
+ readonly patch: number;
66
+ }
67
+ /**
68
+ * Parses a `contractVersion` value.
69
+ *
70
+ * Inputs: any value. Output: the three numbers, or `undefined` when the value is not a string of
71
+ * the form `major.minor.patch` (digits only, no leading zeros, at most 6 digits each, no
72
+ * pre-release or build suffix). Errors: none. Side effects: none.
73
+ */
74
+ export declare function parseContractVersion(value: unknown): ContractVersion | undefined;
75
+ /**
76
+ * The anchored pattern of the versions a policy accepts for its current major: any patch of the
77
+ * minors `0` to `policy.minor`. The manifest schema uses it, so the JSON Schema refuses the same.
78
+ *
79
+ * Inputs: a policy (defaults to this release's). Output: a fresh `RegExp`. Errors: none. Side
80
+ * effects: none.
81
+ */
82
+ export declare function contractVersionPattern(policy?: ContractVersionPolicy): RegExp;
83
+ /**
84
+ * Where a `contractVersion` stands against a policy, before any date is considered:
85
+ * `current` (a known minor of the current major), `older-major`, `newer-minor`, `newer-major`,
86
+ * `malformed` or `missing`.
87
+ */
88
+ export type ContractVersionKind = "current" | "older-major" | "newer-minor" | "newer-major" | "malformed" | "missing";
89
+ /** A classified `contractVersion`; `version` is set for every kind but `missing` and `malformed`. */
90
+ export interface ContractVersionClass {
91
+ readonly kind: ContractVersionKind;
92
+ readonly version: ContractVersion | undefined;
93
+ }
94
+ /**
95
+ * Classifies a `contractVersion` value without looking at dates.
96
+ *
97
+ * Inputs: the raw value (`undefined` when the key is absent) and a policy. Output: its kind and,
98
+ * when well formed, the parsed version. Errors: none. Side effects: none.
99
+ */
100
+ export declare function classifyContractVersion(value: unknown, policy?: ContractVersionPolicy): ContractVersionClass;
101
+ /** Who asks: the builder refuses what it cannot build; the runtime only warns. */
102
+ export type ContractVersionConsumer = "builder" | "runtime";
103
+ /** Why a version is a problem. `deprecated-major` is the only one the builder still accepts. */
104
+ export type ContractVersionCode = "missing" | "malformed" | "newer-minor" | "newer-major" | "deprecated-major" | "unsupported-major";
105
+ /** A problem with a `contractVersion`: an error stops the builder, a warning never stops anything. */
106
+ export interface ContractVersionProblem {
107
+ readonly code: ContractVersionCode;
108
+ readonly severity: "error" | "warning";
109
+ readonly message: string;
110
+ }
111
+ /**
112
+ * The verdict for one consumer. `usable` tells the builder whether to build and the runtime
113
+ * whether to mount the component; `problem` is what to report (the runtime logs it as a warning).
114
+ */
115
+ export interface ContractVersionCheck {
116
+ readonly usable: boolean;
117
+ readonly version: ContractVersion | undefined;
118
+ readonly problem: ContractVersionProblem | undefined;
119
+ }
120
+ /** Where and when a version is checked. `today` is an ISO day (`YYYY-MM-DD`), passed in. */
121
+ export interface ContractVersionContext {
122
+ readonly consumer: ContractVersionConsumer;
123
+ readonly today: string;
124
+ }
125
+ /**
126
+ * The message for a version problem. Shared by `checkContractVersion` and `parseManifest`, so the
127
+ * builder, the runtime and the API say the same thing.
128
+ *
129
+ * Inputs: the problem code (or `older-major` from `classifyContractVersion`), the parsed version,
130
+ * the policy and, for older majors, their support entry. Output: one English sentence that says
131
+ * what to do. Errors: none. Side effects: none.
132
+ */
133
+ export declare function contractVersionMessage(code: ContractVersionCode | "older-major", version: ContractVersion | undefined, policy?: ContractVersionPolicy, support?: ContractMajorSupport): string;
134
+ /**
135
+ * The verdict on a manifest's `contractVersion` for the builder or the runtime (ADR 0019).
136
+ *
137
+ * | Case | Builder | Runtime |
138
+ * | --- | --- | --- |
139
+ * | known minor of the current major | usable | usable |
140
+ * | older major inside its support window | usable, warning `deprecated-major` | usable, no problem |
141
+ * | newer minor of the current major | error `newer-minor` | usable, warning (unknown additions are ignored) |
142
+ * | missing, malformed, newer major, older major out of support | error | not usable, warning |
143
+ *
144
+ * Inputs: the raw value (`undefined` when absent), the consumer and today's ISO day, and a policy
145
+ * (defaults to this release's). Output: `{ usable, version, problem }`. Errors: throws a
146
+ * `RangeError` only when `today` is not `YYYY-MM-DD` (a programming error of the caller); a bad
147
+ * `contractVersion` never throws. Side effects: none.
148
+ */
149
+ export declare function checkContractVersion(value: unknown, context: ContractVersionContext, policy?: ContractVersionPolicy): ContractVersionCheck;
150
+ //# sourceMappingURL=contract-version.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"contract-version.d.ts","sourceRoot":"","sources":["../src/contract-version.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,iGAAiG;AACjG,eAAO,MAAM,cAAc,IAAI,CAAC;AAChC;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,cAAc,KAAK,CAAC;AACjC,uDAAuD;AACvD,eAAO,MAAM,gBAAgB,QAA0D,CAAC;AAExF,2FAA2F;AAC3F,eAAO,MAAM,qBAAqB,KAAK,CAAC;AAExC;;;;;;GAMG;AACH,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,CAAC;CAClC;AAED;;;GAGG;AACH,MAAM,WAAW,qBAAqB;IACpC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAA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