🚀 Socket Launch Week Day 5:Introducing Repository Access Permissions and Custom Roles.Learn more
Sign In

@bamboocss/plugin-vue

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@bamboocss/plugin-vue - npm Package Compare versions

Comparing version
1.11.1
to
1.11.2
+95
dist/index.cjs
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
//#region \0rolldown/runtime.js
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
key = keys[i];
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
get: ((k) => from[k]).bind(null, key),
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
});
}
return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
value: mod,
enumerable: true
}) : target, mod));
//#endregion
let _vue_compiler_sfc = require("@vue/compiler-sfc");
let magic_string = require("magic-string");
magic_string = __toESM(magic_string);
//#region src/vue-to-tsx.ts
/**
* @see https://github.com/vuejs/core/blob/d2c3d8b70b2df6e16f053a7ac58e6b04e7b2078f/packages/compiler-core/src/ast.ts#L28-L60
* import { NodeTypes } from '@vue/compiler-core' isn't working for some reason (?)
* Cannot read properties of undefined (reading 'ELEMENT')
*/
const NodeTypes = {
ROOT: 0,
ELEMENT: 1,
TEXT: 2,
COMMENT: 3,
SIMPLE_EXPRESSION: 4,
INTERPOLATION: 5,
ATTRIBUTE: 6,
DIRECTIVE: 7,
COMPOUND_EXPRESSION: 8,
IF: 9,
IF_BRANCH: 10,
FOR: 11,
TEXT_CALL: 12,
VNODE_CALL: 13,
JS_CALL_EXPRESSION: 14,
JS_OBJECT_EXPRESSION: 15,
JS_PROPERTY: 16,
JS_ARRAY_EXPRESSION: 17,
JS_FUNCTION_EXPRESSION: 18,
JS_CONDITIONAL_EXPRESSION: 19,
JS_CACHE_EXPRESSION: 20,
JS_BLOCK_STATEMENT: 21,
JS_TEMPLATE_LITERAL: 22,
JS_IF_STATEMENT: 23,
JS_ASSIGNMENT_EXPRESSION: 24,
JS_SEQUENCE_EXPRESSION: 25,
JS_RETURN_STATEMENT: 26
};
const vueToTsx = (code) => {
try {
const parsed = (0, _vue_compiler_sfc.parse)(code);
const fileStr = new magic_string.default(`<template>${parsed.descriptor.template?.content}</template>`);
const rewriteProp = (prop) => {
if (prop.type === NodeTypes.DIRECTIVE && prop.exp?.type === NodeTypes.SIMPLE_EXPRESSION && prop.arg?.type === NodeTypes.SIMPLE_EXPRESSION) fileStr.replace(prop.loc.source, `${prop.arg.content}={${prop.exp.content}}`);
};
const stack = Array.from(parsed.descriptor.template?.ast?.children ?? []);
while (stack.length) {
const node = stack.pop();
if (!node) continue;
if (node.type === NodeTypes.ELEMENT) {
node.props.forEach(rewriteProp);
node.children.forEach((child) => stack.push(child));
}
}
return new magic_string.default(`${(parsed.descriptor.scriptSetup ?? parsed.descriptor.script)?.content + "\n"}\nconst render = ${fileStr.toString()}`).toString();
} catch {
return "";
}
};
//#endregion
//#region src/index.ts
function pluginVue() {
return {
name: "@bamboocss/plugin-vue",
hooks: { "parser:before": ({ filePath, content }) => {
if (filePath.endsWith(".vue")) return vueToTsx(content);
} }
};
}
//#endregion
exports.pluginVue = pluginVue;
exports.vueToTsx = vueToTsx;
import { BambooPlugin } from "@bamboocss/types";
//#region src/vue-to-tsx.d.ts
declare const vueToTsx: (code: string) => string;
//#endregion
//#region src/index.d.ts
declare function pluginVue(): BambooPlugin;
//#endregion
export { pluginVue, vueToTsx };
import { BambooPlugin } from "@bamboocss/types";
//#region src/vue-to-tsx.d.ts
declare const vueToTsx: (code: string) => string;
//#endregion
//#region src/index.d.ts
declare function pluginVue(): BambooPlugin;
//#endregion
export { pluginVue, vueToTsx };
+64
-70

@@ -1,76 +0,70 @@

// src/vue-to-tsx.ts
import { parse } from "@vue/compiler-sfc";
import MagicString from "magic-string";
var NodeTypes = {
ROOT: 0,
ELEMENT: 1,
TEXT: 2,
COMMENT: 3,
SIMPLE_EXPRESSION: 4,
INTERPOLATION: 5,
ATTRIBUTE: 6,
DIRECTIVE: 7,
COMPOUND_EXPRESSION: 8,
IF: 9,
IF_BRANCH: 10,
FOR: 11,
TEXT_CALL: 12,
VNODE_CALL: 13,
JS_CALL_EXPRESSION: 14,
JS_OBJECT_EXPRESSION: 15,
JS_PROPERTY: 16,
JS_ARRAY_EXPRESSION: 17,
JS_FUNCTION_EXPRESSION: 18,
JS_CONDITIONAL_EXPRESSION: 19,
JS_CACHE_EXPRESSION: 20,
JS_BLOCK_STATEMENT: 21,
JS_TEMPLATE_LITERAL: 22,
JS_IF_STATEMENT: 23,
JS_ASSIGNMENT_EXPRESSION: 24,
JS_SEQUENCE_EXPRESSION: 25,
JS_RETURN_STATEMENT: 26
//#region src/vue-to-tsx.ts
/**
* @see https://github.com/vuejs/core/blob/d2c3d8b70b2df6e16f053a7ac58e6b04e7b2078f/packages/compiler-core/src/ast.ts#L28-L60
* import { NodeTypes } from '@vue/compiler-core' isn't working for some reason (?)
* Cannot read properties of undefined (reading 'ELEMENT')
*/
const NodeTypes = {
ROOT: 0,
ELEMENT: 1,
TEXT: 2,
COMMENT: 3,
SIMPLE_EXPRESSION: 4,
INTERPOLATION: 5,
ATTRIBUTE: 6,
DIRECTIVE: 7,
COMPOUND_EXPRESSION: 8,
IF: 9,
IF_BRANCH: 10,
FOR: 11,
TEXT_CALL: 12,
VNODE_CALL: 13,
JS_CALL_EXPRESSION: 14,
JS_OBJECT_EXPRESSION: 15,
JS_PROPERTY: 16,
JS_ARRAY_EXPRESSION: 17,
JS_FUNCTION_EXPRESSION: 18,
JS_CONDITIONAL_EXPRESSION: 19,
JS_CACHE_EXPRESSION: 20,
JS_BLOCK_STATEMENT: 21,
JS_TEMPLATE_LITERAL: 22,
JS_IF_STATEMENT: 23,
JS_ASSIGNMENT_EXPRESSION: 24,
JS_SEQUENCE_EXPRESSION: 25,
JS_RETURN_STATEMENT: 26
};
var vueToTsx = (code) => {
try {
const parsed = parse(code);
const fileStr = new MagicString(`<template>${parsed.descriptor.template?.content}</template>`);
const rewriteProp = (prop) => {
if (prop.type === NodeTypes.DIRECTIVE && prop.exp?.type === NodeTypes.SIMPLE_EXPRESSION && prop.arg?.type === NodeTypes.SIMPLE_EXPRESSION) {
fileStr.replace(prop.loc.source, `${prop.arg.content}={${prop.exp.content}}`);
}
};
const stack = Array.from(parsed.descriptor.template?.ast?.children ?? []);
while (stack.length) {
const node = stack.pop();
if (!node) continue;
if (node.type === NodeTypes.ELEMENT) {
node.props.forEach(rewriteProp);
node.children.forEach((child) => stack.push(child));
}
}
const scriptContent = (parsed.descriptor.scriptSetup ?? parsed.descriptor.script)?.content + "\n";
const transformed = new MagicString(`${scriptContent}
const render = ${fileStr.toString()}`);
return transformed.toString();
} catch {
return "";
}
const vueToTsx = (code) => {
try {
const parsed = parse(code);
const fileStr = new MagicString(`<template>${parsed.descriptor.template?.content}</template>`);
const rewriteProp = (prop) => {
if (prop.type === NodeTypes.DIRECTIVE && prop.exp?.type === NodeTypes.SIMPLE_EXPRESSION && prop.arg?.type === NodeTypes.SIMPLE_EXPRESSION) fileStr.replace(prop.loc.source, `${prop.arg.content}={${prop.exp.content}}`);
};
const stack = Array.from(parsed.descriptor.template?.ast?.children ?? []);
while (stack.length) {
const node = stack.pop();
if (!node) continue;
if (node.type === NodeTypes.ELEMENT) {
node.props.forEach(rewriteProp);
node.children.forEach((child) => stack.push(child));
}
}
return new MagicString(`${(parsed.descriptor.scriptSetup ?? parsed.descriptor.script)?.content + "\n"}\nconst render = ${fileStr.toString()}`).toString();
} catch {
return "";
}
};
// src/index.ts
//#endregion
//#region src/index.ts
function pluginVue() {
return {
name: "@bamboocss/plugin-vue",
hooks: {
"parser:before": ({ filePath, content }) => {
if (filePath.endsWith(".vue")) {
return vueToTsx(content);
}
}
}
};
return {
name: "@bamboocss/plugin-vue",
hooks: { "parser:before": ({ filePath, content }) => {
if (filePath.endsWith(".vue")) return vueToTsx(content);
} }
};
}
export {
pluginVue,
vueToTsx
};
//#endregion
export { pluginVue, vueToTsx };
{
"name": "@bamboocss/plugin-vue",
"version": "1.11.1",
"version": "1.11.2",
"description": "Bamboo CSS plugin for Vue single file component support",

@@ -10,3 +10,3 @@ "homepage": "https://bamboo-css.com",

"type": "git",
"url": "git+https://github.com/chakra-ui/bamboo.git",
"url": "git+https://github.com/bamboocss/bamboo.git",
"directory": "packages/plugin-vue"

@@ -18,10 +18,10 @@ },

"sideEffects": false,
"main": "dist/index.js",
"main": "dist/index.cjs",
"module": "dist/index.mjs",
"types": "dist/index.d.ts",
"types": "dist/index.d.cts",
"exports": {
".": {
"source": "./src/index.ts",
"types": "./dist/index.d.ts",
"require": "./dist/index.js",
"types": "./dist/index.d.cts",
"require": "./dist/index.cjs",
"import": {

@@ -40,3 +40,3 @@ "types": "./dist/index.d.mts",

"magic-string": "0.30.21",
"@bamboocss/types": "1.11.1"
"@bamboocss/types": "1.11.2"
},

@@ -47,6 +47,6 @@ "devDependencies": {

"scripts": {
"build": "tsup src/index.ts --format=esm,cjs --dts",
"build-fast": "tsup src/index.ts --format=esm,cjs --no-dts",
"build": "tsdown src/index.ts --format=esm,cjs --dts",
"build-fast": "tsdown --dts=false src/index.ts --format=esm,cjs",
"dev": "pnpm build-fast --watch"
}
}
"use strict";
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
// If the importer is in node compatibility mode or this is not an ESM
// file that has been converted to a CommonJS file using a Babel-
// compatible transform (i.e. "__esModule" has not been set), then set
// "default" to the CommonJS "module.exports" for node compatibility.
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
// src/index.ts
var index_exports = {};
__export(index_exports, {
pluginVue: () => pluginVue,
vueToTsx: () => vueToTsx
});
module.exports = __toCommonJS(index_exports);
// src/vue-to-tsx.ts
var import_compiler_sfc = require("@vue/compiler-sfc");
var import_magic_string = __toESM(require("magic-string"));
var NodeTypes = {
ROOT: 0,
ELEMENT: 1,
TEXT: 2,
COMMENT: 3,
SIMPLE_EXPRESSION: 4,
INTERPOLATION: 5,
ATTRIBUTE: 6,
DIRECTIVE: 7,
COMPOUND_EXPRESSION: 8,
IF: 9,
IF_BRANCH: 10,
FOR: 11,
TEXT_CALL: 12,
VNODE_CALL: 13,
JS_CALL_EXPRESSION: 14,
JS_OBJECT_EXPRESSION: 15,
JS_PROPERTY: 16,
JS_ARRAY_EXPRESSION: 17,
JS_FUNCTION_EXPRESSION: 18,
JS_CONDITIONAL_EXPRESSION: 19,
JS_CACHE_EXPRESSION: 20,
JS_BLOCK_STATEMENT: 21,
JS_TEMPLATE_LITERAL: 22,
JS_IF_STATEMENT: 23,
JS_ASSIGNMENT_EXPRESSION: 24,
JS_SEQUENCE_EXPRESSION: 25,
JS_RETURN_STATEMENT: 26
};
var vueToTsx = (code) => {
try {
const parsed = (0, import_compiler_sfc.parse)(code);
const fileStr = new import_magic_string.default(`<template>${parsed.descriptor.template?.content}</template>`);
const rewriteProp = (prop) => {
if (prop.type === NodeTypes.DIRECTIVE && prop.exp?.type === NodeTypes.SIMPLE_EXPRESSION && prop.arg?.type === NodeTypes.SIMPLE_EXPRESSION) {
fileStr.replace(prop.loc.source, `${prop.arg.content}={${prop.exp.content}}`);
}
};
const stack = Array.from(parsed.descriptor.template?.ast?.children ?? []);
while (stack.length) {
const node = stack.pop();
if (!node) continue;
if (node.type === NodeTypes.ELEMENT) {
node.props.forEach(rewriteProp);
node.children.forEach((child) => stack.push(child));
}
}
const scriptContent = (parsed.descriptor.scriptSetup ?? parsed.descriptor.script)?.content + "\n";
const transformed = new import_magic_string.default(`${scriptContent}
const render = ${fileStr.toString()}`);
return transformed.toString();
} catch {
return "";
}
};
// src/index.ts
function pluginVue() {
return {
name: "@bamboocss/plugin-vue",
hooks: {
"parser:before": ({ filePath, content }) => {
if (filePath.endsWith(".vue")) {
return vueToTsx(content);
}
}
}
};
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
pluginVue,
vueToTsx
});