@venizia/ardor 0.4.8-0 → 0.4.8-10
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/README.md +14 -3
- package/dist/ardor.d.ts +2 -2
- package/dist/ardor.js +2 -2
- package/dist/codemod/bin.js +1 -1
- package/dist/codemod/cli.d.ts +10 -1
- package/dist/codemod/cli.js +115 -23
- package/dist/codemod/files.d.ts +1 -1
- package/dist/codemod/files.js +9 -5
- package/dist/codemod/logger.js +1 -1
- package/dist/codemod/renames.d.ts +12 -0
- package/dist/codemod/renames.js +25 -2
- package/dist/codemod/transform.d.ts +1 -1
- package/dist/codemod/transform.js +58 -6
- package/dist/index.d.ts +21 -0
- package/dist/index.js +21 -0
- package/dist/presets/app/files/.configs/builders/Dockerfile +5 -0
- package/dist/presets/app/files/.configs/builders/docker-entrypoint.d/40-runtime-config.sh +5 -3
- package/dist/presets/app/files/.configs/builders/docker-entrypoint.d/45-api-proxy.sh +19 -0
- package/dist/presets/app/files/.configs/builders/nginx-snippets/api-proxy.conf +4 -0
- package/dist/presets/app/files/.configs/builders/nginx-snippets/security-headers.conf +7 -5
- package/dist/presets/app/files/.configs/builders/nginx.conf.template +3 -0
- package/dist/presets/app/files/.configs/builders/vite.config.mts +7 -8
- package/dist/presets/app/preset.json +14 -14
- package/dist/presets/lib/preset.json +9 -9
- package/dist/testing.d.ts +5 -25
- package/dist/testing.js +2 -50
- package/dist/vite/common/constants.d.ts +6 -0
- package/dist/vite/common/constants.js +6 -0
- package/dist/vite/common/types.d.ts +20 -4
- package/dist/vite/plugin.d.ts +10 -0
- package/dist/vite/plugin.js +10 -0
- package/package.json +20 -20
- package/dist/ardor.d.ts.map +0 -1
- package/dist/ardor.js.map +0 -1
- package/dist/codemod/bin.d.ts.map +0 -1
- package/dist/codemod/bin.js.map +0 -1
- package/dist/codemod/cli.d.ts.map +0 -1
- package/dist/codemod/cli.js.map +0 -1
- package/dist/codemod/files.d.ts.map +0 -1
- package/dist/codemod/files.js.map +0 -1
- package/dist/codemod/logger.d.ts.map +0 -1
- package/dist/codemod/logger.js.map +0 -1
- package/dist/codemod/migrate.d.ts.map +0 -1
- package/dist/codemod/migrate.js.map +0 -1
- package/dist/codemod/renames.d.ts.map +0 -1
- package/dist/codemod/renames.js.map +0 -1
- package/dist/codemod/transform.d.ts.map +0 -1
- package/dist/codemod/transform.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/repository.d.ts.map +0 -1
- package/dist/repository.js.map +0 -1
- package/dist/testing.d.ts.map +0 -1
- package/dist/testing.js.map +0 -1
- package/dist/vite/common/constants.d.ts.map +0 -1
- package/dist/vite/common/constants.js.map +0 -1
- package/dist/vite/common/index.d.ts.map +0 -1
- package/dist/vite/common/index.js.map +0 -1
- package/dist/vite/common/types.d.ts.map +0 -1
- package/dist/vite/common/types.js.map +0 -1
- package/dist/vite/index.d.ts.map +0 -1
- package/dist/vite/index.js.map +0 -1
- package/dist/vite/plugin.d.ts.map +0 -1
- package/dist/vite/plugin.js.map +0 -1
- package/dist/vite/resolver.d.ts.map +0 -1
- package/dist/vite/resolver.js.map +0 -1
- package/dist/vite/sources.d.ts.map +0 -1
- package/dist/vite/sources.js.map +0 -1
package/README.md
CHANGED
|
@@ -13,6 +13,8 @@ control comes from `@venizia/ignis-inversion`, and the data layer speaks the que
|
|
|
13
13
|
bun add @venizia/ardor @venizia/ignis-inversion @venizia/ignis-filter @venizia/ignis-kernel @venizia/ignis-helpers reflect-metadata
|
|
14
14
|
```
|
|
15
15
|
|
|
16
|
+
The React-side peers (`react`, `react-dom`, `react-redux`, `@reduxjs/toolkit`, `@tanstack/react-query`, `ra-core`, `ra-i18n-polyglot`, `react-router-dom`) are installed too; the full `bun add` line is in the [setup guide](https://ardor.venizia.ai/guides/get-started/setup).
|
|
17
|
+
|
|
16
18
|
## The `Ardor` namespace
|
|
17
19
|
|
|
18
20
|
`Ardor` gathers every React hook of the react and admin packages under one name: `Ardor.useRepository(...)`, `Ardor.useTranslate()`. It is the same function as the bare `useRepository`, the Rules of Hooks check the call, and a bundler keeps only the hooks you use, so it adds no bytes to an app.
|
|
@@ -20,8 +22,10 @@ bun add @venizia/ardor @venizia/ignis-inversion @venizia/ignis-filter @venizia/i
|
|
|
20
22
|
```tsx
|
|
21
23
|
import { Ardor } from '@venizia/ardor';
|
|
22
24
|
|
|
25
|
+
import { OrdersRepository } from './orders.repository';
|
|
26
|
+
|
|
23
27
|
export const Orders = () => {
|
|
24
|
-
const repository = Ardor.useRepository({
|
|
28
|
+
const repository = Ardor.useRepository({ target: OrdersRepository });
|
|
25
29
|
|
|
26
30
|
return <div>{String(repository)}</div>;
|
|
27
31
|
};
|
|
@@ -29,7 +33,13 @@ export const Orders = () => {
|
|
|
29
33
|
|
|
30
34
|
## Moving to the new names
|
|
31
35
|
|
|
32
|
-
`bun run ardor codemod namespace src` lists the removed bare names that have a replacement (`getRuntimeConfig` to `RuntimeConfig.get`, `isDefined` to `ValueUtility.isDefined`, `NullableType` to `undefined | null | void`, `Logger.getInstance({ scope })` to `LoggerFactory.getLogger([scope])`, ...) and the removed names with none, and writes nothing; `--write` applies it, `--check` fails while any is left, and `--hooks` also moves hooks imported from `@venizia/ardor` to `Ardor.useX`. It needs the `typescript` package.
|
|
36
|
+
`bun run ardor codemod namespace src` lists the removed bare names that have a replacement (`getRuntimeConfig` to `RuntimeConfig.get`, `isDefined` to `ValueUtility.isDefined`, `NullableType` to `undefined | null | void`, `Logger.getInstance({ scope })` to `LoggerFactory.getLogger([scope])`, ...) and the removed names with none, and writes nothing; `--write` applies it (it refuses a file with local changes unless you add `--allow-dirty`), `--check` fails while any is left, and `--hooks` also moves hooks imported from `@venizia/ardor` to `Ardor.useX`. It needs the `typescript` package.
|
|
37
|
+
|
|
38
|
+
## Subpaths
|
|
39
|
+
|
|
40
|
+
- `@venizia/ardor/repository` - `HttpRepository` and the datasource settings; needs the optional peer `@venizia/ignis-connectors`.
|
|
41
|
+
- `@venizia/ardor/testing` - `assertArdorApplicationBoots` and fakes of `ResizeObserver`, `IntersectionObserver`, `matchMedia`, storage and the clipboard, for your test suite.
|
|
42
|
+
- `@venizia/ardor/vite` - `buildInfoFile`, a Vite plugin that writes the build info file; needs the optional peers `@venizia/ignis-boot` and `vite`.
|
|
33
43
|
|
|
34
44
|
## Quick start
|
|
35
45
|
|
|
@@ -108,7 +118,8 @@ export class Application extends BaseArdorApplication {
|
|
|
108
118
|
```
|
|
109
119
|
|
|
110
120
|
The full guide, including the root component and the typed hooks, is in the
|
|
111
|
-
[
|
|
121
|
+
[Quickstart](https://ardor.venizia.ai/guides/get-started/5-minute-quickstart) and the
|
|
122
|
+
[references](https://ardor.venizia.ai/references/hooks).
|
|
112
123
|
|
|
113
124
|
## Migrating from `@minimaltech/ra-core-infra`
|
|
114
125
|
|
package/dist/ardor.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { useDocumentTitle, useFeatures, useHtmlLang, useNotifyError, useRefreshToken, useRequestHeaderLocale, useTranslate, } from '@venizia/ardor-admin';
|
|
2
|
-
export { useApplicationContext, useApplicationLogger, useAutosave, useBeforeUnload, useComponent, useConfiguration, useConfirm, useCopyToClipboard, useDebounce, useElementSize, useInjectable,
|
|
1
|
+
export { useDocumentTitle, useFeatures, useHtmlLang, useNotifyError, useRefreshToken, useRequestHeaderLocale, useTranslate, useUntypedTranslate, } from '@venizia/ardor-admin';
|
|
2
|
+
export { useApplicationContainer, useApplicationContext, useApplicationLogger, useAutosave, useBeforeUnload, useComponent, useConfiguration, useConfirm, useCopyToClipboard, useDebounce, useDocumentVisibility, useElementSize, useInjectable, useIntersection, useMediaQuery, useOnlineStatus, useProvider, useRepository, useResizeEffect, useService, useStoredState, useWindowDimensions, } from '@venizia/ardor-react';
|
|
3
3
|
//# sourceMappingURL=ardor.d.ts.map
|
package/dist/ardor.js
CHANGED
|
@@ -6,6 +6,6 @@
|
|
|
6
6
|
//
|
|
7
7
|
// A module namespace, not an object literal: a bundler resolves `Ardor.useRepository` to that one
|
|
8
8
|
// hook and drops the rest, where an object that lists them all would pull every hook in.
|
|
9
|
-
export { useDocumentTitle, useFeatures, useHtmlLang, useNotifyError, useRefreshToken, useRequestHeaderLocale, useTranslate, } from '@venizia/ardor-admin';
|
|
10
|
-
export { useApplicationContext, useApplicationLogger, useAutosave, useBeforeUnload, useComponent, useConfiguration, useConfirm, useCopyToClipboard, useDebounce, useElementSize, useInjectable,
|
|
9
|
+
export { useDocumentTitle, useFeatures, useHtmlLang, useNotifyError, useRefreshToken, useRequestHeaderLocale, useTranslate, useUntypedTranslate, } from '@venizia/ardor-admin';
|
|
10
|
+
export { useApplicationContainer, useApplicationContext, useApplicationLogger, useAutosave, useBeforeUnload, useComponent, useConfiguration, useConfirm, useCopyToClipboard, useDebounce, useDocumentVisibility, useElementSize, useInjectable, useIntersection, useMediaQuery, useOnlineStatus, useProvider, useRepository, useResizeEffect, useService, useStoredState, useWindowDimensions, } from '@venizia/ardor-react';
|
|
11
11
|
//# sourceMappingURL=ardor.js.map
|
package/dist/codemod/bin.js
CHANGED
|
@@ -3,7 +3,7 @@ import { NamespaceCommand } from './cli.js';
|
|
|
3
3
|
const USAGE = `Usage: ardor <command>
|
|
4
4
|
|
|
5
5
|
Commands:
|
|
6
|
-
codemod namespace move the
|
|
6
|
+
codemod namespace move the removed bare names to the class members that replace them
|
|
7
7
|
|
|
8
8
|
Run "ardor codemod namespace --help" for the options.`;
|
|
9
9
|
/** The `ardor` bin of `@venizia/ardor`: `ardor codemod namespace [paths...] [--write | --check]`. */
|
package/dist/codemod/cli.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/** `ardor codemod namespace`: a dry run unless `--write`; `--check` is the dry run that fails on work left. */
|
|
2
2
|
export declare class NamespaceCommand {
|
|
3
|
-
static readonly USAGE = "Usage: ardor codemod namespace [paths...] [--hooks] [--write [--allow-dirty] | --check]\n\nMoves the names removed from @venizia/ardor to what replaces them:\n\n isDefined, isString, isNumber, isObject, isValidDate ValueUtility.<name>\n isBrowser BrowserUtility.isBrowser\n toDataUrl FileUtility.toDataUrl\n getRuntimeConfig RuntimeConfig.get\n createAppDispatch, createAppSelectors DispatchHooks.create, SelectorHooks.create\n resolveApplicationProviders ApplicationProviders.resolve\n hasPendingFeatureMessages, loadFeatureMessages Features.hasPendingMessages, Features.loadMessages\n NumberIdType, StringIdType, NullableType number, string, undefined | null | void\n BaseHelper, LogLevels, ILogger, TLogLevel the same names from @venizia/ignis-helpers/core\n Logger.getInstance({ scope }), new Logger({ scope }) LoggerFactory.getLogger([scope]) (enableDebug is dropped, with a note)\n Logger (a type) ILogger\n\nRemoved with nothing to write in their place, so only listed with their line: isEditableTarget,\nTDataCount, ISyncFC, App.DEFAULT_LOCALE, HeaderConstants.REQUEST_DEVICE_INFO, HeaderConstants.RESPONSE_FORMAT,\nthe enableDebug prop of ArdorApplication (pass logger instead), and a Logger use with no one-line form.\n\nIt rewrites a name imported from @venizia/ardor, @venizia/ardor-kernel, @venizia/ardor-react or\n@venizia/ardor-admin, its uses, and the import. It reads syntax only: a name the file also declares\nitself, a re-export by name and a class name already taken are listed with their line and left for you.\n\n --hooks also move a hook imported from @venizia/ardor to the Ardor namespace (useRepository()\n becomes Ardor.useRepository()). A hook imported from @venizia/ardor-react or\n @venizia/ardor-admin is never touched: those packages cannot import Ardor.\n --write write the changed files (without it, nothing is written)\n --allow-dirty with --write, also write a file that has local changes, such as one another codemod\n just changed (devz codemod namespace-functions --write leaves the tree dirty)\n --check dry run that exits 1 when anything would change or is left (for CI)\n --help print this text and exit\n\nWith no flag it lists what would change and writes nothing. Inside a git repository it reads the\nfiles git knows (tracked, or untracked and not ignored), and --write refuses a file with local\nchanges (changed, staged or untracked), so git can undo the codemod: the file is listed as \"refused\"\nwith its path, the summary counts it and the run exits 1. Commit or stash it and run again, or run\nagain with --allow-dirty to write it anyway (it keeps the other codemod's edits). To run two codemods\none after the other in a dirty tree, give this one --write --allow-dirty.\nRun your formatter afterwards: the new names are appended to the import they join.";
|
|
3
|
+
static readonly USAGE = "Usage: ardor codemod namespace [paths...] [--hooks] [--write [--allow-dirty] | --check]\n\nMoves the names removed from @venizia/ardor to what replaces them:\n\n isDefined, isString, isNumber, isObject, isValidDate ValueUtility.<name>\n isBrowser BrowserUtility.isBrowser\n toDataUrl FileUtility.toDataUrl\n getRuntimeConfig RuntimeConfig.get\n createAppDispatch, createAppSelectors DispatchHooks.create, SelectorHooks.create\n resolveApplicationProviders ApplicationProviders.resolve\n hasPendingFeatureMessages, loadFeatureMessages Features.hasPendingMessages, Features.loadMessages\n NumberIdType, StringIdType, NullableType number, string, undefined | null | void\n BaseHelper, LogLevels, ILogger, TLogLevel the same names from @venizia/ignis-helpers/core\n Logger.getInstance({ scope }), new Logger({ scope }) LoggerFactory.getLogger([scope]) (enableDebug is dropped, with a note)\n Logger (a type) ILogger\n ISendResponse INetworkResponse\n\nRemoved with nothing to write in their place, so only listed with their line: isEditableTarget,\nTDataCount, ISyncFC, IListFilter.offset (use skip; listed wherever a file that imports IListFilter or ListFilterBuilder reads or sets .offset), useSizer (use useElementSize), useInjectableContainer (renamed useApplicationContainer), App.DEFAULT_LOCALE, HeaderConstants.REQUEST_DEVICE_INFO, HeaderConstants.RESPONSE_FORMAT,\nthe enableDebug prop of ArdorApplication (pass logger instead), and a Logger use with no one-line form.\n\nIt rewrites a name imported from @venizia/ardor, @venizia/ardor-kernel, @venizia/ardor-react or\n@venizia/ardor-admin, its uses, and the import. It reads syntax only: a name the file also declares\nitself, a re-export by name and a class name already taken are listed with their line and left for you.\n\n --hooks also move a hook imported from @venizia/ardor to the Ardor namespace (useRepository()\n becomes Ardor.useRepository()). A hook imported from @venizia/ardor-react or\n @venizia/ardor-admin is never touched: those packages cannot import Ardor.\n --write write the changed files (without it, nothing is written)\n --allow-dirty with --write, also write a file that has local changes, such as one another codemod\n just changed (devz codemod namespace-functions --write leaves the tree dirty)\n --check dry run that exits 1 when anything would change or is left (for CI)\n --help print this text and exit\n\n--write is all or nothing: it reads and rewrites every file in memory first, and writes only if every\nfile went through. A file that cannot be parsed or rewritten is listed as \"failed\" with its path, the\nrun exits 1 and nothing is written. A file that is not valid UTF-8 and would change is a failure too:\nit is left alone rather than damaged. Outside a git repository nothing can undo a write, so --write\nrefuses unless you give --allow-dirty.\n\nWith no flag it lists what would change and writes nothing. Inside a git repository it reads the\nfiles git knows (tracked, or untracked and not ignored), and --write refuses a file with local\nchanges (changed, staged or untracked), so git can undo the codemod: the file is listed as \"refused\"\nwith its path, the summary counts it and the run exits 1. Commit or stash it and run again, or run\nagain with --allow-dirty to write it anyway (it keeps the other codemod's edits). To run two codemods\none after the other in a dirty tree, give this one --write --allow-dirty.\nRun your formatter afterwards: the new names are appended to the import they join.";
|
|
4
4
|
/** Runs the command and returns the exit code; prints to the console. */
|
|
5
5
|
static run(opts: {
|
|
6
6
|
root: string;
|
|
@@ -8,6 +8,15 @@ export declare class NamespaceCommand {
|
|
|
8
8
|
}): Promise<number>;
|
|
9
9
|
private static loadTypeScript;
|
|
10
10
|
private static sweep;
|
|
11
|
+
/**
|
|
12
|
+
* Writes every file next to itself first, and renames them into place only when all were written,
|
|
13
|
+
* so a failure leaves no file changed. A file that is not the file that was read (a link swapped in,
|
|
14
|
+
* an edit made meanwhile) is refused: the rename replaces a link instead of following it, and a
|
|
15
|
+
* hard link is not written through.
|
|
16
|
+
*/
|
|
17
|
+
private static writeAll;
|
|
18
|
+
/** Text for the terminal: control, format and line-separator characters, such as an escape sequence in a file name, become `?`. */
|
|
19
|
+
private static clean;
|
|
11
20
|
private static report;
|
|
12
21
|
}
|
|
13
22
|
//# sourceMappingURL=cli.d.ts.map
|
package/dist/codemod/cli.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { readFileSync, writeFileSync } from 'node:fs';
|
|
1
|
+
import { chmodSync, existsSync, lstatSync, readFileSync, renameSync, rmSync, writeFileSync, } from 'node:fs';
|
|
2
2
|
import { relative, resolve } from 'node:path';
|
|
3
3
|
import { CodemodFiles } from './files.js';
|
|
4
4
|
import { Migration } from './migrate.js';
|
|
@@ -17,9 +17,10 @@ Moves the names removed from @venizia/ardor to what replaces them:
|
|
|
17
17
|
BaseHelper, LogLevels, ILogger, TLogLevel the same names from @venizia/ignis-helpers/core
|
|
18
18
|
Logger.getInstance({ scope }), new Logger({ scope }) LoggerFactory.getLogger([scope]) (enableDebug is dropped, with a note)
|
|
19
19
|
Logger (a type) ILogger
|
|
20
|
+
ISendResponse INetworkResponse
|
|
20
21
|
|
|
21
22
|
Removed with nothing to write in their place, so only listed with their line: isEditableTarget,
|
|
22
|
-
TDataCount, ISyncFC, App.DEFAULT_LOCALE, HeaderConstants.REQUEST_DEVICE_INFO, HeaderConstants.RESPONSE_FORMAT,
|
|
23
|
+
TDataCount, ISyncFC, IListFilter.offset (use skip; listed wherever a file that imports IListFilter or ListFilterBuilder reads or sets .offset), useSizer (use useElementSize), useInjectableContainer (renamed useApplicationContainer), App.DEFAULT_LOCALE, HeaderConstants.REQUEST_DEVICE_INFO, HeaderConstants.RESPONSE_FORMAT,
|
|
23
24
|
the enableDebug prop of ArdorApplication (pass logger instead), and a Logger use with no one-line form.
|
|
24
25
|
|
|
25
26
|
It rewrites a name imported from @venizia/ardor, @venizia/ardor-kernel, @venizia/ardor-react or
|
|
@@ -35,6 +36,12 @@ itself, a re-export by name and a class name already taken are listed with their
|
|
|
35
36
|
--check dry run that exits 1 when anything would change or is left (for CI)
|
|
36
37
|
--help print this text and exit
|
|
37
38
|
|
|
39
|
+
--write is all or nothing: it reads and rewrites every file in memory first, and writes only if every
|
|
40
|
+
file went through. A file that cannot be parsed or rewritten is listed as "failed" with its path, the
|
|
41
|
+
run exits 1 and nothing is written. A file that is not valid UTF-8 and would change is a failure too:
|
|
42
|
+
it is left alone rather than damaged. Outside a git repository nothing can undo a write, so --write
|
|
43
|
+
refuses unless you give --allow-dirty.
|
|
44
|
+
|
|
38
45
|
With no flag it lists what would change and writes nothing. Inside a git repository it reads the
|
|
39
46
|
files git knows (tracked, or untracked and not ignored), and --write refuses a file with local
|
|
40
47
|
changes (changed, staged or untracked), so git can undo the codemod: the file is listed as "refused"
|
|
@@ -97,6 +104,11 @@ export class NamespaceCommand {
|
|
|
97
104
|
const paths = args.filter((argument) => !argument.startsWith('-'));
|
|
98
105
|
const targets = (paths.length > 0 ? paths : ['.']).map((path) => resolve(root, path));
|
|
99
106
|
const hooks = args.includes(CodemodFlags.HOOKS);
|
|
107
|
+
const missing = targets.filter((target) => !existsSync(target));
|
|
108
|
+
if (missing.length > 0) {
|
|
109
|
+
console.error(`ardor codemod: no such file or folder: ${missing.map(NamespaceCommand.clean).join(', ')}`);
|
|
110
|
+
return USAGE_ERROR_CODE;
|
|
111
|
+
}
|
|
100
112
|
return NamespaceCommand.sweep({ root, ts, targets, hooks, isWrite, isCheck, isAllowDirty });
|
|
101
113
|
}
|
|
102
114
|
static async loadTypeScript() {
|
|
@@ -113,43 +125,118 @@ export class NamespaceCommand {
|
|
|
113
125
|
static sweep(opts) {
|
|
114
126
|
const { root, ts, targets, hooks, isWrite, isCheck, isAllowDirty } = opts;
|
|
115
127
|
const files = [...new Set(targets.flatMap((target) => CodemodFiles.collect({ target })))];
|
|
116
|
-
const
|
|
117
|
-
|
|
118
|
-
:
|
|
128
|
+
const dirtyOf = targets.map((target) => CodemodFiles.dirty({ target }));
|
|
129
|
+
if (isWrite && !isAllowDirty && dirtyOf.some((dirty) => dirty === undefined)) {
|
|
130
|
+
console.error(`ardor codemod: this is not a git repository, so nothing can undo ${CodemodFlags.WRITE}; run again with ${CodemodFlags.ALLOW_DIRTY} to write anyway`);
|
|
131
|
+
return 1;
|
|
132
|
+
}
|
|
133
|
+
const dirty = new Set(isAllowDirty ? [] : dirtyOf.flatMap((paths) => [...(paths ?? [])]));
|
|
119
134
|
const changes = [];
|
|
135
|
+
const pending = [];
|
|
120
136
|
const refused = [];
|
|
137
|
+
const failed = [];
|
|
121
138
|
const left = [];
|
|
122
139
|
const notes = [];
|
|
123
140
|
for (const path of files) {
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
141
|
+
try {
|
|
142
|
+
const stat = lstatSync(path);
|
|
143
|
+
const bytes = readFileSync(path);
|
|
144
|
+
const text = bytes.toString('utf8');
|
|
145
|
+
const result = Migration.run({ ts, fileName: path, text, hooks });
|
|
146
|
+
for (const finding of result.findings) {
|
|
147
|
+
(finding.kind === 'note' ? notes : left).push({ path, finding });
|
|
148
|
+
}
|
|
149
|
+
if (result.text === text) {
|
|
150
|
+
continue;
|
|
151
|
+
}
|
|
152
|
+
if (!Buffer.from(text, 'utf8').equals(bytes)) {
|
|
153
|
+
failed.push({ path, reason: 'it is not valid UTF-8, so a rewrite would damage it' });
|
|
154
|
+
continue;
|
|
155
|
+
}
|
|
156
|
+
if (isWrite && dirty.has(path)) {
|
|
157
|
+
refused.push(path);
|
|
158
|
+
continue;
|
|
159
|
+
}
|
|
160
|
+
changes.push({ path, renamed: result.renamed });
|
|
161
|
+
pending.push({ path, text: result.text, stat });
|
|
128
162
|
}
|
|
129
|
-
|
|
130
|
-
|
|
163
|
+
catch (error) {
|
|
164
|
+
failed.push({ path, reason: error instanceof Error ? error.message : String(error) });
|
|
131
165
|
}
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
166
|
+
}
|
|
167
|
+
if (isWrite && failed.length === 0) {
|
|
168
|
+
failed.push(...NamespaceCommand.writeAll({ pending }));
|
|
169
|
+
}
|
|
170
|
+
return NamespaceCommand.report({
|
|
171
|
+
root,
|
|
172
|
+
isWrite,
|
|
173
|
+
isCheck,
|
|
174
|
+
changes,
|
|
175
|
+
refused,
|
|
176
|
+
failed,
|
|
177
|
+
left,
|
|
178
|
+
notes,
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* Writes every file next to itself first, and renames them into place only when all were written,
|
|
183
|
+
* so a failure leaves no file changed. A file that is not the file that was read (a link swapped in,
|
|
184
|
+
* an edit made meanwhile) is refused: the rename replaces a link instead of following it, and a
|
|
185
|
+
* hard link is not written through.
|
|
186
|
+
*/
|
|
187
|
+
static writeAll(opts) {
|
|
188
|
+
const staged = [];
|
|
189
|
+
const failures = [];
|
|
190
|
+
for (const { path, text, stat } of opts.pending) {
|
|
191
|
+
const temp = `${path}.${process.pid}.codemod`;
|
|
192
|
+
try {
|
|
193
|
+
const now = lstatSync(path);
|
|
194
|
+
if (!now.isFile() || now.mtimeMs !== stat.mtimeMs || now.size !== stat.size) {
|
|
195
|
+
failures.push({
|
|
196
|
+
path,
|
|
197
|
+
reason: 'it changed while the codemod ran, so it was not written',
|
|
198
|
+
});
|
|
199
|
+
continue;
|
|
200
|
+
}
|
|
201
|
+
writeFileSync(temp, text);
|
|
202
|
+
chmodSync(temp, now.mode & 0o7777);
|
|
203
|
+
staged.push({ path, temp });
|
|
204
|
+
}
|
|
205
|
+
catch (error) {
|
|
206
|
+
rmSync(temp, { force: true });
|
|
207
|
+
failures.push({ path, reason: error instanceof Error ? error.message : String(error) });
|
|
135
208
|
}
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
209
|
+
}
|
|
210
|
+
if (failures.length > 0) {
|
|
211
|
+
for (const { temp } of staged) {
|
|
212
|
+
rmSync(temp, { force: true });
|
|
139
213
|
}
|
|
214
|
+
return failures;
|
|
140
215
|
}
|
|
141
|
-
|
|
216
|
+
for (const { path, temp } of staged) {
|
|
217
|
+
renameSync(temp, path);
|
|
218
|
+
}
|
|
219
|
+
return [];
|
|
220
|
+
}
|
|
221
|
+
/** Text for the terminal: control, format and line-separator characters, such as an escape sequence in a file name, become `?`. */
|
|
222
|
+
static clean(text) {
|
|
223
|
+
return text.replace(/[\p{Cc}\p{Cf}\p{Zl}\p{Zp}]/gu, '?');
|
|
142
224
|
}
|
|
143
225
|
static report(opts) {
|
|
144
|
-
const { root, isWrite, isCheck, changes, refused, left, notes } = opts;
|
|
145
|
-
|
|
146
|
-
const
|
|
226
|
+
const { root, isWrite, isCheck, changes, refused, failed, left, notes } = opts;
|
|
227
|
+
// Nothing is written when a file failed, so the files are not "changed".
|
|
228
|
+
const verb = isWrite && failed.length === 0 ? 'changed' : 'would change';
|
|
229
|
+
// A path comes from the file system: a control character in it is shown as `?`, never sent to the terminal.
|
|
230
|
+
const show = (path) => NamespaceCommand.clean(relative(root, path) || path);
|
|
147
231
|
for (const change of changes) {
|
|
148
232
|
console.log(`${verb} ${show(change.path)} (${change.renamed} use${change.renamed === 1 ? '' : 's'})`);
|
|
149
233
|
}
|
|
150
234
|
for (const path of refused) {
|
|
151
235
|
console.error(`refused ${show(path)}: it has local changes, so git cannot undo the codemod there; commit or stash it and run again, or run again with ${CodemodFlags.ALLOW_DIRTY}`);
|
|
152
236
|
}
|
|
237
|
+
for (const { path, reason } of failed) {
|
|
238
|
+
console.error(NamespaceCommand.clean(`failed ${show(path)}: ${reason}`));
|
|
239
|
+
}
|
|
153
240
|
// A note is a change made on purpose that is worth knowing; it is not work left, so --check ignores it.
|
|
154
241
|
for (const { path, finding } of notes) {
|
|
155
242
|
console.log(`note ${show(path)}:${finding.line} ${finding.name}: ${finding.reason}`);
|
|
@@ -157,9 +244,14 @@ export class NamespaceCommand {
|
|
|
157
244
|
for (const { path, finding } of left) {
|
|
158
245
|
console.error(`left ${show(path)}:${finding.line} ${finding.name}: ${finding.reason}`);
|
|
159
246
|
}
|
|
160
|
-
const refusedNote =
|
|
247
|
+
const refusedNote = [
|
|
248
|
+
refused.length > 0 ? `, ${refused.length} refused (listed above)` : '',
|
|
249
|
+
failed.length > 0
|
|
250
|
+
? `, ${failed.length} failed (listed above)${isWrite ? ', nothing was written' : ''}`
|
|
251
|
+
: '',
|
|
252
|
+
].join('');
|
|
161
253
|
console.log(`${changes.length} file${changes.length === 1 ? '' : 's'} ${verb}${refusedNote}, ${left.length} left for you${isWrite || changes.length === 0 ? '' : '. Run again with --write to apply.'}`);
|
|
162
|
-
if (refused.length > 0) {
|
|
254
|
+
if (refused.length > 0 || failed.length > 0) {
|
|
163
255
|
return 1;
|
|
164
256
|
}
|
|
165
257
|
return isCheck && (changes.length > 0 || left.length > 0) ? 1 : 0;
|
package/dist/codemod/files.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ export declare class CodemodFiles {
|
|
|
7
7
|
static isSource(opts: {
|
|
8
8
|
name: string;
|
|
9
9
|
}): boolean;
|
|
10
|
-
/** Every source file under `target`; a file target is returned as it is. */
|
|
10
|
+
/** Every source file under `target`; a file target is returned as it is. A symlink or a file that is not a source file is never returned. */
|
|
11
11
|
static collect(opts: {
|
|
12
12
|
target: string;
|
|
13
13
|
}): string[];
|
package/dist/codemod/files.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { execFileSync } from 'node:child_process';
|
|
2
|
-
import {
|
|
2
|
+
import { lstatSync, readdirSync, statSync } from 'node:fs';
|
|
3
3
|
import { dirname, join } from 'node:path';
|
|
4
4
|
const SKIPPED_DIRECTORIES = new Set(['node_modules', 'dist', 'build', '.git']);
|
|
5
5
|
const SOURCE_PATTERN = /\.(?:ts|tsx|mts|cts)$/;
|
|
@@ -13,11 +13,15 @@ export class CodemodFiles {
|
|
|
13
13
|
static isSource(opts) {
|
|
14
14
|
return SOURCE_PATTERN.test(opts.name) && !DECLARATION_PATTERN.test(opts.name);
|
|
15
15
|
}
|
|
16
|
-
/** Every source file under `target`; a file target is returned as it is. */
|
|
16
|
+
/** Every source file under `target`; a file target is returned as it is. A symlink or a file that is not a source file is never returned. */
|
|
17
17
|
static collect(opts) {
|
|
18
18
|
const { target } = opts;
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
// Read without following a link: a symlink is never a file to write, whatever it points to.
|
|
20
|
+
if (lstatSync(target).isFile()) {
|
|
21
|
+
return CodemodFiles.isSource({ name: target }) ? [target] : [];
|
|
22
|
+
}
|
|
23
|
+
if (!statSync(target).isDirectory()) {
|
|
24
|
+
return [];
|
|
21
25
|
}
|
|
22
26
|
return CodemodFiles.fromGit({ target }) ?? CodemodFiles.fromWalk({ target });
|
|
23
27
|
}
|
|
@@ -42,7 +46,7 @@ export class CodemodFiles {
|
|
|
42
46
|
.filter((path) => path !== '' && CodemodFiles.isSource({ name: path }))
|
|
43
47
|
.filter((path) => !path.split('/').some((segment) => SKIPPED_DIRECTORIES.has(segment)))
|
|
44
48
|
.map((path) => join(target, path))
|
|
45
|
-
.filter((path) =>
|
|
49
|
+
.filter((path) => lstatSync(path, { throwIfNoEntry: false })?.isFile() === true);
|
|
46
50
|
}
|
|
47
51
|
static fromWalk(opts) {
|
|
48
52
|
const files = [];
|
package/dist/codemod/logger.js
CHANGED
|
@@ -179,7 +179,7 @@ export class LoggerTransform {
|
|
|
179
179
|
findings.push({
|
|
180
180
|
line: lineOf(call),
|
|
181
181
|
name: 'enableDebug',
|
|
182
|
-
reason: '
|
|
182
|
+
reason: 'dropped. debug lines are off by default now (a browser, or `DEBUG` unset); turn them on with `LoggerFactory.use({ level: LogLevels.DEBUG })` at startup',
|
|
183
183
|
kind: 'note',
|
|
184
184
|
});
|
|
185
185
|
}
|
|
@@ -34,11 +34,23 @@ export declare class TypeRenames {
|
|
|
34
34
|
name: string;
|
|
35
35
|
}): string | undefined;
|
|
36
36
|
}
|
|
37
|
+
/** Types removed in favour of another export of the same packages: the import and each use are renamed. */
|
|
38
|
+
export declare class TypeExportRenames {
|
|
39
|
+
static readonly TARGETS: Readonly<Record<string, string>>;
|
|
40
|
+
static find(opts: {
|
|
41
|
+
name: string;
|
|
42
|
+
}): string | undefined;
|
|
43
|
+
}
|
|
37
44
|
/** Exports and members removed with no code the codemod can write in their place. */
|
|
38
45
|
export declare class RemovedNames {
|
|
39
46
|
static readonly EXPORTS: Readonly<Record<string, string>>;
|
|
40
47
|
/** Class name to removed static member to the reason. */
|
|
41
48
|
static readonly MEMBERS: Readonly<Record<string, Readonly<Record<string, string>>>>;
|
|
49
|
+
/** A property removed from the list filter: listed in a file that imports one of `owners`, as the file may use it. */
|
|
50
|
+
static readonly PROPERTIES: Readonly<Record<string, {
|
|
51
|
+
owners: ReadonlySet<string>;
|
|
52
|
+
reason: string;
|
|
53
|
+
}>>;
|
|
42
54
|
static findExport(opts: {
|
|
43
55
|
name: string;
|
|
44
56
|
}): string | undefined;
|
package/dist/codemod/renames.js
CHANGED
|
@@ -39,6 +39,7 @@ export class FunctionRenames {
|
|
|
39
39
|
export class HookRenames {
|
|
40
40
|
static { this.OWNER = 'Ardor'; }
|
|
41
41
|
static { this.NAMES = new Set([
|
|
42
|
+
'useApplicationContainer',
|
|
42
43
|
'useApplicationContext',
|
|
43
44
|
'useApplicationLogger',
|
|
44
45
|
'useAutosave',
|
|
@@ -49,20 +50,24 @@ export class HookRenames {
|
|
|
49
50
|
'useCopyToClipboard',
|
|
50
51
|
'useDebounce',
|
|
51
52
|
'useDocumentTitle',
|
|
53
|
+
'useDocumentVisibility',
|
|
52
54
|
'useElementSize',
|
|
53
55
|
'useFeatures',
|
|
54
56
|
'useHtmlLang',
|
|
55
57
|
'useInjectable',
|
|
56
|
-
'
|
|
58
|
+
'useIntersection',
|
|
59
|
+
'useMediaQuery',
|
|
57
60
|
'useNotifyError',
|
|
61
|
+
'useOnlineStatus',
|
|
58
62
|
'useProvider',
|
|
59
63
|
'useRefreshToken',
|
|
60
64
|
'useRepository',
|
|
61
65
|
'useRequestHeaderLocale',
|
|
66
|
+
'useResizeEffect',
|
|
62
67
|
'useService',
|
|
63
|
-
'useSizer',
|
|
64
68
|
'useStoredState',
|
|
65
69
|
'useTranslate',
|
|
70
|
+
'useUntypedTranslate',
|
|
66
71
|
'useWindowDimensions',
|
|
67
72
|
]); }
|
|
68
73
|
static find(opts) {
|
|
@@ -80,12 +85,23 @@ export class TypeRenames {
|
|
|
80
85
|
return Object.hasOwn(this.TARGETS, opts.name) ? this.TARGETS[opts.name] : undefined;
|
|
81
86
|
}
|
|
82
87
|
}
|
|
88
|
+
/** Types removed in favour of another export of the same packages: the import and each use are renamed. */
|
|
89
|
+
export class TypeExportRenames {
|
|
90
|
+
static { this.TARGETS = {
|
|
91
|
+
ISendResponse: 'INetworkResponse',
|
|
92
|
+
}; }
|
|
93
|
+
static find(opts) {
|
|
94
|
+
return Object.hasOwn(this.TARGETS, opts.name) ? this.TARGETS[opts.name] : undefined;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
83
97
|
/** Exports and members removed with no code the codemod can write in their place. */
|
|
84
98
|
export class RemovedNames {
|
|
85
99
|
static { this.EXPORTS = {
|
|
86
100
|
isEditableTarget: 'nothing in ARDOR called it; check the event target in your own code',
|
|
87
101
|
TDataCount: 'nothing in ARDOR used it; declare the shape you need',
|
|
88
102
|
ISyncFC: 'write the function type, (props: TProps) => ReactNode',
|
|
103
|
+
useInjectableContainer: 'renamed: call useApplicationContainer',
|
|
104
|
+
useSizer: 'use useElementSize({ ref, box: "border-box", round: true }) with a ref in place of the id',
|
|
89
105
|
}; }
|
|
90
106
|
/** Class name to removed static member to the reason. */
|
|
91
107
|
static { this.MEMBERS = {
|
|
@@ -95,6 +111,13 @@ export class RemovedNames {
|
|
|
95
111
|
RESPONSE_FORMAT: 'nothing in ARDOR sent or read this header',
|
|
96
112
|
},
|
|
97
113
|
}; }
|
|
114
|
+
/** A property removed from the list filter: listed in a file that imports one of `owners`, as the file may use it. */
|
|
115
|
+
static { this.PROPERTIES = {
|
|
116
|
+
offset: {
|
|
117
|
+
owners: new Set(['IListFilter', 'ListFilterBuilder']),
|
|
118
|
+
reason: 'the list filter has no offset, use skip',
|
|
119
|
+
},
|
|
120
|
+
}; }
|
|
98
121
|
static findExport(opts) {
|
|
99
122
|
return Object.hasOwn(this.EXPORTS, opts.name) ? this.EXPORTS[opts.name] : undefined;
|
|
100
123
|
}
|
|
@@ -15,7 +15,7 @@ export interface INamespaceResult {
|
|
|
15
15
|
findings: IFinding[];
|
|
16
16
|
}
|
|
17
17
|
/**
|
|
18
|
-
* Rewrites the
|
|
18
|
+
* Rewrites the removed bare names of `@venizia/ardor` to their class members, in source text:
|
|
19
19
|
* `isDefined(x)` becomes `ValueUtility.isDefined(x)` and the import follows. With `hooks`, a hook
|
|
20
20
|
* imported from `@venizia/ardor` itself becomes `Ardor.useX` (never one imported from the react or
|
|
21
21
|
* admin package, which cannot import `Ardor`).
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { FunctionRenames, HookRenames, NamespaceModules, RemovedNames, TypeRenames, } from './renames.js';
|
|
1
|
+
import { FunctionRenames, HookRenames, NamespaceModules, RemovedNames, TypeExportRenames, TypeRenames, } from './renames.js';
|
|
2
2
|
/**
|
|
3
|
-
* Rewrites the
|
|
3
|
+
* Rewrites the removed bare names of `@venizia/ardor` to their class members, in source text:
|
|
4
4
|
* `isDefined(x)` becomes `ValueUtility.isDefined(x)` and the import follows. With `hooks`, a hook
|
|
5
5
|
* imported from `@venizia/ardor` itself becomes `Ardor.useX` (never one imported from the react or
|
|
6
6
|
* admin package, which cannot import `Ardor`).
|
|
@@ -66,13 +66,15 @@ export class NamespaceTransform {
|
|
|
66
66
|
});
|
|
67
67
|
continue;
|
|
68
68
|
}
|
|
69
|
-
const
|
|
69
|
+
const exportName = TypeExportRenames.find({ name: imported });
|
|
70
|
+
const typeText = exportName ?? TypeRenames.find({ name: imported });
|
|
70
71
|
if (typeText) {
|
|
71
72
|
renames.push({
|
|
72
73
|
specifier,
|
|
73
74
|
declaration: statement,
|
|
74
75
|
local: specifier.name.text,
|
|
75
76
|
typeText,
|
|
77
|
+
importName: exportName,
|
|
76
78
|
references: [],
|
|
77
79
|
});
|
|
78
80
|
continue;
|
|
@@ -139,7 +141,9 @@ export class NamespaceTransform {
|
|
|
139
141
|
else if ((ts.isFunctionDeclaration(node) ||
|
|
140
142
|
ts.isClassDeclaration(node) ||
|
|
141
143
|
ts.isFunctionExpression(node) ||
|
|
142
|
-
ts.isClassExpression(node)
|
|
144
|
+
ts.isClassExpression(node) ||
|
|
145
|
+
ts.isTypeAliasDeclaration(node) ||
|
|
146
|
+
ts.isInterfaceDeclaration(node)) &&
|
|
143
147
|
node.name) {
|
|
144
148
|
declared.add(node.name.text);
|
|
145
149
|
}
|
|
@@ -162,6 +166,18 @@ export class NamespaceTransform {
|
|
|
162
166
|
});
|
|
163
167
|
return false;
|
|
164
168
|
}
|
|
169
|
+
const { importName } = rename;
|
|
170
|
+
const takenBy = importName ? bindings.imported.get(importName) : undefined;
|
|
171
|
+
if (importName &&
|
|
172
|
+
(bindings.declared.has(importName) ||
|
|
173
|
+
(takenBy && !NamespaceModules.isValid(takenBy.module)))) {
|
|
174
|
+
findings.push({
|
|
175
|
+
line,
|
|
176
|
+
name: rename.local,
|
|
177
|
+
reason: `"${importName}" is already taken in this file; import it under another name and use it in place of ${rename.local}`,
|
|
178
|
+
});
|
|
179
|
+
return false;
|
|
180
|
+
}
|
|
165
181
|
if (!owner || !rename.target) {
|
|
166
182
|
return true;
|
|
167
183
|
}
|
|
@@ -240,7 +256,8 @@ export class NamespaceTransform {
|
|
|
240
256
|
}
|
|
241
257
|
if (rename.typeText !== undefined) {
|
|
242
258
|
// A type is a name in a type position only: `NullableType[]` needs parentheses once replaced.
|
|
243
|
-
if (ts.isTypeReferenceNode(parent) && parent.typeName === node)
|
|
259
|
+
if ((ts.isTypeReferenceNode(parent) && parent.typeName === node) ||
|
|
260
|
+
(ts.isExpressionWithTypeArguments(parent) && parent.expression === node)) {
|
|
244
261
|
const grand = parent.parent;
|
|
245
262
|
const wrap = rename.typeText.includes('|') &&
|
|
246
263
|
(ts.isArrayTypeNode(grand) ||
|
|
@@ -278,7 +295,32 @@ export class NamespaceTransform {
|
|
|
278
295
|
if (owners.size === 0) {
|
|
279
296
|
return;
|
|
280
297
|
}
|
|
298
|
+
const imported = new Set(owners.values());
|
|
281
299
|
const visit = (node) => {
|
|
300
|
+
let name;
|
|
301
|
+
if (ts.isPropertyAccessExpression(node) ||
|
|
302
|
+
ts.isPropertyAssignment(node) ||
|
|
303
|
+
ts.isShorthandPropertyAssignment(node)) {
|
|
304
|
+
name = node.name;
|
|
305
|
+
}
|
|
306
|
+
else if (ts.isBindingElement(node) && ts.isObjectBindingPattern(node.parent)) {
|
|
307
|
+
name = node.propertyName ?? node.name;
|
|
308
|
+
}
|
|
309
|
+
else if (ts.isElementAccessExpression(node) &&
|
|
310
|
+
ts.isStringLiteral(node.argumentExpression)) {
|
|
311
|
+
name = node.argumentExpression;
|
|
312
|
+
}
|
|
313
|
+
const key = name && (ts.isIdentifier(name) || ts.isStringLiteral(name)) ? name : undefined;
|
|
314
|
+
const property = key && Object.hasOwn(RemovedNames.PROPERTIES, key.text)
|
|
315
|
+
? RemovedNames.PROPERTIES[key.text]
|
|
316
|
+
: undefined;
|
|
317
|
+
if (key && property && [...property.owners].some((owner) => imported.has(owner))) {
|
|
318
|
+
findings.push({
|
|
319
|
+
line: sourceFile.getLineAndCharacterOfPosition(key.getStart(sourceFile)).line + 1,
|
|
320
|
+
name: `.${key.text}`,
|
|
321
|
+
reason: `removed: ${property.reason}`,
|
|
322
|
+
});
|
|
323
|
+
}
|
|
282
324
|
if (ts.isPropertyAccessExpression(node) && ts.isIdentifier(node.expression)) {
|
|
283
325
|
const owner = owners.get(node.expression.text);
|
|
284
326
|
const reason = owner
|
|
@@ -323,7 +365,17 @@ export class NamespaceTransform {
|
|
|
323
365
|
for (const owner of owners) {
|
|
324
366
|
added.add(owner);
|
|
325
367
|
}
|
|
326
|
-
const
|
|
368
|
+
const types = [];
|
|
369
|
+
for (const { declaration: from, importName, specifier } of used) {
|
|
370
|
+
if (from === declaration &&
|
|
371
|
+
importName &&
|
|
372
|
+
!bindings.imported.has(importName) &&
|
|
373
|
+
!added.has(importName)) {
|
|
374
|
+
added.add(importName);
|
|
375
|
+
types.push(`${specifier.isTypeOnly ? 'type ' : ''}${importName}`);
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
const names = [...kept, ...owners, ...types];
|
|
327
379
|
if (names.length === 0) {
|
|
328
380
|
edits.push(NamespaceTransform.removeImport({ sourceFile, declaration, clause, named, ts }));
|
|
329
381
|
continue;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Every ARDOR hook under one name: `Ardor.useRepository(...)` is the same function as
|
|
3
|
+
* `useRepository`. Call a member by its name; do not index with a computed key (`Ardor[name]`), which
|
|
4
|
+
* keeps every hook in a bundle.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```tsx
|
|
8
|
+
* import { Ardor, repository } from '@venizia/ardor';
|
|
9
|
+
*
|
|
10
|
+
* @repository()
|
|
11
|
+
* class OrdersRepository {
|
|
12
|
+
* count() { return 3; }
|
|
13
|
+
* }
|
|
14
|
+
*
|
|
15
|
+
* export const Orders = () => {
|
|
16
|
+
* const orders = Ardor.useRepository({ target: OrdersRepository });
|
|
17
|
+
* const container = Ardor.useApplicationContainer();
|
|
18
|
+
* return <span>{orders.count()} {container.isBound({ key: 'repositories.OrdersRepository' }) ? 'bound' : 'missing'}</span>;
|
|
19
|
+
* };
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
1
22
|
export * as Ardor from './ardor.js';
|
|
2
23
|
export * from '@venizia/ardor-kernel';
|
|
3
24
|
export * from '@venizia/ardor-react';
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,27 @@
|
|
|
1
1
|
// ARDOR - one entry point over the framework packages.
|
|
2
2
|
// An application imports from `@venizia/ardor`; a consumer that needs only one layer installs that
|
|
3
3
|
// package directly.
|
|
4
|
+
/**
|
|
5
|
+
* Every ARDOR hook under one name: `Ardor.useRepository(...)` is the same function as
|
|
6
|
+
* `useRepository`. Call a member by its name; do not index with a computed key (`Ardor[name]`), which
|
|
7
|
+
* keeps every hook in a bundle.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```tsx
|
|
11
|
+
* import { Ardor, repository } from '@venizia/ardor';
|
|
12
|
+
*
|
|
13
|
+
* @repository()
|
|
14
|
+
* class OrdersRepository {
|
|
15
|
+
* count() { return 3; }
|
|
16
|
+
* }
|
|
17
|
+
*
|
|
18
|
+
* export const Orders = () => {
|
|
19
|
+
* const orders = Ardor.useRepository({ target: OrdersRepository });
|
|
20
|
+
* const container = Ardor.useApplicationContainer();
|
|
21
|
+
* return <span>{orders.count()} {container.isBound({ key: 'repositories.OrdersRepository' }) ? 'bound' : 'missing'}</span>;
|
|
22
|
+
* };
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
4
25
|
export * as Ardor from './ardor.js';
|
|
5
26
|
export * from '@venizia/ardor-kernel';
|
|
6
27
|
export * from '@venizia/ardor-react';
|