tungsten 0.4.12 → 0.4.13
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/.build-complete +1 -1
- package/dist/.tsbuildinfo +1 -0
- package/dist/AnyComponent.d.ts.map +1 -1
- package/dist/Components.d.ts.map +1 -1
- package/dist/Components.js +11 -8
- package/dist/DomPointer.js +1 -1
- package/dist/DomRegion.js +2 -2
- package/dist/Framework.js +1 -1
- package/dist/FrameworkConfig.d.ts.map +1 -1
- package/dist/Instance/Instance.js +1 -1
- package/dist/RenderedContentNode.d.ts.map +1 -1
- package/dist/RenderedContentNode.js +2 -1
- package/dist/Sass.d.ts.map +1 -1
- package/dist/Sass.js +1 -0
- package/dist/Servers/DevServer.d.ts.map +1 -1
- package/dist/Servers/DevServer.js +4 -3
- package/dist/Servers/ProdServer.js +1 -1
- package/dist/Servers/StaticSiteServer.js +1 -1
- package/dist/Servers/loadEnvsDev.d.ts +1 -1
- package/dist/Servers/loadEnvsDev.d.ts.map +1 -1
- package/dist/Servers/loadEnvsDev.js +4 -2
- package/dist/Servers/routing.d.ts.map +1 -1
- package/dist/Servers/routing.js +1 -1
- package/dist/Store/Store.js +1 -1
- package/dist/Store/TypeSafeStore.js +1 -1
- package/dist/Store/makeStore.js +1 -1
- package/dist/Store/registerStore.js +1 -1
- package/dist/TElement.js +1 -1
- package/dist/TungstenApp.js +6 -2
- package/dist/api/getExport.d.ts.map +1 -1
- package/dist/api/getExport.js +1 -0
- package/dist/babelPlugins/BabelTransformBindDirect.js +2 -0
- package/dist/babelPlugins/BabelTransformBindVar.d.ts.map +1 -1
- package/dist/babelPlugins/BabelTransformComponentState.d.ts.map +1 -1
- package/dist/babelPlugins/BabelTransformComponentStyles.d.ts.map +1 -1
- package/dist/babelPlugins/BabelTransformComponentStyles.js +5 -4
- package/dist/babelPlugins/BabelTransformCssImports.d.ts.map +1 -1
- package/dist/babelPlugins/BabelTransformCssImports.js +2 -2
- package/dist/babelPlugins/BabelTransformDependencyImportsOld.js +1 -1
- package/dist/babelPlugins/BabelTransformDeproxyState.d.ts.map +1 -1
- package/dist/babelPlugins/BabelTransformPackageImports.d.ts.map +1 -1
- package/dist/babelPlugins/BabelTransformPackageImports.js +10 -5
- package/dist/babelPlugins/BabelTransformRemoveBlocks.d.ts.map +1 -1
- package/dist/babelPlugins/transformPackageImports/BabelTransformDependencyImportsCjs.d.ts.map +1 -1
- package/dist/babelPlugins/transformPackageImports/BabelTransformDependencyImportsCjs.js +2 -1
- package/dist/babelPlugins/transformPackageImports/BabelTransformDependencyImportsEsm.d.ts.map +1 -1
- package/dist/babelPlugins/transformPackageImports/BabelTransformDependencyImportsEsm.js +2 -1
- package/dist/bin/args.js +1 -1
- package/dist/bin/commands/build.js +1 -1
- package/dist/bin/commands/compileSimplePackage.js +1 -0
- package/dist/bin/index.d.ts.map +1 -1
- package/dist/bin/index.js +11 -3
- package/dist/bin/vendorHook.d.ts +3 -0
- package/dist/bin/vendorHook.d.ts.map +1 -0
- package/dist/bin/vendorHook.js +34 -0
- package/dist/browserStorage.js +4 -2
- package/dist/build/babel.user.common.config.d.ts +2 -0
- package/dist/build/babel.user.common.config.d.ts.map +1 -1
- package/dist/build/babel.user.common.config.js +10 -4
- package/dist/build/compileJavascript.d.ts.map +1 -1
- package/dist/build/compileJavascript.js +40 -27
- package/dist/build/compileStyles.js +4 -4
- package/dist/build/copyAssets.js +3 -3
- package/dist/build/copyPublicFiles.js +3 -3
- package/dist/build/frameworkStylesheets.js +1 -1
- package/dist/build/getAllSxyClientModules.d.ts.map +1 -1
- package/dist/build/getAllSxyClientModules.js +4 -28
- package/dist/build/getSxyClientPackageAliases.d.ts.map +1 -1
- package/dist/build/makeBabelUserDevConfig.d.ts.map +1 -1
- package/dist/build/makeBabelUserProdConfig.d.ts.map +1 -1
- package/dist/build/rollupExtractComponentStylesheets.js +1 -1
- package/dist/build/sassImportParser.js +2 -2
- package/dist/build/tallyBabel.d.ts +3 -0
- package/dist/build/tallyBabel.d.ts.map +1 -0
- package/dist/build/tallyBabel.js +11 -0
- package/dist/clone.js +4 -4
- package/dist/compat/context.d.ts.map +1 -1
- package/dist/compat/types.d.ts.map +1 -1
- package/dist/componentProxyHandlers.d.ts.map +1 -1
- package/dist/componentProxyHandlers.js +5 -9
- package/dist/components/Stylesheet.d.ts +1 -2
- package/dist/components/Stylesheet.d.ts.map +1 -1
- package/dist/components/Stylesheet.js +1 -1
- package/dist/components/bindable/BindableCheckbox.d.ts.map +1 -1
- package/dist/components/bindable/BindableInput.d.ts.map +1 -1
- package/dist/components/bindable/BindableInputTypedLegacy.d.ts.map +1 -1
- package/dist/components/bindable/BindableRadio.d.ts.map +1 -1
- package/dist/components/bindable/BindableTextarea.d.ts.map +1 -1
- package/dist/components/library/RichTextEditor/RichTextEditor.js +2 -2
- package/dist/components/library/RichTextEditor/contentTree.js +1 -1
- package/dist/concat.d.ts.map +1 -1
- package/dist/concat.js +2 -2
- package/dist/copy.d.ts.map +1 -1
- package/dist/createRoutes.d.ts +1 -1
- package/dist/createRoutes.d.ts.map +1 -1
- package/dist/env/Env.js +2 -2
- package/dist/env/getEnvSchemas.d.ts +2 -2
- package/dist/env/getEnvSchemas.d.ts.map +1 -1
- package/dist/env/getEnvSchemas.js +7 -5
- package/dist/env/windowGlobalEnvStatement.d.ts.map +1 -1
- package/dist/findProjectDir.d.ts.map +1 -1
- package/dist/findProjectDir.js +18 -4
- package/dist/findUserConfig.js +2 -2
- package/dist/foreach.js +1 -0
- package/dist/frameworkConfigSchema.js +2 -2
- package/dist/getComponent.d.ts.map +1 -1
- package/dist/getComponentDev.d.ts.map +1 -1
- package/dist/getRoutes.d.ts.map +1 -1
- package/dist/getRoutes.js +13 -22
- package/dist/getRoutesDevs.d.ts.map +1 -1
- package/dist/getStackTrace.js +1 -1
- package/dist/glob.d.ts +5 -0
- package/dist/glob.d.ts.map +1 -0
- package/dist/glob.js +103 -0
- package/dist/helpers/getFetchCompatibleHeaders.js +2 -2
- package/dist/hmr/applyHmrModule.js +5 -5
- package/dist/hmr/componentIdentity.js +1 -1
- package/dist/hmr/instanceRegistry.js +2 -2
- package/dist/hooks/useReducer.d.ts.map +1 -1
- package/dist/hooks/useState.d.ts.map +1 -1
- package/dist/hooks/useState.js +2 -8
- package/dist/hydrate/hydrate.d.ts +1 -1
- package/dist/hydrate/hydrate.d.ts.map +1 -1
- package/dist/hydrate/hydrate.js +26 -24
- package/dist/hydrate/reconcileHydratedAttributes.js +2 -2
- package/dist/makeFinalConfig.d.ts.map +1 -1
- package/dist/makeFinalConfig.js +2 -2
- package/dist/markOptionSelected.js +1 -1
- package/dist/mergeConfigs.d.ts.map +1 -1
- package/dist/mergeConfigs.js +11 -2
- package/dist/mutatingFunctions.js +3 -3
- package/dist/postcssPlugins/TransformCssNames.js +2 -2
- package/dist/rawHtml/parseHtml.js +1 -1
- package/dist/render/componentNodeToRenderingTree.d.ts.map +1 -1
- package/dist/render/componentNodeToRenderingTree.js +6 -17
- package/dist/render/contentToHtml.d.ts.map +1 -1
- package/dist/render/contentToHtml.js +1 -1
- package/dist/render/getFunctionBodyAsString.d.ts.map +1 -1
- package/dist/render/getFunctionBodyAsString.js +2 -5
- package/dist/render/processProps.js +2 -2
- package/dist/render/renderingTreeToHtml.d.ts.map +1 -1
- package/dist/render/rootToHtml.d.ts.map +1 -1
- package/dist/routing/Route.js +1 -1
- package/dist/routing/RouteDataFunction.type.d.ts.map +1 -1
- package/dist/routing/RoutesWithSafeParams.js +1 -1
- package/dist/routing/WebRedirect.d.ts.map +1 -1
- package/dist/routing/compareRequestToRegex.js +2 -2
- package/dist/routing/getPathPriority.js +1 -1
- package/dist/serverRpc.d.ts.map +1 -1
- package/dist/slash.d.ts +2 -0
- package/dist/slash.d.ts.map +1 -0
- package/dist/slash.js +5 -0
- package/dist/spawnShellCommand.js +1 -1
- package/dist/staticGen/staticGen.d.ts.map +1 -1
- package/dist/staticGen/staticGen.js +9 -7
- package/dist/staticGen/staticGenFunctions.js +1 -1
- package/dist/style/jssToCss.d.ts.map +1 -1
- package/dist/style/jssToCss.js +11 -9
- package/dist/style/unusedStyles.d.ts.map +1 -1
- package/dist/testing/host.js +11 -11
- package/dist/testing/hydrateTestApp.d.ts.map +1 -1
- package/dist/testing/hydrateTestApp.js +9 -9
- package/dist/testing/index.d.ts.map +1 -1
- package/dist/testing/installTestStyleProcessors.js +1 -1
- package/dist/testing/loadEnv.d.ts +4 -1
- package/dist/testing/loadEnv.d.ts.map +1 -1
- package/dist/testing/loadEnv.js +2 -2
- package/dist/testing/temp/componentPackageMock.js +3 -3
- package/dist/timeProfiler.d.ts +4 -0
- package/dist/timeProfiler.d.ts.map +1 -1
- package/dist/timeProfiler.js +16 -0
- package/dist/todo.js +2 -1
- package/dist/update/integrateUpdateVdom.d.ts.map +1 -1
- package/dist/update/integrateUpdateVdom.js +17 -14
- package/dist/update/integrateUpdateVdomPrebuild.js +5 -5
- package/dist/watch.js +2 -2
- package/package.json +10 -29
- package/types/modules.d.ts +0 -1
- package/vendor/babel-core.js +26 -0
- package/vendor/babel-parser.js +9 -0
- package/vendor/babel-plugin-syntax-import-assertions.js +50 -0
- package/vendor/babel-preset-react.js +872 -0
- package/vendor/babel-preset-typescript.js +26 -0
- package/vendor/babel-types.js +9 -0
- package/vendor/chalk-extensions.js +1994 -0
- package/vendor/chalk.js +647 -0
- package/vendor/chokidar.js +6889 -0
- package/vendor/chunk-1TN2rK3j.js +1218 -0
- package/vendor/chunk-1UuLTU0U.js +34 -0
- package/vendor/chunk-B_NeooyV.js +86 -0
- package/vendor/chunk-C12hSZn7.js +88 -0
- package/vendor/chunk-C3YkUGz5.js +19 -0
- package/vendor/chunk-C3fcZDjl.js +41964 -0
- package/vendor/chunk-C9FSKeSx.js +14603 -0
- package/vendor/chunk-CPArXGxa.js +14623 -0
- package/vendor/cjs-module-lexer.js +6 -0
- package/vendor/dotenv.js +412 -0
- package/vendor/express.js +40577 -0
- package/vendor/import-meta-resolve.js +2201 -0
- package/vendor/manifest.json +29 -0
- package/vendor/postcss.js +8546 -0
- package/vendor/serialize-javascript.js +293 -0
- package/vendor/sxy-lib-arrays.js +113 -0
- package/vendor/sxy-lib-object-copy.js +1781 -0
- package/vendor/sxy-lib-objects.js +156 -0
- package/vendor/sxy-lib-promises.js +47 -0
- package/vendor/sxy-package-investigator.js +202 -0
- package/vendor/valibot.js +7664 -0
- package/dist/Servers/hono/DevServerHono.d.ts +0 -2
- package/dist/Servers/hono/DevServerHono.d.ts.map +0 -1
- package/dist/Servers/hono/DevServerHono.js +0 -423
- package/dist/Servers/hono/ProdServerHono.d.ts +0 -2
- package/dist/Servers/hono/ProdServerHono.d.ts.map +0 -1
- package/dist/Servers/hono/ProdServerHono.js +0 -220
- package/dist/Servers/hono/TungstenServerHono.d.ts +0 -6
- package/dist/Servers/hono/TungstenServerHono.d.ts.map +0 -1
- package/dist/Servers/hono/TungstenServerHono.js +0 -36
- package/dist/api/ApiEndpointHono.d.ts +0 -3
- package/dist/api/ApiEndpointHono.d.ts.map +0 -1
- package/dist/api/ApiEndpointHono.js +0 -1
- package/dist/api/ApiRouteHono.d.ts +0 -7
- package/dist/api/ApiRouteHono.d.ts.map +0 -1
- package/dist/api/ApiRouteHono.js +0 -1
- package/dist/api/ApiRoutesHono.d.ts +0 -5
- package/dist/api/ApiRoutesHono.d.ts.map +0 -1
- package/dist/api/ApiRoutesHono.js +0 -1
- package/dist/api/getApiRoutesHono.d.ts +0 -6
- package/dist/api/getApiRoutesHono.d.ts.map +0 -1
- package/dist/api/getApiRoutesHono.js +0 -14
- package/dist/build/compilePackages.d.ts +0 -2
- package/dist/build/compilePackages.d.ts.map +0 -1
- package/dist/build/compilePackages.js +0 -89
- package/dist/build/findRequiredUserModule.d.ts +0 -2
- package/dist/build/findRequiredUserModule.d.ts.map +0 -1
- package/dist/build/findRequiredUserModule.js +0 -36
- package/dist/build/processPackage.d.ts +0 -4
- package/dist/build/processPackage.d.ts.map +0 -1
- package/dist/build/processPackage.js +0 -91
- package/dist/build/tallyBabelPlugins.d.ts +0 -3
- package/dist/build/tallyBabelPlugins.d.ts.map +0 -1
- package/dist/build/tallyBabelPlugins.js +0 -63
- package/dist/testing/loadEnvSetup.d.ts +0 -2
- package/dist/testing/loadEnvSetup.d.ts.map +0 -1
- package/dist/testing/loadEnvSetup.js +0 -7
- package/sxy-loader.config.js +0 -7
|
@@ -0,0 +1,872 @@
|
|
|
1
|
+
import { createRequire as __tungstenCreateRequire } from 'node:module';
|
|
2
|
+
const require = __tungstenCreateRequire(import.meta.url);
|
|
3
|
+
import { r as requireLib$6 } from './chunk-B_NeooyV.js';
|
|
4
|
+
import { a as requireLib$5, r as requireLib$7, b as requireLib$8, c as requireLib$9, d as requireLib$a } from './chunk-C3fcZDjl.js';
|
|
5
|
+
import require$$0 from 'path';
|
|
6
|
+
import './chunk-C9FSKeSx.js';
|
|
7
|
+
import './chunk-CPArXGxa.js';
|
|
8
|
+
import './chunk-C12hSZn7.js';
|
|
9
|
+
import './chunk-1TN2rK3j.js';
|
|
10
|
+
import 'tty';
|
|
11
|
+
import 'util';
|
|
12
|
+
import 'os';
|
|
13
|
+
import './chunk-C3YkUGz5.js';
|
|
14
|
+
import './chunk-1UuLTU0U.js';
|
|
15
|
+
import 'assert';
|
|
16
|
+
import 'fs';
|
|
17
|
+
import 'url';
|
|
18
|
+
import 'module';
|
|
19
|
+
import 'process';
|
|
20
|
+
import 'v8';
|
|
21
|
+
|
|
22
|
+
var lib$4 = {};
|
|
23
|
+
|
|
24
|
+
var lib$3 = {};
|
|
25
|
+
|
|
26
|
+
var createPlugin = {};
|
|
27
|
+
|
|
28
|
+
var hasRequiredCreatePlugin;
|
|
29
|
+
|
|
30
|
+
function requireCreatePlugin () {
|
|
31
|
+
if (hasRequiredCreatePlugin) return createPlugin;
|
|
32
|
+
hasRequiredCreatePlugin = 1;
|
|
33
|
+
|
|
34
|
+
Object.defineProperty(createPlugin, "__esModule", {
|
|
35
|
+
value: true
|
|
36
|
+
});
|
|
37
|
+
createPlugin.default = createPlugin$1;
|
|
38
|
+
var _pluginSyntaxJsx = requireLib$5();
|
|
39
|
+
var _helperPluginUtils = requireLib$6();
|
|
40
|
+
var _core = requireLib$7();
|
|
41
|
+
var _helperModuleImports = requireLib$8();
|
|
42
|
+
var _helperAnnotateAsPure = requireLib$9();
|
|
43
|
+
const DEFAULT = {
|
|
44
|
+
importSource: "react",
|
|
45
|
+
pragma: "React.createElement",
|
|
46
|
+
pragmaFrag: "React.Fragment"
|
|
47
|
+
};
|
|
48
|
+
const JSX_SOURCE_ANNOTATION_REGEX = /^\s*(?:\*\s*)?@jsxImportSource\s+(\S+)\s*$/m;
|
|
49
|
+
const JSX_RUNTIME_ANNOTATION_REGEX = /^\s*(?:\*\s*)?@jsxRuntime\s+(\S+)\s*$/m;
|
|
50
|
+
const JSX_ANNOTATION_REGEX = /^\s*(?:\*\s*)?@jsx\s+(\S+)\s*$/m;
|
|
51
|
+
const JSX_FRAG_ANNOTATION_REGEX = /^\s*(?:\*\s*)?@jsxFrag\s+(\S+)\s*$/m;
|
|
52
|
+
const get = (pass, name) => pass.get(`@babel/plugin-react-jsx/${name}`);
|
|
53
|
+
const set = (pass, name, v) => pass.set(`@babel/plugin-react-jsx/${name}`, v);
|
|
54
|
+
function hasProto(node) {
|
|
55
|
+
return node.properties.some(value => _core.types.isObjectProperty(value, {
|
|
56
|
+
computed: false,
|
|
57
|
+
shorthand: false
|
|
58
|
+
}) && (_core.types.isIdentifier(value.key, {
|
|
59
|
+
name: "__proto__"
|
|
60
|
+
}) || _core.types.isStringLiteral(value.key, {
|
|
61
|
+
value: "__proto__"
|
|
62
|
+
})));
|
|
63
|
+
}
|
|
64
|
+
function createPlugin$1({
|
|
65
|
+
name,
|
|
66
|
+
development
|
|
67
|
+
}) {
|
|
68
|
+
return (0, _helperPluginUtils.declare)((_, options) => {
|
|
69
|
+
const {
|
|
70
|
+
pure: PURE_ANNOTATION,
|
|
71
|
+
throwIfNamespace = true,
|
|
72
|
+
filter,
|
|
73
|
+
runtime: RUNTIME_DEFAULT = development ? "automatic" : "classic",
|
|
74
|
+
importSource: IMPORT_SOURCE_DEFAULT = DEFAULT.importSource,
|
|
75
|
+
pragma: PRAGMA_DEFAULT = DEFAULT.pragma,
|
|
76
|
+
pragmaFrag: PRAGMA_FRAG_DEFAULT = DEFAULT.pragmaFrag
|
|
77
|
+
} = options;
|
|
78
|
+
var {
|
|
79
|
+
useSpread = false,
|
|
80
|
+
useBuiltIns = false
|
|
81
|
+
} = options;
|
|
82
|
+
if (RUNTIME_DEFAULT === "classic") {
|
|
83
|
+
if (typeof useSpread !== "boolean") {
|
|
84
|
+
throw new Error("transform-react-jsx currently only accepts a boolean option for " + "useSpread (defaults to false)");
|
|
85
|
+
}
|
|
86
|
+
if (typeof useBuiltIns !== "boolean") {
|
|
87
|
+
throw new Error("transform-react-jsx currently only accepts a boolean option for " + "useBuiltIns (defaults to false)");
|
|
88
|
+
}
|
|
89
|
+
if (useSpread && useBuiltIns) {
|
|
90
|
+
throw new Error("transform-react-jsx currently only accepts useBuiltIns or useSpread " + "but not both");
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
let commentsNode = null;
|
|
94
|
+
return {
|
|
95
|
+
name,
|
|
96
|
+
inherits: _pluginSyntaxJsx.default,
|
|
97
|
+
visitor: {
|
|
98
|
+
JSXNamespacedName(path) {
|
|
99
|
+
if (throwIfNamespace) {
|
|
100
|
+
throw path.buildCodeFrameError(`Namespace tags are not supported by default. React's JSX doesn't support namespace tags. \
|
|
101
|
+
You can set \`throwIfNamespace: false\` to bypass this warning.`);
|
|
102
|
+
}
|
|
103
|
+
},
|
|
104
|
+
JSXSpreadChild(path) {
|
|
105
|
+
throw path.buildCodeFrameError("Spread children are not supported in React.");
|
|
106
|
+
},
|
|
107
|
+
Program: {
|
|
108
|
+
enter(path, state) {
|
|
109
|
+
const {
|
|
110
|
+
file
|
|
111
|
+
} = state;
|
|
112
|
+
let runtime = RUNTIME_DEFAULT;
|
|
113
|
+
let source = IMPORT_SOURCE_DEFAULT;
|
|
114
|
+
let pragma = PRAGMA_DEFAULT;
|
|
115
|
+
let pragmaFrag = PRAGMA_FRAG_DEFAULT;
|
|
116
|
+
let sourceSet = !!options.importSource;
|
|
117
|
+
let pragmaSet = !!options.pragma;
|
|
118
|
+
let pragmaFragSet = !!options.pragmaFrag;
|
|
119
|
+
if (file.ast.comments) {
|
|
120
|
+
for (const comment of file.ast.comments) {
|
|
121
|
+
const sourceMatches = JSX_SOURCE_ANNOTATION_REGEX.exec(comment.value);
|
|
122
|
+
if (sourceMatches) {
|
|
123
|
+
source = sourceMatches[1];
|
|
124
|
+
sourceSet = true;
|
|
125
|
+
}
|
|
126
|
+
const runtimeMatches = JSX_RUNTIME_ANNOTATION_REGEX.exec(comment.value);
|
|
127
|
+
if (runtimeMatches) {
|
|
128
|
+
runtime = runtimeMatches[1];
|
|
129
|
+
}
|
|
130
|
+
const jsxMatches = JSX_ANNOTATION_REGEX.exec(comment.value);
|
|
131
|
+
if (jsxMatches) {
|
|
132
|
+
pragma = jsxMatches[1];
|
|
133
|
+
pragmaSet = true;
|
|
134
|
+
}
|
|
135
|
+
const jsxFragMatches = JSX_FRAG_ANNOTATION_REGEX.exec(comment.value);
|
|
136
|
+
if (jsxFragMatches) {
|
|
137
|
+
pragmaFrag = jsxFragMatches[1];
|
|
138
|
+
pragmaFragSet = true;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
set(state, "runtime", runtime);
|
|
143
|
+
if (runtime === "classic") {
|
|
144
|
+
if (sourceSet) {
|
|
145
|
+
throw path.buildCodeFrameError(`importSource cannot be set when runtime is classic.`);
|
|
146
|
+
}
|
|
147
|
+
const createElement = toMemberExpression(pragma);
|
|
148
|
+
const fragment = toMemberExpression(pragmaFrag);
|
|
149
|
+
set(state, "id/createElement", () => _core.types.cloneNode(createElement));
|
|
150
|
+
set(state, "id/fragment", () => _core.types.cloneNode(fragment));
|
|
151
|
+
set(state, "defaultPure", pragma === DEFAULT.pragma);
|
|
152
|
+
} else if (runtime === "automatic") {
|
|
153
|
+
if (pragmaSet || pragmaFragSet) {
|
|
154
|
+
throw path.buildCodeFrameError(`pragma and pragmaFrag cannot be set when runtime is automatic.`);
|
|
155
|
+
}
|
|
156
|
+
const define = (name, id) => set(state, name, createImportLazily(state, path, id, source));
|
|
157
|
+
define("id/jsx", development ? "jsxDEV" : "jsx");
|
|
158
|
+
define("id/jsxs", development ? "jsxDEV" : "jsxs");
|
|
159
|
+
define("id/createElement", "createElement");
|
|
160
|
+
define("id/fragment", "Fragment");
|
|
161
|
+
set(state, "defaultPure", source === DEFAULT.importSource);
|
|
162
|
+
} else {
|
|
163
|
+
throw path.buildCodeFrameError(`Runtime must be either "classic" or "automatic".`);
|
|
164
|
+
}
|
|
165
|
+
if (development) {
|
|
166
|
+
function isDerivedClass(classNode) {
|
|
167
|
+
return classNode.superClass !== null;
|
|
168
|
+
}
|
|
169
|
+
function isThisAllowed(parents) {
|
|
170
|
+
let i = parents.length - 1;
|
|
171
|
+
do {
|
|
172
|
+
const {
|
|
173
|
+
node
|
|
174
|
+
} = parents[i];
|
|
175
|
+
if (_core.types.isFunctionParent(node) && !_core.types.isArrowFunctionExpression(node)) {
|
|
176
|
+
if (!_core.types.isMethod(node)) {
|
|
177
|
+
return true;
|
|
178
|
+
}
|
|
179
|
+
if (node.kind !== "constructor") {
|
|
180
|
+
return true;
|
|
181
|
+
}
|
|
182
|
+
return !isDerivedClass(parents[i - 2].node);
|
|
183
|
+
}
|
|
184
|
+
if (_core.types.isTSModuleBlock(node)) {
|
|
185
|
+
return false;
|
|
186
|
+
}
|
|
187
|
+
} while (i-- > 0);
|
|
188
|
+
return true;
|
|
189
|
+
}
|
|
190
|
+
let fileNameIdentifier;
|
|
191
|
+
function makeSource(node) {
|
|
192
|
+
const location = node.loc;
|
|
193
|
+
if (!location) {
|
|
194
|
+
return path.scope.buildUndefinedNode();
|
|
195
|
+
}
|
|
196
|
+
if (!fileNameIdentifier) {
|
|
197
|
+
fileNameIdentifier = path.scope.generateUidIdentifier("_jsxFileName");
|
|
198
|
+
}
|
|
199
|
+
return makeTrace(_core.types.cloneNode(fileNameIdentifier), location.start.line, location.start.column);
|
|
200
|
+
}
|
|
201
|
+
function makeTrace(fileNameIdentifier, lineNumber, column0Based) {
|
|
202
|
+
const fileLineLiteral = lineNumber != null ? _core.types.numericLiteral(lineNumber) : _core.types.nullLiteral();
|
|
203
|
+
const fileColumnLiteral = column0Based != null ? _core.types.numericLiteral(column0Based + 1) : _core.types.nullLiteral();
|
|
204
|
+
return _core.template.expression.ast`{
|
|
205
|
+
fileName: ${fileNameIdentifier},
|
|
206
|
+
lineNumber: ${fileLineLiteral},
|
|
207
|
+
columnNumber: ${fileColumnLiteral},
|
|
208
|
+
}`;
|
|
209
|
+
}
|
|
210
|
+
_core.types.traverse(path.node, {
|
|
211
|
+
enter(node, parents) {
|
|
212
|
+
if (!_core.types.isJSXOpeningElement(node)) {
|
|
213
|
+
return;
|
|
214
|
+
}
|
|
215
|
+
const attributes = node.attributes;
|
|
216
|
+
if (isThisAllowed(parents)) {
|
|
217
|
+
attributes.push(_core.types.jsxAttribute(_core.types.jsxIdentifier("__self"), _core.types.jsxExpressionContainer(_core.types.thisExpression())));
|
|
218
|
+
}
|
|
219
|
+
attributes.push(_core.types.jsxAttribute(_core.types.jsxIdentifier("__source"), _core.types.jsxExpressionContainer(makeSource(node))));
|
|
220
|
+
}
|
|
221
|
+
});
|
|
222
|
+
if (fileNameIdentifier) {
|
|
223
|
+
const {
|
|
224
|
+
filename = ""
|
|
225
|
+
} = state;
|
|
226
|
+
path.scope.push({
|
|
227
|
+
id: fileNameIdentifier,
|
|
228
|
+
init: _core.types.stringLiteral(filename)
|
|
229
|
+
});
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
},
|
|
234
|
+
JSXFragment: {
|
|
235
|
+
exit(path, file) {
|
|
236
|
+
let callExpr;
|
|
237
|
+
if (get(file, "runtime") === "classic") {
|
|
238
|
+
callExpr = buildCreateElementFragmentCall(path, file);
|
|
239
|
+
} else {
|
|
240
|
+
callExpr = buildJSXFragmentCall(path, file);
|
|
241
|
+
}
|
|
242
|
+
path.replaceWith(_core.types.inherits(callExpr, path.node));
|
|
243
|
+
}
|
|
244
|
+
},
|
|
245
|
+
JSXElement: {
|
|
246
|
+
exit(path, file) {
|
|
247
|
+
let callExpr;
|
|
248
|
+
if (get(file, "runtime") === "classic" || shouldUseCreateElement(path)) {
|
|
249
|
+
callExpr = buildCreateElementCall(path, file);
|
|
250
|
+
} else {
|
|
251
|
+
callExpr = buildJSXElementCall(path, file);
|
|
252
|
+
}
|
|
253
|
+
path.replaceWith(_core.types.inherits(callExpr, path.node));
|
|
254
|
+
}
|
|
255
|
+
},
|
|
256
|
+
JSXAttribute(path) {
|
|
257
|
+
if (_core.types.isJSXElement(path.node.value)) {
|
|
258
|
+
path.node.value = _core.types.jsxExpressionContainer(path.node.value);
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
};
|
|
263
|
+
function call(pass, name, args) {
|
|
264
|
+
const node = _core.types.callExpression(get(pass, `id/${name}`)(), args);
|
|
265
|
+
if (PURE_ANNOTATION != null ? PURE_ANNOTATION : get(pass, "defaultPure")) (0, _helperAnnotateAsPure.default)(node);
|
|
266
|
+
return node;
|
|
267
|
+
}
|
|
268
|
+
function shouldUseCreateElement(path) {
|
|
269
|
+
const openingPath = path.get("openingElement");
|
|
270
|
+
const attributes = openingPath.node.attributes;
|
|
271
|
+
let seenPropsSpread = false;
|
|
272
|
+
for (let i = 0; i < attributes.length; i++) {
|
|
273
|
+
const attr = attributes[i];
|
|
274
|
+
if (seenPropsSpread && _core.types.isJSXAttribute(attr) && attr.name.name === "key") {
|
|
275
|
+
return true;
|
|
276
|
+
} else if (_core.types.isJSXSpreadAttribute(attr)) {
|
|
277
|
+
seenPropsSpread = true;
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
return false;
|
|
281
|
+
}
|
|
282
|
+
function convertJSXIdentifier(node, parent) {
|
|
283
|
+
if (_core.types.isJSXIdentifier(node)) {
|
|
284
|
+
if (node.name === "this" && _core.types.isReferenced(node, parent)) {
|
|
285
|
+
return _core.types.thisExpression();
|
|
286
|
+
} else if (_core.types.isValidIdentifier(node.name, false)) {
|
|
287
|
+
node.type = "Identifier";
|
|
288
|
+
return node;
|
|
289
|
+
} else {
|
|
290
|
+
return _core.types.stringLiteral(node.name);
|
|
291
|
+
}
|
|
292
|
+
} else if (_core.types.isJSXMemberExpression(node)) {
|
|
293
|
+
return _core.types.memberExpression(convertJSXIdentifier(node.object, node), convertJSXIdentifier(node.property, node));
|
|
294
|
+
} else if (_core.types.isJSXNamespacedName(node)) {
|
|
295
|
+
return _core.types.stringLiteral(`${node.namespace.name}:${node.name.name}`);
|
|
296
|
+
}
|
|
297
|
+
return node;
|
|
298
|
+
}
|
|
299
|
+
function convertAttributeValue(node) {
|
|
300
|
+
if (_core.types.isJSXExpressionContainer(node)) {
|
|
301
|
+
return node.expression;
|
|
302
|
+
} else {
|
|
303
|
+
return node;
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
function processComments(attribs) {
|
|
307
|
+
commentsNode = null;
|
|
308
|
+
if (attribs.length && attribs[0].isJSXSpreadAttribute()) {
|
|
309
|
+
const node = attribs[0].node.argument;
|
|
310
|
+
if (node.leadingComments || node.trailingComments) {
|
|
311
|
+
commentsNode = _core.types.cloneNode(node);
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
function accumulateAttribute(array, attribute) {
|
|
316
|
+
if (_core.types.isJSXSpreadAttribute(attribute.node)) {
|
|
317
|
+
const arg = attribute.node.argument;
|
|
318
|
+
if (_core.types.isObjectExpression(arg) && !hasProto(arg)) {
|
|
319
|
+
array.push(...arg.properties);
|
|
320
|
+
} else {
|
|
321
|
+
array.push(_core.types.spreadElement(arg));
|
|
322
|
+
}
|
|
323
|
+
return array;
|
|
324
|
+
}
|
|
325
|
+
const value = convertAttributeValue(attribute.node.name.name !== "key" ? attribute.node.value || _core.types.booleanLiteral(true) : attribute.node.value);
|
|
326
|
+
if (attribute.node.name.name === "key" && value === null) {
|
|
327
|
+
throw attribute.buildCodeFrameError('Please provide an explicit key value. Using "key" as a shorthand for "key={true}" is not allowed.');
|
|
328
|
+
}
|
|
329
|
+
if (_core.types.isStringLiteral(value) && !_core.types.isJSXExpressionContainer(attribute.node.value)) {
|
|
330
|
+
var _value$extra;
|
|
331
|
+
value.value = value.value.replace(/\n\s+/g, " ");
|
|
332
|
+
(_value$extra = value.extra) == null || delete _value$extra.raw;
|
|
333
|
+
}
|
|
334
|
+
if (_core.types.isJSXNamespacedName(attribute.node.name)) {
|
|
335
|
+
attribute.node.name = _core.types.stringLiteral(attribute.node.name.namespace.name + ":" + attribute.node.name.name.name);
|
|
336
|
+
} else if (_core.types.isValidIdentifier(attribute.node.name.name, false)) {
|
|
337
|
+
attribute.node.name.type = "Identifier";
|
|
338
|
+
} else {
|
|
339
|
+
attribute.node.name = _core.types.stringLiteral(attribute.node.name.name);
|
|
340
|
+
}
|
|
341
|
+
array.push(_core.types.inherits(_core.types.objectProperty(attribute.node.name, value), attribute.node));
|
|
342
|
+
return array;
|
|
343
|
+
}
|
|
344
|
+
function buildChildrenProperty(children) {
|
|
345
|
+
let childrenNode;
|
|
346
|
+
if (children.length === 1) {
|
|
347
|
+
childrenNode = children[0];
|
|
348
|
+
} else if (children.length > 1) {
|
|
349
|
+
childrenNode = _core.types.arrayExpression(children);
|
|
350
|
+
} else {
|
|
351
|
+
return undefined;
|
|
352
|
+
}
|
|
353
|
+
return _core.types.objectProperty(_core.types.identifier("children"), childrenNode);
|
|
354
|
+
}
|
|
355
|
+
function buildJSXElementCall(path, file) {
|
|
356
|
+
const openingPath = path.get("openingElement");
|
|
357
|
+
const args = [getTag(openingPath)];
|
|
358
|
+
const attribsArray = [];
|
|
359
|
+
const extracted = Object.create(null);
|
|
360
|
+
for (const attr of openingPath.get("attributes")) {
|
|
361
|
+
if (attr.isJSXAttribute() && _core.types.isJSXIdentifier(attr.node.name)) {
|
|
362
|
+
const {
|
|
363
|
+
name
|
|
364
|
+
} = attr.node.name;
|
|
365
|
+
switch (name) {
|
|
366
|
+
case "__source":
|
|
367
|
+
case "__self":
|
|
368
|
+
if (extracted[name]) throw sourceSelfError(path, name);
|
|
369
|
+
case "key":
|
|
370
|
+
{
|
|
371
|
+
const keyValue = convertAttributeValue(attr.node.value);
|
|
372
|
+
if (keyValue === null) {
|
|
373
|
+
throw attr.buildCodeFrameError('Please provide an explicit key value. Using "key" as a shorthand for "key={true}" is not allowed.');
|
|
374
|
+
}
|
|
375
|
+
extracted[name] = keyValue;
|
|
376
|
+
break;
|
|
377
|
+
}
|
|
378
|
+
default:
|
|
379
|
+
attribsArray.push(attr);
|
|
380
|
+
}
|
|
381
|
+
} else {
|
|
382
|
+
attribsArray.push(attr);
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
const children = _core.types.react.buildChildren(path.node);
|
|
386
|
+
let attribs;
|
|
387
|
+
if (attribsArray.length || children.length) {
|
|
388
|
+
attribs = buildJSXOpeningElementAttributes(attribsArray, children);
|
|
389
|
+
if (commentsNode) {
|
|
390
|
+
_core.types.inheritsComments(attribs, commentsNode);
|
|
391
|
+
}
|
|
392
|
+
} else {
|
|
393
|
+
attribs = _core.types.objectExpression([]);
|
|
394
|
+
}
|
|
395
|
+
args.push(attribs);
|
|
396
|
+
if (development) {
|
|
397
|
+
var _extracted$key;
|
|
398
|
+
args.push((_extracted$key = extracted.key) != null ? _extracted$key : path.scope.buildUndefinedNode(), _core.types.booleanLiteral(children.length > 1));
|
|
399
|
+
if (extracted.__source) {
|
|
400
|
+
args.push(extracted.__source);
|
|
401
|
+
if (extracted.__self) args.push(extracted.__self);
|
|
402
|
+
} else if (extracted.__self) {
|
|
403
|
+
args.push(path.scope.buildUndefinedNode(), extracted.__self);
|
|
404
|
+
}
|
|
405
|
+
} else if (extracted.key !== undefined) {
|
|
406
|
+
args.push(extracted.key);
|
|
407
|
+
}
|
|
408
|
+
return call(file, children.length > 1 ? "jsxs" : "jsx", args);
|
|
409
|
+
}
|
|
410
|
+
function buildJSXOpeningElementAttributes(attribs, children) {
|
|
411
|
+
processComments(attribs);
|
|
412
|
+
const props = attribs.reduce(accumulateAttribute, []);
|
|
413
|
+
if ((children == null ? void 0 : children.length) > 0) {
|
|
414
|
+
props.push(buildChildrenProperty(children));
|
|
415
|
+
}
|
|
416
|
+
return _core.types.objectExpression(props);
|
|
417
|
+
}
|
|
418
|
+
function buildJSXFragmentCall(path, file) {
|
|
419
|
+
const args = [get(file, "id/fragment")()];
|
|
420
|
+
const children = _core.types.react.buildChildren(path.node);
|
|
421
|
+
args.push(_core.types.objectExpression(children.length > 0 ? [buildChildrenProperty(children)] : []));
|
|
422
|
+
if (development) {
|
|
423
|
+
args.push(path.scope.buildUndefinedNode(), _core.types.booleanLiteral(children.length > 1));
|
|
424
|
+
}
|
|
425
|
+
return call(file, children.length > 1 ? "jsxs" : "jsx", args);
|
|
426
|
+
}
|
|
427
|
+
function buildCreateElementFragmentCall(path, file) {
|
|
428
|
+
if (filter && !filter(path.node, file)) return;
|
|
429
|
+
return call(file, "createElement", [get(file, "id/fragment")(), _core.types.nullLiteral(), ..._core.types.react.buildChildren(path.node)]);
|
|
430
|
+
}
|
|
431
|
+
function buildCreateElementCall(path, file) {
|
|
432
|
+
const openingPath = path.get("openingElement");
|
|
433
|
+
return call(file, "createElement", [getTag(openingPath), buildCreateElementOpeningElementAttributes(file, path, openingPath.get("attributes")), ..._core.types.react.buildChildren(path.node)]);
|
|
434
|
+
}
|
|
435
|
+
function getTag(openingPath) {
|
|
436
|
+
const tagExpr = convertJSXIdentifier(openingPath.node.name, openingPath.node);
|
|
437
|
+
let tagName;
|
|
438
|
+
if (_core.types.isIdentifier(tagExpr)) {
|
|
439
|
+
tagName = tagExpr.name;
|
|
440
|
+
} else if (_core.types.isStringLiteral(tagExpr)) {
|
|
441
|
+
tagName = tagExpr.value;
|
|
442
|
+
}
|
|
443
|
+
if (_core.types.react.isCompatTag(tagName)) {
|
|
444
|
+
return _core.types.stringLiteral(tagName);
|
|
445
|
+
} else {
|
|
446
|
+
return tagExpr;
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
function buildCreateElementOpeningElementAttributes(file, path, attribs) {
|
|
450
|
+
const runtime = get(file, "runtime");
|
|
451
|
+
if (runtime !== "automatic") {
|
|
452
|
+
const objs = [];
|
|
453
|
+
processComments(attribs);
|
|
454
|
+
const props = attribs.reduce(accumulateAttribute, []);
|
|
455
|
+
if (!useSpread) {
|
|
456
|
+
let start = 0;
|
|
457
|
+
props.forEach((prop, i) => {
|
|
458
|
+
if (_core.types.isSpreadElement(prop)) {
|
|
459
|
+
if (i > start) {
|
|
460
|
+
objs.push(_core.types.objectExpression(props.slice(start, i)));
|
|
461
|
+
}
|
|
462
|
+
objs.push(prop.argument);
|
|
463
|
+
start = i + 1;
|
|
464
|
+
}
|
|
465
|
+
});
|
|
466
|
+
if (props.length > start) {
|
|
467
|
+
objs.push(_core.types.objectExpression(props.slice(start)));
|
|
468
|
+
}
|
|
469
|
+
} else if (props.length) {
|
|
470
|
+
objs.push(_core.types.objectExpression(props));
|
|
471
|
+
}
|
|
472
|
+
if (!objs.length) {
|
|
473
|
+
return _core.types.nullLiteral();
|
|
474
|
+
}
|
|
475
|
+
if (commentsNode) {
|
|
476
|
+
_core.types.inheritsComments(objs[0], commentsNode);
|
|
477
|
+
}
|
|
478
|
+
if (objs.length === 1) {
|
|
479
|
+
if (!(_core.types.isSpreadElement(props[0]) && _core.types.isObjectExpression(props[0].argument))) {
|
|
480
|
+
return objs[0];
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
if (!_core.types.isObjectExpression(objs[0])) {
|
|
484
|
+
objs.unshift(_core.types.objectExpression([]));
|
|
485
|
+
}
|
|
486
|
+
const helper = useBuiltIns ? _core.types.memberExpression(_core.types.identifier("Object"), _core.types.identifier("assign")) : file.addHelper("extends");
|
|
487
|
+
return _core.types.callExpression(helper, objs);
|
|
488
|
+
}
|
|
489
|
+
const props = [];
|
|
490
|
+
const found = Object.create(null);
|
|
491
|
+
processComments(attribs);
|
|
492
|
+
for (const attr of attribs) {
|
|
493
|
+
const {
|
|
494
|
+
node
|
|
495
|
+
} = attr;
|
|
496
|
+
const name = _core.types.isJSXAttribute(node) && _core.types.isJSXIdentifier(node.name) && node.name.name;
|
|
497
|
+
if (runtime === "automatic" && (name === "__source" || name === "__self")) {
|
|
498
|
+
if (found[name]) throw sourceSelfError(path, name);
|
|
499
|
+
found[name] = true;
|
|
500
|
+
}
|
|
501
|
+
accumulateAttribute(props, attr);
|
|
502
|
+
}
|
|
503
|
+
const ret = props.length === 1 && _core.types.isSpreadElement(props[0]) && !_core.types.isObjectExpression(props[0].argument) ? props[0].argument : props.length > 0 ? _core.types.objectExpression(props) : _core.types.nullLiteral();
|
|
504
|
+
if (commentsNode) {
|
|
505
|
+
_core.types.inheritsComments(ret, commentsNode);
|
|
506
|
+
}
|
|
507
|
+
return ret;
|
|
508
|
+
}
|
|
509
|
+
});
|
|
510
|
+
function getSource(source, importName) {
|
|
511
|
+
switch (importName) {
|
|
512
|
+
case "Fragment":
|
|
513
|
+
return `${source}/${development ? "jsx-dev-runtime" : "jsx-runtime"}`;
|
|
514
|
+
case "jsxDEV":
|
|
515
|
+
return `${source}/jsx-dev-runtime`;
|
|
516
|
+
case "jsx":
|
|
517
|
+
case "jsxs":
|
|
518
|
+
return `${source}/jsx-runtime`;
|
|
519
|
+
case "createElement":
|
|
520
|
+
return source;
|
|
521
|
+
}
|
|
522
|
+
}
|
|
523
|
+
function createImportLazily(pass, path, importName, source) {
|
|
524
|
+
return () => {
|
|
525
|
+
const actualSource = getSource(source, importName);
|
|
526
|
+
if ((0, _helperModuleImports.isModule)(path)) {
|
|
527
|
+
let reference = get(pass, `imports/${importName}`);
|
|
528
|
+
if (reference) return _core.types.cloneNode(reference);
|
|
529
|
+
reference = (0, _helperModuleImports.addNamed)(path, importName, actualSource, {
|
|
530
|
+
importedInterop: "uncompiled",
|
|
531
|
+
importPosition: "after"
|
|
532
|
+
});
|
|
533
|
+
set(pass, `imports/${importName}`, reference);
|
|
534
|
+
return reference;
|
|
535
|
+
} else {
|
|
536
|
+
let reference = get(pass, `requires/${actualSource}`);
|
|
537
|
+
if (reference) {
|
|
538
|
+
reference = _core.types.cloneNode(reference);
|
|
539
|
+
} else {
|
|
540
|
+
reference = (0, _helperModuleImports.addNamespace)(path, actualSource, {
|
|
541
|
+
importedInterop: "uncompiled"
|
|
542
|
+
});
|
|
543
|
+
set(pass, `requires/${actualSource}`, reference);
|
|
544
|
+
}
|
|
545
|
+
return _core.types.memberExpression(reference, _core.types.identifier(importName));
|
|
546
|
+
}
|
|
547
|
+
};
|
|
548
|
+
}
|
|
549
|
+
}
|
|
550
|
+
function toMemberExpression(id) {
|
|
551
|
+
return id.split(".").map(name => _core.types.identifier(name)).reduce((object, property) => _core.types.memberExpression(object, property));
|
|
552
|
+
}
|
|
553
|
+
function sourceSelfError(path, name) {
|
|
554
|
+
const pluginName = `transform-react-jsx-${name.slice(2)}`;
|
|
555
|
+
return path.buildCodeFrameError(`Duplicate ${name} prop found. You are most likely using the deprecated ${pluginName} Babel plugin. Both __source and __self are automatically set when using the automatic runtime. Please remove transform-react-jsx-source and transform-react-jsx-self from your Babel config.`);
|
|
556
|
+
}
|
|
557
|
+
|
|
558
|
+
|
|
559
|
+
return createPlugin;
|
|
560
|
+
}
|
|
561
|
+
|
|
562
|
+
var hasRequiredLib$4;
|
|
563
|
+
|
|
564
|
+
function requireLib$4 () {
|
|
565
|
+
if (hasRequiredLib$4) return lib$3;
|
|
566
|
+
hasRequiredLib$4 = 1;
|
|
567
|
+
|
|
568
|
+
Object.defineProperty(lib$3, "__esModule", {
|
|
569
|
+
value: true
|
|
570
|
+
});
|
|
571
|
+
lib$3.default = void 0;
|
|
572
|
+
var _createPlugin = requireCreatePlugin();
|
|
573
|
+
lib$3.default = (0, _createPlugin.default)({
|
|
574
|
+
name: "transform-react-jsx",
|
|
575
|
+
development: false
|
|
576
|
+
});
|
|
577
|
+
|
|
578
|
+
|
|
579
|
+
return lib$3;
|
|
580
|
+
}
|
|
581
|
+
|
|
582
|
+
var lib$2 = {};
|
|
583
|
+
|
|
584
|
+
var development = {};
|
|
585
|
+
|
|
586
|
+
var hasRequiredDevelopment;
|
|
587
|
+
|
|
588
|
+
function requireDevelopment () {
|
|
589
|
+
if (hasRequiredDevelopment) return development;
|
|
590
|
+
hasRequiredDevelopment = 1;
|
|
591
|
+
|
|
592
|
+
Object.defineProperty(development, "__esModule", {
|
|
593
|
+
value: true
|
|
594
|
+
});
|
|
595
|
+
development.default = void 0;
|
|
596
|
+
var _createPlugin = requireCreatePlugin();
|
|
597
|
+
development.default = (0, _createPlugin.default)({
|
|
598
|
+
name: "transform-react-jsx/development",
|
|
599
|
+
development: true
|
|
600
|
+
});
|
|
601
|
+
|
|
602
|
+
|
|
603
|
+
return development;
|
|
604
|
+
}
|
|
605
|
+
|
|
606
|
+
var hasRequiredLib$3;
|
|
607
|
+
|
|
608
|
+
function requireLib$3 () {
|
|
609
|
+
if (hasRequiredLib$3) return lib$2;
|
|
610
|
+
hasRequiredLib$3 = 1;
|
|
611
|
+
|
|
612
|
+
Object.defineProperty(lib$2, "__esModule", {
|
|
613
|
+
value: true
|
|
614
|
+
});
|
|
615
|
+
lib$2.default = void 0;
|
|
616
|
+
var _development = requireDevelopment();
|
|
617
|
+
lib$2.default = _development.default;
|
|
618
|
+
|
|
619
|
+
|
|
620
|
+
return lib$2;
|
|
621
|
+
}
|
|
622
|
+
|
|
623
|
+
var lib$1 = {};
|
|
624
|
+
|
|
625
|
+
var hasRequiredLib$2;
|
|
626
|
+
|
|
627
|
+
function requireLib$2 () {
|
|
628
|
+
if (hasRequiredLib$2) return lib$1;
|
|
629
|
+
hasRequiredLib$2 = 1;
|
|
630
|
+
|
|
631
|
+
Object.defineProperty(lib$1, "__esModule", {
|
|
632
|
+
value: true
|
|
633
|
+
});
|
|
634
|
+
lib$1.default = void 0;
|
|
635
|
+
var _helperPluginUtils = requireLib$6();
|
|
636
|
+
var _path = require$$0;
|
|
637
|
+
var _core = requireLib$7();
|
|
638
|
+
lib$1.default = (0, _helperPluginUtils.declare)(api => {
|
|
639
|
+
api.assertVersion(7);
|
|
640
|
+
function addDisplayName(id, call) {
|
|
641
|
+
const props = call.arguments[0].properties;
|
|
642
|
+
let safe = true;
|
|
643
|
+
for (let i = 0; i < props.length; i++) {
|
|
644
|
+
const prop = props[i];
|
|
645
|
+
if (_core.types.isSpreadElement(prop)) {
|
|
646
|
+
continue;
|
|
647
|
+
}
|
|
648
|
+
const key = _core.types.toComputedKey(prop);
|
|
649
|
+
if (_core.types.isStringLiteral(key, {
|
|
650
|
+
value: "displayName"
|
|
651
|
+
})) {
|
|
652
|
+
safe = false;
|
|
653
|
+
break;
|
|
654
|
+
}
|
|
655
|
+
}
|
|
656
|
+
if (safe) {
|
|
657
|
+
props.unshift(_core.types.objectProperty(_core.types.identifier("displayName"), _core.types.stringLiteral(id)));
|
|
658
|
+
}
|
|
659
|
+
}
|
|
660
|
+
const isCreateClassCallExpression = _core.types.buildMatchMemberExpression("React.createClass");
|
|
661
|
+
const isCreateClassAddon = callee => _core.types.isIdentifier(callee, {
|
|
662
|
+
name: "createReactClass"
|
|
663
|
+
});
|
|
664
|
+
function isCreateClass(node) {
|
|
665
|
+
if (!node || !_core.types.isCallExpression(node)) return false;
|
|
666
|
+
if (!isCreateClassCallExpression(node.callee) && !isCreateClassAddon(node.callee)) {
|
|
667
|
+
return false;
|
|
668
|
+
}
|
|
669
|
+
const args = node.arguments;
|
|
670
|
+
if (args.length !== 1) return false;
|
|
671
|
+
const first = args[0];
|
|
672
|
+
if (!_core.types.isObjectExpression(first)) return false;
|
|
673
|
+
return true;
|
|
674
|
+
}
|
|
675
|
+
return {
|
|
676
|
+
name: "transform-react-display-name",
|
|
677
|
+
visitor: {
|
|
678
|
+
ExportDefaultDeclaration({
|
|
679
|
+
node
|
|
680
|
+
}, state) {
|
|
681
|
+
if (isCreateClass(node.declaration)) {
|
|
682
|
+
const filename = state.filename || "unknown";
|
|
683
|
+
let displayName = _path.basename(filename, _path.extname(filename));
|
|
684
|
+
if (displayName === "index") {
|
|
685
|
+
displayName = _path.basename(_path.dirname(filename));
|
|
686
|
+
}
|
|
687
|
+
addDisplayName(displayName, node.declaration);
|
|
688
|
+
}
|
|
689
|
+
},
|
|
690
|
+
CallExpression(path) {
|
|
691
|
+
const {
|
|
692
|
+
node
|
|
693
|
+
} = path;
|
|
694
|
+
if (!isCreateClass(node)) return;
|
|
695
|
+
let id;
|
|
696
|
+
path.find(function (path) {
|
|
697
|
+
if (path.isAssignmentExpression()) {
|
|
698
|
+
id = path.node.left;
|
|
699
|
+
} else if (path.isObjectProperty()) {
|
|
700
|
+
id = path.node.key;
|
|
701
|
+
} else if (path.isVariableDeclarator()) {
|
|
702
|
+
id = path.node.id;
|
|
703
|
+
} else if (path.isStatement()) {
|
|
704
|
+
return true;
|
|
705
|
+
}
|
|
706
|
+
if (id) return true;
|
|
707
|
+
});
|
|
708
|
+
if (!id) return;
|
|
709
|
+
if (_core.types.isMemberExpression(id)) {
|
|
710
|
+
id = id.property;
|
|
711
|
+
}
|
|
712
|
+
if (_core.types.isIdentifier(id)) {
|
|
713
|
+
addDisplayName(id.name, node);
|
|
714
|
+
}
|
|
715
|
+
}
|
|
716
|
+
}
|
|
717
|
+
};
|
|
718
|
+
});
|
|
719
|
+
|
|
720
|
+
|
|
721
|
+
return lib$1;
|
|
722
|
+
}
|
|
723
|
+
|
|
724
|
+
var lib = {};
|
|
725
|
+
|
|
726
|
+
var hasRequiredLib$1;
|
|
727
|
+
|
|
728
|
+
function requireLib$1 () {
|
|
729
|
+
if (hasRequiredLib$1) return lib;
|
|
730
|
+
hasRequiredLib$1 = 1;
|
|
731
|
+
|
|
732
|
+
Object.defineProperty(lib, "__esModule", {
|
|
733
|
+
value: true
|
|
734
|
+
});
|
|
735
|
+
lib.default = void 0;
|
|
736
|
+
var _helperPluginUtils = requireLib$6();
|
|
737
|
+
var _helperAnnotateAsPure = requireLib$9();
|
|
738
|
+
var _core = requireLib$7();
|
|
739
|
+
const PURE_CALLS = [["react", new Set(["cloneElement", "createContext", "createElement", "createFactory", "createRef", "forwardRef", "isValidElement", "memo", "lazy"])], ["react-dom", new Set(["createPortal"])]];
|
|
740
|
+
lib.default = (0, _helperPluginUtils.declare)(api => {
|
|
741
|
+
api.assertVersion(7);
|
|
742
|
+
return {
|
|
743
|
+
name: "transform-react-pure-annotations",
|
|
744
|
+
visitor: {
|
|
745
|
+
CallExpression(path) {
|
|
746
|
+
if (isReactCall(path)) {
|
|
747
|
+
(0, _helperAnnotateAsPure.default)(path);
|
|
748
|
+
}
|
|
749
|
+
}
|
|
750
|
+
}
|
|
751
|
+
};
|
|
752
|
+
});
|
|
753
|
+
function isReactCall(path) {
|
|
754
|
+
const calleePath = path.get("callee");
|
|
755
|
+
if (!calleePath.isMemberExpression()) {
|
|
756
|
+
for (const [module, methods] of PURE_CALLS) {
|
|
757
|
+
for (const method of methods) {
|
|
758
|
+
if (calleePath.referencesImport(module, method)) {
|
|
759
|
+
return true;
|
|
760
|
+
}
|
|
761
|
+
}
|
|
762
|
+
}
|
|
763
|
+
return false;
|
|
764
|
+
}
|
|
765
|
+
const object = calleePath.get("object");
|
|
766
|
+
const callee = calleePath.node;
|
|
767
|
+
if (!callee.computed && _core.types.isIdentifier(callee.property)) {
|
|
768
|
+
const propertyName = callee.property.name;
|
|
769
|
+
for (const [module, methods] of PURE_CALLS) {
|
|
770
|
+
if (object.referencesImport(module, "default") || object.referencesImport(module, "*")) {
|
|
771
|
+
return methods.has(propertyName);
|
|
772
|
+
}
|
|
773
|
+
}
|
|
774
|
+
}
|
|
775
|
+
return false;
|
|
776
|
+
}
|
|
777
|
+
|
|
778
|
+
|
|
779
|
+
return lib;
|
|
780
|
+
}
|
|
781
|
+
|
|
782
|
+
var hasRequiredLib;
|
|
783
|
+
|
|
784
|
+
function requireLib () {
|
|
785
|
+
if (hasRequiredLib) return lib$4;
|
|
786
|
+
hasRequiredLib = 1;
|
|
787
|
+
|
|
788
|
+
Object.defineProperty(lib$4, '__esModule', { value: true });
|
|
789
|
+
|
|
790
|
+
var helperPluginUtils = requireLib$6();
|
|
791
|
+
var transformReactJSX = requireLib$4();
|
|
792
|
+
var transformReactJSXDevelopment = requireLib$3();
|
|
793
|
+
var transformReactDisplayName = requireLib$2();
|
|
794
|
+
var transformReactPure = requireLib$1();
|
|
795
|
+
var helperValidatorOption = requireLib$a();
|
|
796
|
+
|
|
797
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
798
|
+
|
|
799
|
+
var transformReactJSX__default = /*#__PURE__*/_interopDefault(transformReactJSX);
|
|
800
|
+
var transformReactJSXDevelopment__default = /*#__PURE__*/_interopDefault(transformReactJSXDevelopment);
|
|
801
|
+
var transformReactDisplayName__default = /*#__PURE__*/_interopDefault(transformReactDisplayName);
|
|
802
|
+
var transformReactPure__default = /*#__PURE__*/_interopDefault(transformReactPure);
|
|
803
|
+
|
|
804
|
+
new helperValidatorOption.OptionValidator("@babel/preset-react");
|
|
805
|
+
function normalizeOptions(options = {}) {
|
|
806
|
+
{
|
|
807
|
+
let {
|
|
808
|
+
pragma,
|
|
809
|
+
pragmaFrag
|
|
810
|
+
} = options;
|
|
811
|
+
const {
|
|
812
|
+
pure,
|
|
813
|
+
throwIfNamespace = true,
|
|
814
|
+
runtime = "classic",
|
|
815
|
+
importSource,
|
|
816
|
+
useBuiltIns,
|
|
817
|
+
useSpread
|
|
818
|
+
} = options;
|
|
819
|
+
if (runtime === "classic") {
|
|
820
|
+
pragma = pragma || "React.createElement";
|
|
821
|
+
pragmaFrag = pragmaFrag || "React.Fragment";
|
|
822
|
+
}
|
|
823
|
+
const development = options.development == null ? undefined : !!options.development;
|
|
824
|
+
return {
|
|
825
|
+
development,
|
|
826
|
+
importSource,
|
|
827
|
+
pragma,
|
|
828
|
+
pragmaFrag,
|
|
829
|
+
pure,
|
|
830
|
+
runtime,
|
|
831
|
+
throwIfNamespace,
|
|
832
|
+
useBuiltIns,
|
|
833
|
+
useSpread
|
|
834
|
+
};
|
|
835
|
+
}
|
|
836
|
+
}
|
|
837
|
+
|
|
838
|
+
var index = helperPluginUtils.declarePreset((api, opts) => {
|
|
839
|
+
api.assertVersion(7);
|
|
840
|
+
const {
|
|
841
|
+
development = false,
|
|
842
|
+
importSource,
|
|
843
|
+
pragma,
|
|
844
|
+
pragmaFrag,
|
|
845
|
+
pure,
|
|
846
|
+
runtime,
|
|
847
|
+
throwIfNamespace
|
|
848
|
+
} = normalizeOptions(opts);
|
|
849
|
+
return {
|
|
850
|
+
plugins: [[development ? transformReactJSXDevelopment__default.default : transformReactJSX__default.default, {
|
|
851
|
+
importSource,
|
|
852
|
+
pragma,
|
|
853
|
+
pragmaFrag,
|
|
854
|
+
runtime,
|
|
855
|
+
throwIfNamespace,
|
|
856
|
+
pure,
|
|
857
|
+
useBuiltIns: !!opts.useBuiltIns,
|
|
858
|
+
useSpread: opts.useSpread
|
|
859
|
+
}], transformReactDisplayName__default.default, pure !== false && transformReactPure__default.default].filter(Boolean)
|
|
860
|
+
};
|
|
861
|
+
});
|
|
862
|
+
|
|
863
|
+
lib$4.default = index;
|
|
864
|
+
|
|
865
|
+
return lib$4;
|
|
866
|
+
}
|
|
867
|
+
|
|
868
|
+
var libExports = requireLib();
|
|
869
|
+
|
|
870
|
+
const __v0 = libExports["__esModule"];
|
|
871
|
+
|
|
872
|
+
export { __v0 as __esModule, libExports as default };
|