one
Version:
One is a new React Framework that makes Vite serve both native and web.
61 lines (59 loc) • 2.38 kB
JavaScript
;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
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 __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
value: true
}), mod);
var useDomPlugin_exports = {};
__export(useDomPlugin_exports, {
useDOMPlugin: () => useDOMPlugin
});
module.exports = __toCommonJS(useDomPlugin_exports);
var import_oxc_parser = require("oxc-parser");
function useDOMPlugin() {
return {
name: "one-vite-dom-plugin",
async transform(code, id, options) {
if (!code.includes("use dom")) {
return;
}
try {
var parsed = (0, import_oxc_parser.parseSync)(id, code);
var hasUseDom = false;
for (var i = 0; i < parsed.program.body.length; ++i) {
var item = parsed.program.body[i];
if (item.type === "ExpressionStatement") {
var _item_expression, _item_expression1, _item_expression2, _item_expression3;
if (item.directive === "use dom" || ((_item_expression = item.expression) === null || _item_expression === void 0 ? void 0 : _item_expression.type) === "Literal" && ((_item_expression1 = item.expression) === null || _item_expression1 === void 0 ? void 0 : _item_expression1.value) === "use dom" || ((_item_expression2 = item.expression) === null || _item_expression2 === void 0 ? void 0 : _item_expression2.type) === "StringLiteral" && ((_item_expression3 = item.expression) === null || _item_expression3 === void 0 ? void 0 : _item_expression3.value) === "use dom") {
hasUseDom = true;
break;
}
}
}
if (!hasUseDom) {
return;
}
} catch (unused) {
return;
}
}
};
}
//# sourceMappingURL=useDomPlugin.native.js.map