UNPKG

marko-widgets

Version:

<h1 align="center"> <!-- Logo --> <br/> marko-widgets@8 <br/>

73 lines (72 loc) 3.04 kB
"use strict"; 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 script_marko_init_exports = {}; __export(script_marko_init_exports, { default: () => script_marko_init_default }); module.exports = __toCommonJS(script_marko_init_exports); var import_compiler = require("@marko/compiler"); var import_babel_utils = require("@marko/babel-utils"); var script_marko_init_default = { MarkoTag(tag) { if (tag.node.name.type !== "StringLiteral" || tag.node.name.value !== "script") return; const { file } = tag.hub; for (const attr of tag.get("attributes")) { if (attr.node.type !== "MarkoAttribute") continue; switch (attr.node.name) { case "marko-init": case "template-helpers": { const { body } = tag.node.body; if (!body.length) { (0, import_babel_utils.diagnosticDeprecate)(attr, { label: `The "${attr.node.name}" attribute on <script> is deprecated. Since this tag is empty it can safely be removed. See https://github.com/marko-js/marko/wiki/Deprecation:-script-template-helpers`, fix() { tag.remove(); } }); return; } const start = (0, import_babel_utils.getStart)(file, body[0]); const end = (0, import_babel_utils.getEnd)(file, body[body.length - 1]); if (start == null || end == null) { (0, import_babel_utils.diagnosticError)(attr, { label: `The "${attr.node.name}" attribute on <script> is deprecated. See https://github.com/marko-js/marko/wiki/Deprecation:-script-template-helpers` }); tag.remove(); return; } const statements = (0, import_babel_utils.parseStatements)( file, file.code.slice(start, end), start, end ); (0, import_babel_utils.diagnosticDeprecate)(attr, { label: `The "${attr.node.name}" attribute on <script> is deprecated. Use the static tag instead. See https://github.com/marko-js/marko/wiki/Deprecation:-script-template-helpers`, fix() { tag.replaceWith(import_compiler.types.markoScriptlet(statements)); } }); return; } } } } };