@vue-jsx-vapor/compiler 0.1.5 → 0.1.6
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/index.cjs +16 -16
- package/dist/index.d.cts +5 -3
- package/dist/index.d.ts +5 -3
- package/dist/index.js +16 -16
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
@@ -1292,10 +1292,6 @@ var transformVHtml = (dir, node, context) => {
|
|
1292
1292
|
function compile(source, options = {}) {
|
1293
1293
|
const onError = options.onError || _compilerdom.defaultOnError;
|
1294
1294
|
const isModuleMode = options.mode === "module";
|
1295
|
-
const __BROWSER__3 = false;
|
1296
|
-
if (__BROWSER__3 && isModuleMode) {
|
1297
|
-
onError(_compilerdom.createCompilerError.call(void 0, _compilerdom.ErrorCodes.X_MODULE_MODE_NOT_SUPPORTED));
|
1298
|
-
}
|
1299
1295
|
if (options.scopeId && !isModuleMode) {
|
1300
1296
|
onError(_compilerdom.createCompilerError.call(void 0, _compilerdom.ErrorCodes.X_SCOPE_ID_NOT_SUPPORTED));
|
1301
1297
|
}
|
@@ -1303,7 +1299,7 @@ function compile(source, options = {}) {
|
|
1303
1299
|
prefixIdentifiers: false,
|
1304
1300
|
expressionPlugins: options.expressionPlugins || ["jsx"]
|
1305
1301
|
});
|
1306
|
-
if (
|
1302
|
+
if (options.isTS) {
|
1307
1303
|
const { expressionPlugins } = resolvedOptions;
|
1308
1304
|
if (!expressionPlugins.includes("typescript")) {
|
1309
1305
|
resolvedOptions.expressionPlugins = [
|
@@ -1312,21 +1308,25 @@ function compile(source, options = {}) {
|
|
1312
1308
|
];
|
1313
1309
|
}
|
1314
1310
|
}
|
1315
|
-
|
1316
|
-
|
1317
|
-
|
1318
|
-
|
1319
|
-
|
1320
|
-
|
1321
|
-
|
1322
|
-
|
1323
|
-
|
1311
|
+
let expression;
|
1312
|
+
if (_shared.isString.call(void 0, source)) {
|
1313
|
+
const {
|
1314
|
+
body: [statement]
|
1315
|
+
} = _parser.parse.call(void 0, source, {
|
1316
|
+
sourceType: "module",
|
1317
|
+
plugins: resolvedOptions.expressionPlugins
|
1318
|
+
}).program;
|
1319
|
+
if (statement.type === "ExpressionStatement") {
|
1320
|
+
expression = statement.expression;
|
1321
|
+
}
|
1322
|
+
} else {
|
1323
|
+
expression = source;
|
1324
1324
|
}
|
1325
|
+
const children = expression.type === "JSXFragment" ? expression.children : expression.type === "JSXElement" ? [expression] : [];
|
1325
1326
|
const ast = {
|
1326
1327
|
type: 0 /* ROOT */,
|
1327
1328
|
children,
|
1328
|
-
source: _shared.isString.call(void 0, source) ? source : "",
|
1329
|
-
// TODO
|
1329
|
+
source: _shared.isString.call(void 0, source) ? source : options.source || "",
|
1330
1330
|
components: [],
|
1331
1331
|
directives: [],
|
1332
1332
|
helpers: /* @__PURE__ */ new Set(),
|
package/dist/index.d.cts
CHANGED
@@ -2,7 +2,7 @@ import { IRFor as IRFor$1, VaporCodegenResult as VaporCodegenResult$1 } from '@v
|
|
2
2
|
export { generate } from '@vue/compiler-vapor';
|
3
3
|
import { SimpleExpressionNode, BindingTypes, DirectiveNode, CompoundExpressionNode, TransformOptions as TransformOptions$1, CompilerCompatOptions, CommentNode, CompilerOptions as CompilerOptions$1, ElementNode } from '@vue/compiler-dom';
|
4
4
|
import * as _vue_runtime_vapor from '@vue/runtime-vapor';
|
5
|
-
import { JSXFragment, Node, JSXAttribute, JSXElement
|
5
|
+
import { JSXFragment, Node, JSXAttribute, JSXElement } from '@babel/types';
|
6
6
|
import { Prettify } from '@vue/shared';
|
7
7
|
|
8
8
|
interface IRProp extends Omit<DirectiveTransformResult, 'value'> {
|
@@ -330,8 +330,10 @@ declare function transformNode(context: TransformContext<BlockIRNode['node']>):
|
|
330
330
|
interface VaporCodegenResult extends Omit<VaporCodegenResult$1, 'ast'> {
|
331
331
|
ast: RootIRNode;
|
332
332
|
}
|
333
|
-
declare function compile(source: string |
|
334
|
-
type CompilerOptions = HackOptions<CompilerOptions$1
|
333
|
+
declare function compile(source: string | JSXElement | JSXFragment, options?: CompilerOptions): VaporCodegenResult;
|
334
|
+
type CompilerOptions = HackOptions<CompilerOptions$1> & {
|
335
|
+
source?: string;
|
336
|
+
};
|
335
337
|
type TransformPreset = [
|
336
338
|
NodeTransform[],
|
337
339
|
Record<string, DirectiveTransform>
|
package/dist/index.d.ts
CHANGED
@@ -2,7 +2,7 @@ import { IRFor as IRFor$1, VaporCodegenResult as VaporCodegenResult$1 } from '@v
|
|
2
2
|
export { generate } from '@vue/compiler-vapor';
|
3
3
|
import { SimpleExpressionNode, BindingTypes, DirectiveNode, CompoundExpressionNode, TransformOptions as TransformOptions$1, CompilerCompatOptions, CommentNode, CompilerOptions as CompilerOptions$1, ElementNode } from '@vue/compiler-dom';
|
4
4
|
import * as _vue_runtime_vapor from '@vue/runtime-vapor';
|
5
|
-
import { JSXFragment, Node, JSXAttribute, JSXElement
|
5
|
+
import { JSXFragment, Node, JSXAttribute, JSXElement } from '@babel/types';
|
6
6
|
import { Prettify } from '@vue/shared';
|
7
7
|
|
8
8
|
interface IRProp extends Omit<DirectiveTransformResult, 'value'> {
|
@@ -330,8 +330,10 @@ declare function transformNode(context: TransformContext<BlockIRNode['node']>):
|
|
330
330
|
interface VaporCodegenResult extends Omit<VaporCodegenResult$1, 'ast'> {
|
331
331
|
ast: RootIRNode;
|
332
332
|
}
|
333
|
-
declare function compile(source: string |
|
334
|
-
type CompilerOptions = HackOptions<CompilerOptions$1
|
333
|
+
declare function compile(source: string | JSXElement | JSXFragment, options?: CompilerOptions): VaporCodegenResult;
|
334
|
+
type CompilerOptions = HackOptions<CompilerOptions$1> & {
|
335
|
+
source?: string;
|
336
|
+
};
|
335
337
|
type TransformPreset = [
|
336
338
|
NodeTransform[],
|
337
339
|
Record<string, DirectiveTransform>
|
package/dist/index.js
CHANGED
@@ -1292,10 +1292,6 @@ var transformVHtml = (dir, node, context) => {
|
|
1292
1292
|
function compile(source, options = {}) {
|
1293
1293
|
const onError = options.onError || defaultOnError2;
|
1294
1294
|
const isModuleMode = options.mode === "module";
|
1295
|
-
const __BROWSER__3 = false;
|
1296
|
-
if (__BROWSER__3 && isModuleMode) {
|
1297
|
-
onError(createCompilerError2(ErrorCodes2.X_MODULE_MODE_NOT_SUPPORTED));
|
1298
|
-
}
|
1299
1295
|
if (options.scopeId && !isModuleMode) {
|
1300
1296
|
onError(createCompilerError2(ErrorCodes2.X_SCOPE_ID_NOT_SUPPORTED));
|
1301
1297
|
}
|
@@ -1303,7 +1299,7 @@ function compile(source, options = {}) {
|
|
1303
1299
|
prefixIdentifiers: false,
|
1304
1300
|
expressionPlugins: options.expressionPlugins || ["jsx"]
|
1305
1301
|
});
|
1306
|
-
if (
|
1302
|
+
if (options.isTS) {
|
1307
1303
|
const { expressionPlugins } = resolvedOptions;
|
1308
1304
|
if (!expressionPlugins.includes("typescript")) {
|
1309
1305
|
resolvedOptions.expressionPlugins = [
|
@@ -1312,21 +1308,25 @@ function compile(source, options = {}) {
|
|
1312
1308
|
];
|
1313
1309
|
}
|
1314
1310
|
}
|
1315
|
-
|
1316
|
-
|
1317
|
-
|
1318
|
-
|
1319
|
-
|
1320
|
-
|
1321
|
-
|
1322
|
-
|
1323
|
-
|
1311
|
+
let expression;
|
1312
|
+
if (isString2(source)) {
|
1313
|
+
const {
|
1314
|
+
body: [statement]
|
1315
|
+
} = parse(source, {
|
1316
|
+
sourceType: "module",
|
1317
|
+
plugins: resolvedOptions.expressionPlugins
|
1318
|
+
}).program;
|
1319
|
+
if (statement.type === "ExpressionStatement") {
|
1320
|
+
expression = statement.expression;
|
1321
|
+
}
|
1322
|
+
} else {
|
1323
|
+
expression = source;
|
1324
1324
|
}
|
1325
|
+
const children = expression.type === "JSXFragment" ? expression.children : expression.type === "JSXElement" ? [expression] : [];
|
1325
1326
|
const ast = {
|
1326
1327
|
type: 0 /* ROOT */,
|
1327
1328
|
children,
|
1328
|
-
source: isString2(source) ? source : "",
|
1329
|
-
// TODO
|
1329
|
+
source: isString2(source) ? source : options.source || "",
|
1330
1330
|
components: [],
|
1331
1331
|
directives: [],
|
1332
1332
|
helpers: /* @__PURE__ */ new Set(),
|