@bamboocss/plugin-vue 1.11.1 → 1.11.2

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 ADDED
@@ -0,0 +1,95 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ //#region \0rolldown/runtime.js
3
+ var __create = Object.create;
4
+ var __defProp = Object.defineProperty;
5
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
+ var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __getProtoOf = Object.getPrototypeOf;
8
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
11
+ key = keys[i];
12
+ if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
13
+ get: ((k) => from[k]).bind(null, key),
14
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
15
+ });
16
+ }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
20
+ value: mod,
21
+ enumerable: true
22
+ }) : target, mod));
23
+ //#endregion
24
+ let _vue_compiler_sfc = require("@vue/compiler-sfc");
25
+ let magic_string = require("magic-string");
26
+ magic_string = __toESM(magic_string);
27
+ //#region src/vue-to-tsx.ts
28
+ /**
29
+ * @see https://github.com/vuejs/core/blob/d2c3d8b70b2df6e16f053a7ac58e6b04e7b2078f/packages/compiler-core/src/ast.ts#L28-L60
30
+ * import { NodeTypes } from '@vue/compiler-core' isn't working for some reason (?)
31
+ * Cannot read properties of undefined (reading 'ELEMENT')
32
+ */
33
+ const NodeTypes = {
34
+ ROOT: 0,
35
+ ELEMENT: 1,
36
+ TEXT: 2,
37
+ COMMENT: 3,
38
+ SIMPLE_EXPRESSION: 4,
39
+ INTERPOLATION: 5,
40
+ ATTRIBUTE: 6,
41
+ DIRECTIVE: 7,
42
+ COMPOUND_EXPRESSION: 8,
43
+ IF: 9,
44
+ IF_BRANCH: 10,
45
+ FOR: 11,
46
+ TEXT_CALL: 12,
47
+ VNODE_CALL: 13,
48
+ JS_CALL_EXPRESSION: 14,
49
+ JS_OBJECT_EXPRESSION: 15,
50
+ JS_PROPERTY: 16,
51
+ JS_ARRAY_EXPRESSION: 17,
52
+ JS_FUNCTION_EXPRESSION: 18,
53
+ JS_CONDITIONAL_EXPRESSION: 19,
54
+ JS_CACHE_EXPRESSION: 20,
55
+ JS_BLOCK_STATEMENT: 21,
56
+ JS_TEMPLATE_LITERAL: 22,
57
+ JS_IF_STATEMENT: 23,
58
+ JS_ASSIGNMENT_EXPRESSION: 24,
59
+ JS_SEQUENCE_EXPRESSION: 25,
60
+ JS_RETURN_STATEMENT: 26
61
+ };
62
+ const vueToTsx = (code) => {
63
+ try {
64
+ const parsed = (0, _vue_compiler_sfc.parse)(code);
65
+ const fileStr = new magic_string.default(`<template>${parsed.descriptor.template?.content}</template>`);
66
+ const rewriteProp = (prop) => {
67
+ 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}}`);
68
+ };
69
+ const stack = Array.from(parsed.descriptor.template?.ast?.children ?? []);
70
+ while (stack.length) {
71
+ const node = stack.pop();
72
+ if (!node) continue;
73
+ if (node.type === NodeTypes.ELEMENT) {
74
+ node.props.forEach(rewriteProp);
75
+ node.children.forEach((child) => stack.push(child));
76
+ }
77
+ }
78
+ return new magic_string.default(`${(parsed.descriptor.scriptSetup ?? parsed.descriptor.script)?.content + "\n"}\nconst render = ${fileStr.toString()}`).toString();
79
+ } catch {
80
+ return "";
81
+ }
82
+ };
83
+ //#endregion
84
+ //#region src/index.ts
85
+ function pluginVue() {
86
+ return {
87
+ name: "@bamboocss/plugin-vue",
88
+ hooks: { "parser:before": ({ filePath, content }) => {
89
+ if (filePath.endsWith(".vue")) return vueToTsx(content);
90
+ } }
91
+ };
92
+ }
93
+ //#endregion
94
+ exports.pluginVue = pluginVue;
95
+ exports.vueToTsx = vueToTsx;
@@ -0,0 +1,9 @@
1
+ import { BambooPlugin } from "@bamboocss/types";
2
+
3
+ //#region src/vue-to-tsx.d.ts
4
+ declare const vueToTsx: (code: string) => string;
5
+ //#endregion
6
+ //#region src/index.d.ts
7
+ declare function pluginVue(): BambooPlugin;
8
+ //#endregion
9
+ export { pluginVue, vueToTsx };
@@ -0,0 +1,9 @@
1
+ import { BambooPlugin } from "@bamboocss/types";
2
+
3
+ //#region src/vue-to-tsx.d.ts
4
+ declare const vueToTsx: (code: string) => string;
5
+ //#endregion
6
+ //#region src/index.d.ts
7
+ declare function pluginVue(): BambooPlugin;
8
+ //#endregion
9
+ export { pluginVue, vueToTsx };
package/dist/index.mjs CHANGED
@@ -1,76 +1,70 @@
1
- // src/vue-to-tsx.ts
2
1
  import { parse } from "@vue/compiler-sfc";
3
2
  import MagicString from "magic-string";
4
- var NodeTypes = {
5
- ROOT: 0,
6
- ELEMENT: 1,
7
- TEXT: 2,
8
- COMMENT: 3,
9
- SIMPLE_EXPRESSION: 4,
10
- INTERPOLATION: 5,
11
- ATTRIBUTE: 6,
12
- DIRECTIVE: 7,
13
- COMPOUND_EXPRESSION: 8,
14
- IF: 9,
15
- IF_BRANCH: 10,
16
- FOR: 11,
17
- TEXT_CALL: 12,
18
- VNODE_CALL: 13,
19
- JS_CALL_EXPRESSION: 14,
20
- JS_OBJECT_EXPRESSION: 15,
21
- JS_PROPERTY: 16,
22
- JS_ARRAY_EXPRESSION: 17,
23
- JS_FUNCTION_EXPRESSION: 18,
24
- JS_CONDITIONAL_EXPRESSION: 19,
25
- JS_CACHE_EXPRESSION: 20,
26
- JS_BLOCK_STATEMENT: 21,
27
- JS_TEMPLATE_LITERAL: 22,
28
- JS_IF_STATEMENT: 23,
29
- JS_ASSIGNMENT_EXPRESSION: 24,
30
- JS_SEQUENCE_EXPRESSION: 25,
31
- JS_RETURN_STATEMENT: 26
3
+ //#region src/vue-to-tsx.ts
4
+ /**
5
+ * @see https://github.com/vuejs/core/blob/d2c3d8b70b2df6e16f053a7ac58e6b04e7b2078f/packages/compiler-core/src/ast.ts#L28-L60
6
+ * import { NodeTypes } from '@vue/compiler-core' isn't working for some reason (?)
7
+ * Cannot read properties of undefined (reading 'ELEMENT')
8
+ */
9
+ const NodeTypes = {
10
+ ROOT: 0,
11
+ ELEMENT: 1,
12
+ TEXT: 2,
13
+ COMMENT: 3,
14
+ SIMPLE_EXPRESSION: 4,
15
+ INTERPOLATION: 5,
16
+ ATTRIBUTE: 6,
17
+ DIRECTIVE: 7,
18
+ COMPOUND_EXPRESSION: 8,
19
+ IF: 9,
20
+ IF_BRANCH: 10,
21
+ FOR: 11,
22
+ TEXT_CALL: 12,
23
+ VNODE_CALL: 13,
24
+ JS_CALL_EXPRESSION: 14,
25
+ JS_OBJECT_EXPRESSION: 15,
26
+ JS_PROPERTY: 16,
27
+ JS_ARRAY_EXPRESSION: 17,
28
+ JS_FUNCTION_EXPRESSION: 18,
29
+ JS_CONDITIONAL_EXPRESSION: 19,
30
+ JS_CACHE_EXPRESSION: 20,
31
+ JS_BLOCK_STATEMENT: 21,
32
+ JS_TEMPLATE_LITERAL: 22,
33
+ JS_IF_STATEMENT: 23,
34
+ JS_ASSIGNMENT_EXPRESSION: 24,
35
+ JS_SEQUENCE_EXPRESSION: 25,
36
+ JS_RETURN_STATEMENT: 26
32
37
  };
33
- var vueToTsx = (code) => {
34
- try {
35
- const parsed = parse(code);
36
- const fileStr = new MagicString(`<template>${parsed.descriptor.template?.content}</template>`);
37
- const rewriteProp = (prop) => {
38
- if (prop.type === NodeTypes.DIRECTIVE && prop.exp?.type === NodeTypes.SIMPLE_EXPRESSION && prop.arg?.type === NodeTypes.SIMPLE_EXPRESSION) {
39
- fileStr.replace(prop.loc.source, `${prop.arg.content}={${prop.exp.content}}`);
40
- }
41
- };
42
- const stack = Array.from(parsed.descriptor.template?.ast?.children ?? []);
43
- while (stack.length) {
44
- const node = stack.pop();
45
- if (!node) continue;
46
- if (node.type === NodeTypes.ELEMENT) {
47
- node.props.forEach(rewriteProp);
48
- node.children.forEach((child) => stack.push(child));
49
- }
50
- }
51
- const scriptContent = (parsed.descriptor.scriptSetup ?? parsed.descriptor.script)?.content + "\n";
52
- const transformed = new MagicString(`${scriptContent}
53
- const render = ${fileStr.toString()}`);
54
- return transformed.toString();
55
- } catch {
56
- return "";
57
- }
38
+ const vueToTsx = (code) => {
39
+ try {
40
+ const parsed = parse(code);
41
+ const fileStr = new MagicString(`<template>${parsed.descriptor.template?.content}</template>`);
42
+ const rewriteProp = (prop) => {
43
+ 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}}`);
44
+ };
45
+ const stack = Array.from(parsed.descriptor.template?.ast?.children ?? []);
46
+ while (stack.length) {
47
+ const node = stack.pop();
48
+ if (!node) continue;
49
+ if (node.type === NodeTypes.ELEMENT) {
50
+ node.props.forEach(rewriteProp);
51
+ node.children.forEach((child) => stack.push(child));
52
+ }
53
+ }
54
+ return new MagicString(`${(parsed.descriptor.scriptSetup ?? parsed.descriptor.script)?.content + "\n"}\nconst render = ${fileStr.toString()}`).toString();
55
+ } catch {
56
+ return "";
57
+ }
58
58
  };
59
-
60
- // src/index.ts
59
+ //#endregion
60
+ //#region src/index.ts
61
61
  function pluginVue() {
62
- return {
63
- name: "@bamboocss/plugin-vue",
64
- hooks: {
65
- "parser:before": ({ filePath, content }) => {
66
- if (filePath.endsWith(".vue")) {
67
- return vueToTsx(content);
68
- }
69
- }
70
- }
71
- };
62
+ return {
63
+ name: "@bamboocss/plugin-vue",
64
+ hooks: { "parser:before": ({ filePath, content }) => {
65
+ if (filePath.endsWith(".vue")) return vueToTsx(content);
66
+ } }
67
+ };
72
68
  }
73
- export {
74
- pluginVue,
75
- vueToTsx
76
- };
69
+ //#endregion
70
+ export { pluginVue, vueToTsx };
package/package.json CHANGED
@@ -1,27 +1,27 @@
1
1
  {
2
2
  "name": "@bamboocss/plugin-vue",
3
- "version": "1.11.1",
3
+ "version": "1.11.2",
4
4
  "description": "Bamboo CSS plugin for Vue single file component support",
5
5
  "homepage": "https://bamboo-css.com",
6
6
  "license": "MIT",
7
7
  "author": "Segun Adebayo <joseshegs@gmail.com>",
8
8
  "repository": {
9
9
  "type": "git",
10
- "url": "git+https://github.com/chakra-ui/bamboo.git",
10
+ "url": "git+https://github.com/bamboocss/bamboo.git",
11
11
  "directory": "packages/plugin-vue"
12
12
  },
13
13
  "files": [
14
14
  "dist"
15
15
  ],
16
16
  "sideEffects": false,
17
- "main": "dist/index.js",
17
+ "main": "dist/index.cjs",
18
18
  "module": "dist/index.mjs",
19
- "types": "dist/index.d.ts",
19
+ "types": "dist/index.d.cts",
20
20
  "exports": {
21
21
  ".": {
22
22
  "source": "./src/index.ts",
23
- "types": "./dist/index.d.ts",
24
- "require": "./dist/index.js",
23
+ "types": "./dist/index.d.cts",
24
+ "require": "./dist/index.cjs",
25
25
  "import": {
26
26
  "types": "./dist/index.d.mts",
27
27
  "default": "./dist/index.mjs"
@@ -35,14 +35,14 @@
35
35
  "dependencies": {
36
36
  "@vue/compiler-sfc": "3.5.25",
37
37
  "magic-string": "0.30.21",
38
- "@bamboocss/types": "1.11.1"
38
+ "@bamboocss/types": "1.11.2"
39
39
  },
40
40
  "devDependencies": {
41
41
  "@vue/compiler-core": "3.5.25"
42
42
  },
43
43
  "scripts": {
44
- "build": "tsup src/index.ts --format=esm,cjs --dts",
45
- "build-fast": "tsup src/index.ts --format=esm,cjs --no-dts",
44
+ "build": "tsdown src/index.ts --format=esm,cjs --dts",
45
+ "build-fast": "tsdown --dts=false src/index.ts --format=esm,cjs",
46
46
  "dev": "pnpm build-fast --watch"
47
47
  }
48
48
  }
package/dist/index.js DELETED
@@ -1,114 +0,0 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
- var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
19
- };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
-
30
- // src/index.ts
31
- var index_exports = {};
32
- __export(index_exports, {
33
- pluginVue: () => pluginVue,
34
- vueToTsx: () => vueToTsx
35
- });
36
- module.exports = __toCommonJS(index_exports);
37
-
38
- // src/vue-to-tsx.ts
39
- var import_compiler_sfc = require("@vue/compiler-sfc");
40
- var import_magic_string = __toESM(require("magic-string"));
41
- var NodeTypes = {
42
- ROOT: 0,
43
- ELEMENT: 1,
44
- TEXT: 2,
45
- COMMENT: 3,
46
- SIMPLE_EXPRESSION: 4,
47
- INTERPOLATION: 5,
48
- ATTRIBUTE: 6,
49
- DIRECTIVE: 7,
50
- COMPOUND_EXPRESSION: 8,
51
- IF: 9,
52
- IF_BRANCH: 10,
53
- FOR: 11,
54
- TEXT_CALL: 12,
55
- VNODE_CALL: 13,
56
- JS_CALL_EXPRESSION: 14,
57
- JS_OBJECT_EXPRESSION: 15,
58
- JS_PROPERTY: 16,
59
- JS_ARRAY_EXPRESSION: 17,
60
- JS_FUNCTION_EXPRESSION: 18,
61
- JS_CONDITIONAL_EXPRESSION: 19,
62
- JS_CACHE_EXPRESSION: 20,
63
- JS_BLOCK_STATEMENT: 21,
64
- JS_TEMPLATE_LITERAL: 22,
65
- JS_IF_STATEMENT: 23,
66
- JS_ASSIGNMENT_EXPRESSION: 24,
67
- JS_SEQUENCE_EXPRESSION: 25,
68
- JS_RETURN_STATEMENT: 26
69
- };
70
- var vueToTsx = (code) => {
71
- try {
72
- const parsed = (0, import_compiler_sfc.parse)(code);
73
- const fileStr = new import_magic_string.default(`<template>${parsed.descriptor.template?.content}</template>`);
74
- const rewriteProp = (prop) => {
75
- if (prop.type === NodeTypes.DIRECTIVE && prop.exp?.type === NodeTypes.SIMPLE_EXPRESSION && prop.arg?.type === NodeTypes.SIMPLE_EXPRESSION) {
76
- fileStr.replace(prop.loc.source, `${prop.arg.content}={${prop.exp.content}}`);
77
- }
78
- };
79
- const stack = Array.from(parsed.descriptor.template?.ast?.children ?? []);
80
- while (stack.length) {
81
- const node = stack.pop();
82
- if (!node) continue;
83
- if (node.type === NodeTypes.ELEMENT) {
84
- node.props.forEach(rewriteProp);
85
- node.children.forEach((child) => stack.push(child));
86
- }
87
- }
88
- const scriptContent = (parsed.descriptor.scriptSetup ?? parsed.descriptor.script)?.content + "\n";
89
- const transformed = new import_magic_string.default(`${scriptContent}
90
- const render = ${fileStr.toString()}`);
91
- return transformed.toString();
92
- } catch {
93
- return "";
94
- }
95
- };
96
-
97
- // src/index.ts
98
- function pluginVue() {
99
- return {
100
- name: "@bamboocss/plugin-vue",
101
- hooks: {
102
- "parser:before": ({ filePath, content }) => {
103
- if (filePath.endsWith(".vue")) {
104
- return vueToTsx(content);
105
- }
106
- }
107
- }
108
- };
109
- }
110
- // Annotate the CommonJS export names for ESM import in node:
111
- 0 && (module.exports = {
112
- pluginVue,
113
- vueToTsx
114
- });