Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
363 changes: 223 additions & 140 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion packages/cli/src/lib/live-server/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import open from "opn";
import es from "event-stream";
import os from "os";
import chokidar from "chokidar";
import fsUtil from "@markbind/core/src/utils/fsUtil";
import * as fsUtil from "@markbind/core/src/utils/fsUtil";
import "colors";
import { dirname } from 'path';
import { fileURLToPath } from 'url';
Expand Down
33 changes: 33 additions & 0 deletions packages/core/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
module.exports = {
extends: ['../../.eslintrc.js'],
overrides: [
{
files: ['./**/*.ts'],
rules: {
// Override airbnb import/extensions rule to require extension for non-package import
// ESM relative imports require file extensions: https://nodejs.org/api/esm.html#esm_import_specifiers
// This conflicts with the airbnb lint rule:
// https://github.com/airbnb/javascript?tab=readme-ov-file#modules--import-extensions
// Additional discussion on the issue: https://github.com/airbnb/javascript/issues/2030
'import/extensions': [
'error',
'ignorePackages',
{
js: 'always',
ts: 'always',
mjs: 'always',
},
],
// Override lodash import-scope rule to turn it off and allow full import
// lodash currently does not have a mechanism to use its optimized imports
// along with type definitions: https://github.com/lodash/lodash/issues/3192
// Additional discussion here: https://github.com/MarkBind/markbind/issues/2615
'lodash/import-scope': 0,
// These rules are annoying and should go away
// (To be updated soon in lodash removal)
'lodash/prop-shorthand': 0,
'lodash/prefer-lodash-chain': 0,
},
},
],
};
10 changes: 10 additions & 0 deletions packages/core/babel.config.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
module.exports = {
presets: [
'@babel/preset-typescript',
['@babel/preset-env', { targets: { node: 'current' }, modules: 'cjs' }],
],
plugins: [
'@babel/plugin-syntax-import-attributes',
['babel-plugin-transform-import-meta', { module: 'ES6' }]
],
};
4 changes: 2 additions & 2 deletions packages/core/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Site } from './src/Site';
import { Template } from './src/Site/template';
import { Site } from './src/Site/index.js';
import { Template } from './src/Site/template.js';

export { Site, Template };
11 changes: 11 additions & 0 deletions packages/core/jest.config.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
const config = {
verbose: true,
moduleNameMapper: {
'^(\\.{1,2}/.*)\\.js$': '$1',
},
testEnvironment: 'node',
collectCoverage: true,
testMatch: ['**/*.test.ts'],
};

module.exports = config;
8 changes: 0 additions & 8 deletions packages/core/jest.config.js

This file was deleted.

11 changes: 10 additions & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"name": "@markbind/core",
"version": "6.3.1",
"type": "module",
"description": "MarkBind core module",
"keywords": [
"mark",
Expand Down Expand Up @@ -98,6 +99,7 @@
"winston": "^3.19.0"
},
"devDependencies": {
"@babel/cli": "^7.27.0",
"@jest/globals": "^29.5.0",
"@types/cheerio": "^0.22.31",
"@types/domhandler": "^2.4.2",
Expand All @@ -109,13 +111,20 @@
"@types/katex": "^0.16.0",
"@types/lodash": "4.14.181",
"@types/markdown-it": "^12.2.3",
"@types/markdown-it-attrs": "^4.1.3",
"@types/markdown-it-emoji": "^3.0.1",
"@types/nunjucks": "^3.2.1",
"@types/path-is-inside": "^1.0.0",
"@types/primer__octicons": "^17.11.0",
"@types/url-parse": "^1.4.8",
"@types/uuid": "^9.0.0",
"jest": "^29.7.0",
"memfs": "^3.0.1",
"ts-jest": "^29.4.6"
"@babel/core": "^7.29.0",
"@babel/plugin-transform-dynamic-import": "^7.27.1",
"@babel/preset-env": "^7.29.0",
"@babel/preset-typescript": "^7.28.5",
"babel-jest": "^29.7.0",
"babel-plugin-transform-import-meta": "^2.3.3"
}
}
10 changes: 5 additions & 5 deletions packages/core/src/External/External.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import fs from 'fs-extra';
import path from 'path';
import * as jsBeautify from 'js-beautify';
import { PageSources } from '../Page/PageSources';
import { NodeProcessor } from '../html/NodeProcessor';
import * as fsUtil from '../utils/fsUtil';
import type { ExternalManager, ExternalManagerConfig } from './ExternalManager';
import jsBeautify from 'js-beautify';
import { PageSources } from '../Page/PageSources.js';
import { NodeProcessor } from '../html/NodeProcessor.js';
import * as fsUtil from '../utils/fsUtil.js';
import type { ExternalManager, ExternalManagerConfig } from './ExternalManager.js';

const htmlBeautify = jsBeautify.html;

Expand Down
22 changes: 9 additions & 13 deletions packages/core/src/External/ExternalManager.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
import path from 'path';
import uniqBy from 'lodash/uniqBy';
import { External } from './External';
import * as fsUtil from '../utils/fsUtil';
import * as urlUtil from '../utils/urlUtil';
import type { DynamicSrc } from '../Page/PageSources';
import type { VariableProcessor } from '../variables/VariableProcessor';
import type { SiteLinkManager } from '../html/SiteLinkManager';
import type { PluginManager } from '../plugins/PluginManager';
import { NodeProcessorConfig } from '../html/NodeProcessor';

const _ = {
uniqBy,
};
import _ from 'lodash';
import { External } from './External.js';
import * as fsUtil from '../utils/fsUtil.js';
import * as urlUtil from '../utils/urlUtil.js';
import type { DynamicSrc } from '../Page/PageSources.js';
import type { VariableProcessor } from '../variables/VariableProcessor.js';
import type { SiteLinkManager } from '../html/SiteLinkManager.js';
import type { PluginManager } from '../plugins/PluginManager.js';
import { NodeProcessorConfig } from '../html/NodeProcessor.js';

export type ExternalManagerConfig = NodeProcessorConfig & {
variableProcessor: VariableProcessor,
Expand Down
8 changes: 4 additions & 4 deletions packages/core/src/Layout/Layout.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { v4 as uuidv4 } from 'uuid';
import { PageSources } from '../Page/PageSources';
import { NodeProcessor } from '../html/NodeProcessor';
import * as logger from '../utils/logger';
import { ExternalManager, ExternalManagerConfig } from '../External/ExternalManager';
import { PageSources } from '../Page/PageSources.js';
import { NodeProcessor } from '../html/NodeProcessor.js';
import * as logger from '../utils/logger.js';
import { ExternalManager, ExternalManagerConfig } from '../External/ExternalManager.js';

const LAYOUT_PAGE_BODY_VARIABLE = 'content';

Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/Layout/LayoutManager.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import fs from 'fs-extra';
import path from 'path';
import { Layout, LayoutConfig, PageNjkAssets } from './Layout';
import * as logger from '../utils/logger';
import { Layout, LayoutConfig, PageNjkAssets } from './Layout.js';
import * as logger from '../utils/logger.js';

const FRONTMATTER_NONE_ATTR = 'none';

Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/Layout/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Layout } from './Layout';
import { LayoutManager } from './LayoutManager';
import { Layout } from './Layout.js';
import { LayoutManager } from './LayoutManager.js';

export const LAYOUT_DEFAULT_NAME = 'default.md';
export const LAYOUT_FOLDER_PATH = '_markbind/layouts';
Expand Down
8 changes: 4 additions & 4 deletions packages/core/src/Page/PageConfig.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import type { Template } from 'nunjucks';
import type { SiteLinkManager } from '../html/SiteLinkManager';
import type { PluginManager } from '../plugins/PluginManager';
import type { SiteLinkManager } from '../html/SiteLinkManager.js';
import type { PluginManager } from '../plugins/PluginManager.js';

import { VariableProcessor } from '../variables/VariableProcessor';
import { LayoutManager } from '../Layout';
import { VariableProcessor } from '../variables/VariableProcessor.js';
import { LayoutManager } from '../Layout/index.js';

export interface PageAssets {
bootstrap: string;
Expand Down
4 changes: 1 addition & 3 deletions packages/core/src/Page/PageSources.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import clone from 'lodash/clone';

const _ = { clone };
import _ from 'lodash';

interface Src {
to: string,
Expand Down
14 changes: 7 additions & 7 deletions packages/core/src/Page/PageVueServerRenderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,17 @@ import type { SFCTemplateCompileOptions, CompilerOptions } from 'vue/compiler-sf

import path from 'path';
import fs from 'fs-extra';
import * as logger from '../utils/logger';
import type { PageConfig, PageAssets } from './PageConfig';
import type { Page } from '.';
import { PluginManager } from '../plugins/PluginManager';
import vueCommonAppFactory from '@markbind/core-web/dist/js/vueCommonAppFactory.min.js';

/* eslint-enable import/no-import-module-exports */

let bundle = require('@markbind/core-web/dist/js/vueCommonAppFactory.min');
import * as logger from '../utils/logger.js';
import type { PageConfig, PageAssets } from './PageConfig.js';
import type { Page } from './index.js';
import { PluginManager } from '../plugins/PluginManager.js';

let customElementTagsCache: Set<string> | undefined;

let bundle = { ...vueCommonAppFactory };

/**
* Retrieves the set of tags that should be treated as custom elements by the Vue compiler.
* These are tags defined in plugins with isCustomElement: true.
Expand Down
43 changes: 21 additions & 22 deletions packages/core/src/Page/index.ts
Original file line number Diff line number Diff line change
@@ -1,34 +1,33 @@
import cheerio from 'cheerio';
import fs from 'fs-extra';
import path from 'path';
import { html as htmlBeautify } from 'js-beautify';
import jsPkg from 'js-beautify';

import cloneDeep from 'lodash/cloneDeep';
import isObject from 'lodash/isObject';
import isArray from 'lodash/isArray';
import { pageVueServerRenderer } from './PageVueServerRenderer';
import _ from 'lodash';
import { pageVueServerRenderer } from './PageVueServerRenderer.js';

import CyclicReferenceError from '../errors/CyclicReferenceError';
import { PageSources } from './PageSources';
import { NodeProcessor, NodeProcessorConfig } from '../html/NodeProcessor';
import { CyclicReferenceError } from '../errors/CyclicReferenceError.js';
import { PageSources } from './PageSources.js';
import { NodeProcessor, NodeProcessorConfig } from '../html/NodeProcessor.js';

import * as logger from '../utils/logger';
import type { PageAssets, PageConfig } from './PageConfig';
import type { SiteConfig } from '../Site/SiteConfig';
import type { FrontMatter } from '../plugins/Plugin';
import type { ExternalManager } from '../External/ExternalManager';
import { MbNode } from '../utils/node';
import { checkForVueHydrationViolation } from '../utils/htmlValidationUtil';
import * as logger from '../utils/logger.js';
import type { PageAssets, PageConfig } from './PageConfig.js';
import type { SiteConfig } from '../Site/SiteConfig.js';
import type { FrontMatter } from '../plugins/Plugin.js';
import type { ExternalManager } from '../External/ExternalManager.js';
import { MbNode } from '../utils/node.js';
import { checkForVueHydrationViolation } from '../utils/htmlValidationUtil.js';

import { LAYOUT_DEFAULT_NAME } from '../Layout';
import { LAYOUT_DEFAULT_NAME } from '../Layout/index.js';
import { instance as LockManager } from '../utils/LockManager.js';
import packageJson from '../../package.json' with { type: 'json' };

require('../patches/htmlparser2');
import '../patches/htmlparser2.js';

const _ = { cloneDeep, isObject, isArray };

const LockManager = require('../utils/LockManager');

const PACKAGE_VERSION = require('../../package.json').version;
// Destructure for CJS interoperability.
// Using ESM-style import does not work due to the fact that jsPkg is exported as a CJS module.
const { html: htmlBeautify } = jsPkg;
const PACKAGE_VERSION = packageJson.version;

const TITLE_PREFIX_SEPARATOR = ' - ';
const TITLE_SUFFIX_SEPARATOR = ' - ';
Expand Down
17 changes: 12 additions & 5 deletions packages/core/src/Site/SiteAssetsManager.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
import fs from 'fs-extra';
import ignore, { Ignore } from 'ignore';
import { type Ignore } from 'ignore';
import path from 'path';
import walkSync from 'walk-sync';

import { SiteConfig, SiteConfigStyle } from './SiteConfig';
import { delay } from '../utils/delay';
import * as logger from '../utils/logger';
import { TEMPLATE_SITE_ASSET_FOLDER_NAME, _ } from './constants';
import { createRequire } from 'module';
import { SiteConfig, SiteConfigStyle } from './SiteConfig.js';
import { delay } from '../utils/delay.js';
import * as logger from '../utils/logger.js';
import { TEMPLATE_SITE_ASSET_FOLDER_NAME, _ } from './constants.js';

const require = createRequire(import.meta.url);
// `ignore` is a CJS package with no `exports` field. Under NodeNext, TS resolves
// the default import as the module namespace (not callable). Using require() returns
// module.exports directly, which is the callable factory function
const ignore: (opts?: { ignorecase?: boolean }) => Ignore = require('ignore');

function getBootswatchThemePath(theme: string) {
return require.resolve(`bootswatch/dist/${theme}/bootstrap.min.css`);
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/Site/SiteConfig.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import fs from 'fs-extra';
import path from 'path';
import { FrontMatter } from '../plugins/Plugin';
import { FrontMatter } from '../plugins/Plugin.js';

const HEADING_INDEXING_LEVEL_DEFAULT = 3;

Expand Down
10 changes: 5 additions & 5 deletions packages/core/src/Site/SiteDeployManager.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import fs from 'fs-extra';
import path from 'path';
import simpleGit, { SimpleGit } from 'simple-git';
import { simpleGit, SimpleGit } from 'simple-git';
import ghpages, { PublishOptions } from 'gh-pages';
import * as gitUtil from '../utils/git';
import * as logger from '../utils/logger';
import { _ } from './constants';
import { SiteConfig } from './SiteConfig';
import * as gitUtil from '../utils/git.js';
import * as logger from '../utils/logger.js';
import { _ } from './constants.js';
import { SiteConfig } from './SiteConfig.js';

export type DeployOptions = {
branch: string,
Expand Down
Loading
Loading