@astryxdesign/cli 0.7.8 → 0.7.9-canary.0200dfe
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/api/component/__fixtures__/resolutions/modules.txt +1 -1
- package/api/discover/_adapter.d.mts +1 -1
- package/api/docs/_adapter.d.mts +8 -2
- package/api/docs/_adapter.mjs +10 -4
- package/api/docs/detail/section/section.d.mts +5 -2
- package/api/docs/detail/section/section.mjs +6 -2
- package/api/docs/docs.mjs +7 -1
- package/api/search/_adapter.d.mts +3 -1
- package/api/search/_adapter.mjs +12 -2
- package/api/search/_candidate-score.mjs +25 -23
- package/api/search/_main-searcher.mjs +1 -1
- package/api/search/_result.d.mts +5 -5
- package/api/search/_words.d.mts +44 -7
- package/api/search/_words.mjs +113 -21
- package/api/search/search.d.mts +4 -2
- package/api/search/search.mjs +9 -8
- package/api/swizzle/_adapter.d.mts +10 -0
- package/api/swizzle/_adapter.mjs +24 -1
- package/api/swizzle/copy/copy.mjs +9 -4
- package/api/theme/build/build.d.mts +26 -1
- package/api/theme/build/build.mjs +71 -20
- package/api/theme/build/core-interception.d.mts +2 -1
- package/api/theme/build/core-interception.mjs +23 -5
- package/assets/discover/official-packages.json +4 -0
- package/assets/docs/tree/calendar-systems.doc.mjs +146 -0
- package/assets/docs/tree/calendars.doc.mjs +46 -0
- package/assets/docs/tree/i18n-calendars.doc.mjs +51 -0
- package/assets/docs/tree/internationalization.doc.mjs +3 -3
- package/assets/docs/tree/tokens-color.doc.mjs +1 -1
- package/assets/templates/blocks/components/Hooks/useClickableContainerHookUsage.doc.mjs +14 -0
- package/assets/templates/blocks/components/Hooks/useClickableContainerHookUsage.tsx +67 -0
- package/assets/templates/blocks/components/Hooks/useImageModeHookUsage.doc.mjs +14 -0
- package/assets/templates/blocks/components/Hooks/useImageModeHookUsage.tsx +55 -0
- package/assets/templates/blocks/components/Icon/useIconHookUsage.doc.mjs +19 -0
- package/assets/templates/blocks/components/Icon/useIconHookUsage.tsx +68 -0
- package/assets/templates/blocks/components/InfoTip/InfoTipMetricDefinitions.doc.mjs +14 -0
- package/assets/templates/blocks/components/InfoTip/InfoTipMetricDefinitions.tsx +46 -0
- package/assets/templates/blocks/components/InfoTip/InfoTipPermissionNotes.doc.mjs +14 -0
- package/assets/templates/blocks/components/InfoTip/InfoTipPermissionNotes.tsx +41 -0
- package/assets/templates/blocks/components/InfoTip/InfoTipShowcase.doc.mjs +13 -0
- package/assets/templates/blocks/components/InfoTip/InfoTipShowcase.tsx +24 -0
- package/assets/templates/blocks/components/PowerSearch/PowerSearchContentSearch.tsx +8 -7
- package/assets/templates/blocks/components/PowerSearch/PowerSearchFullFeatured.tsx +8 -7
- package/assets/templates/blocks/components/PowerSearch/PowerSearchPresetFilters.tsx +8 -7
- package/assets/templates/blocks/components/PowerSearch/PowerSearchSearchWithTable.tsx +12 -10
- package/assets/templates/blocks/components/PowerSearch/PowerSearchShowcase.tsx +8 -7
- package/assets/templates/blocks/components/Tokenizer/TokenizerClear.doc.mjs +2 -1
- package/assets/templates/blocks/components/Tokenizer/TokenizerClear.tsx +2 -2
- package/assets/templates/blocks/components/Tokenizer/TokenizerCreatable.tsx +0 -1
- package/assets/templates/blocks/components/Tokenizer/TokenizerEndContent.tsx +0 -1
- package/assets/templates/blocks/components/Tokenizer/TokenizerOverflow.doc.mjs +2 -1
- package/assets/templates/blocks/components/Tokenizer/TokenizerOverflow.tsx +0 -2
- package/assets/templates/pages/table-inbox/page.tsx +11 -8
- package/assets/templates/pages/work-item-detail/page.tsx +6 -2
- package/assets/theme.template.ts +1 -1
- package/authoring/debug/parse.d.mts +2 -2
- package/clients/cli/commands/ensure-core-built.mjs +399 -43
- package/clients/cli/index.mjs +11 -6
- package/foundation/agent-docs/agent-docs-target.d.mts +49 -0
- package/foundation/agent-docs/agent-docs-target.mjs +201 -0
- package/foundation/agent-docs/agent-docs.d.mts +1 -38
- package/foundation/agent-docs/agent-docs.mjs +16 -181
- package/foundation/config/config-path.d.mts +13 -0
- package/foundation/config/config-path.mjs +42 -0
- package/foundation/config/project.d.mts +1 -10
- package/foundation/config/project.mjs +31 -35
- package/foundation/discovery/component-discovery.mjs +56 -10
- package/foundation/discovery/component-loader.d.mts +1 -1
- package/foundation/discovery/icon-set-paths.d.mts +18 -0
- package/foundation/discovery/icon-set-paths.mjs +23 -0
- package/foundation/discovery/icon-set-writer.d.mts +2 -7
- package/foundation/discovery/icon-set-writer.mjs +3 -12
- package/foundation/env/search-path.d.mts +12 -0
- package/foundation/env/search-path.mjs +71 -43
- package/foundation/fs/module-loader.d.mts +2 -8
- package/foundation/fs/module-loader.mjs +3 -12
- package/foundation/fs/present-files.d.mts +11 -0
- package/foundation/fs/present-files.mjs +25 -0
- package/foundation/integrations/autolink.d.mts +2 -21
- package/foundation/integrations/autolink.mjs +6 -42
- package/foundation/integrations/contribution-fixes.mjs +26 -3
- package/foundation/integrations/contribution-inventory.mjs +1 -1
- package/foundation/integrations/installed-package.d.mts +36 -0
- package/foundation/integrations/installed-package.mjs +57 -0
- package/foundation/integrations/integrations.d.mts +3 -75
- package/foundation/integrations/integrations.mjs +3 -16
- package/foundation/integrations/manifest-paths.d.mts +13 -0
- package/foundation/integrations/manifest-paths.mjs +31 -0
- package/foundation/integrations/manifest-writer.d.mts +3 -4
- package/foundation/integrations/manifest-writer.mjs +5 -3
- package/foundation/release/cache.d.mts +11 -4
- package/foundation/release/cache.mjs +15 -7
- package/foundation/runtime/locked-versions.mjs +1 -1
- package/foundation/runtime/package-set.mjs +1 -1
- package/foundation/text/levenshtein.d.mts +4 -1
- package/foundation/text/levenshtein.mjs +44 -1
- package/package.json +9 -9
- package/api/swizzle/_github.d.mts +0 -8
- package/api/swizzle/_github.mjs +0 -22
package/api/search/search.d.mts
CHANGED
|
@@ -13,12 +13,14 @@
|
|
|
13
13
|
*/
|
|
14
14
|
export function search(query: string, options?: {
|
|
15
15
|
cwd?: string | undefined;
|
|
16
|
-
type?: "template" | "component" | "
|
|
16
|
+
type?: "template" | "component" | "doc" | "theme" | "hook" | undefined;
|
|
17
17
|
limit?: number | undefined;
|
|
18
18
|
}): Promise<import("./search.type.mjs").SearchResponse>;
|
|
19
19
|
/**
|
|
20
20
|
* The lexical ranker alone: keyword and fuzzy scoring of every candidate.
|
|
21
|
-
* `build` ranks from it.
|
|
21
|
+
* `build` ranks from it. It ranks the candidates search gathers, reused the
|
|
22
|
+
* same way. A later query in the same folder, for the same `type`, gathers
|
|
23
|
+
* again only when an input changed.
|
|
22
24
|
*
|
|
23
25
|
* @param {string} query
|
|
24
26
|
* @param {{cwd?: string, type?: 'component'|'hook'|'doc'|'template'|'theme', limit?: number}} [options]
|
package/api/search/search.mjs
CHANGED
|
@@ -19,11 +19,7 @@ import {
|
|
|
19
19
|
runWithDocPackageManager,
|
|
20
20
|
} from '../../foundation/env/package-manager.mjs';
|
|
21
21
|
import {withListingCache} from '../../foundation/fs/listing-cache.mjs';
|
|
22
|
-
import {
|
|
23
|
-
gatherCandidates,
|
|
24
|
-
gatherCandidatesReused,
|
|
25
|
-
loadSearchData,
|
|
26
|
-
} from './_adapter.mjs';
|
|
22
|
+
import {gatherCandidatesReused, loadSearchData} from './_adapter.mjs';
|
|
27
23
|
import {rankLexical} from './_lexical.mjs';
|
|
28
24
|
import {checkSearchArgs} from './_result.mjs';
|
|
29
25
|
import {runTree} from '../../foundation/route/route.mjs';
|
|
@@ -76,7 +72,10 @@ async function searchRead(query, options) {
|
|
|
76
72
|
await runTree(
|
|
77
73
|
SEARCH_TREE,
|
|
78
74
|
{query, options},
|
|
79
|
-
{
|
|
75
|
+
{
|
|
76
|
+
...(await gatherCandidatesReused(options)),
|
|
77
|
+
data: loadSearchData(),
|
|
78
|
+
},
|
|
80
79
|
)
|
|
81
80
|
),
|
|
82
81
|
options.cwd ?? process.cwd(),
|
|
@@ -87,7 +86,9 @@ async function searchRead(query, options) {
|
|
|
87
86
|
|
|
88
87
|
/**
|
|
89
88
|
* The lexical ranker alone: keyword and fuzzy scoring of every candidate.
|
|
90
|
-
* `build` ranks from it.
|
|
89
|
+
* `build` ranks from it. It ranks the candidates search gathers, reused the
|
|
90
|
+
* same way. A later query in the same folder, for the same `type`, gathers
|
|
91
|
+
* again only when an input changed.
|
|
91
92
|
*
|
|
92
93
|
* @param {string} query
|
|
93
94
|
* @param {{cwd?: string, type?: 'component'|'hook'|'doc'|'template'|'theme', limit?: number}} [options]
|
|
@@ -109,7 +110,7 @@ export async function searchCore(query, options = {}) {
|
|
|
109
110
|
async function searchCoreRead(query, options) {
|
|
110
111
|
return withListingCache(async () =>
|
|
111
112
|
linkSearchResponse(
|
|
112
|
-
rankLexical(query, options, await
|
|
113
|
+
rankLexical(query, options, await gatherCandidatesReused(options)),
|
|
113
114
|
options.cwd ?? process.cwd(),
|
|
114
115
|
),
|
|
115
116
|
);
|
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
// @generated by scripts/sync-api-types.mjs from the JSDoc in api/**/*.mjs.
|
|
2
2
|
// DO NOT EDIT — run `pnpm sync:api-types` to regenerate.
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* Whether an executable `gh` is on `PATH` (with a `PATHEXT` extension on
|
|
6
|
+
* Windows), found without running it. The copy receipt offers its
|
|
7
|
+
* `gh issue create` line on it. Running `gh` would make every copy wait on a
|
|
8
|
+
* process start, and for `gh auth status` on GitHub, before it reports.
|
|
9
|
+
* @param {NodeJS.ProcessEnv} [env]
|
|
10
|
+
* @param {NodeJS.Platform} [platform]
|
|
11
|
+
* @returns {boolean}
|
|
12
|
+
*/
|
|
13
|
+
export function checkGhCli(env?: NodeJS.ProcessEnv, platform?: NodeJS.Platform): boolean;
|
|
4
14
|
/**
|
|
5
15
|
* The integration component that replaces the Core component `name`
|
|
6
16
|
* (spec:AST-035 FR11), or undefined when none does.
|
package/api/swizzle/_adapter.mjs
CHANGED
|
@@ -8,14 +8,37 @@
|
|
|
8
8
|
* of swizzlable components: `list` returns the names directly, `copy` uses them
|
|
9
9
|
* for its "component not found" suggestions. Resolving core + listing lives
|
|
10
10
|
* here once so neither leaf re-walks the filesystem. Throws AstryxError
|
|
11
|
-
* (ERR_CORE_NOT_FOUND) when core can't be located.
|
|
11
|
+
* (ERR_CORE_NOT_FOUND) when core can't be located. The copy receipt's `gh`
|
|
12
|
+
* lookup is here too, on the shared search-path walk.
|
|
12
13
|
*/
|
|
13
14
|
|
|
15
|
+
import {executablesOnSearchPath} from '../../foundation/env/search-path.mjs';
|
|
14
16
|
import {findProjectCoreDir, listComponents} from '../../foundation/fs/paths.mjs';
|
|
15
17
|
import {resolveComponentReplacements} from '../../foundation/discovery/component-replacement.mjs';
|
|
16
18
|
import {ERROR_CODES} from '../../foundation/response/error-codes.mjs';
|
|
17
19
|
import {AstryxError} from '../error.mjs';
|
|
18
20
|
|
|
21
|
+
/**
|
|
22
|
+
* Whether an executable `gh` is on `PATH` (with a `PATHEXT` extension on
|
|
23
|
+
* Windows), found without running it. The copy receipt offers its
|
|
24
|
+
* `gh issue create` line on it. Running `gh` would make every copy wait on a
|
|
25
|
+
* process start, and for `gh auth status` on GitHub, before it reports.
|
|
26
|
+
* @param {NodeJS.ProcessEnv} [env]
|
|
27
|
+
* @param {NodeJS.Platform} [platform]
|
|
28
|
+
* @returns {boolean}
|
|
29
|
+
*/
|
|
30
|
+
export function checkGhCli(env = process.env, platform = process.platform) {
|
|
31
|
+
const names =
|
|
32
|
+
platform === 'win32'
|
|
33
|
+
? (env.PATHEXT ?? '.COM;.EXE;.BAT;.CMD')
|
|
34
|
+
.split(';')
|
|
35
|
+
.filter(Boolean)
|
|
36
|
+
.map(extension => `gh${extension.toLowerCase()}`)
|
|
37
|
+
: ['gh'];
|
|
38
|
+
const searchPath = env.PATH ?? env.Path ?? '';
|
|
39
|
+
return executablesOnSearchPath(names, {searchPath, platform}).length > 0;
|
|
40
|
+
}
|
|
41
|
+
|
|
19
42
|
/** The package that owns Core's components, hooks, and codemods. */
|
|
20
43
|
export {CORE_PROVIDER_ID as CORE_PACKAGE} from '../../foundation/identity/providers.mjs';
|
|
21
44
|
|
|
@@ -15,9 +15,12 @@
|
|
|
15
15
|
|
|
16
16
|
import * as fs from 'node:fs';
|
|
17
17
|
import * as path from 'node:path';
|
|
18
|
-
import {
|
|
18
|
+
import {
|
|
19
|
+
checkGhCli,
|
|
20
|
+
resolveComponentReplacement,
|
|
21
|
+
resolveCore,
|
|
22
|
+
} from '../_adapter.mjs';
|
|
19
23
|
import {assertWithin, sanitizeName, PathSafetyError} from '../../../foundation/fs/path-safety.mjs';
|
|
20
|
-
import {checkGhCli} from '../_github.mjs';
|
|
21
24
|
import {Project} from '../../../foundation/config/project.mjs';
|
|
22
25
|
import {
|
|
23
26
|
CORE_PACKAGE,
|
|
@@ -299,6 +302,10 @@ export async function swizzleCopy(component, options = {}) {
|
|
|
299
302
|
const outputBase = confineWrite(output, cwd, {label: 'output directory'});
|
|
300
303
|
const outputDir = path.join(outputBase, dirName);
|
|
301
304
|
|
|
305
|
+
// The receipt's feedback first: a swizzle that fails must fail before it
|
|
306
|
+
// writes anything.
|
|
307
|
+
const feedback = buildFeedback(dirName, owner.issuesUrl);
|
|
308
|
+
|
|
302
309
|
// Pre-flight path and overwrite checks before any mkdir/writeFile.
|
|
303
310
|
const sourceFiles = fs.readdirSync(componentDir).filter(file => {
|
|
304
311
|
if (isExcludedFromCopy(file)) return false;
|
|
@@ -380,8 +387,6 @@ export async function swizzleCopy(component, options = {}) {
|
|
|
380
387
|
!isExcludedFromCopy(f) &&
|
|
381
388
|
fs.statSync(path.join(componentDir, f)).isFile(),
|
|
382
389
|
);
|
|
383
|
-
const feedback = buildFeedback(dirName, owner.issuesUrl);
|
|
384
|
-
|
|
385
390
|
/** @type {import('../swizzle.type.mjs').SwizzleCopyResponse['data']} */
|
|
386
391
|
const data = {
|
|
387
392
|
component: dirName,
|
|
@@ -1,6 +1,31 @@
|
|
|
1
1
|
// @generated by scripts/sync-api-types.mjs from the JSDoc in api/**/*.mjs.
|
|
2
2
|
// DO NOT EDIT — run `pnpm sync:api-types` to regenerate.
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* The bindings one Core provides: the namespaces interception spreads, the
|
|
6
|
+
* functions the build calls, and why the import failed, if it did.
|
|
7
|
+
* @typedef {{
|
|
8
|
+
* themeModule: any,
|
|
9
|
+
* rootModule: (() => any) | null,
|
|
10
|
+
* importError: any,
|
|
11
|
+
* defineTheme: any,
|
|
12
|
+
* generateThemeRulesSplit: any,
|
|
13
|
+
* generateOnMediaCSS: any,
|
|
14
|
+
* generateAdaptationCSS: any,
|
|
15
|
+
* }} CoreBindings
|
|
16
|
+
*/
|
|
17
|
+
/**
|
|
18
|
+
* A Core's root namespace, loaded on first use. The root entry loads all of
|
|
19
|
+
* Core and React, and only a theme that imports the root specifier needs it.
|
|
20
|
+
* Requiring the file an import resolves to returns the namespace `import()`
|
|
21
|
+
* gives. A root that cannot be loaded gives null, and interception then hands
|
|
22
|
+
* the theme namespace in its place. A root that only `import()` can load
|
|
23
|
+
* throws instead: one that awaits at its top level, or any root when Node runs
|
|
24
|
+
* without require(esm).
|
|
25
|
+
* @param {() => string | null} resolveFile
|
|
26
|
+
* @returns {() => any}
|
|
27
|
+
*/
|
|
28
|
+
export function lazyRootModule(resolveFile: () => string | null): () => any;
|
|
4
29
|
/**
|
|
5
30
|
* Why `theme build` has no Core to generate with, and the fix for where it
|
|
6
31
|
* ran: the Astryx repository builds Core, an app installs it, and an installed
|
|
@@ -170,7 +195,7 @@ export function themeBuildFamily(files: string[], options: {
|
|
|
170
195
|
*/
|
|
171
196
|
export type CoreBindings = {
|
|
172
197
|
themeModule: any;
|
|
173
|
-
rootModule: any;
|
|
198
|
+
rootModule: (() => any) | null;
|
|
174
199
|
importError: any;
|
|
175
200
|
defineTheme: any;
|
|
176
201
|
generateThemeRulesSplit: any;
|
|
@@ -132,12 +132,13 @@ import {resolveIconImports} from './icon-imports.mjs';
|
|
|
132
132
|
*/
|
|
133
133
|
/** @type {any} */ let _coreThemeModule = null;
|
|
134
134
|
/**
|
|
135
|
-
* The `@astryxdesign/core` ROOT namespace,
|
|
135
|
+
* The `@astryxdesign/core` ROOT namespace, loaded separately because it
|
|
136
136
|
* exports far more than the theme subpath. Interception must hand a theme file
|
|
137
137
|
* that imports a component from the root the root's own exports, not the theme
|
|
138
|
-
* namespace wearing its name.
|
|
138
|
+
* namespace wearing its name. It loads on first use: see lazyRootModule.
|
|
139
|
+
* @type {(() => any) | null}
|
|
139
140
|
*/
|
|
140
|
-
|
|
141
|
+
let _coreRootModule = null;
|
|
141
142
|
/** @type {any} */ let _coreImportError = null;
|
|
142
143
|
|
|
143
144
|
/**
|
|
@@ -145,7 +146,7 @@ import {resolveIconImports} from './icon-imports.mjs';
|
|
|
145
146
|
* functions the build calls, and why the import failed, if it did.
|
|
146
147
|
* @typedef {{
|
|
147
148
|
* themeModule: any,
|
|
148
|
-
* rootModule: any,
|
|
149
|
+
* rootModule: (() => any) | null,
|
|
149
150
|
* importError: any,
|
|
150
151
|
* defineTheme: any,
|
|
151
152
|
* generateThemeRulesSplit: any,
|
|
@@ -154,6 +155,47 @@ import {resolveIconImports} from './icon-imports.mjs';
|
|
|
154
155
|
* }} CoreBindings
|
|
155
156
|
*/
|
|
156
157
|
|
|
158
|
+
/**
|
|
159
|
+
* A Core's root namespace, loaded on first use. The root entry loads all of
|
|
160
|
+
* Core and React, and only a theme that imports the root specifier needs it.
|
|
161
|
+
* Requiring the file an import resolves to returns the namespace `import()`
|
|
162
|
+
* gives. A root that cannot be loaded gives null, and interception then hands
|
|
163
|
+
* the theme namespace in its place. A root that only `import()` can load
|
|
164
|
+
* throws instead: one that awaits at its top level, or any root when Node runs
|
|
165
|
+
* without require(esm).
|
|
166
|
+
* @param {() => string | null} resolveFile
|
|
167
|
+
* @returns {() => any}
|
|
168
|
+
*/
|
|
169
|
+
export function lazyRootModule(resolveFile) {
|
|
170
|
+
/** @type {{namespace: any} | null} */
|
|
171
|
+
let loaded = null;
|
|
172
|
+
return () => {
|
|
173
|
+
if (loaded) return loaded.namespace;
|
|
174
|
+
let namespace = null;
|
|
175
|
+
let file = null;
|
|
176
|
+
try {
|
|
177
|
+
file = resolveFile();
|
|
178
|
+
} catch {
|
|
179
|
+
// A Core whose root entry does not resolve falls back below.
|
|
180
|
+
}
|
|
181
|
+
try {
|
|
182
|
+
if (file) namespace = createRequire(import.meta.url)(file);
|
|
183
|
+
} catch (error) {
|
|
184
|
+
const code = /** @type {any} */ (error)?.code;
|
|
185
|
+
// The theme namespace would stand in for the root's own exports here.
|
|
186
|
+
if (code === 'ERR_REQUIRE_ASYNC_MODULE' || code === 'ERR_REQUIRE_ESM') {
|
|
187
|
+
throw new Error(
|
|
188
|
+
`The @astryxdesign/core root entry at ${file} cannot be loaded with require() (${code}), so a theme that imports it cannot be built.`,
|
|
189
|
+
{cause: error},
|
|
190
|
+
);
|
|
191
|
+
}
|
|
192
|
+
// A Core without a usable root entry still builds themes.
|
|
193
|
+
}
|
|
194
|
+
loaded = {namespace};
|
|
195
|
+
return namespace;
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
|
|
157
199
|
/**
|
|
158
200
|
* Import the CLI's own Core: the `@astryxdesign/core` this module resolves.
|
|
159
201
|
* Never throws. A failed import is kept as `importError`, so the build can
|
|
@@ -178,12 +220,9 @@ async function importCliCore() {
|
|
|
178
220
|
core.generateThemeRulesSplit = coreTheme.generateThemeRulesSplit;
|
|
179
221
|
core.generateOnMediaCSS = coreTheme.generateOnMediaCSS;
|
|
180
222
|
core.generateAdaptationCSS = coreTheme.generateAdaptationCSS;
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
// A core without a usable root entry still builds themes; interception
|
|
185
|
-
// falls back to the theme namespace for the root specifier.
|
|
186
|
-
}
|
|
223
|
+
core.rootModule = lazyRootModule(() =>
|
|
224
|
+
fileURLToPath(import.meta.resolve('@astryxdesign/core')),
|
|
225
|
+
);
|
|
187
226
|
} catch (e) {
|
|
188
227
|
// Capture the reason so the theme action can surface a precise, actionable
|
|
189
228
|
// error. The hard failure happens when `theme build` runs.
|
|
@@ -350,18 +389,10 @@ async function loadProjectCore(cwd, cliCore, {projectOnly = false} = {}) {
|
|
|
350
389
|
ERROR_CODES.ERR_CORE_INCOMPATIBLE,
|
|
351
390
|
);
|
|
352
391
|
}
|
|
353
|
-
let rootModule = null;
|
|
354
392
|
const rootFile = importTarget(dir, '.');
|
|
355
|
-
if (rootFile) {
|
|
356
|
-
try {
|
|
357
|
-
rootModule = await import(pathToFileURL(rootFile).href);
|
|
358
|
-
} catch {
|
|
359
|
-
// As with the CLI's own import, the theme namespace stands in for it.
|
|
360
|
-
}
|
|
361
|
-
}
|
|
362
393
|
return {
|
|
363
394
|
themeModule,
|
|
364
|
-
rootModule,
|
|
395
|
+
rootModule: lazyRootModule(() => rootFile),
|
|
365
396
|
importError: null,
|
|
366
397
|
defineTheme: themeModule.defineTheme,
|
|
367
398
|
generateThemeRulesSplit: themeModule.generateThemeRulesSplit,
|
|
@@ -2813,12 +2844,29 @@ async function themeBuildInternal(
|
|
|
2813
2844
|
let themeExportName;
|
|
2814
2845
|
/** Paths through the load that interception could not fully observe. */
|
|
2815
2846
|
let loadDegradation;
|
|
2847
|
+
/**
|
|
2848
|
+
* The theme file's bytes as loaded: read before and after the load, and the
|
|
2849
|
+
* registry scan below reads these rather than the file again. An editor's
|
|
2850
|
+
* in-place save truncates before it writes, so a later read can find an
|
|
2851
|
+
* empty file the load never saw; a file that changed while it loaded is not
|
|
2852
|
+
* built from.
|
|
2853
|
+
* @type {string}
|
|
2854
|
+
*/
|
|
2855
|
+
let themeSource;
|
|
2816
2856
|
try {
|
|
2857
|
+
const before = fs.readFileSync(filePath, 'utf8');
|
|
2817
2858
|
const loaded = await extractThemeDefinition(
|
|
2818
2859
|
filePath,
|
|
2819
2860
|
interception,
|
|
2820
2861
|
options.__familyLoader,
|
|
2821
2862
|
);
|
|
2863
|
+
const after = fs.readFileSync(filePath, 'utf8');
|
|
2864
|
+
if (before !== after || before === '') {
|
|
2865
|
+
throw new Error(
|
|
2866
|
+
`${filePath} changed while it was loading. Build again once it is saved.`,
|
|
2867
|
+
);
|
|
2868
|
+
}
|
|
2869
|
+
themeSource = before;
|
|
2822
2870
|
themeDef = loaded.theme;
|
|
2823
2871
|
themeExportName = loaded.exportName;
|
|
2824
2872
|
loadDegradation = loaded.degraded;
|
|
@@ -2908,7 +2956,10 @@ async function themeBuildInternal(
|
|
|
2908
2956
|
: []),
|
|
2909
2957
|
];
|
|
2910
2958
|
const iconResolution = {
|
|
2911
|
-
readSource: (/** @type {string} */ file) =>
|
|
2959
|
+
readSource: (/** @type {string} */ file) =>
|
|
2960
|
+
path.resolve(file) === path.resolve(filePath)
|
|
2961
|
+
? themeSource
|
|
2962
|
+
: fs.readFileSync(file, 'utf8'),
|
|
2912
2963
|
resolveModule: resolveThemeModule,
|
|
2913
2964
|
reservedNames: reservedNames(functionEntries),
|
|
2914
2965
|
functionEntries,
|
|
@@ -16,7 +16,8 @@
|
|
|
16
16
|
* standalone builds with current Core do not.
|
|
17
17
|
*
|
|
18
18
|
* @param {any} coreThemeModule - The installed `@astryxdesign/core/theme` namespace.
|
|
19
|
-
* @param {any} [coreRootModule] - The installed `@astryxdesign/core` namespace
|
|
19
|
+
* @param {any} [coreRootModule] - The installed `@astryxdesign/core` namespace,
|
|
20
|
+
* or a function that loads it. A function is called once, on first use.
|
|
20
21
|
* @returns {CoreInterception}
|
|
21
22
|
*/
|
|
22
23
|
export function interceptCore(coreThemeModule: any, coreRootModule?: any): CoreInterception;
|
|
@@ -236,7 +236,8 @@ function mergeGenerativeAxes(inherited, own) {
|
|
|
236
236
|
* standalone builds with current Core do not.
|
|
237
237
|
*
|
|
238
238
|
* @param {any} coreThemeModule - The installed `@astryxdesign/core/theme` namespace.
|
|
239
|
-
* @param {any} [coreRootModule] - The installed `@astryxdesign/core` namespace
|
|
239
|
+
* @param {any} [coreRootModule] - The installed `@astryxdesign/core` namespace,
|
|
240
|
+
* or a function that loads it. A function is called once, on first use.
|
|
240
241
|
* @returns {CoreInterception}
|
|
241
242
|
*/
|
|
242
243
|
export function interceptCore(coreThemeModule, coreRootModule) {
|
|
@@ -287,14 +288,31 @@ export function interceptCore(coreThemeModule, coreRootModule) {
|
|
|
287
288
|
};
|
|
288
289
|
};
|
|
289
290
|
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
291
|
+
const modules = {
|
|
292
|
+
'@astryxdesign/core/theme': wrapNamespace(coreThemeModule),
|
|
293
|
+
};
|
|
294
|
+
/** @type {any} */
|
|
295
|
+
let wrappedRoot;
|
|
296
|
+
// jiti reads a virtual module only when a theme imports its specifier. So
|
|
297
|
+
// the root, which loads all of Core, loads only for a theme that asks.
|
|
298
|
+
Object.defineProperty(modules, '@astryxdesign/core', {
|
|
299
|
+
enumerable: true,
|
|
300
|
+
configurable: true,
|
|
301
|
+
get() {
|
|
302
|
+
const root =
|
|
303
|
+
typeof coreRootModule === 'function'
|
|
304
|
+
? coreRootModule()
|
|
305
|
+
: coreRootModule;
|
|
293
306
|
// Falls back to the theme namespace only when the root could not be
|
|
294
307
|
// imported at all; a partial root is better than none, and a core
|
|
295
308
|
// missing its own root entry is already broken.
|
|
296
|
-
|
|
309
|
+
wrappedRoot ??= wrapNamespace(root ?? coreThemeModule);
|
|
310
|
+
return wrappedRoot;
|
|
297
311
|
},
|
|
312
|
+
});
|
|
313
|
+
|
|
314
|
+
return {
|
|
315
|
+
modules,
|
|
298
316
|
|
|
299
317
|
// prettier-ignore
|
|
300
318
|
observed(theme) { return wasObserved(theme, byReference); },
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @file `astryx docs calendars/calendar-systems`: choosing a calendar, the
|
|
5
|
+
* supported calendars, loading Temporal on the server and in the browser, the
|
|
6
|
+
* lunisolar calendars, and week numbers.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
/** @type {import('@astryxdesign/cli/authoring').ReferenceDoc} */
|
|
10
|
+
|
|
11
|
+
export const docs = {
|
|
12
|
+
type: 'generic',
|
|
13
|
+
name: 'calendar-systems',
|
|
14
|
+
title: 'Calendar systems',
|
|
15
|
+
placement: {
|
|
16
|
+
parent: 'namespace:calendars',
|
|
17
|
+
slot: 'guides',
|
|
18
|
+
order: 10,
|
|
19
|
+
},
|
|
20
|
+
category: 'guide',
|
|
21
|
+
description:
|
|
22
|
+
'Choosing a calendar, which calendars need Temporal, server rendering, the lunisolar calendars, and week numbers.',
|
|
23
|
+
|
|
24
|
+
sections: [
|
|
25
|
+
{
|
|
26
|
+
title: 'Choose a calendar',
|
|
27
|
+
content: [
|
|
28
|
+
{
|
|
29
|
+
type: 'prose',
|
|
30
|
+
text: '`Calendar` shows the Gregorian calendar unless you choose another one. Pass `calendar` to `<InternationalizationProvider>` to set it for a subtree. A locale on its own never changes the calendar: `fa-IR` shows Gregorian dates in Persian until you pass `calendar="persian"`. A locale with a `-u-ca-` keyword, such as `th-TH-u-ca-buddhist`, keeps Gregorian dates too; set `calendar` to choose one.',
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
type: 'code',
|
|
34
|
+
lang: 'tsx',
|
|
35
|
+
label: 'Persian dates in a Persian interface',
|
|
36
|
+
code: `import {InternationalizationProvider} from '@astryxdesign/core/i18n';
|
|
37
|
+
import {Calendar} from '@astryxdesign/core/Calendar';
|
|
38
|
+
|
|
39
|
+
<InternationalizationProvider locale="fa-IR" calendar="persian">
|
|
40
|
+
{/* shows Aban 1405; value and onChange stay '2026-10-30' */}
|
|
41
|
+
<Calendar value={date} onChange={setDate} />
|
|
42
|
+
</InternationalizationProvider>;`,
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
type: 'prose',
|
|
46
|
+
text: 'Calendar and language are independent: `locale="en" calendar="hebrew"` shows Hebrew dates in English. `Calendar` also takes its own `calendar`, which wins over the provider. Use it when one screen shows two calendars side by side.',
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
type: 'prose',
|
|
50
|
+
text: 'Values never change with the calendar. `value`, `defaultValue`, `onChange`, `min`, and `max` stay Gregorian ISO dates (`YYYY-MM-DD`) in every calendar, so your data, server code, and existing handlers keep working.',
|
|
51
|
+
},
|
|
52
|
+
],
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
title: 'Supported calendars',
|
|
56
|
+
content: [
|
|
57
|
+
{
|
|
58
|
+
type: 'table',
|
|
59
|
+
headers: ['Calendar', 'Identifiers', 'Needs Temporal'],
|
|
60
|
+
rows: [
|
|
61
|
+
['Gregorian', '`gregory`, `iso8601`', 'No'],
|
|
62
|
+
['Buddhist (Thai)', '`buddhist`', 'No'],
|
|
63
|
+
['Minguo', '`roc`', 'No'],
|
|
64
|
+
['Japanese (eras)', '`japanese`', 'No'],
|
|
65
|
+
['Persian (Solar Hijri)', '`persian`', 'Yes'],
|
|
66
|
+
['Indian national (Saka)', '`indian`', 'Yes'],
|
|
67
|
+
['Hebrew', '`hebrew`', 'Yes'],
|
|
68
|
+
[
|
|
69
|
+
'Islamic (Hijri)',
|
|
70
|
+
'`islamic-umalqura`, `islamic-civil`, `islamic-tbla`',
|
|
71
|
+
'Yes',
|
|
72
|
+
],
|
|
73
|
+
['Lunisolar', '`chinese`, `dangi`', 'Yes'],
|
|
74
|
+
['Coptic', '`coptic`', 'Yes'],
|
|
75
|
+
['Ethiopian', '`ethiopic`, `ethioaa`', 'Yes'],
|
|
76
|
+
],
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
type: 'prose',
|
|
80
|
+
text: 'Any other identifier, such as `islamic`, shows Gregorian dates and warns once in development.',
|
|
81
|
+
},
|
|
82
|
+
],
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
title: 'Load Temporal where the runtime lacks it',
|
|
86
|
+
content: [
|
|
87
|
+
{
|
|
88
|
+
type: 'prose',
|
|
89
|
+
text: "Calendars whose months are not Gregorian use the runtime's `Temporal` for their month lengths, leap months, and years. Chrome and Edge 144 and later, Firefox 139 and later, and Node.js 26 and later ship it. Safari and older runtimes do not. Astryx bundles no polyfill, so Gregorian applications pay nothing.",
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
type: 'prose',
|
|
93
|
+
text: 'Where `Temporal` is missing, load the full build of `temporal-polyfill` before your app renders. The default build has no non-ISO calendars. Load it only where `Temporal` is missing: a native implementation is more accurate for the lunisolar calendars.',
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
type: 'code',
|
|
97
|
+
lang: 'ts',
|
|
98
|
+
label: 'Load the polyfill only where Temporal is missing',
|
|
99
|
+
code: `// temporal-setup.ts: import before your app renders, on the server and in the browser
|
|
100
|
+
if (!('Temporal' in globalThis)) {
|
|
101
|
+
await import('temporal-polyfill/full/global');
|
|
102
|
+
}`,
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
type: 'prose',
|
|
106
|
+
text: 'If you render on the server, load it there too. `Calendar` resolves its calendar during render, so a server without `Temporal` renders Gregorian dates, and a browser with it renders Persian ones: hydration then fails. When both have `Temporal`, or both lack it, they render the same markup.',
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
type: 'prose',
|
|
110
|
+
text: 'Without a `Temporal` that supports it, a calendar that needs one shows Gregorian dates and warns once in development, on the server and in the browser. The Gregorian-aligned calendars (`buddhist`, `roc`, `japanese`) work everywhere without it.',
|
|
111
|
+
},
|
|
112
|
+
],
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
title: 'Lunisolar calendars',
|
|
116
|
+
content: [
|
|
117
|
+
{
|
|
118
|
+
type: 'prose',
|
|
119
|
+
text: "In the lunisolar calendars, months start on new moons computed from astronomy, and runtimes do not all agree on a few of them. Astryx follows the runtime's `Temporal` and does not correct it.",
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
type: 'list',
|
|
123
|
+
style: 'unordered',
|
|
124
|
+
items: [
|
|
125
|
+
'Native `Temporal` in Chrome, Edge, Firefox, and Node.js 26 agrees with official observatory data from 1900 through 2100.',
|
|
126
|
+
"A polyfill reads the platform's `Intl` data instead. Under a polyfill, Node.js 24 starts nine `chinese` and four `dangi` months in that range one day apart from the native result: the first month of the 2027 `chinese` year starts on February 6 with native `Temporal` and on February 7 under the polyfill. Safari uses the same kind of `Intl` data, so expect the same differences there.",
|
|
127
|
+
'Within one browser, the day numbers a person sees, the dates a screen reader announces, and the value they pick agree. Only two different runtimes can disagree.',
|
|
128
|
+
],
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
type: 'prose',
|
|
132
|
+
text: 'If you render on the server, a server and a browser that use different implementations can disagree on one of these month starts. The browser then renders that month differently from the server markup, and React renders that part again on the client during hydration. The `temporal-polyfill/full/global` import keeps a native `Temporal` where one exists, so on its own it leaves Chrome, Edge, and Firefox on native `Temporal` and a Node.js 24 server on the polyfill. When identical server and browser markup for these calendars matters more than matching official data, call `installImplementation()` from `temporal-polyfill/full/shim` on the server and in the browser before rendering: it installs the polyfill even over a native `Temporal`. A server runtime with native `Temporal`, such as Node.js 26, also matches native browsers. Otherwise, do not replace a native `Temporal`: that makes native environments less accurate.',
|
|
133
|
+
},
|
|
134
|
+
],
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
title: 'Week numbers',
|
|
138
|
+
content: [
|
|
139
|
+
{
|
|
140
|
+
type: 'prose',
|
|
141
|
+
text: "`Calendar`'s `hasWeekNumbers` shows ISO 8601 week numbers in every calendar. Temporal defines week numbering only for the ISO calendar.",
|
|
142
|
+
},
|
|
143
|
+
],
|
|
144
|
+
},
|
|
145
|
+
],
|
|
146
|
+
};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @file `astryx docs calendars`: calendar systems in detail. Which calendars
|
|
5
|
+
* date components show, how to load Temporal, server rendering, and the
|
|
6
|
+
* lunisolar calendars. The `internationalization/i18n-calendars` guide has the
|
|
7
|
+
* short version.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
/** @type {import('@astryxdesign/cli/authoring').NamespaceDoc} */
|
|
11
|
+
export const docs = {
|
|
12
|
+
type: 'namespace',
|
|
13
|
+
name: 'calendars',
|
|
14
|
+
// The docsite lists guide pages by title, so this one sorts directly below
|
|
15
|
+
// Internationalization, the page that links here.
|
|
16
|
+
title: 'Internationalization: calendars',
|
|
17
|
+
summary:
|
|
18
|
+
'Show dates in the Persian, Hebrew, Islamic, Buddhist, Japanese, lunisolar, and other calendars while values stay Gregorian ISO dates.',
|
|
19
|
+
keywords: [
|
|
20
|
+
'calendar',
|
|
21
|
+
'calendar system',
|
|
22
|
+
'Persian',
|
|
23
|
+
'Jalali',
|
|
24
|
+
'Hebrew',
|
|
25
|
+
'Hijri',
|
|
26
|
+
'Islamic',
|
|
27
|
+
'Buddhist',
|
|
28
|
+
'Japanese era',
|
|
29
|
+
'lunisolar',
|
|
30
|
+
'chinese',
|
|
31
|
+
'dangi',
|
|
32
|
+
'Ethiopian',
|
|
33
|
+
'Temporal',
|
|
34
|
+
'polyfill',
|
|
35
|
+
'u-ca',
|
|
36
|
+
],
|
|
37
|
+
slots: {
|
|
38
|
+
guides: {title: 'Guides', accepts: {kinds: ['generic']}},
|
|
39
|
+
},
|
|
40
|
+
blocks: [
|
|
41
|
+
{
|
|
42
|
+
type: 'prose',
|
|
43
|
+
text: '`Calendar`, DateInput, DateRangeInput, and DateTimeInput show the Gregorian calendar unless the application chooses another one. Values never change with the calendar: they stay Gregorian ISO dates. {@link generic:i18n-calendars} has the short version.',
|
|
44
|
+
},
|
|
45
|
+
],
|
|
46
|
+
};
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @file `astryx docs internationalization/i18n-calendars`: the short version of
|
|
5
|
+
* showing dates in another calendar. The `calendars` namespace holds the
|
|
6
|
+
* detail.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
/** @type {import('@astryxdesign/cli/authoring').ReferenceDoc} */
|
|
10
|
+
|
|
11
|
+
export const docs = {
|
|
12
|
+
type: 'generic',
|
|
13
|
+
name: 'i18n-calendars',
|
|
14
|
+
title: 'Other calendars',
|
|
15
|
+
placement: {
|
|
16
|
+
parent: 'namespace:internationalization',
|
|
17
|
+
slot: 'guides',
|
|
18
|
+
order: 25,
|
|
19
|
+
},
|
|
20
|
+
category: 'guide',
|
|
21
|
+
description:
|
|
22
|
+
'Show dates in the Persian, Hebrew, Islamic, Buddhist, Japanese, and other calendars while values stay Gregorian ISO dates.',
|
|
23
|
+
|
|
24
|
+
sections: [
|
|
25
|
+
{
|
|
26
|
+
title: 'Show dates in another calendar',
|
|
27
|
+
content: [
|
|
28
|
+
{
|
|
29
|
+
type: 'prose',
|
|
30
|
+
text: 'Set `calendar` on `<InternationalizationProvider>` for a subtree, or on `Calendar` itself; without it, `Calendar` is Gregorian. Values stay Gregorian ISO dates (`YYYY-MM-DD`) in every calendar.',
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
type: 'code',
|
|
34
|
+
lang: 'tsx',
|
|
35
|
+
label: 'Persian dates in a Persian interface',
|
|
36
|
+
code: `import {InternationalizationProvider} from '@astryxdesign/core/i18n';
|
|
37
|
+
import {Calendar} from '@astryxdesign/core/Calendar';
|
|
38
|
+
|
|
39
|
+
<InternationalizationProvider locale="fa-IR" calendar="persian">
|
|
40
|
+
{/* shows Aban 1405; value and onChange stay '2026-10-30' */}
|
|
41
|
+
<Calendar value={date} onChange={setDate} />
|
|
42
|
+
</InternationalizationProvider>;`,
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
type: 'prose',
|
|
46
|
+
text: "Most calendars need the runtime's `Temporal`. Safari and older runtimes lack it: load `temporal-polyfill/full/global` there, on the server and in the browser. Without it, those calendars show Gregorian dates. See {@link namespace:calendars} for the supported calendars, server rendering, and the lunisolar calendars.",
|
|
47
|
+
},
|
|
48
|
+
],
|
|
49
|
+
},
|
|
50
|
+
],
|
|
51
|
+
};
|