Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

codehike

Package Overview
Dependencies
Maintainers
1
Versions
39
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

codehike - npm Package Compare versions

Comparing version 1.0.0-alpha.4 to 1.0.0-alpha.5

dist/1.remark-list-to-section.d.ts

33

dist/5.recma-export-hike.js

@@ -11,3 +11,3 @@ import { SKIP, visit } from "estree-util-visit";

const _createMdxContent = body.find(({ type, id }) => type === "FunctionDeclaration" && (id === null || id === void 0 ? void 0 : id.name) === "_createMdxContent");
const _createMdxContentReturn = find(_createMdxContent, (node) => node.type === "ReturnStatement");
const [_createMdxContentReturn] = find(_createMdxContent, (node) => node.type === "ReturnStatement");
// stop if _createMdxContent is returning an element

@@ -33,8 +33,8 @@ // with the hike attribute

// change getHike return to hike object
const returnStatement = find(getHike, (node) => node.type === "ReturnStatement");
const hikeAttribute = find(returnStatement, (node) => { var _a; return node.type === "JSXAttribute" && ((_a = node === null || node === void 0 ? void 0 : node.name) === null || _a === void 0 ? void 0 : _a.name) === "hike"; });
const [returnStatement] = find(getHike, (node) => node.type === "ReturnStatement");
const [hikeAttribute] = find(returnStatement, (node) => { var _a; return node.type === "JSXAttribute" && ((_a = node === null || node === void 0 ? void 0 : node.name) === null || _a === void 0 ? void 0 : _a.name) === "hike"; });
const hikeObject = hikeAttribute.value.expression;
returnStatement.argument = hikeObject;
// change _createMdxContent attribute to getHike()
const _createMdxHikeAttribute = find(_createMdxContentReturn, (node) => { var _a; return node.type === "JSXAttribute" && ((_a = node === null || node === void 0 ? void 0 : node.name) === null || _a === void 0 ? void 0 : _a.name) === "hike"; });
const [_createMdxHikeAttribute] = find(_createMdxContentReturn, (node) => { var _a; return node.type === "JSXAttribute" && ((_a = node === null || node === void 0 ? void 0 : node.name) === null || _a === void 0 ? void 0 : _a.name) === "hike"; });
_createMdxHikeAttribute.value.expression = {

@@ -46,8 +46,27 @@ type: "CallExpression",

};
// remove `if (!Hike) _missingMdxReference("Hike", true)`
const [missingMdxReference, parent] = find(getHike, (node) => {
var _a, _b, _c, _d;
return node.type === "IfStatement" &&
((_a = node.test) === null || _a === void 0 ? void 0 : _a.type) === "UnaryExpression" &&
((_b = node.test) === null || _b === void 0 ? void 0 : _b.operator) === "!" &&
((_d = (_c = node.test) === null || _c === void 0 ? void 0 : _c.argument) === null || _d === void 0 ? void 0 : _d.name) === "Hike";
});
if (missingMdxReference) {
parent.body = parent.body.filter((node) => node !== missingMdxReference);
}
// add default props: getHike(props = {})
getHike.declaration.params = [
{
type: "AssignmentPattern",
left: { type: "Identifier", name: "props" },
right: { type: "ObjectExpression", properties: [] },
},
];
}
function find(node, predicate) {
let result;
visit(node, (node) => {
let result = [];
visit(node, (node, key, index, ancestors) => {
if (predicate(node)) {
result = node;
result = [node, ...ancestors.slice().reverse()];
return SKIP;

@@ -54,0 +73,0 @@ }

// this adds the jsx node types to Root
import "mdast-util-mdx-jsx";
import { isHikeHeading, listToTree } from "./1.remark-list-to-tree.js";
import { hydrateTree, parseCode } from "./2.hydrate-tree.js";
import { treeToAttribute } from "./3.remark-tree-to-attribute.js";
import { SKIP, visit } from "estree-util-visit";

@@ -10,2 +7,4 @@ import { moveChildrenToHikeProp } from "./4.recma-move-children.js";

import { getObjectAttribute } from "./estree.js";
import { listToSection, isHikeHeading, parseCode, } from "./1.remark-list-to-section.js";
import { sectionToAttribute } from "./2.remark-section-to-attribute.js";
export const remarkCodeHike = (config) => {

@@ -16,3 +15,3 @@ return async (root, file) => {

// let's wrap everything in a <Hike>
if (root.children.some((node) => isHikeHeading(node, "!"))) {
if (root.children.some(isHikeHeading)) {
tree.children = [

@@ -77,6 +76,4 @@ {

var _a;
const prefix = "!";
const tree = listToTree(node, prefix);
const hydratedTree = hydrateTree(tree, mdxPath);
const { children, attributes } = treeToAttribute(hydratedTree);
const section = listToSection(node, mdxPath);
const { children, attributes } = sectionToAttribute(section);
node.children = children;

@@ -83,0 +80,0 @@ node.attributes.push(...attributes);

{
"name": "codehike",
"version": "1.0.0-alpha.4",
"version": "1.0.0-alpha.5",
"type": "module",

@@ -5,0 +5,0 @@ "sideEffects": false,

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc