@vxrn/vite-flow 0.1.10

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2020 Nate Wienert
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,55 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf, __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: !0 });
9
+ }, __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from == "object" || typeof from == "function")
11
+ for (let key of __getOwnPropNames(from))
12
+ !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
13
+ return to;
14
+ };
15
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
16
+ // If the importer is in node compatibility mode or this is not an ESM
17
+ // file that has been converted to a CommonJS file using a Babel-
18
+ // compatible transform (i.e. "__esModule" has not been set), then set
19
+ // "default" to the CommonJS "module.exports" for node compatibility.
20
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: !0 }) : target,
21
+ mod
22
+ )), __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
23
+ var src_exports = {};
24
+ __export(src_exports, {
25
+ default: () => createFlowPlugin,
26
+ transformFlow: () => transformFlow
27
+ });
28
+ module.exports = __toCommonJS(src_exports);
29
+ var import_vite = require("vite"), import_core = __toESM(require("@babel/core"), 1);
30
+ async function transformFlow(input) {
31
+ return await new Promise((res, rej) => {
32
+ import_core.default.transform(
33
+ input,
34
+ {
35
+ presets: ["module:metro-react-native-babel-preset"]
36
+ },
37
+ (err, result) => {
38
+ (!result || err) && rej(err || "no res"), res(result.code);
39
+ }
40
+ );
41
+ });
42
+ }
43
+ function createFlowPlugin(opts) {
44
+ if (!opts?.include || Array.isArray(opts.include) && opts.include.length === 0)
45
+ return;
46
+ const filter = (0, import_vite.createFilter)(opts?.include, opts?.exclude);
47
+ return {
48
+ name: "@vxrn/vite-flow",
49
+ enforce: "pre",
50
+ transform(code, id) {
51
+ return filter(id) ? transformFlow(code) : null;
52
+ }
53
+ };
54
+ }
55
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,6 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/index.ts"],
4
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,kBAA6B,iBAC7B,cAAkB;AAElB,eAAsB,cAAc,OAAe;AACjD,SAAO,MAAM,IAAI,QAAgB,CAAC,KAAK,QAAQ;AAC7C,gBAAAA,QAAM;AAAA,MACJ;AAAA,MACA;AAAA,QACE,SAAS,CAAC,wCAAwC;AAAA,MACpD;AAAA,MACA,CAAC,KAAU,WAAW;AACpB,SAAI,CAAC,UAAU,QAAK,IAAI,OAAO,QAAQ,GACvC,IAAI,OAAQ,IAAK;AAAA,MACnB;AAAA,IACF;AAAA,EACF,CAAC;AACH;AAOe,SAAR,iBAAkC,MAA8B;AACrE,MAAI,CAAC,MAAM,WAAY,MAAM,QAAQ,KAAK,OAAO,KAAK,KAAK,QAAQ,WAAW;AAC5E;AAGF,QAAM,aAAS,0BAAa,MAAM,SAAS,MAAM,OAAO;AAExD,SAAO;AAAA,IACL,MAAM;AAAA,IACN,SAAS;AAAA,IACT,UAAU,MAAM,IAAI;AAClB,aAAI,OAAO,EAAE,IACJ,cAAc,IAAI,IAEpB;AAAA,IACT;AAAA,EACF;AACF;",
5
+ "names": ["babel"]
6
+ }
@@ -0,0 +1,191 @@
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, __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: !0 });
10
+ }, __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from == "object" || typeof from == "function")
12
+ for (let key of __getOwnPropNames(from))
13
+ !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ return to;
15
+ };
16
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
17
+ // If the importer is in node compatibility mode or this is not an ESM
18
+ // file that has been converted to a CommonJS file using a Babel-
19
+ // compatible transform (i.e. "__esModule" has not been set), then set
20
+ // "default" to the CommonJS "module.exports" for node compatibility.
21
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: !0 }) : target,
22
+ mod
23
+ )), __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
24
+ var src_exports = {};
25
+ __export(src_exports, {
26
+ default: () => createFlowPlugin,
27
+ transformFlow: () => transformFlow
28
+ });
29
+ module.exports = __toCommonJS(src_exports);
30
+ var import_vite = require("vite"), import_core = __toESM(require("@babel/core"), 1);
31
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
32
+ try {
33
+ var info = gen[key](arg), value = info.value;
34
+ } catch (error) {
35
+ reject(error);
36
+ return;
37
+ }
38
+ info.done ? resolve(value) : Promise.resolve(value).then(_next, _throw);
39
+ }
40
+ function _async_to_generator(fn) {
41
+ return function() {
42
+ var self = this, args = arguments;
43
+ return new Promise(function(resolve, reject) {
44
+ var gen = fn.apply(self, args);
45
+ function _next(value) {
46
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
47
+ }
48
+ function _throw(err) {
49
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
50
+ }
51
+ _next(void 0);
52
+ });
53
+ };
54
+ }
55
+ function _ts_generator(thisArg, body) {
56
+ var f, y, t, g, _ = {
57
+ label: 0,
58
+ sent: function() {
59
+ if (t[0] & 1)
60
+ throw t[1];
61
+ return t[1];
62
+ },
63
+ trys: [],
64
+ ops: []
65
+ };
66
+ return g = {
67
+ next: verb(0),
68
+ throw: verb(1),
69
+ return: verb(2)
70
+ }, typeof Symbol == "function" && (g[Symbol.iterator] = function() {
71
+ return this;
72
+ }), g;
73
+ function verb(n) {
74
+ return function(v) {
75
+ return step([
76
+ n,
77
+ v
78
+ ]);
79
+ };
80
+ }
81
+ function step(op) {
82
+ if (f)
83
+ throw new TypeError("Generator is already executing.");
84
+ for (; _; )
85
+ try {
86
+ if (f = 1, y && (t = op[0] & 2 ? y.return : op[0] ? y.throw || ((t = y.return) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done)
87
+ return t;
88
+ switch (y = 0, t && (op = [
89
+ op[0] & 2,
90
+ t.value
91
+ ]), op[0]) {
92
+ case 0:
93
+ case 1:
94
+ t = op;
95
+ break;
96
+ case 4:
97
+ return _.label++, {
98
+ value: op[1],
99
+ done: !1
100
+ };
101
+ case 5:
102
+ _.label++, y = op[1], op = [
103
+ 0
104
+ ];
105
+ continue;
106
+ case 7:
107
+ op = _.ops.pop(), _.trys.pop();
108
+ continue;
109
+ default:
110
+ if (t = _.trys, !(t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
111
+ _ = 0;
112
+ continue;
113
+ }
114
+ if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
115
+ _.label = op[1];
116
+ break;
117
+ }
118
+ if (op[0] === 6 && _.label < t[1]) {
119
+ _.label = t[1], t = op;
120
+ break;
121
+ }
122
+ if (t && _.label < t[2]) {
123
+ _.label = t[2], _.ops.push(op);
124
+ break;
125
+ }
126
+ t[2] && _.ops.pop(), _.trys.pop();
127
+ continue;
128
+ }
129
+ op = body.call(thisArg, _);
130
+ } catch (e) {
131
+ op = [
132
+ 6,
133
+ e
134
+ ], y = 0;
135
+ } finally {
136
+ f = t = 0;
137
+ }
138
+ if (op[0] & 5)
139
+ throw op[1];
140
+ return {
141
+ value: op[0] ? op[1] : void 0,
142
+ done: !0
143
+ };
144
+ }
145
+ }
146
+ function transformFlow(input) {
147
+ return _transformFlow.apply(this, arguments);
148
+ }
149
+ function _transformFlow() {
150
+ return _transformFlow = _async_to_generator(function(input) {
151
+ return _ts_generator(this, function(_state) {
152
+ switch (_state.label) {
153
+ case 0:
154
+ return [
155
+ 4,
156
+ new Promise(function(res, rej) {
157
+ import_core.default.transform(input, {
158
+ presets: [
159
+ "module:metro-react-native-babel-preset"
160
+ ]
161
+ }, function(err, result) {
162
+ (!result || err) && rej(err || "no res"), res(result.code);
163
+ });
164
+ })
165
+ ];
166
+ case 1:
167
+ return [
168
+ 2,
169
+ _state.sent()
170
+ ];
171
+ }
172
+ });
173
+ }), _transformFlow.apply(this, arguments);
174
+ }
175
+ function createFlowPlugin(opts) {
176
+ if (!(!(opts != null && opts.include) || Array.isArray(opts.include) && opts.include.length === 0)) {
177
+ var filter = (0, import_vite.createFilter)(opts == null ? void 0 : opts.include, opts == null ? void 0 : opts.exclude);
178
+ return {
179
+ name: "@vxrn/vite-flow",
180
+ enforce: "pre",
181
+ transform: function(code, id) {
182
+ return filter(id) ? transformFlow(code) : null;
183
+ }
184
+ };
185
+ }
186
+ }
187
+ // Annotate the CommonJS export names for ESM import in node:
188
+ 0 && (module.exports = {
189
+ transformFlow
190
+ });
191
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,6 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/Users/n8/vxrn/packages/vite-flow/src/index.ts"],
4
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,kBAA6B,iBAC7B,cAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAElB,SAAsBA,cAAcC,OAAa;SAA3BD,eAAAA,MAAAA,MAAAA,SAAAA;;SAAAA,iBAAAA;AAAAA,0BAAf,oBAAA,SAA6BC,OAAa;;;;AACxC,iBAAA;;YAAM,IAAIC,QAAgB,SAACC,KAAKC,KAAAA;AACrCC,0BAAAA,QAAMC,UACJL,OACA;gBACEM,SAAS;kBAAC;;cACZ,GACA,SAACC,KAAUC,QAAAA;AACT,iBAAI,CAACA,UAAUD,QAAKJ,IAAII,OAAO,QAAA,GAC/BL,IAAIM,OAAQC,IAAI;cAClB,CAAA;YAEJ,CAAA;;;AAXA,iBAAA;;YAAO,OAAA,KAAA;;;;EAYT,CAAA,GAbsBV,eAAAA,MAAAA,MAAAA,SAAAA;;AAoBP,SAAf,iBAAyCW,MAAc;AACrD,MAAI,IAACA,QAAAA,QAAAA,KAAMC,YAAYC,MAAMC,QAAQH,KAAKC,OAAO,KAAKD,KAAKC,QAAQG,WAAW,IAI9E;QAAMC,aAASC,0BAAaN,QAAAA,OAAAA,SAAAA,KAAMC,SAASD,QAAAA,OAAAA,SAAAA,KAAMO,OAAO;AAExD,WAAO;MACLC,MAAM;MACNC,SAAS;MACTd,WAAAA,SAAUI,MAAMW,IAAE;AAChB,eAAIL,OAAOK,EAAAA,IACFrB,cAAcU,IAAAA,IAEhB;MACT;IACF;;AACF;",
5
+ "names": ["transformFlow", "input", "Promise", "res", "rej", "babel", "transform", "presets", "err", "result", "code", "opts", "include", "Array", "isArray", "length", "filter", "createFilter", "exclude", "name", "enforce", "id"]
6
+ }
@@ -0,0 +1,32 @@
1
+ import { createFilter } from "vite";
2
+ import babel from "@babel/core";
3
+ async function transformFlow(input) {
4
+ return await new Promise((res, rej) => {
5
+ babel.transform(
6
+ input,
7
+ {
8
+ presets: ["module:metro-react-native-babel-preset"]
9
+ },
10
+ (err, result) => {
11
+ (!result || err) && rej(err || "no res"), res(result.code);
12
+ }
13
+ );
14
+ });
15
+ }
16
+ function createFlowPlugin(opts) {
17
+ if (!opts?.include || Array.isArray(opts.include) && opts.include.length === 0)
18
+ return;
19
+ const filter = createFilter(opts?.include, opts?.exclude);
20
+ return {
21
+ name: "@vxrn/vite-flow",
22
+ enforce: "pre",
23
+ transform(code, id) {
24
+ return filter(id) ? transformFlow(code) : null;
25
+ }
26
+ };
27
+ }
28
+ export {
29
+ createFlowPlugin as default,
30
+ transformFlow
31
+ };
32
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,6 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/index.ts"],
4
+ "mappings": "AACA,SAAS,oBAAoB;AAC7B,OAAO,WAAW;AAElB,eAAsB,cAAc,OAAe;AACjD,SAAO,MAAM,IAAI,QAAgB,CAAC,KAAK,QAAQ;AAC7C,UAAM;AAAA,MACJ;AAAA,MACA;AAAA,QACE,SAAS,CAAC,wCAAwC;AAAA,MACpD;AAAA,MACA,CAAC,KAAU,WAAW;AACpB,SAAI,CAAC,UAAU,QAAK,IAAI,OAAO,QAAQ,GACvC,IAAI,OAAQ,IAAK;AAAA,MACnB;AAAA,IACF;AAAA,EACF,CAAC;AACH;AAOe,SAAR,iBAAkC,MAA8B;AACrE,MAAI,CAAC,MAAM,WAAY,MAAM,QAAQ,KAAK,OAAO,KAAK,KAAK,QAAQ,WAAW;AAC5E;AAGF,QAAM,SAAS,aAAa,MAAM,SAAS,MAAM,OAAO;AAExD,SAAO;AAAA,IACL,MAAM;AAAA,IACN,SAAS;AAAA,IACT,UAAU,MAAM,IAAI;AAClB,aAAI,OAAO,EAAE,IACJ,cAAc,IAAI,IAEpB;AAAA,IACT;AAAA,EACF;AACF;",
5
+ "names": []
6
+ }
@@ -0,0 +1,23 @@
1
+ import { createFilter } from "vite";
2
+ import babel from "@babel/core";
3
+ async function transformFlow(input) {
4
+ return await new Promise((res, rej) => {
5
+ babel.transform(input, {
6
+ presets: ["module:metro-react-native-babel-preset"]
7
+ }, (err, result) => {
8
+ (!result || err) && rej(err || "no res"), res(result.code);
9
+ });
10
+ });
11
+ }
12
+ function createFlowPlugin(opts) {
13
+ if (!opts?.include || Array.isArray(opts.include) && opts.include.length === 0) return;
14
+ const filter = createFilter(opts?.include, opts?.exclude);
15
+ return {
16
+ name: "@vxrn/vite-flow",
17
+ enforce: "pre",
18
+ transform(code, id) {
19
+ return filter(id) ? transformFlow(code) : null;
20
+ }
21
+ };
22
+ }
23
+ export { createFlowPlugin as default, transformFlow };
@@ -0,0 +1,163 @@
1
+ import { createFilter } from "vite";
2
+ import babel from "@babel/core";
3
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
4
+ try {
5
+ var info = gen[key](arg), value = info.value;
6
+ } catch (error) {
7
+ reject(error);
8
+ return;
9
+ }
10
+ info.done ? resolve(value) : Promise.resolve(value).then(_next, _throw);
11
+ }
12
+ function _async_to_generator(fn) {
13
+ return function() {
14
+ var self = this, args = arguments;
15
+ return new Promise(function(resolve, reject) {
16
+ var gen = fn.apply(self, args);
17
+ function _next(value) {
18
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
19
+ }
20
+ function _throw(err) {
21
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
22
+ }
23
+ _next(void 0);
24
+ });
25
+ };
26
+ }
27
+ function _ts_generator(thisArg, body) {
28
+ var f, y, t, g, _ = {
29
+ label: 0,
30
+ sent: function() {
31
+ if (t[0] & 1)
32
+ throw t[1];
33
+ return t[1];
34
+ },
35
+ trys: [],
36
+ ops: []
37
+ };
38
+ return g = {
39
+ next: verb(0),
40
+ throw: verb(1),
41
+ return: verb(2)
42
+ }, typeof Symbol == "function" && (g[Symbol.iterator] = function() {
43
+ return this;
44
+ }), g;
45
+ function verb(n) {
46
+ return function(v) {
47
+ return step([
48
+ n,
49
+ v
50
+ ]);
51
+ };
52
+ }
53
+ function step(op) {
54
+ if (f)
55
+ throw new TypeError("Generator is already executing.");
56
+ for (; _; )
57
+ try {
58
+ if (f = 1, y && (t = op[0] & 2 ? y.return : op[0] ? y.throw || ((t = y.return) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done)
59
+ return t;
60
+ switch (y = 0, t && (op = [
61
+ op[0] & 2,
62
+ t.value
63
+ ]), op[0]) {
64
+ case 0:
65
+ case 1:
66
+ t = op;
67
+ break;
68
+ case 4:
69
+ return _.label++, {
70
+ value: op[1],
71
+ done: !1
72
+ };
73
+ case 5:
74
+ _.label++, y = op[1], op = [
75
+ 0
76
+ ];
77
+ continue;
78
+ case 7:
79
+ op = _.ops.pop(), _.trys.pop();
80
+ continue;
81
+ default:
82
+ if (t = _.trys, !(t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
83
+ _ = 0;
84
+ continue;
85
+ }
86
+ if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
87
+ _.label = op[1];
88
+ break;
89
+ }
90
+ if (op[0] === 6 && _.label < t[1]) {
91
+ _.label = t[1], t = op;
92
+ break;
93
+ }
94
+ if (t && _.label < t[2]) {
95
+ _.label = t[2], _.ops.push(op);
96
+ break;
97
+ }
98
+ t[2] && _.ops.pop(), _.trys.pop();
99
+ continue;
100
+ }
101
+ op = body.call(thisArg, _);
102
+ } catch (e) {
103
+ op = [
104
+ 6,
105
+ e
106
+ ], y = 0;
107
+ } finally {
108
+ f = t = 0;
109
+ }
110
+ if (op[0] & 5)
111
+ throw op[1];
112
+ return {
113
+ value: op[0] ? op[1] : void 0,
114
+ done: !0
115
+ };
116
+ }
117
+ }
118
+ function transformFlow(input) {
119
+ return _transformFlow.apply(this, arguments);
120
+ }
121
+ function _transformFlow() {
122
+ return _transformFlow = _async_to_generator(function(input) {
123
+ return _ts_generator(this, function(_state) {
124
+ switch (_state.label) {
125
+ case 0:
126
+ return [
127
+ 4,
128
+ new Promise(function(res, rej) {
129
+ babel.transform(input, {
130
+ presets: [
131
+ "module:metro-react-native-babel-preset"
132
+ ]
133
+ }, function(err, result) {
134
+ (!result || err) && rej(err || "no res"), res(result.code);
135
+ });
136
+ })
137
+ ];
138
+ case 1:
139
+ return [
140
+ 2,
141
+ _state.sent()
142
+ ];
143
+ }
144
+ });
145
+ }), _transformFlow.apply(this, arguments);
146
+ }
147
+ function createFlowPlugin(opts) {
148
+ if (!(!(opts != null && opts.include) || Array.isArray(opts.include) && opts.include.length === 0)) {
149
+ var filter = createFilter(opts == null ? void 0 : opts.include, opts == null ? void 0 : opts.exclude);
150
+ return {
151
+ name: "@vxrn/vite-flow",
152
+ enforce: "pre",
153
+ transform: function(code, id) {
154
+ return filter(id) ? transformFlow(code) : null;
155
+ }
156
+ };
157
+ }
158
+ }
159
+ export {
160
+ createFlowPlugin as default,
161
+ transformFlow
162
+ };
163
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,6 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/Users/n8/vxrn/packages/vite-flow/src/index.ts"],
4
+ "mappings": "AACA,SAASA,oBAAoB;AAC7B,OAAOC,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAElB,SAAsBC,cAAcC,OAAa;SAA3BD,eAAAA,MAAAA,MAAAA,SAAAA;;SAAAA,iBAAAA;AAAAA,0BAAf,oBAAA,SAA6BC,OAAa;;;;AACxC,iBAAA;;YAAM,IAAIC,QAAgB,SAACC,KAAKC,KAAAA;AACrCL,oBAAMM,UACJJ,OACA;gBACEK,SAAS;kBAAC;;cACZ,GACA,SAACC,KAAUC,QAAAA;AACT,iBAAI,CAACA,UAAUD,QAAKH,IAAIG,OAAO,QAAA,GAC/BJ,IAAIK,OAAQC,IAAI;cAClB,CAAA;YAEJ,CAAA;;;AAXA,iBAAA;;YAAO,OAAA,KAAA;;;;EAYT,CAAA,GAbsBT,eAAAA,MAAAA,MAAAA,SAAAA;;AAoBP,SAAf,iBAAyCU,MAAc;AACrD,MAAI,IAACA,QAAAA,QAAAA,KAAMC,YAAYC,MAAMC,QAAQH,KAAKC,OAAO,KAAKD,KAAKC,QAAQG,WAAW,IAI9E;QAAMC,SAASjB,aAAaY,QAAAA,OAAAA,SAAAA,KAAMC,SAASD,QAAAA,OAAAA,SAAAA,KAAMM,OAAO;AAExD,WAAO;MACLC,MAAM;MACNC,SAAS;MACTb,WAAAA,SAAUI,MAAMU,IAAE;AAChB,eAAIJ,OAAOI,EAAAA,IACFnB,cAAcS,IAAAA,IAEhB;MACT;IACF;;AACF;",
5
+ "names": ["createFilter", "babel", "transformFlow", "input", "Promise", "res", "rej", "transform", "presets", "err", "result", "code", "opts", "include", "Array", "isArray", "length", "filter", "exclude", "name", "enforce", "id"]
6
+ }
package/package.json ADDED
@@ -0,0 +1,41 @@
1
+ {
2
+ "name": "@vxrn/vite-flow",
3
+ "version": "0.1.10",
4
+ "types": "./types/index.d.ts",
5
+ "type": "module",
6
+ "main": "dist/cjs",
7
+ "module": "dist/esm",
8
+ "files": [
9
+ "src",
10
+ "types",
11
+ "dist"
12
+ ],
13
+ "scripts": {
14
+ "build": "tamagui-build",
15
+ "watch": "tamagui-build --watch",
16
+ "lint": "../../node_modules/.bin/biome check src",
17
+ "lint:fix": "../../node_modules/.bin/biome check --apply-unsafe src",
18
+ "clean": "tamagui-build clean",
19
+ "clean:build": "tamagui-build clean:build"
20
+ },
21
+ "exports": {
22
+ "./package.json": "./package.json",
23
+ ".": {
24
+ "types": "./types/index.d.ts",
25
+ "import": "./dist/esm/index.mjs",
26
+ "require": "./dist/cjs/index.js"
27
+ }
28
+ },
29
+ "dependencies": {
30
+ "@babel/core": "^7.21.8",
31
+ "metro-react-native-babel-preset": "^0.77.0"
32
+ },
33
+ "devDependencies": {
34
+ "@biomejs/biome": "^1.6.3",
35
+ "@tamagui/build": "^1.94.4",
36
+ "vite": "^5.2.8"
37
+ },
38
+ "publishConfig": {
39
+ "access": "public"
40
+ }
41
+ }
package/src/index.ts ADDED
@@ -0,0 +1,42 @@
1
+ import type { FilterPattern, PluginOption } from 'vite'
2
+ import { createFilter } from 'vite'
3
+ import babel from '@babel/core'
4
+
5
+ export async function transformFlow(input: string) {
6
+ return await new Promise<string>((res, rej) => {
7
+ babel.transform(
8
+ input,
9
+ {
10
+ presets: ['module:metro-react-native-babel-preset'],
11
+ },
12
+ (err: any, result) => {
13
+ if (!result || err) rej(err || 'no res')
14
+ res(result!.code!)
15
+ }
16
+ )
17
+ })
18
+ }
19
+
20
+ export type Options = {
21
+ include?: FilterPattern
22
+ exclude?: FilterPattern
23
+ }
24
+
25
+ export default function createFlowPlugin(opts?: Options): PluginOption {
26
+ if (!opts?.include || (Array.isArray(opts.include) && opts.include.length === 0)) {
27
+ return
28
+ }
29
+
30
+ const filter = createFilter(opts?.include, opts?.exclude)
31
+
32
+ return {
33
+ name: '@vxrn/vite-flow',
34
+ enforce: 'pre',
35
+ transform(code, id) {
36
+ if (filter(id)) {
37
+ return transformFlow(code)
38
+ }
39
+ return null
40
+ },
41
+ }
42
+ }
@@ -0,0 +1,8 @@
1
+ import type { FilterPattern, PluginOption } from 'vite';
2
+ export declare function transformFlow(input: string): Promise<string>;
3
+ export type Options = {
4
+ include?: FilterPattern;
5
+ exclude?: FilterPattern;
6
+ };
7
+ export default function createFlowPlugin(opts?: Options): PluginOption;
8
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,MAAM,CAAA;AAIvD,wBAAsB,aAAa,CAAC,KAAK,EAAE,MAAM,mBAahD;AAED,MAAM,MAAM,OAAO,GAAG;IACpB,OAAO,CAAC,EAAE,aAAa,CAAA;IACvB,OAAO,CAAC,EAAE,aAAa,CAAA;CACxB,CAAA;AAED,MAAM,CAAC,OAAO,UAAU,gBAAgB,CAAC,IAAI,CAAC,EAAE,OAAO,GAAG,YAAY,CAiBrE"}