@taggor/contract 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +61 -2
- package/dist/.tsbuildinfo +1 -0
- package/dist/artifact-keys.d.ts +169 -0
- package/dist/artifact-keys.d.ts.map +1 -0
- package/dist/artifact-keys.js +195 -0
- package/dist/artifact-keys.js.map +1 -0
- package/dist/assets.d.ts +72 -0
- package/dist/assets.d.ts.map +1 -0
- package/dist/assets.js +94 -0
- package/dist/assets.js.map +1 -0
- package/dist/bounded-path.d.ts +29 -0
- package/dist/bounded-path.d.ts.map +1 -0
- package/dist/bounded-path.js +57 -0
- package/dist/bounded-path.js.map +1 -0
- package/dist/bounded.d.ts +47 -0
- package/dist/bounded.d.ts.map +1 -0
- package/dist/bounded.js +93 -0
- package/dist/bounded.js.map +1 -0
- package/dist/build-diagnostic.d.ts +89 -0
- package/dist/build-diagnostic.d.ts.map +1 -0
- package/dist/build-diagnostic.js +91 -0
- package/dist/build-diagnostic.js.map +1 -0
- package/dist/component-types.d.ts +61 -0
- package/dist/component-types.d.ts.map +1 -0
- package/dist/component-types.js +277 -0
- package/dist/component-types.js.map +1 -0
- package/dist/consent-text.d.ts +31 -0
- package/dist/consent-text.d.ts.map +1 -0
- package/dist/consent-text.js +41 -0
- package/dist/consent-text.js.map +1 -0
- package/dist/contract-version.d.ts +150 -0
- package/dist/contract-version.d.ts.map +1 -0
- package/dist/contract-version.js +198 -0
- package/dist/contract-version.js.map +1 -0
- package/dist/credential-fields.d.ts +31 -0
- package/dist/credential-fields.d.ts.map +1 -0
- package/dist/credential-fields.js +36 -0
- package/dist/credential-fields.js.map +1 -0
- package/dist/css-tokens.d.ts +46 -0
- package/dist/css-tokens.d.ts.map +1 -0
- package/dist/css-tokens.js +189 -0
- package/dist/css-tokens.js.map +1 -0
- package/dist/css-value.d.ts +42 -0
- package/dist/css-value.d.ts.map +1 -0
- package/dist/css-value.js +78 -0
- package/dist/css-value.js.map +1 -0
- package/dist/data-api.d.ts +127 -0
- package/dist/data-api.d.ts.map +1 -0
- package/dist/data-api.js +167 -0
- package/dist/data-api.js.map +1 -0
- package/dist/denylist-keys.d.ts +19 -0
- package/dist/denylist-keys.d.ts.map +1 -0
- package/dist/denylist-keys.js +48 -0
- package/dist/denylist-keys.js.map +1 -0
- package/dist/diagnostic-catalog.d.ts +1402 -0
- package/dist/diagnostic-catalog.d.ts.map +1 -0
- package/dist/diagnostic-catalog.js +1311 -0
- package/dist/diagnostic-catalog.js.map +1 -0
- package/dist/dom-members.snapshot.d.ts +33 -0
- package/dist/dom-members.snapshot.d.ts.map +1 -0
- package/dist/dom-members.snapshot.js +760 -0
- package/dist/dom-members.snapshot.js.map +1 -0
- package/dist/early-loading.d.ts +27 -0
- package/dist/early-loading.d.ts.map +1 -0
- package/dist/early-loading.js +44 -0
- package/dist/early-loading.js.map +1 -0
- package/dist/error-catalog.d.ts +749 -0
- package/dist/error-catalog.d.ts.map +1 -0
- package/dist/error-catalog.js +720 -0
- package/dist/error-catalog.js.map +1 -0
- package/dist/executable-config.d.ts +35 -0
- package/dist/executable-config.d.ts.map +1 -0
- package/dist/executable-config.js +44 -0
- package/dist/executable-config.js.map +1 -0
- package/dist/freeze.d.ts +17 -0
- package/dist/freeze.d.ts.map +1 -0
- package/dist/freeze.js +29 -0
- package/dist/freeze.js.map +1 -0
- package/dist/gunzip.d.ts +33 -0
- package/dist/gunzip.d.ts.map +1 -0
- package/dist/gunzip.js +330 -0
- package/dist/gunzip.js.map +1 -0
- package/dist/hostname.d.ts +74 -0
- package/dist/hostname.d.ts.map +1 -0
- package/dist/hostname.js +215 -0
- package/dist/hostname.js.map +1 -0
- package/dist/human-actions.d.ts +49 -0
- package/dist/human-actions.d.ts.map +1 -0
- package/dist/human-actions.js +272 -0
- package/dist/human-actions.js.map +1 -0
- package/dist/index.d.ts +72 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +72 -0
- package/dist/index.js.map +1 -0
- package/dist/json-schema.d.ts +108 -0
- package/dist/json-schema.d.ts.map +1 -0
- package/dist/json-schema.js +240 -0
- package/dist/json-schema.js.map +1 -0
- package/dist/key-checksum.d.ts +33 -0
- package/dist/key-checksum.d.ts.map +1 -0
- package/dist/key-checksum.js +67 -0
- package/dist/key-checksum.js.map +1 -0
- package/dist/libraries.d.ts +60 -0
- package/dist/libraries.d.ts.map +1 -0
- package/dist/libraries.js +120 -0
- package/dist/libraries.js.map +1 -0
- package/dist/limit-catalog.d.ts +371 -0
- package/dist/limit-catalog.d.ts.map +1 -0
- package/dist/limit-catalog.js +414 -0
- package/dist/limit-catalog.js.map +1 -0
- package/dist/limits.d.ts +167 -0
- package/dist/limits.d.ts.map +1 -0
- package/dist/limits.js +175 -0
- package/dist/limits.js.map +1 -0
- package/dist/locale-tag.d.ts +21 -0
- package/dist/locale-tag.d.ts.map +1 -0
- package/dist/locale-tag.js +21 -0
- package/dist/locale-tag.js.map +1 -0
- package/dist/make-diagnostic.d.ts +74 -0
- package/dist/make-diagnostic.d.ts.map +1 -0
- package/dist/make-diagnostic.js +100 -0
- package/dist/make-diagnostic.js.map +1 -0
- package/dist/manifest-compat-diagnostics.d.ts +23 -0
- package/dist/manifest-compat-diagnostics.d.ts.map +1 -0
- package/dist/manifest-compat-diagnostics.js +150 -0
- package/dist/manifest-compat-diagnostics.js.map +1 -0
- package/dist/manifest-compat.d.ts +58 -0
- package/dist/manifest-compat.d.ts.map +1 -0
- package/dist/manifest-compat.js +377 -0
- package/dist/manifest-compat.js.map +1 -0
- package/dist/manifest.d.ts +1769 -0
- package/dist/manifest.d.ts.map +1 -0
- package/dist/manifest.js +421 -0
- package/dist/manifest.js.map +1 -0
- package/dist/metering.d.ts +126 -0
- package/dist/metering.d.ts.map +1 -0
- package/dist/metering.js +147 -0
- package/dist/metering.js.map +1 -0
- package/dist/migrate.d.ts +70 -0
- package/dist/migrate.d.ts.map +1 -0
- package/dist/migrate.js +159 -0
- package/dist/migrate.js.map +1 -0
- package/dist/names.d.ts +37 -0
- package/dist/names.d.ts.map +1 -0
- package/dist/names.js +55 -0
- package/dist/names.js.map +1 -0
- package/dist/overage-pricing.d.ts +89 -0
- package/dist/overage-pricing.d.ts.map +1 -0
- package/dist/overage-pricing.js +170 -0
- package/dist/overage-pricing.js.map +1 -0
- package/dist/plan-ids.d.ts +10 -0
- package/dist/plan-ids.d.ts.map +1 -0
- package/dist/plan-ids.js +8 -0
- package/dist/plan-ids.js.map +1 -0
- package/dist/plan-limits.d.ts +138 -0
- package/dist/plan-limits.d.ts.map +1 -0
- package/dist/plan-limits.js +112 -0
- package/dist/plan-limits.js.map +1 -0
- package/dist/plan-pricing.d.ts +145 -0
- package/dist/plan-pricing.d.ts.map +1 -0
- package/dist/plan-pricing.js +172 -0
- package/dist/plan-pricing.js.map +1 -0
- package/dist/plan-usage.d.ts +112 -0
- package/dist/plan-usage.d.ts.map +1 -0
- package/dist/plan-usage.js +134 -0
- package/dist/plan-usage.js.map +1 -0
- package/dist/preview-token.d.ts +52 -0
- package/dist/preview-token.d.ts.map +1 -0
- package/dist/preview-token.js +106 -0
- package/dist/preview-token.js.map +1 -0
- package/dist/prop-names.d.ts +51 -0
- package/dist/prop-names.d.ts.map +1 -0
- package/dist/prop-names.js +150 -0
- package/dist/prop-names.js.map +1 -0
- package/dist/prop-type-docs.d.ts +20 -0
- package/dist/prop-type-docs.d.ts.map +1 -0
- package/dist/prop-type-docs.js +89 -0
- package/dist/prop-type-docs.js.map +1 -0
- package/dist/prop-types.d.ts +97 -0
- package/dist/prop-types.d.ts.map +1 -0
- package/dist/prop-types.js +299 -0
- package/dist/prop-types.js.map +1 -0
- package/dist/props.d.ts +996 -0
- package/dist/props.d.ts.map +1 -0
- package/dist/props.js +183 -0
- package/dist/props.js.map +1 -0
- package/dist/proto-guard.d.ts +29 -0
- package/dist/proto-guard.d.ts.map +1 -0
- package/dist/proto-guard.js +79 -0
- package/dist/proto-guard.js.map +1 -0
- package/dist/runtime-errors.d.ts +42 -0
- package/dist/runtime-errors.d.ts.map +1 -0
- package/dist/runtime-errors.js +42 -0
- package/dist/runtime-errors.js.map +1 -0
- package/dist/runtime-pointers.d.ts +58 -0
- package/dist/runtime-pointers.d.ts.map +1 -0
- package/dist/runtime-pointers.js +84 -0
- package/dist/runtime-pointers.js.map +1 -0
- package/dist/secret-scan.d.ts +191 -0
- package/dist/secret-scan.d.ts.map +1 -0
- package/dist/secret-scan.js +542 -0
- package/dist/secret-scan.js.map +1 -0
- package/dist/semver.d.ts +89 -0
- package/dist/semver.d.ts.map +1 -0
- package/dist/semver.js +400 -0
- package/dist/semver.js.map +1 -0
- package/dist/server-key.d.ts +68 -0
- package/dist/server-key.d.ts.map +1 -0
- package/dist/server-key.js +150 -0
- package/dist/server-key.js.map +1 -0
- package/dist/site-manifest-keys.d.ts +107 -0
- package/dist/site-manifest-keys.d.ts.map +1 -0
- package/dist/site-manifest-keys.js +146 -0
- package/dist/site-manifest-keys.js.map +1 -0
- package/dist/site-manifest.d.ts +286 -0
- package/dist/site-manifest.d.ts.map +1 -0
- package/dist/site-manifest.js +100 -0
- package/dist/site-manifest.js.map +1 -0
- package/dist/source-archive.d.ts +119 -0
- package/dist/source-archive.d.ts.map +1 -0
- package/dist/source-archive.js +644 -0
- package/dist/source-archive.js.map +1 -0
- package/dist/source-package-corpus.d.ts +55 -0
- package/dist/source-package-corpus.d.ts.map +1 -0
- package/dist/source-package-corpus.js +303 -0
- package/dist/source-package-corpus.js.map +1 -0
- package/dist/source-package.d.ts +227 -0
- package/dist/source-package.d.ts.map +1 -0
- package/dist/source-package.js +361 -0
- package/dist/source-package.js.map +1 -0
- package/dist/source-secrets.d.ts +21 -0
- package/dist/source-secrets.d.ts.map +1 -0
- package/dist/source-secrets.js +43 -0
- package/dist/source-secrets.js.map +1 -0
- package/dist/ssr-cap.d.ts +61 -0
- package/dist/ssr-cap.d.ts.map +1 -0
- package/dist/ssr-cap.js +107 -0
- package/dist/ssr-cap.js.map +1 -0
- package/dist/ssr-kv.d.ts +18 -0
- package/dist/ssr-kv.d.ts.map +1 -0
- package/dist/ssr-kv.js +18 -0
- package/dist/ssr-kv.js.map +1 -0
- package/dist/ssr-version-ledger.d.ts +53 -0
- package/dist/ssr-version-ledger.d.ts.map +1 -0
- package/dist/ssr-version-ledger.js +88 -0
- package/dist/ssr-version-ledger.js.map +1 -0
- package/dist/style-references.d.ts +58 -0
- package/dist/style-references.d.ts.map +1 -0
- package/dist/style-references.js +241 -0
- package/dist/style-references.js.map +1 -0
- package/dist/tag-name.d.ts +87 -0
- package/dist/tag-name.d.ts.map +1 -0
- package/dist/tag-name.js +222 -0
- package/dist/tag-name.js.map +1 -0
- package/dist/tar-writer.d.ts +74 -0
- package/dist/tar-writer.d.ts.map +1 -0
- package/dist/tar-writer.js +148 -0
- package/dist/tar-writer.js.map +1 -0
- package/dist/testing.d.ts +11 -0
- package/dist/testing.d.ts.map +1 -0
- package/dist/testing.js +11 -0
- package/dist/testing.js.map +1 -0
- package/dist/text-codec.d.ts +36 -0
- package/dist/text-codec.d.ts.map +1 -0
- package/dist/text-codec.js +32 -0
- package/dist/text-codec.js.map +1 -0
- package/dist/url-value.d.ts +41 -0
- package/dist/url-value.d.ts.map +1 -0
- package/dist/url-value.js +147 -0
- package/dist/url-value.js.map +1 -0
- package/dist/usage-guard.d.ts +99 -0
- package/dist/usage-guard.d.ts.map +1 -0
- package/dist/usage-guard.js +104 -0
- package/dist/usage-guard.js.map +1 -0
- package/dist/usage-mirror.d.ts +55 -0
- package/dist/usage-mirror.d.ts.map +1 -0
- package/dist/usage-mirror.js +52 -0
- package/dist/usage-mirror.js.map +1 -0
- package/dist/value-check.d.ts +88 -0
- package/dist/value-check.d.ts.map +1 -0
- package/dist/value-check.js +279 -0
- package/dist/value-check.js.map +1 -0
- package/dist/value-patterns.d.ts +9 -0
- package/dist/value-patterns.d.ts.map +1 -0
- package/dist/value-patterns.js +17 -0
- package/dist/value-patterns.js.map +1 -0
- package/dist/value-schema.d.ts +796 -0
- package/dist/value-schema.d.ts.map +1 -0
- package/dist/value-schema.js +231 -0
- package/dist/value-schema.js.map +1 -0
- package/dist/zod-free.d.ts +59 -0
- package/dist/zod-free.d.ts.map +1 -0
- package/dist/zod-free.js +57 -0
- package/dist/zod-free.js.map +1 -0
- package/package.json +75 -3
- package/schema/DEPLOYED +12 -0
- package/schema/build-diagnostic.v1.json +63 -0
- package/schema/component-manifest.v1.json +1000 -0
- package/schema/data-api.v1.json +194 -0
- package/schema/library-manifest.v1.json +60 -0
- package/schema/published/SHA256SUMS +36 -0
- package/schema/published/build-diagnostic/v1.10.json +83 -0
- package/schema/published/build-diagnostic/v1.3.json +83 -0
- package/schema/published/build-diagnostic/v1.4.json +83 -0
- package/schema/published/build-diagnostic/v1.5.json +83 -0
- package/schema/published/build-diagnostic/v1.6.json +83 -0
- package/schema/published/build-diagnostic/v1.7.json +83 -0
- package/schema/published/build-diagnostic/v1.8.json +83 -0
- package/schema/published/build-diagnostic/v1.9.json +83 -0
- package/schema/published/component-manifest/v1.10.json +1443 -0
- package/schema/published/component-manifest/v1.3.json +1411 -0
- package/schema/published/component-manifest/v1.4.json +1419 -0
- package/schema/published/component-manifest/v1.5.json +1437 -0
- package/schema/published/component-manifest/v1.6.json +1437 -0
- package/schema/published/component-manifest/v1.7.json +1437 -0
- package/schema/published/component-manifest/v1.8.json +1437 -0
- package/schema/published/component-manifest/v1.9.json +1437 -0
- package/schema/published/data-api/v1.10.json +282 -0
- package/schema/published/data-api/v1.3.json +281 -0
- package/schema/published/data-api/v1.4.json +281 -0
- package/schema/published/data-api/v1.5.json +281 -0
- package/schema/published/data-api/v1.6.json +281 -0
- package/schema/published/data-api/v1.7.json +281 -0
- package/schema/published/data-api/v1.8.json +282 -0
- package/schema/published/data-api/v1.9.json +282 -0
- package/schema/published/library-manifest/v1.10.json +68 -0
- package/schema/published/library-manifest/v1.5.json +68 -0
- package/schema/published/library-manifest/v1.6.json +68 -0
- package/schema/published/library-manifest/v1.7.json +68 -0
- package/schema/published/library-manifest/v1.8.json +68 -0
- package/schema/published/library-manifest/v1.9.json +68 -0
- package/schema/published/taggor-config/v1.10.json +56 -0
- package/schema/published/taggor-config/v1.5.json +56 -0
- package/schema/published/taggor-config/v1.6.json +56 -0
- package/schema/published/taggor-config/v1.7.json +56 -0
- package/schema/published/taggor-config/v1.8.json +56 -0
- package/schema/published/taggor-config/v1.9.json +56 -0
- package/schema/taggor-config.v1.json +39 -0
|
@@ -0,0 +1,198 @@
|
|
|
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 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 const CONTRACT_MINOR = 10;
|
|
28
|
+
/** Newest contract version this package implements. */
|
|
29
|
+
export const CONTRACT_VERSION = `${String(CONTRACT_MAJOR)}.${String(CONTRACT_MINOR)}.0`;
|
|
30
|
+
/** Minimum months an older major stays supported after the next major ships (ADR 0019). */
|
|
31
|
+
export const SUPPORT_WINDOW_MONTHS = 12;
|
|
32
|
+
/**
|
|
33
|
+
* The policy of this release: contract 1.7, with v1 as the only (and current) major.
|
|
34
|
+
*
|
|
35
|
+
* Inputs: none. Output: frozen data. When a major ships, the previous entry gains `deprecatedOn`
|
|
36
|
+
* and `supportedUntil` in the same change that bumps `CONTRACT_MAJOR` (ADR 0019). Errors: none.
|
|
37
|
+
* Side effects: none.
|
|
38
|
+
*/
|
|
39
|
+
export const CONTRACT_VERSION_POLICY = Object.freeze({
|
|
40
|
+
major: CONTRACT_MAJOR,
|
|
41
|
+
minor: CONTRACT_MINOR,
|
|
42
|
+
majors: Object.freeze([Object.freeze({ major: 1 })]),
|
|
43
|
+
});
|
|
44
|
+
/** Each part has at most 6 digits and no leading zero, so the text is short and canonical. */
|
|
45
|
+
const NUMBER = "(0|[1-9]\\d{0,5})";
|
|
46
|
+
const SEMVER_PATTERN = new RegExp(`^${NUMBER}\\.${NUMBER}\\.${NUMBER}$`);
|
|
47
|
+
const PATCH_PATTERN = "(?:0|[1-9]\\d{0,5})";
|
|
48
|
+
const ISO_DAY_PATTERN = /^\d{4}-(?:0[1-9]|1[0-2])-(?:0[1-9]|[12]\d|3[01])$/;
|
|
49
|
+
/**
|
|
50
|
+
* Parses a `contractVersion` value.
|
|
51
|
+
*
|
|
52
|
+
* Inputs: any value. Output: the three numbers, or `undefined` when the value is not a string of
|
|
53
|
+
* the form `major.minor.patch` (digits only, no leading zeros, at most 6 digits each, no
|
|
54
|
+
* pre-release or build suffix). Errors: none. Side effects: none.
|
|
55
|
+
*/
|
|
56
|
+
export function parseContractVersion(value) {
|
|
57
|
+
if (typeof value !== "string")
|
|
58
|
+
return undefined;
|
|
59
|
+
const match = SEMVER_PATTERN.exec(value);
|
|
60
|
+
if (match === null)
|
|
61
|
+
return undefined;
|
|
62
|
+
return { major: Number(match[1]), minor: Number(match[2]), patch: Number(match[3]) };
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* The anchored pattern of the versions a policy accepts for its current major: any patch of the
|
|
66
|
+
* minors `0` to `policy.minor`. The manifest schema uses it, so the JSON Schema refuses the same.
|
|
67
|
+
*
|
|
68
|
+
* Inputs: a policy (defaults to this release's). Output: a fresh `RegExp`. Errors: none. Side
|
|
69
|
+
* effects: none.
|
|
70
|
+
*/
|
|
71
|
+
export function contractVersionPattern(policy = CONTRACT_VERSION_POLICY) {
|
|
72
|
+
const minors = Array.from({ length: policy.minor + 1 }, (_, minor) => String(minor));
|
|
73
|
+
const minor = minors.length === 1 ? minors.join("") : `(?:${minors.join("|")})`;
|
|
74
|
+
return new RegExp(`^${String(policy.major)}\\.${minor}\\.${PATCH_PATTERN}$`);
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Classifies a `contractVersion` value without looking at dates.
|
|
78
|
+
*
|
|
79
|
+
* Inputs: the raw value (`undefined` when the key is absent) and a policy. Output: its kind and,
|
|
80
|
+
* when well formed, the parsed version. Errors: none. Side effects: none.
|
|
81
|
+
*/
|
|
82
|
+
export function classifyContractVersion(value, policy = CONTRACT_VERSION_POLICY) {
|
|
83
|
+
if (value === undefined)
|
|
84
|
+
return { kind: "missing", version: undefined };
|
|
85
|
+
const version = parseContractVersion(value);
|
|
86
|
+
if (version === undefined)
|
|
87
|
+
return { kind: "malformed", version };
|
|
88
|
+
if (version.major > policy.major)
|
|
89
|
+
return { kind: "newer-major", version };
|
|
90
|
+
if (version.major < policy.major)
|
|
91
|
+
return { kind: "older-major", version };
|
|
92
|
+
if (version.minor > policy.minor)
|
|
93
|
+
return { kind: "newer-minor", version };
|
|
94
|
+
return { kind: "current", version };
|
|
95
|
+
}
|
|
96
|
+
function formatVersion(version) {
|
|
97
|
+
return version === undefined
|
|
98
|
+
? ""
|
|
99
|
+
: `${String(version.major)}.${String(version.minor)}.${String(version.patch)}`;
|
|
100
|
+
}
|
|
101
|
+
function newestVersion(policy) {
|
|
102
|
+
return `${String(policy.major)}.${String(policy.minor)}.x`;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* The message for a version problem. Shared by `checkContractVersion` and `parseManifest`, so the
|
|
106
|
+
* builder, the runtime and the API say the same thing.
|
|
107
|
+
*
|
|
108
|
+
* Inputs: the problem code (or `older-major` from `classifyContractVersion`), the parsed version,
|
|
109
|
+
* the policy and, for older majors, their support entry. Output: one English sentence that says
|
|
110
|
+
* what to do. Errors: none. Side effects: none.
|
|
111
|
+
*/
|
|
112
|
+
export function contractVersionMessage(code, version, policy = CONTRACT_VERSION_POLICY, support) {
|
|
113
|
+
const newest = newestVersion(policy);
|
|
114
|
+
const text = formatVersion(version);
|
|
115
|
+
const major = String(version?.major ?? "");
|
|
116
|
+
switch (code) {
|
|
117
|
+
case "missing":
|
|
118
|
+
return `contractVersion is missing: declare the contract version the manifest was written for (newest supported: ${newest})`;
|
|
119
|
+
case "malformed":
|
|
120
|
+
return `contractVersion must be a semantic version major.minor.patch such as "${String(policy.major)}.${String(policy.minor)}.0" (digits only, no suffix)`;
|
|
121
|
+
case "newer-minor":
|
|
122
|
+
return `contractVersion ${text} is newer than the newest supported (${newest}): update the Taggor toolchain that reads this manifest`;
|
|
123
|
+
case "newer-major":
|
|
124
|
+
return `contractVersion ${text} is contract v${major}, newer than the newest supported (${newest})`;
|
|
125
|
+
case "older-major":
|
|
126
|
+
return `contractVersion ${text} is contract v${major}: migrate it with migrateManifest to v${String(policy.major)} before parsing`;
|
|
127
|
+
case "deprecated-major":
|
|
128
|
+
return `contract v${major} is deprecated since ${support?.deprecatedOn ?? "?"} and supported until ${support?.supportedUntil ?? "?"}: migrate the component to v${String(policy.major)}`;
|
|
129
|
+
case "unsupported-major":
|
|
130
|
+
return support?.supportedUntil === undefined
|
|
131
|
+
? `contract v${major} is not supported (newest supported: ${newest})`
|
|
132
|
+
: `contract v${major} is no longer supported (support ended ${support.supportedUntil}): migrate the component to v${String(policy.major)}`;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
function problem(code, context, version, policy, support) {
|
|
136
|
+
const fatal = code !== "deprecated-major";
|
|
137
|
+
return {
|
|
138
|
+
code,
|
|
139
|
+
severity: context.consumer === "builder" && fatal ? "error" : "warning",
|
|
140
|
+
message: contractVersionMessage(code, version, policy, support),
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* The verdict on a manifest's `contractVersion` for the builder or the runtime (ADR 0019).
|
|
145
|
+
*
|
|
146
|
+
* | Case | Builder | Runtime |
|
|
147
|
+
* | --- | --- | --- |
|
|
148
|
+
* | known minor of the current major | usable | usable |
|
|
149
|
+
* | older major inside its support window | usable, warning `deprecated-major` | usable, no problem |
|
|
150
|
+
* | newer minor of the current major | error `newer-minor` | usable, warning (unknown additions are ignored) |
|
|
151
|
+
* | missing, malformed, newer major, older major out of support | error | not usable, warning |
|
|
152
|
+
*
|
|
153
|
+
* Inputs: the raw value (`undefined` when absent), the consumer and today's ISO day, and a policy
|
|
154
|
+
* (defaults to this release's). Output: `{ usable, version, problem }`. Errors: throws a
|
|
155
|
+
* `RangeError` only when `today` is not `YYYY-MM-DD` (a programming error of the caller); a bad
|
|
156
|
+
* `contractVersion` never throws. Side effects: none.
|
|
157
|
+
*/
|
|
158
|
+
export function checkContractVersion(value, context, policy = CONTRACT_VERSION_POLICY) {
|
|
159
|
+
if (!ISO_DAY_PATTERN.test(context.today)) {
|
|
160
|
+
throw new RangeError(`today must be an ISO day (YYYY-MM-DD), got "${context.today}"`);
|
|
161
|
+
}
|
|
162
|
+
const { kind, version } = classifyContractVersion(value, policy);
|
|
163
|
+
switch (kind) {
|
|
164
|
+
case "current":
|
|
165
|
+
return { usable: true, version, problem: undefined };
|
|
166
|
+
case "newer-minor":
|
|
167
|
+
// A minor only adds, so an older runtime can still show the component without the additions;
|
|
168
|
+
// the builder cannot, because it would drop declarations it does not know.
|
|
169
|
+
return {
|
|
170
|
+
usable: context.consumer === "runtime",
|
|
171
|
+
version,
|
|
172
|
+
problem: problem(kind, context, version, policy),
|
|
173
|
+
};
|
|
174
|
+
case "older-major": {
|
|
175
|
+
const support = policy.majors.find((entry) => entry.major === version?.major);
|
|
176
|
+
const until = support?.supportedUntil;
|
|
177
|
+
if (support === undefined || until === undefined || context.today > until) {
|
|
178
|
+
return {
|
|
179
|
+
usable: false,
|
|
180
|
+
version,
|
|
181
|
+
problem: problem("unsupported-major", context, version, policy, support),
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
return {
|
|
185
|
+
usable: true,
|
|
186
|
+
version,
|
|
187
|
+
problem: context.consumer === "builder"
|
|
188
|
+
? problem("deprecated-major", context, version, policy, support)
|
|
189
|
+
: undefined,
|
|
190
|
+
};
|
|
191
|
+
}
|
|
192
|
+
case "newer-major":
|
|
193
|
+
case "malformed":
|
|
194
|
+
case "missing":
|
|
195
|
+
return { usable: false, version, problem: problem(kind, context, version, policy) };
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
//# sourceMappingURL=contract-version.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contract-version.js","sourceRoot":"","sources":["../src/contract-version.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,iGA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CAAC,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,CAAC,EAAE,CAAC;IACxF,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Names of fields that hold credentials (TAG-1706, moved here by TAG-703 for its second use): the
|
|
3
|
+
* builder's quality gate refuses a component that collects them, and the API and the edge refuse to
|
|
4
|
+
* accept submissions to a collection that declares one, with the very same rule. Zod-free and pure.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Names of a field that holds a password or a card's number or code, in English and Portuguese,
|
|
8
|
+
* camelCase, snake_case or kebab-case (`password`, `senha`, `cardNumber`, `numero_cartao`, `cvv`).
|
|
9
|
+
* The whole name must match, so `passwordHint`, `cardholder` or an e-mail's `cc` do not.
|
|
10
|
+
*/
|
|
11
|
+
export declare const CREDENTIAL_FIELD_NAME: RegExp;
|
|
12
|
+
/**
|
|
13
|
+
* Whether a field name names a credential (`CREDENTIAL_FIELD_NAME`).
|
|
14
|
+
*
|
|
15
|
+
* Inputs: the name. Output: a boolean. Errors: none. Side effects: none.
|
|
16
|
+
*/
|
|
17
|
+
export declare function isCredentialFieldName(name: string): boolean;
|
|
18
|
+
/**
|
|
19
|
+
* The first field of a set of collections that names a credential.
|
|
20
|
+
*
|
|
21
|
+
* Inputs: the collections of a component (`data.collections`: name to a declaration with `fields`).
|
|
22
|
+
* Output: `{ collection, field }` of the first credential field in iteration order, or `null`.
|
|
23
|
+
* Errors: none. Side effects: none.
|
|
24
|
+
*/
|
|
25
|
+
export declare function findCredentialCollectionField(collections: Readonly<Record<string, {
|
|
26
|
+
readonly fields: Readonly<Record<string, unknown>>;
|
|
27
|
+
}>>): {
|
|
28
|
+
readonly collection: string;
|
|
29
|
+
readonly field: string;
|
|
30
|
+
} | null;
|
|
31
|
+
//# sourceMappingURL=credential-fields.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"credential-fields.d.ts","sourceRoot":"","sources":["../src/credential-fields.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,QACwK,CAAC;AAE3M;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAE3D;AAED;;;;;;GAMG;AACH,wBAAgB,6BAA6B,CAC3C,WAAW,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE;IAAE,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAA;CAAE,CAAC,CAAC,GAC5F;IAAE,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAOhE"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Names of fields that hold credentials (TAG-1706, moved here by TAG-703 for its second use): the
|
|
3
|
+
* builder's quality gate refuses a component that collects them, and the API and the edge refuse to
|
|
4
|
+
* accept submissions to a collection that declares one, with the very same rule. Zod-free and pure.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Names of a field that holds a password or a card's number or code, in English and Portuguese,
|
|
8
|
+
* camelCase, snake_case or kebab-case (`password`, `senha`, `cardNumber`, `numero_cartao`, `cvv`).
|
|
9
|
+
* The whole name must match, so `passwordHint`, `cardholder` or an e-mail's `cc` do not.
|
|
10
|
+
*/
|
|
11
|
+
export const CREDENTIAL_FIELD_NAME = /^(?:pass(?:word)?|passwd|pwd|senha|card[-_]?(?:number|num|no)|credit[-_]?card(?:[-_]?number)?|cc[-_]?(?:number|num|no)|cvv2?|cvc2?|csc|security[-_]?code|n(?:u|ú)mero[-_]?(?:do[-_]?)?cart(?:a|ã)o)$/iu;
|
|
12
|
+
/**
|
|
13
|
+
* Whether a field name names a credential (`CREDENTIAL_FIELD_NAME`).
|
|
14
|
+
*
|
|
15
|
+
* Inputs: the name. Output: a boolean. Errors: none. Side effects: none.
|
|
16
|
+
*/
|
|
17
|
+
export function isCredentialFieldName(name) {
|
|
18
|
+
return CREDENTIAL_FIELD_NAME.test(name.trim());
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* The first field of a set of collections that names a credential.
|
|
22
|
+
*
|
|
23
|
+
* Inputs: the collections of a component (`data.collections`: name to a declaration with `fields`).
|
|
24
|
+
* Output: `{ collection, field }` of the first credential field in iteration order, or `null`.
|
|
25
|
+
* Errors: none. Side effects: none.
|
|
26
|
+
*/
|
|
27
|
+
export function findCredentialCollectionField(collections) {
|
|
28
|
+
for (const [collection, declaration] of Object.entries(collections)) {
|
|
29
|
+
for (const field of Object.keys(declaration.fields)) {
|
|
30
|
+
if (isCredentialFieldName(field))
|
|
31
|
+
return { collection, field };
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=credential-fields.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"credential-fields.js","sourceRoot":"","sources":["../src/credential-fields.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;GAIG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAChC,wMAAwM,CAAC;AAE3M;;;;GAIG;AACH,MAAM,UAAU,qBAAqB,CAAC,IAAY;IAChD,OAAO,qBAAqB,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;AACjD,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,6BAA6B,CAC3C,WAA6F;IAE7F,KAAK,MAAM,CAAC,UAAU,EAAE,WAAW,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,WAAW,CAAC,EAAE,CAAC;QACpE,KAAK,MAAM,KAAK,IAAI,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,EAAE,CAAC;YACpD,IAAI,qBAAqB,CAAC,KAAK,CAAC;gBAAE,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,CAAC;QACjE,CAAC;IACH,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A small CSS tokenizer (TAG-206; moved out of `style-references.ts` by TAG-1706, which reads the
|
|
3
|
+
* same tokens to find viewport overlays in the builder's security gate).
|
|
4
|
+
*
|
|
5
|
+
* It follows the CSS Syntax Level 3 rules that matter to the checks built on it: a raw NUL read as
|
|
6
|
+
* U+FFFD, comments dropped, strings and escapes decoded, unquoted `url(` bodies skipped as one
|
|
7
|
+
* token, identifiers, functions and at-keywords with their escapes decoded (`fi\78 ed` is the
|
|
8
|
+
* identifier `fixed`), everything else one delimiter per character. The CSS is untrusted (golden
|
|
9
|
+
* rule 5): it runs in linear time and memory, never evaluates anything and never throws. Zod-free,
|
|
10
|
+
* so any consumer, the runtime included, may import it.
|
|
11
|
+
*/
|
|
12
|
+
/** One token: its kind, its decoded value when it has one and its offset in the text. */
|
|
13
|
+
export type CssToken = {
|
|
14
|
+
readonly type: "ident";
|
|
15
|
+
readonly value: string;
|
|
16
|
+
readonly offset: number;
|
|
17
|
+
} | {
|
|
18
|
+
readonly type: "function";
|
|
19
|
+
readonly value: string;
|
|
20
|
+
readonly offset: number;
|
|
21
|
+
} | {
|
|
22
|
+
readonly type: "at-keyword";
|
|
23
|
+
readonly value: string;
|
|
24
|
+
readonly offset: number;
|
|
25
|
+
} | {
|
|
26
|
+
readonly type: "string";
|
|
27
|
+
readonly value: string;
|
|
28
|
+
readonly offset: number;
|
|
29
|
+
} | {
|
|
30
|
+
readonly type: "delim";
|
|
31
|
+
readonly value: string;
|
|
32
|
+
readonly offset: number;
|
|
33
|
+
} | {
|
|
34
|
+
readonly type: "whitespace" | "other";
|
|
35
|
+
readonly offset: number;
|
|
36
|
+
};
|
|
37
|
+
/** ASCII lowercase, the case-insensitivity CSS uses for function names and keywords. */
|
|
38
|
+
export declare const asciiLower: (text: string) => string;
|
|
39
|
+
/**
|
|
40
|
+
* The tokens of a CSS text.
|
|
41
|
+
*
|
|
42
|
+
* Inputs: the CSS. Output: its tokens in order, comments left out, offsets in UTF-16 code units of
|
|
43
|
+
* the text given. Errors: never throws. Side effects: none. Linear in the length.
|
|
44
|
+
*/
|
|
45
|
+
export declare function tokenizeCss(css: string): CssToken[];
|
|
46
|
+
//# sourceMappingURL=css-tokens.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"css-tokens.d.ts","sourceRoot":"","sources":["../src/css-tokens.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,yFAAyF;AACzF,MAAM,MAAM,QAAQ,GAChB;IAAE,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GAC3E;IAAE,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GAC9E;IAAE,QAAQ,CAAC,IAAI,EAAE,YAAY,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GAChF;IAAE,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GAC5E;IAAE,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GAC3E;IAAE,QAAQ,CAAC,IAAI,EAAE,YAAY,GAAG,OAAO,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AAWvE,wFAAwF;AACxF,eAAO,MAAM,UAAU,GAAI,MAAM,MAAM,WAAmD,CAAC;AA+J3F;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,QAAQ,EAAE,CAEnD"}
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A small CSS tokenizer (TAG-206; moved out of `style-references.ts` by TAG-1706, which reads the
|
|
3
|
+
* same tokens to find viewport overlays in the builder's security gate).
|
|
4
|
+
*
|
|
5
|
+
* It follows the CSS Syntax Level 3 rules that matter to the checks built on it: a raw NUL read as
|
|
6
|
+
* U+FFFD, comments dropped, strings and escapes decoded, unquoted `url(` bodies skipped as one
|
|
7
|
+
* token, identifiers, functions and at-keywords with their escapes decoded (`fi\78 ed` is the
|
|
8
|
+
* identifier `fixed`), everything else one delimiter per character. The CSS is untrusted (golden
|
|
9
|
+
* rule 5): it runs in linear time and memory, never evaluates anything and never throws. Zod-free,
|
|
10
|
+
* so any consumer, the runtime included, may import it.
|
|
11
|
+
*/
|
|
12
|
+
const isNewline = (c) => c === "\n" || c === "\r" || c === "\f";
|
|
13
|
+
const isWhitespace = (c) => c === " " || c === "\t" || isNewline(c);
|
|
14
|
+
const isHexDigit = (c) => c !== undefined && /^[0-9a-fA-F]$/.test(c);
|
|
15
|
+
const isNameStart = (c) => c !== undefined && (/^[a-zA-Z_]$/.test(c) || c.charCodeAt(0) >= 0x80);
|
|
16
|
+
const isNameChar = (c) => c !== undefined && (/^[a-zA-Z0-9_-]$/.test(c) || c.charCodeAt(0) >= 0x80);
|
|
17
|
+
/** ASCII lowercase, the case-insensitivity CSS uses for function names and keywords. */
|
|
18
|
+
export const asciiLower = (text) => text.replace(/[A-Z]/g, (c) => c.toLowerCase());
|
|
19
|
+
/** Splits one CSS text into the tokens the checks need; comments are dropped. */
|
|
20
|
+
class Tokenizer {
|
|
21
|
+
index = 0;
|
|
22
|
+
tokens = [];
|
|
23
|
+
css;
|
|
24
|
+
constructor(css) {
|
|
25
|
+
// CSS Syntax §3.3: the browser reads a raw NUL as U+FFFD before tokenizing, so
|
|
26
|
+
// `var(--declared\0x)` names `--declared\uFFFDx`, never `--declared`. Same length: offsets hold.
|
|
27
|
+
this.css = css.replace(/\u0000/g, "\uFFFD");
|
|
28
|
+
}
|
|
29
|
+
run() {
|
|
30
|
+
while (this.index < this.css.length)
|
|
31
|
+
this.next();
|
|
32
|
+
return this.tokens;
|
|
33
|
+
}
|
|
34
|
+
at(offset = 0) {
|
|
35
|
+
return this.css[this.index + offset];
|
|
36
|
+
}
|
|
37
|
+
validEscapeAt(offset) {
|
|
38
|
+
return this.at(offset) === "\\" && !isNewline(this.at(offset + 1));
|
|
39
|
+
}
|
|
40
|
+
startsIdentAt(offset) {
|
|
41
|
+
const first = this.at(offset);
|
|
42
|
+
if (first === "-") {
|
|
43
|
+
const second = this.at(offset + 1);
|
|
44
|
+
return isNameStart(second) || second === "-" || this.validEscapeAt(offset + 1);
|
|
45
|
+
}
|
|
46
|
+
return isNameStart(first) || this.validEscapeAt(offset);
|
|
47
|
+
}
|
|
48
|
+
next() {
|
|
49
|
+
const start = this.index;
|
|
50
|
+
const c = this.at();
|
|
51
|
+
if (c === "/" && this.at(1) === "*") {
|
|
52
|
+
const end = this.css.indexOf("*/", start + 2);
|
|
53
|
+
this.index = end === -1 ? this.css.length : end + 2;
|
|
54
|
+
}
|
|
55
|
+
else if (isWhitespace(c)) {
|
|
56
|
+
while (isWhitespace(this.at()))
|
|
57
|
+
this.index += 1;
|
|
58
|
+
this.tokens.push({ type: "whitespace", offset: start });
|
|
59
|
+
}
|
|
60
|
+
else if (c === '"' || c === "'") {
|
|
61
|
+
this.tokens.push({ type: "string", value: this.string(c), offset: start });
|
|
62
|
+
}
|
|
63
|
+
else if (c === "@" && this.startsIdentAt(1)) {
|
|
64
|
+
this.index += 1;
|
|
65
|
+
this.tokens.push({ type: "at-keyword", value: this.name(), offset: start });
|
|
66
|
+
}
|
|
67
|
+
else if (c === "#" && (isNameChar(this.at(1)) || this.validEscapeAt(1))) {
|
|
68
|
+
// A hash (`#--x`, `#fff`) is never a custom property or a part name.
|
|
69
|
+
this.index += 1;
|
|
70
|
+
this.name();
|
|
71
|
+
this.tokens.push({ type: "other", offset: start });
|
|
72
|
+
}
|
|
73
|
+
else if (this.startsIdentAt(0)) {
|
|
74
|
+
this.identLike(start);
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
this.index += c.length;
|
|
78
|
+
this.tokens.push({ type: "delim", value: c, offset: start });
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
identLike(start) {
|
|
82
|
+
const value = this.name();
|
|
83
|
+
if (this.at() !== "(") {
|
|
84
|
+
this.tokens.push({ type: "ident", value, offset: start });
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
this.index += 1;
|
|
88
|
+
if (asciiLower(value) === "url") {
|
|
89
|
+
let lookahead = this.index;
|
|
90
|
+
while (isWhitespace(this.css[lookahead]))
|
|
91
|
+
lookahead += 1;
|
|
92
|
+
const quote = this.css[lookahead];
|
|
93
|
+
if (quote !== '"' && quote !== "'") {
|
|
94
|
+
this.skipUrl();
|
|
95
|
+
this.tokens.push({ type: "other", offset: start });
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
this.tokens.push({ type: "function", value, offset: start });
|
|
100
|
+
}
|
|
101
|
+
/** Consumes an unquoted `url(…)` body up to and including `)`. */
|
|
102
|
+
skipUrl() {
|
|
103
|
+
while (this.index < this.css.length) {
|
|
104
|
+
const c = this.at();
|
|
105
|
+
if (c === ")") {
|
|
106
|
+
this.index += 1;
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
this.index += c === "\\" && this.index + 1 < this.css.length ? 2 : 1;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
/** Consumes a name (identifier body), decoding escapes. */
|
|
113
|
+
name() {
|
|
114
|
+
let value = "";
|
|
115
|
+
for (;;) {
|
|
116
|
+
const c = this.at();
|
|
117
|
+
if (isNameChar(c)) {
|
|
118
|
+
value += c;
|
|
119
|
+
this.index += 1;
|
|
120
|
+
}
|
|
121
|
+
else if (this.validEscapeAt(0)) {
|
|
122
|
+
this.index += 1;
|
|
123
|
+
value += this.escape();
|
|
124
|
+
}
|
|
125
|
+
else {
|
|
126
|
+
return value;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
/** Consumes the escape after a backslash (already consumed) and returns its character. */
|
|
131
|
+
escape() {
|
|
132
|
+
if (this.index >= this.css.length)
|
|
133
|
+
return "\uFFFD";
|
|
134
|
+
if (isHexDigit(this.at())) {
|
|
135
|
+
let hex = "";
|
|
136
|
+
for (let c = this.at(); hex.length < 6 && isHexDigit(c); c = this.at()) {
|
|
137
|
+
hex += c;
|
|
138
|
+
this.index += 1;
|
|
139
|
+
}
|
|
140
|
+
if (this.at() === "\r" && this.at(1) === "\n")
|
|
141
|
+
this.index += 2;
|
|
142
|
+
else if (isWhitespace(this.at()))
|
|
143
|
+
this.index += 1;
|
|
144
|
+
const point = Number.parseInt(hex, 16);
|
|
145
|
+
const valid = point !== 0 && point <= 0x10ffff && (point < 0xd800 || point > 0xdfff);
|
|
146
|
+
return valid ? String.fromCodePoint(point) : "\uFFFD";
|
|
147
|
+
}
|
|
148
|
+
const point = this.css.codePointAt(this.index);
|
|
149
|
+
const char = String.fromCodePoint(point);
|
|
150
|
+
this.index += char.length;
|
|
151
|
+
return char;
|
|
152
|
+
}
|
|
153
|
+
/** Consumes a quoted string (the opening quote included) and returns its decoded value. */
|
|
154
|
+
string(quote) {
|
|
155
|
+
this.index += 1;
|
|
156
|
+
let value = "";
|
|
157
|
+
while (this.index < this.css.length) {
|
|
158
|
+
const c = this.at();
|
|
159
|
+
if (c === quote) {
|
|
160
|
+
this.index += 1;
|
|
161
|
+
return value;
|
|
162
|
+
}
|
|
163
|
+
// A newline ends a bad string; the newline itself is left for the next token.
|
|
164
|
+
if (isNewline(c))
|
|
165
|
+
return value;
|
|
166
|
+
this.index += 1;
|
|
167
|
+
if (c !== "\\") {
|
|
168
|
+
value += c;
|
|
169
|
+
}
|
|
170
|
+
else if (isNewline(this.at())) {
|
|
171
|
+
this.index += this.at() === "\r" && this.at(1) === "\n" ? 2 : 1;
|
|
172
|
+
}
|
|
173
|
+
else if (this.index < this.css.length) {
|
|
174
|
+
value += this.escape();
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
return value;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* The tokens of a CSS text.
|
|
182
|
+
*
|
|
183
|
+
* Inputs: the CSS. Output: its tokens in order, comments left out, offsets in UTF-16 code units of
|
|
184
|
+
* the text given. Errors: never throws. Side effects: none. Linear in the length.
|
|
185
|
+
*/
|
|
186
|
+
export function tokenizeCss(css) {
|
|
187
|
+
return new Tokenizer(css).run();
|
|
188
|
+
}
|
|
189
|
+
//# sourceMappingURL=css-tokens.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"css-tokens.js","sourceRoot":"","sources":["../src/css-tokens.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAWH,MAAM,SAAS,GAAG,CAAC,CAAqB,EAAE,EAAE,CAAC,CAAC,KAAK,IAAI,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,KAAK,IAAI,CAAC;AACpF,MAAM,YAAY,GAAG,CAAC,CAAqB,EAAE,EAAE,CAAC,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,IAAI,IAAI,SAAS,CAAC,CAAC,CAAC,CAAC;AACxF,MAAM,UAAU,GAAG,CAAC,CAAqB,EAAe,EAAE,CACxD,CAAC,KAAK,SAAS,IAAI,eAAe,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAC7C,MAAM,WAAW,GAAG,CAAC,CAAqB,EAA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,CAAC;YAChB,IAAI,CAAC,KAAK,IAAI,EAAE,CAAC;gBACf,KAAK,IAAI,CAAC,CAAC;YACb,CAAC;iBAAM,IAAI,SAAS,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC;gBAChC,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,EAAE,EAAE,KAAK,IAAI,IAAI,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;YAClE,CAAC;iBAAM,IAAI,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,MAAM,EAAE,CAAC;gBACxC,KAAK,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;YACzB,CAAC;QACH,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC;CACF;AAED;;;;;GAKG;AACH,MAAM,UAAU,WAAW,CAAC,GAAW;IACrC,OAAO,IAAI,SAAS,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,CAAC;AAClC,CAAC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CSS values a manifest may declare (TAG-201): the default of a `color` prop and the defaults of
|
|
3
|
+
* public CSS variables, which the runtime writes into the component's stylesheet.
|
|
4
|
+
*
|
|
5
|
+
* A CSS value can fetch from the network (`url()`, `image-set()`, `src()`, `cross-fade()`…), so a
|
|
6
|
+
* free-form value would let a manifest leak every visitor's IP and Referer to an undeclared origin
|
|
7
|
+
* through `var(--x)` (threat T-64, golden rule 6). Values are therefore built from an allowlist:
|
|
8
|
+
* numbers, identifiers, `#`, `,`, `.`, `%`, `/`, `+`, whitespace, and `(` only right after a
|
|
9
|
+
* function in `CSS_FUNCTIONS` (lowercase). No `;`, braces, quotes, backslashes, `*` or angle
|
|
10
|
+
* brackets, so a value can neither close a declaration nor open a comment. JSON Schema cannot
|
|
11
|
+
* count parentheses, so only Zod checks that they are balanced (`SEMANTIC_RULES`).
|
|
12
|
+
*
|
|
13
|
+
* This module has no Zod (TAG-205), so the runtime may import it; `cssValueSchema` lives in
|
|
14
|
+
* `bounded.ts`.
|
|
15
|
+
*/
|
|
16
|
+
/** CSS functions a declared value may call: colors, math and `var()`. None of them loads a URL. */
|
|
17
|
+
export declare const CSS_FUNCTIONS: readonly ["rgb", "rgba", "hsl", "hsla", "hwb", "lab", "lch", "oklab", "oklch", "color", "color-mix", "calc", "min", "max", "clamp", "var"];
|
|
18
|
+
/**
|
|
19
|
+
* A CSS value from the allowlist. An identifier is read greedily and may be followed by `(` only
|
|
20
|
+
* when it is an allowed function, so `url(`, `image-set(`, `expression(` or `xrgb(` never match.
|
|
21
|
+
*/
|
|
22
|
+
export declare const CSS_VALUE_PATTERN: RegExp;
|
|
23
|
+
/** A `font-family` list: names, commas and whitespace; no functions or quotes at all. */
|
|
24
|
+
export declare const FONT_FAMILY_PATTERN: RegExp;
|
|
25
|
+
/**
|
|
26
|
+
* Tells whether every `(` in a value is closed, in order.
|
|
27
|
+
*
|
|
28
|
+
* Inputs: any string. Output: `true` when parentheses are balanced. Errors: none. Side effects:
|
|
29
|
+
* none.
|
|
30
|
+
*/
|
|
31
|
+
export declare function hasBalancedParentheses(value: string): boolean;
|
|
32
|
+
/**
|
|
33
|
+
* Tells whether a text is a declared CSS value: within `maxLength`, built from the allowlist
|
|
34
|
+
* `pattern` and with balanced parentheses. The Zod form is `cssValueSchema` (bounded.ts); the
|
|
35
|
+
* prop catalog (TAG-205) uses this one, which the runtime may import without Zod.
|
|
36
|
+
*
|
|
37
|
+
* Inputs: the text, the maximum length, the allowlist pattern (`CSS_VALUE_PATTERN` or
|
|
38
|
+
* `FONT_FAMILY_PATTERN`). Output: `true` when every rule holds (empty text is refused). Errors:
|
|
39
|
+
* none. Side effects: none.
|
|
40
|
+
*/
|
|
41
|
+
export declare function isCssValue(value: string, maxLength: number, pattern: RegExp): boolean;
|
|
42
|
+
//# sourceMappingURL=css-value.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"css-value.d.ts","sourceRoot":"","sources":["../src/css-value.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,mGAAmG;AACnG,eAAO,MAAM,aAAa,4IAiBf,CAAC;AAKZ;;;GAGG;AACH,eAAO,MAAM,iBAAiB,QAE7B,CAAC;AAEF,yFAAyF;AACzF,eAAO,MAAM,mBAAmB,QAAuB,CAAC;AAExD;;;;;GAKG;AACH,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAU7D;AAED;;;;;;;;GAQG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAOrF"}
|