This commit is contained in:
nik
2025-10-03 22:27:28 +03:00
parent 829fad0e17
commit 871cf7e792
16520 changed files with 2967597 additions and 3 deletions

View File

@@ -0,0 +1,110 @@
System.register(['@babel/core', '@babel/template'], (function (exports) {
'use strict';
var _templateBuilder;
return {
setters: [null, function (module) {
_templateBuilder = module.default;
}],
execute: (function () {
exports("default", debugLabelPlugin);
function isAtom(t, callee, customAtomNames = []) {
const atomNames = [...atomFunctionNames, ...customAtomNames];
if (t.isIdentifier(callee) && atomNames.includes(callee.name)) {
return true;
}
if (t.isMemberExpression(callee)) {
const { property } = callee;
if (t.isIdentifier(property) && atomNames.includes(property.name)) {
return true;
}
}
return false;
}
const atomFunctionNames = [
// Core
"atom",
"atomFamily",
"atomWithDefault",
"atomWithObservable",
"atomWithReducer",
"atomWithReset",
"atomWithStorage",
"freezeAtom",
"loadable",
"selectAtom",
"splitAtom",
"unwrap",
// jotai-xstate
"atomWithMachine",
// jotai-immer
"atomWithImmer",
// jotai-valtio
"atomWithProxy",
// jotai-trpc + jotai-relay
"atomWithQuery",
"atomWithMutation",
"atomWithSubscription",
// jotai-redux + jotai-zustand
"atomWithStore",
// jotai-location
"atomWithHash",
"atomWithLocation",
// jotai-optics
"focusAtom",
// jotai-form
"atomWithValidate",
"validateAtoms",
// jotai-cache
"atomWithCache",
// jotai-recoil
"atomWithRecoilValue"
];
const templateBuilder = _templateBuilder.default || _templateBuilder;
function debugLabelPlugin({ types: t }, options) {
return {
visitor: {
ExportDefaultDeclaration(nodePath, state) {
const { node } = nodePath;
if (t.isCallExpression(node.declaration) && isAtom(t, node.declaration.callee, options == null ? void 0 : options.customAtomNames)) {
const filename = (state.filename || "unknown").replace(/\.\w+$/, "");
let displayName = filename.split("/").pop();
if (displayName === "index") {
displayName = filename.slice(0, -"/index".length).split("/").pop() || "unknown";
}
const buildExport = templateBuilder(`
const %%atomIdentifier%% = %%atom%%;
export default %%atomIdentifier%%
`);
const ast = buildExport({
atomIdentifier: t.identifier(displayName),
atom: node.declaration
});
nodePath.replaceWithMultiple(ast);
}
},
VariableDeclarator(path) {
if (t.isIdentifier(path.node.id) && t.isCallExpression(path.node.init) && isAtom(t, path.node.init.callee, options == null ? void 0 : options.customAtomNames)) {
path.parentPath.insertAfter(
t.expressionStatement(
t.assignmentExpression(
"=",
t.memberExpression(
t.identifier(path.node.id.name),
t.identifier("debugLabel")
),
t.stringLiteral(path.node.id.name)
)
)
);
}
}
}
};
}
})
};
}));

View File

@@ -0,0 +1,4 @@
System.register(["@babel/core","@babel/template"],(function(m){"use strict";var r;return{setters:[null,function(o){r=o.default}],execute:(function(){m("default",d);function o(t,i,e=[]){const n=[...c,...e];if(t.isIdentifier(i)&&n.includes(i.name))return!0;if(t.isMemberExpression(i)){const{property:a}=i;if(t.isIdentifier(a)&&n.includes(a.name))return!0}return!1}const c=["atom","atomFamily","atomWithDefault","atomWithObservable","atomWithReducer","atomWithReset","atomWithStorage","freezeAtom","loadable","selectAtom","splitAtom","unwrap","atomWithMachine","atomWithImmer","atomWithProxy","atomWithQuery","atomWithMutation","atomWithSubscription","atomWithStore","atomWithHash","atomWithLocation","focusAtom","atomWithValidate","validateAtoms","atomWithCache","atomWithRecoilValue"],u=r.default||r;function d({types:t},i){return{visitor:{ExportDefaultDeclaration(e,n){const{node:a}=e;if(t.isCallExpression(a.declaration)&&o(t,a.declaration.callee,i==null?void 0:i.customAtomNames)){const l=(n.filename||"unknown").replace(/\.\w+$/,"");let s=l.split("/").pop();s==="index"&&(s=l.slice(0,-6).split("/").pop()||"unknown");const f=u(`
const %%atomIdentifier%% = %%atom%%;
export default %%atomIdentifier%%
`)({atomIdentifier:t.identifier(s),atom:a.declaration});e.replaceWithMultiple(f)}},VariableDeclarator(e){t.isIdentifier(e.node.id)&&t.isCallExpression(e.node.init)&&o(t,e.node.init.callee,i==null?void 0:i.customAtomNames)&&e.parentPath.insertAfter(t.expressionStatement(t.assignmentExpression("=",t.memberExpression(t.identifier(e.node.id.name),t.identifier("debugLabel")),t.stringLiteral(e.node.id.name))))}}}}})}}));

View File

@@ -0,0 +1,128 @@
System.register(['@babel/core', '@babel/template'], (function (exports) {
'use strict';
var _templateBuilder;
return {
setters: [null, function (module) {
_templateBuilder = module.default;
}],
execute: (function () {
exports("default", reactRefreshPlugin);
function isAtom(t, callee, customAtomNames = []) {
const atomNames = [...atomFunctionNames, ...customAtomNames];
if (t.isIdentifier(callee) && atomNames.includes(callee.name)) {
return true;
}
if (t.isMemberExpression(callee)) {
const { property } = callee;
if (t.isIdentifier(property) && atomNames.includes(property.name)) {
return true;
}
}
return false;
}
const atomFunctionNames = [
// Core
"atom",
"atomFamily",
"atomWithDefault",
"atomWithObservable",
"atomWithReducer",
"atomWithReset",
"atomWithStorage",
"freezeAtom",
"loadable",
"selectAtom",
"splitAtom",
"unwrap",
// jotai-xstate
"atomWithMachine",
// jotai-immer
"atomWithImmer",
// jotai-valtio
"atomWithProxy",
// jotai-trpc + jotai-relay
"atomWithQuery",
"atomWithMutation",
"atomWithSubscription",
// jotai-redux + jotai-zustand
"atomWithStore",
// jotai-location
"atomWithHash",
"atomWithLocation",
// jotai-optics
"focusAtom",
// jotai-form
"atomWithValidate",
"validateAtoms",
// jotai-cache
"atomWithCache",
// jotai-recoil
"atomWithRecoilValue"
];
const templateBuilder = _templateBuilder.default || _templateBuilder;
function reactRefreshPlugin({ types: t }, options) {
return {
pre({ opts }) {
if (!opts.filename) {
throw new Error("Filename must be available");
}
},
visitor: {
Program: {
exit(path) {
const jotaiAtomCache = templateBuilder(`
globalThis.jotaiAtomCache = globalThis.jotaiAtomCache || {
cache: new Map(),
get(name, inst) {
if (this.cache.has(name)) {
return this.cache.get(name)
}
this.cache.set(name, inst)
return inst
},
}`)();
path.unshiftContainer("body", jotaiAtomCache);
}
},
ExportDefaultDeclaration(nodePath, state) {
const { node } = nodePath;
if (t.isCallExpression(node.declaration) && isAtom(t, node.declaration.callee, options == null ? void 0 : options.customAtomNames)) {
const filename = state.filename || "unknown";
const atomKey = `${filename}/defaultExport`;
const buildExport = templateBuilder(
`export default globalThis.jotaiAtomCache.get(%%atomKey%%, %%atom%%)`
);
const ast = buildExport({
atomKey: t.stringLiteral(atomKey),
atom: node.declaration
});
nodePath.replaceWith(ast);
}
},
VariableDeclarator(nodePath, state) {
var _a, _b;
if (t.isIdentifier(nodePath.node.id) && t.isCallExpression(nodePath.node.init) && isAtom(t, nodePath.node.init.callee, options == null ? void 0 : options.customAtomNames) && // Make sure atom declaration is in module scope
(((_a = nodePath.parentPath.parentPath) == null ? void 0 : _a.isProgram()) || ((_b = nodePath.parentPath.parentPath) == null ? void 0 : _b.isExportNamedDeclaration()))) {
const filename = state.filename || "unknown";
const atomKey = `${filename}/${nodePath.node.id.name}`;
const buildAtomDeclaration = templateBuilder(
`const %%atomIdentifier%% = globalThis.jotaiAtomCache.get(%%atomKey%%, %%atom%%)`
);
const ast = buildAtomDeclaration({
atomIdentifier: t.identifier(nodePath.node.id.name),
atomKey: t.stringLiteral(atomKey),
atom: nodePath.node.init
});
nodePath.parentPath.replaceWith(ast);
}
}
}
};
}
})
};
}));

View File

@@ -0,0 +1,11 @@
System.register(["@babel/core","@babel/template"],(function(c){"use strict";var m;return{setters:[null,function(n){m=n.default}],execute:(function(){c("default",u);function n(e,a,t=[]){const o=[...h,...t];if(e.isIdentifier(a)&&o.includes(a.name))return!0;if(e.isMemberExpression(a)){const{property:i}=a;if(e.isIdentifier(i)&&o.includes(i.name))return!0}return!1}const h=["atom","atomFamily","atomWithDefault","atomWithObservable","atomWithReducer","atomWithReset","atomWithStorage","freezeAtom","loadable","selectAtom","splitAtom","unwrap","atomWithMachine","atomWithImmer","atomWithProxy","atomWithQuery","atomWithMutation","atomWithSubscription","atomWithStore","atomWithHash","atomWithLocation","focusAtom","atomWithValidate","validateAtoms","atomWithCache","atomWithRecoilValue"],l=m.default||m;function u({types:e},a){return{pre({opts:t}){if(!t.filename)throw new Error("Filename must be available")},visitor:{Program:{exit(t){const o=l(`
globalThis.jotaiAtomCache = globalThis.jotaiAtomCache || {
cache: new Map(),
get(name, inst) {
if (this.cache.has(name)) {
return this.cache.get(name)
}
this.cache.set(name, inst)
return inst
},
}`)();t.unshiftContainer("body",o)}},ExportDefaultDeclaration(t,o){const{node:i}=t;if(e.isCallExpression(i.declaration)&&n(e,i.declaration.callee,a==null?void 0:a.customAtomNames)){const r=`${o.filename||"unknown"}/defaultExport`,s=l("export default globalThis.jotaiAtomCache.get(%%atomKey%%, %%atom%%)")({atomKey:e.stringLiteral(r),atom:i.declaration});t.replaceWith(s)}},VariableDeclarator(t,o){var i,r;if(e.isIdentifier(t.node.id)&&e.isCallExpression(t.node.init)&&n(e,t.node.init.callee,a==null?void 0:a.customAtomNames)&&((i=t.parentPath.parentPath)!=null&&i.isProgram()||(r=t.parentPath.parentPath)!=null&&r.isExportNamedDeclaration())){const s=`${o.filename||"unknown"}/${t.node.id.name}`,d=l("const %%atomIdentifier%% = globalThis.jotaiAtomCache.get(%%atomKey%%, %%atom%%)")({atomIdentifier:e.identifier(t.node.id.name),atomKey:e.stringLiteral(s),atom:t.node.init});t.parentPath.replaceWith(d)}}}}}})}}));

180
node_modules/jotai/system/babel/preset.development.js generated vendored Normal file
View File

@@ -0,0 +1,180 @@
System.register(['@babel/core', '@babel/template'], (function (exports) {
'use strict';
var _templateBuilder;
return {
setters: [null, function (module) {
_templateBuilder = module.default;
}],
execute: (function () {
exports("default", jotaiPreset);
function isAtom(t, callee, customAtomNames = []) {
const atomNames = [...atomFunctionNames, ...customAtomNames];
if (t.isIdentifier(callee) && atomNames.includes(callee.name)) {
return true;
}
if (t.isMemberExpression(callee)) {
const { property } = callee;
if (t.isIdentifier(property) && atomNames.includes(property.name)) {
return true;
}
}
return false;
}
const atomFunctionNames = [
// Core
"atom",
"atomFamily",
"atomWithDefault",
"atomWithObservable",
"atomWithReducer",
"atomWithReset",
"atomWithStorage",
"freezeAtom",
"loadable",
"selectAtom",
"splitAtom",
"unwrap",
// jotai-xstate
"atomWithMachine",
// jotai-immer
"atomWithImmer",
// jotai-valtio
"atomWithProxy",
// jotai-trpc + jotai-relay
"atomWithQuery",
"atomWithMutation",
"atomWithSubscription",
// jotai-redux + jotai-zustand
"atomWithStore",
// jotai-location
"atomWithHash",
"atomWithLocation",
// jotai-optics
"focusAtom",
// jotai-form
"atomWithValidate",
"validateAtoms",
// jotai-cache
"atomWithCache",
// jotai-recoil
"atomWithRecoilValue"
];
const templateBuilder$1 = _templateBuilder.default || _templateBuilder;
function debugLabelPlugin({ types: t }, options) {
return {
visitor: {
ExportDefaultDeclaration(nodePath, state) {
const { node } = nodePath;
if (t.isCallExpression(node.declaration) && isAtom(t, node.declaration.callee, options == null ? void 0 : options.customAtomNames)) {
const filename = (state.filename || "unknown").replace(/\.\w+$/, "");
let displayName = filename.split("/").pop();
if (displayName === "index") {
displayName = filename.slice(0, -"/index".length).split("/").pop() || "unknown";
}
const buildExport = templateBuilder$1(`
const %%atomIdentifier%% = %%atom%%;
export default %%atomIdentifier%%
`);
const ast = buildExport({
atomIdentifier: t.identifier(displayName),
atom: node.declaration
});
nodePath.replaceWithMultiple(ast);
}
},
VariableDeclarator(path) {
if (t.isIdentifier(path.node.id) && t.isCallExpression(path.node.init) && isAtom(t, path.node.init.callee, options == null ? void 0 : options.customAtomNames)) {
path.parentPath.insertAfter(
t.expressionStatement(
t.assignmentExpression(
"=",
t.memberExpression(
t.identifier(path.node.id.name),
t.identifier("debugLabel")
),
t.stringLiteral(path.node.id.name)
)
)
);
}
}
}
};
}
const templateBuilder = _templateBuilder.default || _templateBuilder;
function reactRefreshPlugin({ types: t }, options) {
return {
pre({ opts }) {
if (!opts.filename) {
throw new Error("Filename must be available");
}
},
visitor: {
Program: {
exit(path) {
const jotaiAtomCache = templateBuilder(`
globalThis.jotaiAtomCache = globalThis.jotaiAtomCache || {
cache: new Map(),
get(name, inst) {
if (this.cache.has(name)) {
return this.cache.get(name)
}
this.cache.set(name, inst)
return inst
},
}`)();
path.unshiftContainer("body", jotaiAtomCache);
}
},
ExportDefaultDeclaration(nodePath, state) {
const { node } = nodePath;
if (t.isCallExpression(node.declaration) && isAtom(t, node.declaration.callee, options == null ? void 0 : options.customAtomNames)) {
const filename = state.filename || "unknown";
const atomKey = `${filename}/defaultExport`;
const buildExport = templateBuilder(
`export default globalThis.jotaiAtomCache.get(%%atomKey%%, %%atom%%)`
);
const ast = buildExport({
atomKey: t.stringLiteral(atomKey),
atom: node.declaration
});
nodePath.replaceWith(ast);
}
},
VariableDeclarator(nodePath, state) {
var _a, _b;
if (t.isIdentifier(nodePath.node.id) && t.isCallExpression(nodePath.node.init) && isAtom(t, nodePath.node.init.callee, options == null ? void 0 : options.customAtomNames) && // Make sure atom declaration is in module scope
(((_a = nodePath.parentPath.parentPath) == null ? void 0 : _a.isProgram()) || ((_b = nodePath.parentPath.parentPath) == null ? void 0 : _b.isExportNamedDeclaration()))) {
const filename = state.filename || "unknown";
const atomKey = `${filename}/${nodePath.node.id.name}`;
const buildAtomDeclaration = templateBuilder(
`const %%atomIdentifier%% = globalThis.jotaiAtomCache.get(%%atomKey%%, %%atom%%)`
);
const ast = buildAtomDeclaration({
atomIdentifier: t.identifier(nodePath.node.id.name),
atomKey: t.stringLiteral(atomKey),
atom: nodePath.node.init
});
nodePath.parentPath.replaceWith(ast);
}
}
}
};
}
function jotaiPreset(_, options) {
return {
plugins: [
[debugLabelPlugin, options],
[reactRefreshPlugin, options]
]
};
}
})
};
}));

14
node_modules/jotai/system/babel/preset.production.js generated vendored Normal file
View File

@@ -0,0 +1,14 @@
System.register(["@babel/core","@babel/template"],(function(d){"use strict";var s;return{setters:[null,function(l){s=l.default}],execute:(function(){d("default",b);function l(e,i,t=[]){const o=[...u,...t];if(e.isIdentifier(i)&&o.includes(i.name))return!0;if(e.isMemberExpression(i)){const{property:a}=i;if(e.isIdentifier(a)&&o.includes(a.name))return!0}return!1}const u=["atom","atomFamily","atomWithDefault","atomWithObservable","atomWithReducer","atomWithReset","atomWithStorage","freezeAtom","loadable","selectAtom","splitAtom","unwrap","atomWithMachine","atomWithImmer","atomWithProxy","atomWithQuery","atomWithMutation","atomWithSubscription","atomWithStore","atomWithHash","atomWithLocation","focusAtom","atomWithValidate","validateAtoms","atomWithCache","atomWithRecoilValue"],f=s.default||s;function h({types:e},i){return{visitor:{ExportDefaultDeclaration(t,o){const{node:a}=t;if(e.isCallExpression(a.declaration)&&l(e,a.declaration.callee,i==null?void 0:i.customAtomNames)){const n=(o.filename||"unknown").replace(/\.\w+$/,"");let r=n.split("/").pop();r==="index"&&(r=n.slice(0,-6).split("/").pop()||"unknown");const c=f(`
const %%atomIdentifier%% = %%atom%%;
export default %%atomIdentifier%%
`)({atomIdentifier:e.identifier(r),atom:a.declaration});t.replaceWithMultiple(c)}},VariableDeclarator(t){e.isIdentifier(t.node.id)&&e.isCallExpression(t.node.init)&&l(e,t.node.init.callee,i==null?void 0:i.customAtomNames)&&t.parentPath.insertAfter(e.expressionStatement(e.assignmentExpression("=",e.memberExpression(e.identifier(t.node.id.name),e.identifier("debugLabel")),e.stringLiteral(t.node.id.name))))}}}}const m=s.default||s;function p({types:e},i){return{pre({opts:t}){if(!t.filename)throw new Error("Filename must be available")},visitor:{Program:{exit(t){const o=m(`
globalThis.jotaiAtomCache = globalThis.jotaiAtomCache || {
cache: new Map(),
get(name, inst) {
if (this.cache.has(name)) {
return this.cache.get(name)
}
this.cache.set(name, inst)
return inst
},
}`)();t.unshiftContainer("body",o)}},ExportDefaultDeclaration(t,o){const{node:a}=t;if(e.isCallExpression(a.declaration)&&l(e,a.declaration.callee,i==null?void 0:i.customAtomNames)){const n=`${o.filename||"unknown"}/defaultExport`,r=m("export default globalThis.jotaiAtomCache.get(%%atomKey%%, %%atom%%)")({atomKey:e.stringLiteral(n),atom:a.declaration});t.replaceWith(r)}},VariableDeclarator(t,o){var a,n;if(e.isIdentifier(t.node.id)&&e.isCallExpression(t.node.init)&&l(e,t.node.init.callee,i==null?void 0:i.customAtomNames)&&((a=t.parentPath.parentPath)!=null&&a.isProgram()||(n=t.parentPath.parentPath)!=null&&n.isExportNamedDeclaration())){const r=`${o.filename||"unknown"}/${t.node.id.name}`,c=m("const %%atomIdentifier%% = globalThis.jotaiAtomCache.get(%%atomKey%%, %%atom%%)")({atomIdentifier:e.identifier(t.node.id.name),atomKey:e.stringLiteral(r),atom:t.node.init});t.parentPath.replaceWith(c)}}}}}function b(e,i){return{plugins:[[h,i],[p,i]]}}})}}));