modality-ts 0.0.13 → 0.0.15
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/dist/cli/cli.js +117 -27
- package/dist/cli/cli.js.map +1 -1
- package/dist/cli/features/check/command.d.ts +7 -0
- package/dist/cli/features/check/command.d.ts.map +1 -1
- package/dist/cli/features/check/command.js +39 -6
- package/dist/cli/features/check/command.js.map +1 -1
- package/dist/cli/features/check/index.d.ts +2 -0
- package/dist/cli/features/check/index.d.ts.map +1 -1
- package/dist/cli/features/check/index.js +1 -0
- package/dist/cli/features/check/index.js.map +1 -1
- package/dist/cli/features/check/output.d.ts +29 -0
- package/dist/cli/features/check/output.d.ts.map +1 -0
- package/dist/cli/features/check/output.js +174 -0
- package/dist/cli/features/check/output.js.map +1 -0
- package/dist/cli/features/ci/command.d.ts +2 -0
- package/dist/cli/features/ci/command.d.ts.map +1 -1
- package/dist/cli/features/ci/command.js +21 -0
- package/dist/cli/features/ci/command.js.map +1 -1
- package/dist/cli/features/ci/index.d.ts +2 -0
- package/dist/cli/features/ci/index.d.ts.map +1 -1
- package/dist/cli/features/ci/index.js +1 -0
- package/dist/cli/features/ci/index.js.map +1 -1
- package/dist/cli/features/ci/output.d.ts +19 -0
- package/dist/cli/features/ci/output.d.ts.map +1 -0
- package/dist/cli/features/ci/output.js +40 -0
- package/dist/cli/features/ci/output.js.map +1 -0
- package/dist/cli/features/conform/index.d.ts +1 -0
- package/dist/cli/features/conform/index.d.ts.map +1 -1
- package/dist/cli/features/conform/index.js +1 -0
- package/dist/cli/features/conform/index.js.map +1 -1
- package/dist/cli/features/conform/output.d.ts +9 -0
- package/dist/cli/features/conform/output.d.ts.map +1 -0
- package/dist/cli/features/conform/output.js +28 -0
- package/dist/cli/features/conform/output.js.map +1 -0
- package/dist/cli/features/export/command.d.ts +2 -0
- package/dist/cli/features/export/command.d.ts.map +1 -1
- package/dist/cli/features/export/command.js +8 -2
- package/dist/cli/features/export/command.js.map +1 -1
- package/dist/cli/features/export/index.d.ts +1 -0
- package/dist/cli/features/export/index.d.ts.map +1 -1
- package/dist/cli/features/export/index.js +1 -0
- package/dist/cli/features/export/index.js.map +1 -1
- package/dist/cli/features/export/output.d.ts +8 -0
- package/dist/cli/features/export/output.d.ts.map +1 -0
- package/dist/cli/features/export/output.js +14 -0
- package/dist/cli/features/export/output.js.map +1 -0
- package/dist/cli/features/extract/command.d.ts +9 -0
- package/dist/cli/features/extract/command.d.ts.map +1 -1
- package/dist/cli/features/extract/command.js +20 -1
- package/dist/cli/features/extract/command.js.map +1 -1
- package/dist/cli/features/extract/index.d.ts +2 -0
- package/dist/cli/features/extract/index.d.ts.map +1 -1
- package/dist/cli/features/extract/index.js +1 -0
- package/dist/cli/features/extract/index.js.map +1 -1
- package/dist/cli/features/extract/output.d.ts +22 -0
- package/dist/cli/features/extract/output.d.ts.map +1 -0
- package/dist/cli/features/extract/output.js +48 -0
- package/dist/cli/features/extract/output.js.map +1 -0
- package/dist/cli/features/init/index.d.ts +1 -0
- package/dist/cli/features/init/index.d.ts.map +1 -1
- package/dist/cli/features/init/index.js +1 -0
- package/dist/cli/features/init/index.js.map +1 -1
- package/dist/cli/features/init/output.d.ts +4 -0
- package/dist/cli/features/init/output.d.ts.map +1 -0
- package/dist/cli/features/init/output.js +9 -0
- package/dist/cli/features/init/output.js.map +1 -0
- package/dist/cli/features/replay/index.d.ts +1 -0
- package/dist/cli/features/replay/index.d.ts.map +1 -1
- package/dist/cli/features/replay/index.js +1 -0
- package/dist/cli/features/replay/index.js.map +1 -1
- package/dist/cli/features/replay/output.d.ts +10 -0
- package/dist/cli/features/replay/output.d.ts.map +1 -0
- package/dist/cli/features/replay/output.js +37 -0
- package/dist/cli/features/replay/output.js.map +1 -0
- package/dist/cli/output.d.ts +28 -0
- package/dist/cli/output.d.ts.map +1 -0
- package/dist/cli/output.js +64 -0
- package/dist/cli/output.js.map +1 -0
- package/dist/extract/engine/ts/context.d.ts.map +1 -1
- package/dist/extract/engine/ts/context.js +7 -1
- package/dist/extract/engine/ts/context.js.map +1 -1
- package/dist/extract/engine/ts/react-source-transitions.d.ts +4 -1
- package/dist/extract/engine/ts/react-source-transitions.d.ts.map +1 -1
- package/dist/extract/engine/ts/react-source-transitions.js +11 -2
- package/dist/extract/engine/ts/react-source-transitions.js.map +1 -1
- package/dist/extract/engine/ts/transition/expressions.d.ts +1 -1
- package/dist/extract/engine/ts/transition/expressions.d.ts.map +1 -1
- package/dist/extract/engine/ts/transition/expressions.js +12 -1
- package/dist/extract/engine/ts/transition/expressions.js.map +1 -1
- package/dist/extract/engine/ts/transition/handlers.d.ts +3 -3
- package/dist/extract/engine/ts/transition/handlers.d.ts.map +1 -1
- package/dist/extract/engine/ts/transition/handlers.js +10 -7
- package/dist/extract/engine/ts/transition/handlers.js.map +1 -1
- package/dist/extract/engine/ts/transition/statement-summary.d.ts +6 -2
- package/dist/extract/engine/ts/transition/statement-summary.d.ts.map +1 -1
- package/dist/extract/engine/ts/transition/statement-summary.js +40 -6
- package/dist/extract/engine/ts/transition/statement-summary.js.map +1 -1
- package/dist/extract/engine/ts/types.d.ts +3 -0
- package/dist/extract/engine/ts/types.d.ts.map +1 -1
- package/dist/extract/sources/jotai/derived-writes.d.ts +11 -0
- package/dist/extract/sources/jotai/derived-writes.d.ts.map +1 -0
- package/dist/extract/sources/jotai/derived-writes.js +141 -0
- package/dist/extract/sources/jotai/derived-writes.js.map +1 -0
- package/dist/extract/sources/jotai/discover.d.ts +16 -0
- package/dist/extract/sources/jotai/discover.d.ts.map +1 -1
- package/dist/extract/sources/jotai/discover.js +163 -46
- package/dist/extract/sources/jotai/discover.js.map +1 -1
- package/dist/extract/sources/jotai/domains.d.ts +14 -1
- package/dist/extract/sources/jotai/domains.d.ts.map +1 -1
- package/dist/extract/sources/jotai/domains.js +481 -70
- package/dist/extract/sources/jotai/domains.js.map +1 -1
- package/dist/extract/sources/jotai/harness.d.ts +4 -1
- package/dist/extract/sources/jotai/harness.d.ts.map +1 -1
- package/dist/extract/sources/jotai/harness.js +10 -3
- package/dist/extract/sources/jotai/harness.js.map +1 -1
- package/dist/extract/sources/jotai/hydration.d.ts +16 -0
- package/dist/extract/sources/jotai/hydration.d.ts.map +1 -0
- package/dist/extract/sources/jotai/hydration.js +116 -0
- package/dist/extract/sources/jotai/hydration.js.map +1 -0
- package/dist/extract/sources/jotai/ids.d.ts +7 -0
- package/dist/extract/sources/jotai/ids.d.ts.map +1 -0
- package/dist/extract/sources/jotai/ids.js +23 -0
- package/dist/extract/sources/jotai/ids.js.map +1 -0
- package/dist/extract/sources/jotai/imports.d.ts +23 -0
- package/dist/extract/sources/jotai/imports.d.ts.map +1 -0
- package/dist/extract/sources/jotai/imports.js +111 -0
- package/dist/extract/sources/jotai/imports.js.map +1 -0
- package/dist/extract/sources/jotai/jsx.d.ts +4 -0
- package/dist/extract/sources/jotai/jsx.d.ts.map +1 -0
- package/dist/extract/sources/jotai/jsx.js +52 -0
- package/dist/extract/sources/jotai/jsx.js.map +1 -0
- package/dist/extract/sources/jotai/plugin.d.ts.map +1 -1
- package/dist/extract/sources/jotai/plugin.js +9 -2
- package/dist/extract/sources/jotai/plugin.js.map +1 -1
- package/dist/extract/sources/jotai/stores.d.ts +3 -0
- package/dist/extract/sources/jotai/stores.d.ts.map +1 -0
- package/dist/extract/sources/jotai/stores.js +40 -0
- package/dist/extract/sources/jotai/stores.js.map +1 -0
- package/dist/extract/sources/jotai/transitions.d.ts.map +1 -1
- package/dist/extract/sources/jotai/transitions.js +16 -5
- package/dist/extract/sources/jotai/transitions.js.map +1 -1
- package/dist/extract/sources/jotai/types.d.ts +22 -0
- package/dist/extract/sources/jotai/types.d.ts.map +1 -0
- package/dist/extract/sources/jotai/types.js +86 -0
- package/dist/extract/sources/jotai/types.js.map +1 -0
- package/dist/extract/sources/jotai/writes.d.ts +23 -1
- package/dist/extract/sources/jotai/writes.d.ts.map +1 -1
- package/dist/extract/sources/jotai/writes.js +330 -89
- package/dist/extract/sources/jotai/writes.js.map +1 -1
- package/dist/extract/sources/shared/react-transition-extract.d.ts +3 -0
- package/dist/extract/sources/shared/react-transition-extract.d.ts.map +1 -1
- package/dist/extract/sources/shared/react-transition-extract.js +5 -0
- package/dist/extract/sources/shared/react-transition-extract.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"discover.js","sourceRoot":"","sources":["../../../../src/extract/sources/jotai/discover.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,YAAY,CAAC;AAGjC,OAAO,EACL,eAAe,EACf,mBAAmB,
|
|
1
|
+
{"version":3,"file":"discover.js","sourceRoot":"","sources":["../../../../src/extract/sources/jotai/discover.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,YAAY,CAAC;AAGjC,OAAO,EACL,eAAe,EACf,iBAAiB,EACjB,mBAAmB,GACpB,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,gBAAgB,EAChB,sBAAsB,EACtB,iBAAiB,EACjB,qBAAqB,GACtB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAClD,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,EACL,uBAAuB,EACvB,0BAA0B,GAC3B,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,4BAA4B,EAAE,MAAM,aAAa,CAAC;AAS3D,MAAM,UAAU,kBAAkB,CAChC,UAAkB,EAClB,QAAQ,GAAG,UAAU;IAErB,OAAO,0BAA0B,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC,KAAK,CAAC;AAChE,CAAC;AAED,MAAM,UAAU,0BAA0B,CACxC,UAAkB,EAClB,QAAQ,GAAG,UAAU;IAErB,MAAM,MAAM,GAAG,EAAE,CAAC,gBAAgB,CAChC,QAAQ,EACR,UAAU,EACV,EAAE,CAAC,YAAY,CAAC,MAAM,EACtB,IAAI,E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omain, Value } from "modality-ts/core";
|
|
2
3
|
import { typeAliasDeclarations } from "modality-ts/extract/engine/spi";
|
|
3
|
-
import { type
|
|
4
|
+
import { type JotaiResolvedImports } from "./imports.js";
|
|
5
|
+
import type { AtomConfigKind, JotaiAtomMetadata } from "./types.js";
|
|
4
6
|
export { typeAliasDeclarations };
|
|
7
|
+
export interface AtomClassification {
|
|
8
|
+
configKind: AtomConfigKind;
|
|
9
|
+
domain: AbstractDomain;
|
|
10
|
+
initial: Value;
|
|
11
|
+
metadata: JotaiAtomMetadata;
|
|
12
|
+
emitVar: boolean;
|
|
13
|
+
warning?: string;
|
|
14
|
+
}
|
|
15
|
+
export declare function classifyAtomCall(call: ts.CallExpression, atomName: string, imports: JotaiResolvedImports, typeAliases: ReadonlyMap<string, ts.TypeNode>): AtomClassification;
|
|
16
|
+
export declare function classifyFamilyInstance(familyName: string, param: string, innerCall: ts.CallExpression, typeAliases: ReadonlyMap<string, ts.TypeNode>): AtomClassification;
|
|
5
17
|
export declare function inferAtomDomain(call: ts.CallExpression, typeAliases?: ReadonlyMap<string, ts.TypeNode>): AbstractDomain;
|
|
6
18
|
export declare function initialValueForAtom(call: ts.CallExpression, domain: AbstractDomain): Value;
|
|
19
|
+
export declare function staticFamilyParam(expression: ts.Expression): string | undefined;
|
|
7
20
|
//# sourceMappingURL=domains.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"domains.d.ts","sourceRoot":"","sources":["../../../../src/extract/sources/jotai/domains.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,YAAY,CAAC;AACjC,OAAO,EAGL,qBAAqB,EACtB,MAAM,gCAAgC,CAAC;
|
|
1
|
+
{"version":3,"file":"domains.d.ts","sourceRoot":"","sources":["../../../../src/extract/sources/jotai/domains.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,YAAY,CAAC;AACjC,OAAO,KAAK,EAAE,cAAc,EAAE,KAAK,EAAE,MAAM,k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|
1
1
|
import * as ts from "typescript";
|
|
2
2
|
import { firstValue, inferDomainFromTypeNode, typeAliasDeclarations, } from "modality-ts/extract/engine/spi";
|
|
3
|
+
import { literalValue, propertyName } from "../../engine/ts/ast.js";
|
|
3
4
|
import { validateValue, } from "modality-ts/core";
|
|
5
|
+
import { atomCreatorName } from "./imports.js";
|
|
6
|
+
import { getCallsInReadFunction, isAsyncReadFunction, isReadFunction, } from "./derived-writes.js";
|
|
4
7
|
export { typeAliasDeclarations };
|
|
8
|
+
export function classifyAtomCall(call, atomName, imports, typeAliases) {
|
|
9
|
+
const creator = atomCreatorName(call, imports.atomCreators) ?? "atom";
|
|
10
|
+
switch (creator) {
|
|
11
|
+
case "atomWithStorage":
|
|
12
|
+
return classifyStorageAtom(call, atomName, typeAliases);
|
|
13
|
+
case "atomWithLazy":
|
|
14
|
+
return classifyLazyAtom(call, atomName, typeAliases);
|
|
15
|
+
case "atomWithReset":
|
|
16
|
+
return classifyResetAtom(call, atomName, typeAliases);
|
|
17
|
+
case "atomWithDefault":
|
|
18
|
+
return classifyDefaultAtom(call, atomName, typeAliases);
|
|
19
|
+
case "atomWithRefresh":
|
|
20
|
+
return classifyRefreshAtom(call, atomName, typeAliases);
|
|
21
|
+
case "loadable":
|
|
22
|
+
return classifyLoadableAtom(call, atomName);
|
|
23
|
+
case "unwrap":
|
|
24
|
+
return classifyUnwrapAtom(call, atomName);
|
|
25
|
+
case "atomWithObservable":
|
|
26
|
+
return classifyObservableAtom(call, atomName, typeAliases);
|
|
27
|
+
case "atomFamily":
|
|
28
|
+
return classifyFamilyAtom(atomName);
|
|
29
|
+
default:
|
|
30
|
+
return classifyCoreAtom(call, atomName, typeAliases);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
function classifyCoreAtom(call, atomName, typeAliases) {
|
|
34
|
+
const args = call.arguments;
|
|
35
|
+
const first = args[0];
|
|
36
|
+
const second = args[1];
|
|
37
|
+
if (first && isReadFunction(first)) {
|
|
38
|
+
if (isAsyncReadFunction(first)) {
|
|
39
|
+
return {
|
|
40
|
+
configKind: "readOnlyDerived",
|
|
41
|
+
domain: { kind: "tokens", count: 1 },
|
|
42
|
+
initial: "tok1",
|
|
43
|
+
emitVar: true,
|
|
44
|
+
metadata: {
|
|
45
|
+
atomName,
|
|
46
|
+
configKind: "readOnlyDerived",
|
|
47
|
+
creator: "atom",
|
|
48
|
+
asyncDerived: true,
|
|
49
|
+
readDependencies: getCallsInReadFunction(first),
|
|
50
|
+
warning: "Jotai async derived atom read abstracted",
|
|
51
|
+
},
|
|
52
|
+
warning: "Jotai async derived atom read abstracted",
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
if (second && isReadFunction(second)) {
|
|
56
|
+
return {
|
|
57
|
+
configKind: "readWriteDerived",
|
|
58
|
+
domain: inferAtomDomain(call, typeAliases),
|
|
59
|
+
initial: firstValue(inferAtomDomain(call, typeAliases)),
|
|
60
|
+
emitVar: false,
|
|
61
|
+
metadata: {
|
|
62
|
+
atomName,
|
|
63
|
+
configKind: "readWriteDerived",
|
|
64
|
+
creator: "atom",
|
|
65
|
+
readDependencies: getCallsInReadFunction(first),
|
|
66
|
+
},
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
return {
|
|
70
|
+
configKind: "readOnlyDerived",
|
|
71
|
+
domain: { kind: "tokens", count: 1 },
|
|
72
|
+
initial: "tok1",
|
|
73
|
+
emitVar: true,
|
|
74
|
+
metadata: {
|
|
75
|
+
atomName,
|
|
76
|
+
configKind: "readOnlyDerived",
|
|
77
|
+
creator: "atom",
|
|
78
|
+
readDependencies: getCallsInReadFunction(first),
|
|
79
|
+
warning: "Jotai derived read-only atom uses token domain",
|
|
80
|
+
},
|
|
81
|
+
warning: "Jotai derived read-only atom uses token domain",
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
if ((first === undefined ||
|
|
85
|
+
first.kind === ts.SyntaxKind.NullKeyword ||
|
|
86
|
+
!isReadFunction(first)) &&
|
|
87
|
+
second &&
|
|
88
|
+
isReadFunction(second)) {
|
|
89
|
+
return {
|
|
90
|
+
configKind: "writeOnlyDerived",
|
|
91
|
+
domain: { kind: "tokens", count: 1 },
|
|
92
|
+
initial: "tok1",
|
|
93
|
+
emitVar: false,
|
|
94
|
+
metadata: {
|
|
95
|
+
atomName,
|
|
96
|
+
configKind: "writeOnlyDerived",
|
|
97
|
+
creator: "atom",
|
|
98
|
+
},
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
const domain = inferAtomDomain(call, typeAliases);
|
|
102
|
+
return {
|
|
103
|
+
configKind: "primitive",
|
|
104
|
+
domain,
|
|
105
|
+
initial: initialValueForAtom(call, domain),
|
|
106
|
+
emitVar: true,
|
|
107
|
+
metadata: { atomName, configKind: "primitive", creator: "atom" },
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
function classifyStorageAtom(call, atomName, typeAliases) {
|
|
111
|
+
const keyArg = call.arguments[0];
|
|
112
|
+
const initialArg = call.arguments[1];
|
|
113
|
+
const optionsArg = call.arguments[3];
|
|
114
|
+
const storageKey = keyArg && ts.isStringLiteral(keyArg) ? keyArg.text : undefined;
|
|
115
|
+
const domain = initialArg
|
|
116
|
+
? domainFromExpression(initialArg, typeAliases, call.typeArguments?.[0])
|
|
117
|
+
: { kind: "tokens", count: 1 };
|
|
118
|
+
const initial = initialArg
|
|
119
|
+
? valueFromExpression(initialArg, domain)
|
|
120
|
+
: firstValue(domain);
|
|
121
|
+
let getOnInit = false;
|
|
122
|
+
let storageKind;
|
|
123
|
+
if (optionsArg && ts.isObjectLiteralExpression(optionsArg)) {
|
|
124
|
+
for (const prop of optionsArg.properties) {
|
|
125
|
+
if (!ts.isPropertyAssignment(prop))
|
|
126
|
+
continue;
|
|
127
|
+
const name = propertyName(prop.name);
|
|
128
|
+
if (name === "getOnInit" &&
|
|
129
|
+
prop.initializer.kind === ts.SyntaxKind.TrueKeyword) {
|
|
130
|
+
getOnInit = true;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
const storageArg = call.arguments[2];
|
|
135
|
+
if (storageArg) {
|
|
136
|
+
const text = storageArg.getText();
|
|
137
|
+
if (text.includes("localStorage"))
|
|
138
|
+
storageKind = "localStorage";
|
|
139
|
+
else if (text.includes("sessionStorage"))
|
|
140
|
+
storageKind = "sessionStorage";
|
|
141
|
+
}
|
|
142
|
+
const warning = getOnInit
|
|
143
|
+
? "Jotai atomWithStorage getOnInit may read unknown stored value"
|
|
144
|
+
: undefined;
|
|
145
|
+
return {
|
|
146
|
+
configKind: "storage",
|
|
147
|
+
domain,
|
|
148
|
+
initial,
|
|
149
|
+
emitVar: true,
|
|
150
|
+
warning,
|
|
151
|
+
metadata: {
|
|
152
|
+
atomName,
|
|
153
|
+
configKind: "storage",
|
|
154
|
+
creator: "atomWithStorage",
|
|
155
|
+
...(storageKey ? { storageKey } : {}),
|
|
156
|
+
...(storageKind ? { storageKind } : {}),
|
|
157
|
+
getOnInit,
|
|
158
|
+
resettableInitial: initial,
|
|
159
|
+
...(warning ? { warning } : {}),
|
|
160
|
+
},
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
function classifyLazyAtom(call, atomName, typeAliases) {
|
|
164
|
+
const initArg = call.arguments[0];
|
|
165
|
+
if (initArg &&
|
|
166
|
+
(ts.isArrowFunction(initArg) || ts.isFunctionExpression(initArg))) {
|
|
167
|
+
if (!ts.isBlock(initArg.body)) {
|
|
168
|
+
const domain = domainFromExpression(initArg.body, typeAliases);
|
|
169
|
+
const initial = valueFromExpression(initArg.body, domain);
|
|
170
|
+
return {
|
|
171
|
+
configKind: "lazy",
|
|
172
|
+
domain,
|
|
173
|
+
initial,
|
|
174
|
+
emitVar: true,
|
|
175
|
+
metadata: { atomName, configKind: "lazy", creator: "atomWithLazy" },
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
const warning = `Jotai lazy initializer ${atomName} not statically evaluated`;
|
|
180
|
+
return {
|
|
181
|
+
configKind: "lazy",
|
|
182
|
+
domain: { kind: "tokens", count: 1 },
|
|
183
|
+
initial: "tok1",
|
|
184
|
+
emitVar: true,
|
|
185
|
+
warning,
|
|
186
|
+
metadata: {
|
|
187
|
+
atomName,
|
|
188
|
+
configKind: "lazy",
|
|
189
|
+
creator: "atomWithLazy",
|
|
190
|
+
warning,
|
|
191
|
+
},
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
function classifyResetAtom(call, atomName, typeAliases) {
|
|
195
|
+
const domain = inferAtomDomain(call, typeAliases);
|
|
196
|
+
const initial = initialValueForAtom(call, domain);
|
|
197
|
+
return {
|
|
198
|
+
configKind: "resettable",
|
|
199
|
+
domain,
|
|
200
|
+
initial,
|
|
201
|
+
emitVar: true,
|
|
202
|
+
metadata: {
|
|
203
|
+
atomName,
|
|
204
|
+
configKind: "resettable",
|
|
205
|
+
creator: "atomWithReset",
|
|
206
|
+
resettableInitial: initial,
|
|
207
|
+
},
|
|
208
|
+
};
|
|
209
|
+
}
|
|
210
|
+
function classifyDefaultAtom(call, atomName, typeAliases) {
|
|
211
|
+
const readArg = call.arguments[0];
|
|
212
|
+
if (readArg && isReadFunction(readArg)) {
|
|
213
|
+
const deps = getCallsInReadFunction(readArg);
|
|
214
|
+
if (deps.length > 0) {
|
|
215
|
+
const warning = `Jotai atomWithDefault ${atomName} read not statically inlined`;
|
|
216
|
+
return {
|
|
217
|
+
configKind: "defaultResettable",
|
|
218
|
+
domain: { kind: "tokens", count: 1 },
|
|
219
|
+
initial: "tok1",
|
|
220
|
+
emitVar: true,
|
|
221
|
+
warning,
|
|
222
|
+
metadata: {
|
|
223
|
+
atomName,
|
|
224
|
+
configKind: "defaultResettable",
|
|
225
|
+
creator: "atomWithDefault",
|
|
226
|
+
readDependencies: deps,
|
|
227
|
+
warning,
|
|
228
|
+
},
|
|
229
|
+
};
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
const domain = inferAtomDomain(call, typeAliases);
|
|
233
|
+
return {
|
|
234
|
+
configKind: "defaultResettable",
|
|
235
|
+
domain,
|
|
236
|
+
initial: initialValueForAtom(call, domain),
|
|
237
|
+
emitVar: true,
|
|
238
|
+
metadata: {
|
|
239
|
+
atomName,
|
|
240
|
+
configKind: "defaultResettable",
|
|
241
|
+
creator: "atomWithDefault",
|
|
242
|
+
},
|
|
243
|
+
};
|
|
244
|
+
}
|
|
245
|
+
function classifyRefreshAtom(call, atomName, typeAliases) {
|
|
246
|
+
const readArg = call.arguments[0];
|
|
247
|
+
const warning = readArg && isReadFunction(readArg)
|
|
248
|
+
? `Jotai atomWithRefresh ${atomName} re-evaluation abstracted`
|
|
249
|
+
: undefined;
|
|
250
|
+
const domain = inferAtomDomain(call, typeAliases);
|
|
251
|
+
return {
|
|
252
|
+
configKind: "refreshable",
|
|
253
|
+
domain,
|
|
254
|
+
initial: initialValueForAtom(call, domain),
|
|
255
|
+
emitVar: true,
|
|
256
|
+
warning,
|
|
257
|
+
metadata: {
|
|
258
|
+
atomName,
|
|
259
|
+
configKind: "refreshable",
|
|
260
|
+
creator: "atomWithRefresh",
|
|
261
|
+
...(warning ? { warning } : {}),
|
|
262
|
+
},
|
|
263
|
+
};
|
|
264
|
+
}
|
|
265
|
+
function classifyLoadableAtom(call, atomName) {
|
|
266
|
+
return {
|
|
267
|
+
configKind: "asyncWrapper",
|
|
268
|
+
domain: {
|
|
269
|
+
kind: "tagged",
|
|
270
|
+
tag: "state",
|
|
271
|
+
variants: {
|
|
272
|
+
loading: { kind: "record", fields: {} },
|
|
273
|
+
hasData: {
|
|
274
|
+
kind: "record",
|
|
275
|
+
fields: { data: { kind: "tokens", count: 1 } },
|
|
276
|
+
},
|
|
277
|
+
hasError: {
|
|
278
|
+
kind: "record",
|
|
279
|
+
fields: { error: { kind: "tokens", count: 1 } },
|
|
280
|
+
},
|
|
281
|
+
},
|
|
282
|
+
},
|
|
283
|
+
initial: { state: "loading" },
|
|
284
|
+
emitVar: true,
|
|
285
|
+
metadata: {
|
|
286
|
+
atomName,
|
|
287
|
+
configKind: "asyncWrapper",
|
|
288
|
+
creator: "loadable",
|
|
289
|
+
loadableState: true,
|
|
290
|
+
},
|
|
291
|
+
};
|
|
292
|
+
}
|
|
293
|
+
function classifyUnwrapAtom(call, atomName) {
|
|
294
|
+
const fallback = call.arguments[1];
|
|
295
|
+
let warning;
|
|
296
|
+
let domain = {
|
|
297
|
+
kind: "option",
|
|
298
|
+
inner: { kind: "tokens", count: 1 },
|
|
299
|
+
};
|
|
300
|
+
let initial = null;
|
|
301
|
+
if (fallback &&
|
|
302
|
+
(ts.isArrowFunction(fallback) || ts.isFunctionExpression(fallback))) {
|
|
303
|
+
if (!ts.isBlock(fallback.body)) {
|
|
304
|
+
const lit = literalValue(fallback.body);
|
|
305
|
+
if (lit !== undefined) {
|
|
306
|
+
domain = { kind: "enum", values: [String(lit)] };
|
|
307
|
+
initial = lit;
|
|
308
|
+
}
|
|
309
|
+
else {
|
|
310
|
+
warning = `Jotai unwrap fallback for ${atomName} not statically evaluated`;
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
else {
|
|
314
|
+
warning = `Jotai unwrap fallback for ${atomName} not statically evaluated`;
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
else {
|
|
318
|
+
warning = `Jotai unwrap ${atomName} pending value abstracted`;
|
|
319
|
+
}
|
|
320
|
+
return {
|
|
321
|
+
configKind: "asyncWrapper",
|
|
322
|
+
domain,
|
|
323
|
+
initial,
|
|
324
|
+
emitVar: true,
|
|
325
|
+
warning,
|
|
326
|
+
metadata: {
|
|
327
|
+
atomName,
|
|
328
|
+
configKind: "asyncWrapper",
|
|
329
|
+
creator: "unwrap",
|
|
330
|
+
...(warning ? { warning } : {}),
|
|
331
|
+
},
|
|
332
|
+
};
|
|
333
|
+
}
|
|
334
|
+
function classifyObservableAtom(call, atomName, typeAliases) {
|
|
335
|
+
const optionsArg = call.arguments[1];
|
|
336
|
+
let initialArg;
|
|
337
|
+
if (optionsArg && ts.isObjectLiteralExpression(optionsArg)) {
|
|
338
|
+
for (const prop of optionsArg.properties) {
|
|
339
|
+
if (!ts.isPropertyAssignment(prop))
|
|
340
|
+
continue;
|
|
341
|
+
if (propertyName(prop.name) === "initialValue") {
|
|
342
|
+
initialArg = prop.initializer;
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
if (initialArg) {
|
|
347
|
+
const domain = domainFromExpression(initialArg, typeAliases);
|
|
348
|
+
return {
|
|
349
|
+
configKind: "asyncWrapper",
|
|
350
|
+
domain,
|
|
351
|
+
initial: valueFromExpression(initialArg, domain),
|
|
352
|
+
emitVar: true,
|
|
353
|
+
metadata: {
|
|
354
|
+
atomName,
|
|
355
|
+
configKind: "asyncWrapper",
|
|
356
|
+
creator: "atomWithObservable",
|
|
357
|
+
},
|
|
358
|
+
};
|
|
359
|
+
}
|
|
360
|
+
const warning = `Jotai atomWithObservable ${atomName} may suspend before first value`;
|
|
361
|
+
return {
|
|
362
|
+
configKind: "asyncWrapper",
|
|
363
|
+
domain: { kind: "tokens", count: 1 },
|
|
364
|
+
initial: "tok1",
|
|
365
|
+
emitVar: true,
|
|
366
|
+
warning,
|
|
367
|
+
metadata: {
|
|
368
|
+
atomName,
|
|
369
|
+
configKind: "asyncWrapper",
|
|
370
|
+
creator: "atomWithObservable",
|
|
371
|
+
warning,
|
|
372
|
+
},
|
|
373
|
+
};
|
|
374
|
+
}
|
|
375
|
+
function classifyFamilyAtom(atomName) {
|
|
376
|
+
return {
|
|
377
|
+
configKind: "family",
|
|
378
|
+
domain: { kind: "tokens", count: 1 },
|
|
379
|
+
initial: "tok1",
|
|
380
|
+
emitVar: false,
|
|
381
|
+
metadata: {
|
|
382
|
+
atomName,
|
|
383
|
+
configKind: "family",
|
|
384
|
+
creator: "atomFamily",
|
|
385
|
+
},
|
|
386
|
+
};
|
|
387
|
+
}
|
|
388
|
+
export function classifyFamilyInstance(familyName, param, innerCall, typeAliases) {
|
|
389
|
+
const domain = inferAtomDomain(innerCall, typeAliases);
|
|
390
|
+
const initial = initialValueForAtom(innerCall, domain);
|
|
391
|
+
return {
|
|
392
|
+
configKind: "familyInstance",
|
|
393
|
+
domain,
|
|
394
|
+
initial,
|
|
395
|
+
emitVar: true,
|
|
396
|
+
metadata: {
|
|
397
|
+
atomName: familyName,
|
|
398
|
+
configKind: "familyInstance",
|
|
399
|
+
creator: "atomFamily",
|
|
400
|
+
familyFactory: familyName,
|
|
401
|
+
familyParam: param,
|
|
402
|
+
},
|
|
403
|
+
};
|
|
404
|
+
}
|
|
5
405
|
export function inferAtomDomain(call, typeAliases = new Map()) {
|
|
6
406
|
const typeArg = call.typeArguments?.[0];
|
|
7
407
|
if (typeArg)
|
|
8
408
|
return inferDomainFromTypeNode(typeArg, typeAliases);
|
|
9
409
|
const initial = call.arguments[0];
|
|
10
|
-
if (!initial)
|
|
410
|
+
if (!initial || isReadFunction(initial))
|
|
11
411
|
return { kind: "tokens", count: 1 };
|
|
12
|
-
|
|
13
|
-
initial.kind === ts.SyntaxKind.FalseKeyword)
|
|
14
|
-
return { kind: "bool" };
|
|
15
|
-
if (ts.isStringLiteral(initial))
|
|
16
|
-
return { kind: "enum", values: [initial.text] };
|
|
17
|
-
if (ts.isNumericLiteral(initial))
|
|
18
|
-
return {
|
|
19
|
-
kind: "boundedInt",
|
|
20
|
-
min: Number(initial.text),
|
|
21
|
-
max: Number(initial.text),
|
|
22
|
-
};
|
|
23
|
-
if (initial.kind === ts.SyntaxKind.NullKeyword)
|
|
24
|
-
return { kind: "option", inner: { kind: "tokens", count: 1 } };
|
|
25
|
-
if (ts.isArrayLiteralExpression(initial))
|
|
26
|
-
return { kind: "lengthCat" };
|
|
27
|
-
if (ts.isObjectLiteralExpression(initial))
|
|
28
|
-
return domainFromObjectLiteral(initial);
|
|
29
|
-
return { kind: "tokens", count: 1 };
|
|
412
|
+
return domainFromExpression(initial, typeAliases);
|
|
30
413
|
}
|
|
31
414
|
export function initialValueForAtom(call, domain) {
|
|
32
415
|
const initial = call.arguments[0];
|
|
33
|
-
if (!initial)
|
|
416
|
+
if (!initial || isReadFunction(initial))
|
|
34
417
|
return firstValue(domain);
|
|
35
|
-
|
|
36
|
-
return validInitialOrFirst(domain, true);
|
|
37
|
-
if (initial.kind === ts.SyntaxKind.FalseKeyword)
|
|
38
|
-
return validInitialOrFirst(domain, false);
|
|
39
|
-
if (ts.isStringLiteral(initial))
|
|
40
|
-
return validInitialOrFirst(domain, initial.text);
|
|
41
|
-
if (ts.isNumericLiteral(initial))
|
|
42
|
-
return validInitialOrFirst(domain, Number(initial.text));
|
|
43
|
-
if (initial.kind === ts.SyntaxKind.NullKeyword)
|
|
44
|
-
return validInitialOrFirst(domain, null);
|
|
45
|
-
if (ts.isArrayLiteralExpression(initial))
|
|
46
|
-
return validInitialOrFirst(domain, initial.elements.length === 0
|
|
47
|
-
? "0"
|
|
48
|
-
: initial.elements.length === 1
|
|
49
|
-
? "1"
|
|
50
|
-
: "many");
|
|
51
|
-
if (ts.isObjectLiteralExpression(initial))
|
|
52
|
-
return valueFromObjectLiteral(initial, domain);
|
|
53
|
-
return firstValue(domain);
|
|
418
|
+
return valueFromExpression(initial, domain);
|
|
54
419
|
}
|
|
55
|
-
function
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
function domainFromObjectLiteral(node) {
|
|
59
|
-
const fields = {};
|
|
60
|
-
for (const prop of node.properties) {
|
|
61
|
-
if (!ts.isPropertyAssignment(prop) || !ts.isIdentifier(prop.name))
|
|
62
|
-
continue;
|
|
63
|
-
fields[prop.name.text] = domainFromExpression(prop.initializer);
|
|
64
|
-
}
|
|
65
|
-
return { kind: "record", fields };
|
|
66
|
-
}
|
|
67
|
-
function domainFromExpression(expr) {
|
|
420
|
+
function domainFromExpression(expr, typeAliases, typeArg) {
|
|
421
|
+
if (typeArg)
|
|
422
|
+
return inferDomainFromTypeNode(typeArg, typeAliases);
|
|
68
423
|
if (expr.kind === ts.SyntaxKind.TrueKeyword ||
|
|
69
424
|
expr.kind === ts.SyntaxKind.FalseKeyword)
|
|
70
425
|
return { kind: "bool" };
|
|
@@ -84,38 +439,94 @@ function domainFromExpression(expr) {
|
|
|
84
439
|
return domainFromObjectLiteral(expr);
|
|
85
440
|
return { kind: "tokens", count: 1 };
|
|
86
441
|
}
|
|
87
|
-
function
|
|
88
|
-
const
|
|
442
|
+
function domainFromObjectLiteral(node) {
|
|
443
|
+
const fields = {};
|
|
89
444
|
for (const prop of node.properties) {
|
|
90
445
|
if (!ts.isPropertyAssignment(prop) || !ts.isIdentifier(prop.name))
|
|
91
446
|
continue;
|
|
92
|
-
|
|
447
|
+
fields[prop.name.text] = domainFromExpression(prop.initializer, new Map());
|
|
93
448
|
}
|
|
94
|
-
|
|
95
|
-
const tag = Object.keys(domain.variants)[0] ?? "unknown";
|
|
96
|
-
return { ...values, [domain.tag]: tag };
|
|
97
|
-
}
|
|
98
|
-
return values;
|
|
449
|
+
return { kind: "record", fields };
|
|
99
450
|
}
|
|
100
|
-
function valueFromExpression(expr) {
|
|
451
|
+
function valueFromExpression(expr, domain) {
|
|
101
452
|
if (expr.kind === ts.SyntaxKind.TrueKeyword)
|
|
102
|
-
return true;
|
|
453
|
+
return validInitialOrFirst(domain, true);
|
|
103
454
|
if (expr.kind === ts.SyntaxKind.FalseKeyword)
|
|
104
|
-
return false;
|
|
455
|
+
return validInitialOrFirst(domain, false);
|
|
105
456
|
if (ts.isStringLiteral(expr))
|
|
106
|
-
return expr.text;
|
|
457
|
+
return validInitialOrFirst(domain, expr.text);
|
|
107
458
|
if (ts.isNumericLiteral(expr))
|
|
108
|
-
return Number(expr.text);
|
|
459
|
+
return validInitialOrFirst(domain, Number(expr.text));
|
|
109
460
|
if (expr.kind === ts.SyntaxKind.NullKeyword)
|
|
110
|
-
return null;
|
|
461
|
+
return validInitialOrFirst(domain, null);
|
|
111
462
|
if (ts.isArrayLiteralExpression(expr))
|
|
112
|
-
return expr.elements.length === 0
|
|
463
|
+
return validInitialOrFirst(domain, expr.elements.length === 0
|
|
113
464
|
? "0"
|
|
114
465
|
: expr.elements.length === 1
|
|
115
466
|
? "1"
|
|
116
|
-
: "many";
|
|
467
|
+
: "many");
|
|
117
468
|
if (ts.isObjectLiteralExpression(expr))
|
|
118
|
-
return valueFromObjectLiteral(expr,
|
|
119
|
-
return
|
|
469
|
+
return valueFromObjectLiteral(expr, domain);
|
|
470
|
+
return firstValue(domain);
|
|
471
|
+
}
|
|
472
|
+
function validInitialOrFirst(domain, value) {
|
|
473
|
+
return validateValue(domain, value)
|
|
474
|
+
? value
|
|
475
|
+
: firstValue(domain);
|
|
476
|
+
}
|
|
477
|
+
function valueFromObjectLiteral(node, domain) {
|
|
478
|
+
const values = {};
|
|
479
|
+
for (const prop of node.properties) {
|
|
480
|
+
if (!ts.isPropertyAssignment(prop) || !ts.isIdentifier(prop.name))
|
|
481
|
+
continue;
|
|
482
|
+
const fieldDomain = domain.kind === "record"
|
|
483
|
+
? domain.fields[prop.name.text]
|
|
484
|
+
: domain.kind === "tagged"
|
|
485
|
+
? taggedFieldDomain(domain, prop.name.text)
|
|
486
|
+
: undefined;
|
|
487
|
+
values[prop.name.text] = valueFromExpression(prop.initializer, fieldDomain ?? { kind: "tokens", count: 1 });
|
|
488
|
+
}
|
|
489
|
+
if (domain.kind === "tagged") {
|
|
490
|
+
const tagField = domain.tag;
|
|
491
|
+
if (!(tagField in values)) {
|
|
492
|
+
const tag = Object.keys(domain.variants)[0] ?? "unknown";
|
|
493
|
+
return { ...values, [tagField]: tag };
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
return values;
|
|
497
|
+
}
|
|
498
|
+
function taggedFieldDomain(domain, field) {
|
|
499
|
+
if (field === domain.tag) {
|
|
500
|
+
return {
|
|
501
|
+
kind: "enum",
|
|
502
|
+
values: Object.keys(domain.variants),
|
|
503
|
+
};
|
|
504
|
+
}
|
|
505
|
+
const variants = Object.values(domain.variants).filter((variant) => variant.kind === "record");
|
|
506
|
+
const fieldDomains = variants
|
|
507
|
+
.map((variant) => variant.fields[field])
|
|
508
|
+
.filter((candidate) => Boolean(candidate));
|
|
509
|
+
return fieldDomains[0];
|
|
510
|
+
}
|
|
511
|
+
export function staticFamilyParam(expression) {
|
|
512
|
+
if (ts.isStringLiteral(expression) || ts.isNumericLiteral(expression)) {
|
|
513
|
+
return expression.text;
|
|
514
|
+
}
|
|
515
|
+
if (ts.isObjectLiteralExpression(expression)) {
|
|
516
|
+
const fields = {};
|
|
517
|
+
for (const prop of expression.properties) {
|
|
518
|
+
if (!ts.isPropertyAssignment(prop))
|
|
519
|
+
return undefined;
|
|
520
|
+
const name = propertyName(prop.name);
|
|
521
|
+
if (!name)
|
|
522
|
+
return undefined;
|
|
523
|
+
const lit = literalValue(prop.initializer);
|
|
524
|
+
if (lit === undefined || typeof lit !== "string")
|
|
525
|
+
return undefined;
|
|
526
|
+
fields[name] = lit;
|
|
527
|
+
}
|
|
528
|
+
return JSON.stringify(fields);
|
|
529
|
+
}
|
|
530
|
+
return undefined;
|
|
120
531
|
}
|
|
121
532
|
//# sourceMappingURL=domains.js.map
|