@bleedingdev/modern-js-app-tools 3.5.0-ultramodern.36 → 3.5.0-ultramodern.38

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 (59) hide show
  1. package/dist/cjs/builder/shared/lazyCompilation.js +2 -10
  2. package/dist/cjs/commands/index.js +0 -4
  3. package/dist/cjs/index.js +18 -53
  4. package/dist/cjs/plugins/deploy/index.js +4 -4
  5. package/dist/cjs/plugins/deploy/platforms/cloudflare/index.js +2 -2
  6. package/dist/cjs/plugins/deploy/platforms/cloudflare/security-policies.js +2 -20
  7. package/dist/cjs/plugins/deploy/platforms/cloudflare-output-verifier/mutation-policy.js +0 -9
  8. package/dist/cjs/plugins/deploy/platforms/cloudflare-output-verifier/worker-bundles.js +0 -6
  9. package/dist/esm/builder/shared/lazyCompilation.mjs +1 -3
  10. package/dist/esm/commands/index.mjs +0 -1
  11. package/dist/esm/index.mjs +1 -4
  12. package/dist/esm/plugins/analyze/getHtmlTemplate.mjs +2 -2
  13. package/dist/esm/plugins/analyze/isDefaultExportFunction.mjs +2 -2
  14. package/dist/esm/plugins/deploy/index.mjs +1 -1
  15. package/dist/esm/plugins/deploy/platforms/cloudflare/index.mjs +1 -1
  16. package/dist/esm/plugins/deploy/platforms/cloudflare/security-policies.mjs +1 -1
  17. package/dist/esm/plugins/deploy/platforms/cloudflare-output-verifier/mutation-policy.mjs +1 -1
  18. package/dist/esm/plugins/deploy/platforms/cloudflare-output-verifier/worker-bundles.mjs +1 -1
  19. package/dist/esm-node/builder/shared/lazyCompilation.mjs +1 -3
  20. package/dist/esm-node/commands/index.mjs +0 -1
  21. package/dist/esm-node/index.mjs +1 -4
  22. package/dist/esm-node/plugins/analyze/getHtmlTemplate.mjs +2 -2
  23. package/dist/esm-node/plugins/analyze/isDefaultExportFunction.mjs +2 -2
  24. package/dist/esm-node/plugins/deploy/index.mjs +1 -1
  25. package/dist/esm-node/plugins/deploy/platforms/cloudflare/index.mjs +1 -1
  26. package/dist/esm-node/plugins/deploy/platforms/cloudflare/security-policies.mjs +1 -1
  27. package/dist/esm-node/plugins/deploy/platforms/cloudflare-output-verifier/mutation-policy.mjs +1 -1
  28. package/dist/esm-node/plugins/deploy/platforms/cloudflare-output-verifier/worker-bundles.mjs +1 -1
  29. package/dist/types/builder/generator/createCopyPattern.d.ts +7 -5
  30. package/dist/types/builder/shared/lazyCompilation.d.ts +2 -4
  31. package/dist/types/commands/index.d.ts +0 -1
  32. package/dist/types/index.d.ts +0 -2
  33. package/dist/types/plugins/deploy/platforms/cloudflare/i18n-worker.d.ts +3 -2
  34. package/dist/types/plugins/deploy/platforms/cloudflare/security-policies.d.ts +0 -37
  35. package/dist/types/plugins/deploy/platforms/cloudflare/worker-manifest.d.ts +14 -1
  36. package/dist/types/plugins/deploy/platforms/cloudflare-output-plan.d.ts +2 -1
  37. package/dist/types/plugins/deploy/platforms/cloudflare-output-verifier/mutation-policy.d.ts +1 -8
  38. package/dist/types/plugins/deploy/platforms/cloudflare-output-verifier/worker-bundles.d.ts +3 -4
  39. package/package.json +22 -22
  40. package/dist/cjs/baseline.js +0 -45
  41. package/dist/cjs/commands/runtime.js +0 -196
  42. package/dist/cjs/plugins/deploy/platforms/cloudflare-output-verifier.js +0 -62
  43. package/dist/cjs/plugins/deploy/platforms/cloudflare.js +0 -40
  44. package/dist/cjs/ultramodern/designSystem.js +0 -123
  45. package/dist/esm/baseline.mjs +0 -4
  46. package/dist/esm/commands/runtime.mjs +0 -146
  47. package/dist/esm/plugins/deploy/platforms/cloudflare-output-verifier.mjs +0 -1
  48. package/dist/esm/plugins/deploy/platforms/cloudflare.mjs +0 -1
  49. package/dist/esm/ultramodern/designSystem.mjs +0 -73
  50. package/dist/esm-node/baseline.mjs +0 -5
  51. package/dist/esm-node/commands/runtime.mjs +0 -147
  52. package/dist/esm-node/plugins/deploy/platforms/cloudflare-output-verifier.mjs +0 -2
  53. package/dist/esm-node/plugins/deploy/platforms/cloudflare.mjs +0 -2
  54. package/dist/esm-node/ultramodern/designSystem.mjs +0 -74
  55. package/dist/types/baseline.d.ts +0 -16
  56. package/dist/types/commands/runtime.d.ts +0 -12
  57. package/dist/types/plugins/deploy/platforms/cloudflare-output-verifier.d.ts +0 -1
  58. package/dist/types/plugins/deploy/platforms/cloudflare.d.ts +0 -1
  59. package/dist/types/ultramodern/designSystem.d.ts +0 -54
@@ -1,123 +0,0 @@
1
- "use strict";
2
- var __webpack_require__ = {};
3
- (()=>{
4
- __webpack_require__.d = (exports1, getters, values)=>{
5
- var define = (defs, kind)=>{
6
- for(var key in defs)if (__webpack_require__.o(defs, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
7
- enumerable: true,
8
- [kind]: defs[key]
9
- });
10
- };
11
- define(getters, "get");
12
- define(values, "value");
13
- };
14
- })();
15
- (()=>{
16
- __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
17
- })();
18
- (()=>{
19
- __webpack_require__.r = (exports1)=>{
20
- if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
21
- value: 'Module'
22
- });
23
- Object.defineProperty(exports1, '__esModule', {
24
- value: true
25
- });
26
- };
27
- })();
28
- var __webpack_exports__ = {};
29
- __webpack_require__.r(__webpack_exports__);
30
- const DESIGN_SYSTEM_MODES = [
31
- 'off',
32
- 'tokens',
33
- 'components',
34
- 'strict'
35
- ];
36
- const DESIGN_SYSTEM_OVERRIDE_LAYERS = [
37
- 'brand',
38
- 'vertical',
39
- 'application'
40
- ];
41
- const VALID_MODES = new Set(DESIGN_SYSTEM_MODES);
42
- const VALID_OVERRIDE_LAYERS = new Set(DESIGN_SYSTEM_OVERRIDE_LAYERS);
43
- const createValidationResult = (issues)=>({
44
- valid: 0 === issues.length,
45
- issues
46
- });
47
- const addIssue = (issues, path, message)=>{
48
- issues.push({
49
- path,
50
- message
51
- });
52
- };
53
- const createDesignSystemTokenPackMap = (tokenPacks)=>new Map(tokenPacks.map((tokenPack)=>[
54
- tokenPack.id,
55
- tokenPack
56
- ]));
57
- const validateDesignSystemConsumerCompatibility = (vertical, tokenPack, path = 'vertical')=>{
58
- const issues = [];
59
- const consumers = vertical.consumers ?? [];
60
- for (const [consumerIndex, consumer] of consumers.entries()){
61
- const consumerPath = `${path}.consumers[${consumerIndex}]`;
62
- if (consumer.unsupportedModes?.includes(vertical.mode)) addIssue(issues, `${consumerPath}.unsupportedModes`, `consumer "${consumer.id}" does not support "${vertical.mode}" mode`);
63
- if (!tokenPack) continue;
64
- const expectedVersion = consumer.tokenPackVersions?.[tokenPack.id];
65
- if (expectedVersion && expectedVersion !== tokenPack.version) addIssue(issues, `${consumerPath}.tokenPackVersions.${tokenPack.id}`, `consumer "${consumer.id}" requires "${tokenPack.id}" version "${expectedVersion}" but received "${tokenPack.version}"`);
66
- for (const tokenName of consumer.requiredTokens ?? [])if (!(tokenName in tokenPack.tokens)) addIssue(issues, `${consumerPath}.requiredTokens`, `consumer "${consumer.id}" requires missing token "${tokenName}" from "${tokenPack.id}"`);
67
- }
68
- return createValidationResult(issues);
69
- };
70
- const validateDesignSystemContract = (contract)=>{
71
- const issues = [];
72
- const tokenPackMap = createDesignSystemTokenPackMap(contract.tokenPacks);
73
- for (const [tokenPackIndex, tokenPack] of contract.tokenPacks.entries()){
74
- const tokenPackPath = `tokenPacks[${tokenPackIndex}]`;
75
- if (tokenPackMap.get(tokenPack.id) !== tokenPack) addIssue(issues, `${tokenPackPath}.id`, `duplicate token pack id "${tokenPack.id}"`);
76
- if (0 === Object.keys(tokenPack.tokens).length) addIssue(issues, `${tokenPackPath}.tokens`, `token pack "${tokenPack.id}" must define at least one token`);
77
- }
78
- for (const [verticalName, vertical] of Object.entries(contract.verticals)){
79
- const verticalPath = `verticals.${verticalName}`;
80
- const tokenPack = vertical.tokenPack ? tokenPackMap.get(vertical.tokenPack) : void 0;
81
- if (!VALID_MODES.has(vertical.mode)) addIssue(issues, `${verticalPath}.mode`, `unsupported design system mode "${vertical.mode}"`);
82
- if ('off' !== vertical.mode && !vertical.tokenPack) addIssue(issues, `${verticalPath}.tokenPack`, `vertical "${verticalName}" must select a token pack when mode is "${vertical.mode}"`);
83
- if (vertical.tokenPack && !tokenPack) addIssue(issues, `${verticalPath}.tokenPack`, `unknown token pack "${vertical.tokenPack}"`);
84
- for (const [overrideIndex, override] of (vertical.overrides ?? []).entries())if (!VALID_OVERRIDE_LAYERS.has(override.layer)) addIssue(issues, `${verticalPath}.overrides[${overrideIndex}].layer`, `override layer "${override.layer}" is not approved`);
85
- if (vertical.pin) {
86
- const pinnedTokenPack = tokenPackMap.get(vertical.pin.tokenPack);
87
- const rollbackTokenPack = tokenPackMap.get(vertical.pin.rollback.tokenPack);
88
- if (pinnedTokenPack) {
89
- if (pinnedTokenPack.version !== vertical.pin.version) addIssue(issues, `${verticalPath}.pin.version`, `pinned version "${vertical.pin.version}" does not match token pack "${vertical.pin.tokenPack}" version "${pinnedTokenPack.version}"`);
90
- } else addIssue(issues, `${verticalPath}.pin.tokenPack`, `unknown pinned token pack "${vertical.pin.tokenPack}"`);
91
- if (vertical.tokenPack && vertical.pin.tokenPack !== vertical.tokenPack) addIssue(issues, `${verticalPath}.pin.tokenPack`, `pinned token pack "${vertical.pin.tokenPack}" must match selected token pack "${vertical.tokenPack}"`);
92
- if (rollbackTokenPack) {
93
- if (rollbackTokenPack.version !== vertical.pin.rollback.version) addIssue(issues, `${verticalPath}.pin.rollback.version`, `rollback version "${vertical.pin.rollback.version}" does not match token pack "${vertical.pin.rollback.tokenPack}" version "${rollbackTokenPack.version}"`);
94
- } else addIssue(issues, `${verticalPath}.pin.rollback.tokenPack`, `unknown rollback token pack "${vertical.pin.rollback.tokenPack}"`);
95
- if (!vertical.pin.rollback.reason) addIssue(issues, `${verticalPath}.pin.rollback.reason`, 'rollback metadata must include a reason');
96
- }
97
- const compatibility = validateDesignSystemConsumerCompatibility(vertical, tokenPack, verticalPath);
98
- issues.push(...compatibility.issues);
99
- }
100
- return createValidationResult(issues);
101
- };
102
- __webpack_require__.d(__webpack_exports__, {}, {
103
- DESIGN_SYSTEM_MODES: DESIGN_SYSTEM_MODES,
104
- DESIGN_SYSTEM_OVERRIDE_LAYERS: DESIGN_SYSTEM_OVERRIDE_LAYERS,
105
- createDesignSystemTokenPackMap: createDesignSystemTokenPackMap,
106
- validateDesignSystemConsumerCompatibility: validateDesignSystemConsumerCompatibility,
107
- validateDesignSystemContract: validateDesignSystemContract
108
- });
109
- exports.DESIGN_SYSTEM_MODES = __webpack_exports__.DESIGN_SYSTEM_MODES;
110
- exports.DESIGN_SYSTEM_OVERRIDE_LAYERS = __webpack_exports__.DESIGN_SYSTEM_OVERRIDE_LAYERS;
111
- exports.createDesignSystemTokenPackMap = __webpack_exports__.createDesignSystemTokenPackMap;
112
- exports.validateDesignSystemConsumerCompatibility = __webpack_exports__.validateDesignSystemConsumerCompatibility;
113
- exports.validateDesignSystemContract = __webpack_exports__.validateDesignSystemContract;
114
- for(var __rspack_i in __webpack_exports__)if (-1 === [
115
- "DESIGN_SYSTEM_MODES",
116
- "DESIGN_SYSTEM_OVERRIDE_LAYERS",
117
- "createDesignSystemTokenPackMap",
118
- "validateDesignSystemConsumerCompatibility",
119
- "validateDesignSystemContract"
120
- ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
121
- Object.defineProperty(exports, '__esModule', {
122
- value: true
123
- });
@@ -1,4 +0,0 @@
1
- import { createPresetUltramodernConfig, presetUltramodern } from "./presetUltramodern.mjs";
2
- const createAppBaselineConfig = createPresetUltramodernConfig;
3
- const withAppBaseline = presetUltramodern;
4
- export { createAppBaselineConfig, withAppBaseline };
@@ -1,146 +0,0 @@
1
- const DEFAULT_RUNTIME_HOST = 'http://127.0.0.1:8080';
2
- const DEFAULT_RUNTIME_STATUS_PATH = '/_modern/runtime/status';
3
- const DEFAULT_RUNTIME_FALLBACK_SIGNAL_PATH = '/_modern/contract-gates/runtime-fallback';
4
- const DEFAULT_RUNTIME_TOKEN_HEADER = 'x-modernjs-runtime-signal-token';
5
- const DEFAULT_TIMEOUT_MS = 5000;
6
- const resolveRuntimeEndpoint = (input, defaultPath)=>{
7
- const rawInput = input?.trim();
8
- if (!rawInput) return `${DEFAULT_RUNTIME_HOST}${defaultPath}`;
9
- if (rawInput.startsWith('http://') || rawInput.startsWith('https://')) return rawInput;
10
- const normalized = rawInput.startsWith('/') ? rawInput : `/${rawInput}`;
11
- return `${DEFAULT_RUNTIME_HOST}${normalized}`;
12
- };
13
- const resolveToken = ({ token, tokenEnv })=>{
14
- if ('string' == typeof token && token.trim().length > 0) return token.trim();
15
- if ('string' == typeof tokenEnv && tokenEnv.trim().length > 0) {
16
- const value = process.env[tokenEnv.trim()];
17
- if ('string' == typeof value && value.trim().length > 0) return value.trim();
18
- }
19
- };
20
- const parseTimeoutMs = (value)=>{
21
- if ('string' != typeof value || 0 === value.trim().length) return DEFAULT_TIMEOUT_MS;
22
- const parsed = Number.parseInt(value, 10);
23
- if (!Number.isFinite(parsed) || parsed <= 0) return DEFAULT_TIMEOUT_MS;
24
- return parsed;
25
- };
26
- const parseMetadata = (metadata)=>{
27
- if ('string' != typeof metadata || 0 === metadata.trim().length) return;
28
- const parsed = JSON.parse(metadata);
29
- if (!parsed || 'object' != typeof parsed || Array.isArray(parsed)) throw new Error('metadata must be a JSON object');
30
- return parsed;
31
- };
32
- const fetchWithTimeout = async (url, init, timeoutMs)=>{
33
- const controller = new AbortController();
34
- const timeout = setTimeout(()=>{
35
- controller.abort();
36
- }, timeoutMs);
37
- try {
38
- return await fetch(url, {
39
- ...init,
40
- signal: controller.signal
41
- });
42
- } finally{
43
- clearTimeout(timeout);
44
- }
45
- };
46
- const parseResponseBody = async (response)=>{
47
- const text = await response.text();
48
- if (!text) return {};
49
- try {
50
- return JSON.parse(text);
51
- } catch (_error) {
52
- return {
53
- raw: text
54
- };
55
- }
56
- };
57
- const INDENT_STEP = ' ';
58
- const formatScalar = (value)=>'string' == typeof value ? value : JSON.stringify(value) ?? 'undefined';
59
- const formatHumanReadableLines = (value, indent)=>{
60
- if (Array.isArray(value)) {
61
- if (0 === value.length) return [
62
- `${indent}(empty)`
63
- ];
64
- return value.flatMap((entry)=>null !== entry && 'object' == typeof entry ? [
65
- `${indent}-`,
66
- ...formatHumanReadableLines(entry, indent + INDENT_STEP)
67
- ] : [
68
- `${indent}- ${formatScalar(entry)}`
69
- ]);
70
- }
71
- if (null !== value && 'object' == typeof value) {
72
- const entries = Object.entries(value);
73
- if (0 === entries.length) return [
74
- `${indent}(empty)`
75
- ];
76
- return entries.flatMap(([key, entry])=>null !== entry && 'object' == typeof entry ? [
77
- `${indent}${key}:`,
78
- ...formatHumanReadableLines(entry, indent + INDENT_STEP)
79
- ] : [
80
- `${indent}${key}: ${formatScalar(entry)}`
81
- ]);
82
- }
83
- return [
84
- `${indent}${formatScalar(value)}`
85
- ];
86
- };
87
- const formatRuntimeOutput = (payload, jsonOnly)=>jsonOnly ? JSON.stringify(payload, null, 2) : formatHumanReadableLines(payload, '').join('\n');
88
- const printOutput = (payload, jsonOnly)=>{
89
- console.log(formatRuntimeOutput(payload, jsonOnly));
90
- };
91
- const createRuntimeFallbackSignalPayload = (options)=>{
92
- const payload = {
93
- appName: options.app,
94
- reason: options.reason || 'runtime_fallback',
95
- phase: options.phase || 'load'
96
- };
97
- if (options.entry) payload.entry = options.entry;
98
- if (options.runtimeDigest) payload.runtimeDigest = options.runtimeDigest;
99
- const metadata = parseMetadata(options.metadata);
100
- if (metadata) payload.metadata = metadata;
101
- return payload;
102
- };
103
- const runtimeCommand = async (program, _api)=>{
104
- const runtime = program.command('runtime').description('runtime operations');
105
- runtime.command('status').description('read runtime status snapshot').option('--endpoint <endpoint>', 'runtime status endpoint URL or path').option('--token <token>', 'runtime status auth token').option('--token-env <name>', 'environment variable name that stores runtime status auth token', 'MODERN_RUNTIME_SIGNAL_TOKEN').option('--header-name <name>', 'auth header name', DEFAULT_RUNTIME_TOKEN_HEADER).option('--timeout <ms>', 'request timeout in milliseconds', '5000').option('--json', 'output as JSON format for machine reading').action(async (options)=>{
106
- const endpoint = resolveRuntimeEndpoint(options.endpoint, DEFAULT_RUNTIME_STATUS_PATH);
107
- const timeoutMs = parseTimeoutMs(options.timeout);
108
- const token = resolveToken({
109
- token: options.token,
110
- tokenEnv: options.tokenEnv
111
- });
112
- const headerName = options.headerName?.trim() || DEFAULT_RUNTIME_TOKEN_HEADER;
113
- const headers = new Headers();
114
- if (token) headers.set(headerName, token);
115
- const response = await fetchWithTimeout(endpoint, {
116
- method: 'GET',
117
- headers
118
- }, timeoutMs);
119
- const payload = await parseResponseBody(response);
120
- if (!response.ok) throw new Error(`runtime status request failed with ${response.status}: ${JSON.stringify(payload)}`);
121
- printOutput(payload, options.json);
122
- });
123
- runtime.command('fallback-signal').description('emit runtime fallback signal for canary gate mutation').requiredOption('--app <appName>', 'remote app name').option('--endpoint <endpoint>', 'runtime fallback signal endpoint URL or path').option('--reason <reason>', 'fallback reason', 'runtime_fallback').option('--phase <phase>', 'fallback phase', 'load').option('--entry <entry>', 'remote entry URL').option('--runtime-digest <digest>', 'runtime digest value').option('--metadata <json>', 'metadata JSON object string').option('--token <token>', 'runtime signal auth token').option('--token-env <name>', 'environment variable name that stores runtime signal auth token', 'MODERN_RUNTIME_SIGNAL_TOKEN').option('--header-name <name>', 'auth header name', DEFAULT_RUNTIME_TOKEN_HEADER).option('--timeout <ms>', 'request timeout in milliseconds', '5000').option('--json', 'output as JSON format for machine reading').action(async (options)=>{
124
- const endpoint = resolveRuntimeEndpoint(options.endpoint, DEFAULT_RUNTIME_FALLBACK_SIGNAL_PATH);
125
- const timeoutMs = parseTimeoutMs(options.timeout);
126
- const token = resolveToken({
127
- token: options.token,
128
- tokenEnv: options.tokenEnv
129
- });
130
- const headerName = options.headerName?.trim() || DEFAULT_RUNTIME_TOKEN_HEADER;
131
- const payload = createRuntimeFallbackSignalPayload(options);
132
- const headers = new Headers({
133
- 'content-type': 'application/json'
134
- });
135
- if (token) headers.set(headerName, token);
136
- const response = await fetchWithTimeout(endpoint, {
137
- method: 'POST',
138
- headers,
139
- body: JSON.stringify(payload)
140
- }, timeoutMs);
141
- const responsePayload = await parseResponseBody(response);
142
- if (!response.ok) throw new Error(`runtime fallback signal request failed with ${response.status}: ${JSON.stringify(responsePayload)}`);
143
- printOutput(responsePayload, options.json);
144
- });
145
- };
146
- export { createRuntimeFallbackSignalPayload, formatRuntimeOutput, resolveRuntimeEndpoint, resolveToken, runtimeCommand };
@@ -1 +0,0 @@
1
- export * from "./cloudflare-output-verifier/index.mjs";
@@ -1 +0,0 @@
1
- export { createCloudflarePreset } from "./cloudflare/index.mjs";
@@ -1,73 +0,0 @@
1
- const DESIGN_SYSTEM_MODES = [
2
- 'off',
3
- 'tokens',
4
- 'components',
5
- 'strict'
6
- ];
7
- const DESIGN_SYSTEM_OVERRIDE_LAYERS = [
8
- 'brand',
9
- 'vertical',
10
- 'application'
11
- ];
12
- const VALID_MODES = new Set(DESIGN_SYSTEM_MODES);
13
- const VALID_OVERRIDE_LAYERS = new Set(DESIGN_SYSTEM_OVERRIDE_LAYERS);
14
- const createValidationResult = (issues)=>({
15
- valid: 0 === issues.length,
16
- issues
17
- });
18
- const addIssue = (issues, path, message)=>{
19
- issues.push({
20
- path,
21
- message
22
- });
23
- };
24
- const createDesignSystemTokenPackMap = (tokenPacks)=>new Map(tokenPacks.map((tokenPack)=>[
25
- tokenPack.id,
26
- tokenPack
27
- ]));
28
- const validateDesignSystemConsumerCompatibility = (vertical, tokenPack, path = 'vertical')=>{
29
- const issues = [];
30
- const consumers = vertical.consumers ?? [];
31
- for (const [consumerIndex, consumer] of consumers.entries()){
32
- const consumerPath = `${path}.consumers[${consumerIndex}]`;
33
- if (consumer.unsupportedModes?.includes(vertical.mode)) addIssue(issues, `${consumerPath}.unsupportedModes`, `consumer "${consumer.id}" does not support "${vertical.mode}" mode`);
34
- if (!tokenPack) continue;
35
- const expectedVersion = consumer.tokenPackVersions?.[tokenPack.id];
36
- if (expectedVersion && expectedVersion !== tokenPack.version) addIssue(issues, `${consumerPath}.tokenPackVersions.${tokenPack.id}`, `consumer "${consumer.id}" requires "${tokenPack.id}" version "${expectedVersion}" but received "${tokenPack.version}"`);
37
- for (const tokenName of consumer.requiredTokens ?? [])if (!(tokenName in tokenPack.tokens)) addIssue(issues, `${consumerPath}.requiredTokens`, `consumer "${consumer.id}" requires missing token "${tokenName}" from "${tokenPack.id}"`);
38
- }
39
- return createValidationResult(issues);
40
- };
41
- const validateDesignSystemContract = (contract)=>{
42
- const issues = [];
43
- const tokenPackMap = createDesignSystemTokenPackMap(contract.tokenPacks);
44
- for (const [tokenPackIndex, tokenPack] of contract.tokenPacks.entries()){
45
- const tokenPackPath = `tokenPacks[${tokenPackIndex}]`;
46
- if (tokenPackMap.get(tokenPack.id) !== tokenPack) addIssue(issues, `${tokenPackPath}.id`, `duplicate token pack id "${tokenPack.id}"`);
47
- if (0 === Object.keys(tokenPack.tokens).length) addIssue(issues, `${tokenPackPath}.tokens`, `token pack "${tokenPack.id}" must define at least one token`);
48
- }
49
- for (const [verticalName, vertical] of Object.entries(contract.verticals)){
50
- const verticalPath = `verticals.${verticalName}`;
51
- const tokenPack = vertical.tokenPack ? tokenPackMap.get(vertical.tokenPack) : void 0;
52
- if (!VALID_MODES.has(vertical.mode)) addIssue(issues, `${verticalPath}.mode`, `unsupported design system mode "${vertical.mode}"`);
53
- if ('off' !== vertical.mode && !vertical.tokenPack) addIssue(issues, `${verticalPath}.tokenPack`, `vertical "${verticalName}" must select a token pack when mode is "${vertical.mode}"`);
54
- if (vertical.tokenPack && !tokenPack) addIssue(issues, `${verticalPath}.tokenPack`, `unknown token pack "${vertical.tokenPack}"`);
55
- for (const [overrideIndex, override] of (vertical.overrides ?? []).entries())if (!VALID_OVERRIDE_LAYERS.has(override.layer)) addIssue(issues, `${verticalPath}.overrides[${overrideIndex}].layer`, `override layer "${override.layer}" is not approved`);
56
- if (vertical.pin) {
57
- const pinnedTokenPack = tokenPackMap.get(vertical.pin.tokenPack);
58
- const rollbackTokenPack = tokenPackMap.get(vertical.pin.rollback.tokenPack);
59
- if (pinnedTokenPack) {
60
- if (pinnedTokenPack.version !== vertical.pin.version) addIssue(issues, `${verticalPath}.pin.version`, `pinned version "${vertical.pin.version}" does not match token pack "${vertical.pin.tokenPack}" version "${pinnedTokenPack.version}"`);
61
- } else addIssue(issues, `${verticalPath}.pin.tokenPack`, `unknown pinned token pack "${vertical.pin.tokenPack}"`);
62
- if (vertical.tokenPack && vertical.pin.tokenPack !== vertical.tokenPack) addIssue(issues, `${verticalPath}.pin.tokenPack`, `pinned token pack "${vertical.pin.tokenPack}" must match selected token pack "${vertical.tokenPack}"`);
63
- if (rollbackTokenPack) {
64
- if (rollbackTokenPack.version !== vertical.pin.rollback.version) addIssue(issues, `${verticalPath}.pin.rollback.version`, `rollback version "${vertical.pin.rollback.version}" does not match token pack "${vertical.pin.rollback.tokenPack}" version "${rollbackTokenPack.version}"`);
65
- } else addIssue(issues, `${verticalPath}.pin.rollback.tokenPack`, `unknown rollback token pack "${vertical.pin.rollback.tokenPack}"`);
66
- if (!vertical.pin.rollback.reason) addIssue(issues, `${verticalPath}.pin.rollback.reason`, 'rollback metadata must include a reason');
67
- }
68
- const compatibility = validateDesignSystemConsumerCompatibility(vertical, tokenPack, verticalPath);
69
- issues.push(...compatibility.issues);
70
- }
71
- return createValidationResult(issues);
72
- };
73
- export { DESIGN_SYSTEM_MODES, DESIGN_SYSTEM_OVERRIDE_LAYERS, createDesignSystemTokenPackMap, validateDesignSystemConsumerCompatibility, validateDesignSystemContract };
@@ -1,5 +0,0 @@
1
- import "node:module";
2
- import { createPresetUltramodernConfig, presetUltramodern } from "./presetUltramodern.mjs";
3
- const createAppBaselineConfig = createPresetUltramodernConfig;
4
- const withAppBaseline = presetUltramodern;
5
- export { createAppBaselineConfig, withAppBaseline };
@@ -1,147 +0,0 @@
1
- import "node:module";
2
- const DEFAULT_RUNTIME_HOST = 'http://127.0.0.1:8080';
3
- const DEFAULT_RUNTIME_STATUS_PATH = '/_modern/runtime/status';
4
- const DEFAULT_RUNTIME_FALLBACK_SIGNAL_PATH = '/_modern/contract-gates/runtime-fallback';
5
- const DEFAULT_RUNTIME_TOKEN_HEADER = 'x-modernjs-runtime-signal-token';
6
- const DEFAULT_TIMEOUT_MS = 5000;
7
- const resolveRuntimeEndpoint = (input, defaultPath)=>{
8
- const rawInput = input?.trim();
9
- if (!rawInput) return `${DEFAULT_RUNTIME_HOST}${defaultPath}`;
10
- if (rawInput.startsWith('http://') || rawInput.startsWith('https://')) return rawInput;
11
- const normalized = rawInput.startsWith('/') ? rawInput : `/${rawInput}`;
12
- return `${DEFAULT_RUNTIME_HOST}${normalized}`;
13
- };
14
- const resolveToken = ({ token, tokenEnv })=>{
15
- if ('string' == typeof token && token.trim().length > 0) return token.trim();
16
- if ('string' == typeof tokenEnv && tokenEnv.trim().length > 0) {
17
- const value = process.env[tokenEnv.trim()];
18
- if ('string' == typeof value && value.trim().length > 0) return value.trim();
19
- }
20
- };
21
- const parseTimeoutMs = (value)=>{
22
- if ('string' != typeof value || 0 === value.trim().length) return DEFAULT_TIMEOUT_MS;
23
- const parsed = Number.parseInt(value, 10);
24
- if (!Number.isFinite(parsed) || parsed <= 0) return DEFAULT_TIMEOUT_MS;
25
- return parsed;
26
- };
27
- const parseMetadata = (metadata)=>{
28
- if ('string' != typeof metadata || 0 === metadata.trim().length) return;
29
- const parsed = JSON.parse(metadata);
30
- if (!parsed || 'object' != typeof parsed || Array.isArray(parsed)) throw new Error('metadata must be a JSON object');
31
- return parsed;
32
- };
33
- const fetchWithTimeout = async (url, init, timeoutMs)=>{
34
- const controller = new AbortController();
35
- const timeout = setTimeout(()=>{
36
- controller.abort();
37
- }, timeoutMs);
38
- try {
39
- return await fetch(url, {
40
- ...init,
41
- signal: controller.signal
42
- });
43
- } finally{
44
- clearTimeout(timeout);
45
- }
46
- };
47
- const parseResponseBody = async (response)=>{
48
- const text = await response.text();
49
- if (!text) return {};
50
- try {
51
- return JSON.parse(text);
52
- } catch (_error) {
53
- return {
54
- raw: text
55
- };
56
- }
57
- };
58
- const INDENT_STEP = ' ';
59
- const formatScalar = (value)=>'string' == typeof value ? value : JSON.stringify(value) ?? 'undefined';
60
- const formatHumanReadableLines = (value, indent)=>{
61
- if (Array.isArray(value)) {
62
- if (0 === value.length) return [
63
- `${indent}(empty)`
64
- ];
65
- return value.flatMap((entry)=>null !== entry && 'object' == typeof entry ? [
66
- `${indent}-`,
67
- ...formatHumanReadableLines(entry, indent + INDENT_STEP)
68
- ] : [
69
- `${indent}- ${formatScalar(entry)}`
70
- ]);
71
- }
72
- if (null !== value && 'object' == typeof value) {
73
- const entries = Object.entries(value);
74
- if (0 === entries.length) return [
75
- `${indent}(empty)`
76
- ];
77
- return entries.flatMap(([key, entry])=>null !== entry && 'object' == typeof entry ? [
78
- `${indent}${key}:`,
79
- ...formatHumanReadableLines(entry, indent + INDENT_STEP)
80
- ] : [
81
- `${indent}${key}: ${formatScalar(entry)}`
82
- ]);
83
- }
84
- return [
85
- `${indent}${formatScalar(value)}`
86
- ];
87
- };
88
- const formatRuntimeOutput = (payload, jsonOnly)=>jsonOnly ? JSON.stringify(payload, null, 2) : formatHumanReadableLines(payload, '').join('\n');
89
- const printOutput = (payload, jsonOnly)=>{
90
- console.log(formatRuntimeOutput(payload, jsonOnly));
91
- };
92
- const createRuntimeFallbackSignalPayload = (options)=>{
93
- const payload = {
94
- appName: options.app,
95
- reason: options.reason || 'runtime_fallback',
96
- phase: options.phase || 'load'
97
- };
98
- if (options.entry) payload.entry = options.entry;
99
- if (options.runtimeDigest) payload.runtimeDigest = options.runtimeDigest;
100
- const metadata = parseMetadata(options.metadata);
101
- if (metadata) payload.metadata = metadata;
102
- return payload;
103
- };
104
- const runtimeCommand = async (program, _api)=>{
105
- const runtime = program.command('runtime').description('runtime operations');
106
- runtime.command('status').description('read runtime status snapshot').option('--endpoint <endpoint>', 'runtime status endpoint URL or path').option('--token <token>', 'runtime status auth token').option('--token-env <name>', 'environment variable name that stores runtime status auth token', 'MODERN_RUNTIME_SIGNAL_TOKEN').option('--header-name <name>', 'auth header name', DEFAULT_RUNTIME_TOKEN_HEADER).option('--timeout <ms>', 'request timeout in milliseconds', '5000').option('--json', 'output as JSON format for machine reading').action(async (options)=>{
107
- const endpoint = resolveRuntimeEndpoint(options.endpoint, DEFAULT_RUNTIME_STATUS_PATH);
108
- const timeoutMs = parseTimeoutMs(options.timeout);
109
- const token = resolveToken({
110
- token: options.token,
111
- tokenEnv: options.tokenEnv
112
- });
113
- const headerName = options.headerName?.trim() || DEFAULT_RUNTIME_TOKEN_HEADER;
114
- const headers = new Headers();
115
- if (token) headers.set(headerName, token);
116
- const response = await fetchWithTimeout(endpoint, {
117
- method: 'GET',
118
- headers
119
- }, timeoutMs);
120
- const payload = await parseResponseBody(response);
121
- if (!response.ok) throw new Error(`runtime status request failed with ${response.status}: ${JSON.stringify(payload)}`);
122
- printOutput(payload, options.json);
123
- });
124
- runtime.command('fallback-signal').description('emit runtime fallback signal for canary gate mutation').requiredOption('--app <appName>', 'remote app name').option('--endpoint <endpoint>', 'runtime fallback signal endpoint URL or path').option('--reason <reason>', 'fallback reason', 'runtime_fallback').option('--phase <phase>', 'fallback phase', 'load').option('--entry <entry>', 'remote entry URL').option('--runtime-digest <digest>', 'runtime digest value').option('--metadata <json>', 'metadata JSON object string').option('--token <token>', 'runtime signal auth token').option('--token-env <name>', 'environment variable name that stores runtime signal auth token', 'MODERN_RUNTIME_SIGNAL_TOKEN').option('--header-name <name>', 'auth header name', DEFAULT_RUNTIME_TOKEN_HEADER).option('--timeout <ms>', 'request timeout in milliseconds', '5000').option('--json', 'output as JSON format for machine reading').action(async (options)=>{
125
- const endpoint = resolveRuntimeEndpoint(options.endpoint, DEFAULT_RUNTIME_FALLBACK_SIGNAL_PATH);
126
- const timeoutMs = parseTimeoutMs(options.timeout);
127
- const token = resolveToken({
128
- token: options.token,
129
- tokenEnv: options.tokenEnv
130
- });
131
- const headerName = options.headerName?.trim() || DEFAULT_RUNTIME_TOKEN_HEADER;
132
- const payload = createRuntimeFallbackSignalPayload(options);
133
- const headers = new Headers({
134
- 'content-type': 'application/json'
135
- });
136
- if (token) headers.set(headerName, token);
137
- const response = await fetchWithTimeout(endpoint, {
138
- method: 'POST',
139
- headers,
140
- body: JSON.stringify(payload)
141
- }, timeoutMs);
142
- const responsePayload = await parseResponseBody(response);
143
- if (!response.ok) throw new Error(`runtime fallback signal request failed with ${response.status}: ${JSON.stringify(responsePayload)}`);
144
- printOutput(responsePayload, options.json);
145
- });
146
- };
147
- export { createRuntimeFallbackSignalPayload, formatRuntimeOutput, resolveRuntimeEndpoint, resolveToken, runtimeCommand };
@@ -1,2 +0,0 @@
1
- import "node:module";
2
- export * from "./cloudflare-output-verifier/index.mjs";
@@ -1,2 +0,0 @@
1
- import "node:module";
2
- export { createCloudflarePreset } from "./cloudflare/index.mjs";
@@ -1,74 +0,0 @@
1
- import "node:module";
2
- const DESIGN_SYSTEM_MODES = [
3
- 'off',
4
- 'tokens',
5
- 'components',
6
- 'strict'
7
- ];
8
- const DESIGN_SYSTEM_OVERRIDE_LAYERS = [
9
- 'brand',
10
- 'vertical',
11
- 'application'
12
- ];
13
- const VALID_MODES = new Set(DESIGN_SYSTEM_MODES);
14
- const VALID_OVERRIDE_LAYERS = new Set(DESIGN_SYSTEM_OVERRIDE_LAYERS);
15
- const createValidationResult = (issues)=>({
16
- valid: 0 === issues.length,
17
- issues
18
- });
19
- const addIssue = (issues, path, message)=>{
20
- issues.push({
21
- path,
22
- message
23
- });
24
- };
25
- const createDesignSystemTokenPackMap = (tokenPacks)=>new Map(tokenPacks.map((tokenPack)=>[
26
- tokenPack.id,
27
- tokenPack
28
- ]));
29
- const validateDesignSystemConsumerCompatibility = (vertical, tokenPack, path = 'vertical')=>{
30
- const issues = [];
31
- const consumers = vertical.consumers ?? [];
32
- for (const [consumerIndex, consumer] of consumers.entries()){
33
- const consumerPath = `${path}.consumers[${consumerIndex}]`;
34
- if (consumer.unsupportedModes?.includes(vertical.mode)) addIssue(issues, `${consumerPath}.unsupportedModes`, `consumer "${consumer.id}" does not support "${vertical.mode}" mode`);
35
- if (!tokenPack) continue;
36
- const expectedVersion = consumer.tokenPackVersions?.[tokenPack.id];
37
- if (expectedVersion && expectedVersion !== tokenPack.version) addIssue(issues, `${consumerPath}.tokenPackVersions.${tokenPack.id}`, `consumer "${consumer.id}" requires "${tokenPack.id}" version "${expectedVersion}" but received "${tokenPack.version}"`);
38
- for (const tokenName of consumer.requiredTokens ?? [])if (!(tokenName in tokenPack.tokens)) addIssue(issues, `${consumerPath}.requiredTokens`, `consumer "${consumer.id}" requires missing token "${tokenName}" from "${tokenPack.id}"`);
39
- }
40
- return createValidationResult(issues);
41
- };
42
- const validateDesignSystemContract = (contract)=>{
43
- const issues = [];
44
- const tokenPackMap = createDesignSystemTokenPackMap(contract.tokenPacks);
45
- for (const [tokenPackIndex, tokenPack] of contract.tokenPacks.entries()){
46
- const tokenPackPath = `tokenPacks[${tokenPackIndex}]`;
47
- if (tokenPackMap.get(tokenPack.id) !== tokenPack) addIssue(issues, `${tokenPackPath}.id`, `duplicate token pack id "${tokenPack.id}"`);
48
- if (0 === Object.keys(tokenPack.tokens).length) addIssue(issues, `${tokenPackPath}.tokens`, `token pack "${tokenPack.id}" must define at least one token`);
49
- }
50
- for (const [verticalName, vertical] of Object.entries(contract.verticals)){
51
- const verticalPath = `verticals.${verticalName}`;
52
- const tokenPack = vertical.tokenPack ? tokenPackMap.get(vertical.tokenPack) : void 0;
53
- if (!VALID_MODES.has(vertical.mode)) addIssue(issues, `${verticalPath}.mode`, `unsupported design system mode "${vertical.mode}"`);
54
- if ('off' !== vertical.mode && !vertical.tokenPack) addIssue(issues, `${verticalPath}.tokenPack`, `vertical "${verticalName}" must select a token pack when mode is "${vertical.mode}"`);
55
- if (vertical.tokenPack && !tokenPack) addIssue(issues, `${verticalPath}.tokenPack`, `unknown token pack "${vertical.tokenPack}"`);
56
- for (const [overrideIndex, override] of (vertical.overrides ?? []).entries())if (!VALID_OVERRIDE_LAYERS.has(override.layer)) addIssue(issues, `${verticalPath}.overrides[${overrideIndex}].layer`, `override layer "${override.layer}" is not approved`);
57
- if (vertical.pin) {
58
- const pinnedTokenPack = tokenPackMap.get(vertical.pin.tokenPack);
59
- const rollbackTokenPack = tokenPackMap.get(vertical.pin.rollback.tokenPack);
60
- if (pinnedTokenPack) {
61
- if (pinnedTokenPack.version !== vertical.pin.version) addIssue(issues, `${verticalPath}.pin.version`, `pinned version "${vertical.pin.version}" does not match token pack "${vertical.pin.tokenPack}" version "${pinnedTokenPack.version}"`);
62
- } else addIssue(issues, `${verticalPath}.pin.tokenPack`, `unknown pinned token pack "${vertical.pin.tokenPack}"`);
63
- if (vertical.tokenPack && vertical.pin.tokenPack !== vertical.tokenPack) addIssue(issues, `${verticalPath}.pin.tokenPack`, `pinned token pack "${vertical.pin.tokenPack}" must match selected token pack "${vertical.tokenPack}"`);
64
- if (rollbackTokenPack) {
65
- if (rollbackTokenPack.version !== vertical.pin.rollback.version) addIssue(issues, `${verticalPath}.pin.rollback.version`, `rollback version "${vertical.pin.rollback.version}" does not match token pack "${vertical.pin.rollback.tokenPack}" version "${rollbackTokenPack.version}"`);
66
- } else addIssue(issues, `${verticalPath}.pin.rollback.tokenPack`, `unknown rollback token pack "${vertical.pin.rollback.tokenPack}"`);
67
- if (!vertical.pin.rollback.reason) addIssue(issues, `${verticalPath}.pin.rollback.reason`, 'rollback metadata must include a reason');
68
- }
69
- const compatibility = validateDesignSystemConsumerCompatibility(vertical, tokenPack, verticalPath);
70
- issues.push(...compatibility.issues);
71
- }
72
- return createValidationResult(issues);
73
- };
74
- export { DESIGN_SYSTEM_MODES, DESIGN_SYSTEM_OVERRIDE_LAYERS, createDesignSystemTokenPackMap, validateDesignSystemConsumerCompatibility, validateDesignSystemContract };
@@ -1,16 +0,0 @@
1
- import { type PresetUltramodernOptions } from './presetUltramodern';
2
- /**
3
- * @deprecated Use `PresetUltramodernOptions` from `@modern-js/app-tools`
4
- * instead. This alias will be removed in a future release.
5
- */
6
- export type AppBaselineOptions = PresetUltramodernOptions;
7
- /**
8
- * @deprecated Use `createPresetUltramodernConfig` from `@modern-js/app-tools`
9
- * instead. This alias will be removed in a future release.
10
- */
11
- export declare const createAppBaselineConfig: (options?: PresetUltramodernOptions) => import("./types").AppUserConfig;
12
- /**
13
- * @deprecated Use `presetUltramodern` from `@modern-js/app-tools` instead.
14
- * This alias will be removed in a future release.
15
- */
16
- export declare const withAppBaseline: (config: import("./types").AppUserConfig, options?: PresetUltramodernOptions) => import("./types").AppUserConfig;
@@ -1,12 +0,0 @@
1
- import type { CLIPluginAPI } from '@modern-js/plugin';
2
- import type { Command } from '@modern-js/utils';
3
- import type { AppTools } from '../types';
4
- import type { RuntimeFallbackSignalOptions } from '../utils/types';
5
- export declare const resolveRuntimeEndpoint: (input: string | undefined, defaultPath: string) => string;
6
- export declare const resolveToken: ({ token, tokenEnv, }: {
7
- token?: string;
8
- tokenEnv?: string;
9
- }) => string | undefined;
10
- export declare const formatRuntimeOutput: (payload: unknown, jsonOnly?: boolean) => string;
11
- export declare const createRuntimeFallbackSignalPayload: (options: RuntimeFallbackSignalOptions) => Record<string, unknown>;
12
- export declare const runtimeCommand: (program: Command, _api: CLIPluginAPI<AppTools>) => Promise<void>;
@@ -1 +0,0 @@
1
- export * from './cloudflare-output-verifier/index';
@@ -1 +0,0 @@
1
- export { createCloudflarePreset } from './cloudflare/index';