Skip to content

feat: Added compatibility of MDJS with SSGors with HMR and updated dependencies on lion/lit #462

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
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
462 changes: 400 additions & 62 deletions package-lock.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions packages/mdjs-core/src/mdjsParse.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ import { remove } from 'unist-util-remove';
/** @typedef {import('unist').Node} Node */

export function mdjsParse() {
let jsCode = '';

/**
* @param {Node} tree
* @param {VFileOptions} file
*/
function transformer(tree, file) {
let jsCode = '';

visit(
tree,
'code',
Expand Down
6 changes: 2 additions & 4 deletions packages/mdjs-core/src/mdjsStoryParse.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export function mdjsStoryParse({
previewStoryTag = defaultPreviewStoryTag,
} = {}) {
/** @type {Story[]} */
const stories = [];
let stories = [];
let htmlIndex = 0;

/* eslint-disable no-param-reassign */
Expand Down Expand Up @@ -181,13 +181,11 @@ export function mdjsStoryParse({
async function transformer(tree, file) {
// unifiedjs expects node changes to be made on the given node...
await init;
stories = [];
// @ts-ignore
visit(tree, 'code', nodeCodeVisitor);
// we can only return/modify the tree but stories should not be part of the tree
// so we attach it globally to the file.data
if (!file.data) {
file.data = {};
}
file.data.stories = stories;

return tree;
Expand Down
69 changes: 15 additions & 54 deletions packages/mdjs-preview/index.js
Original file line number Diff line number Diff line change
@@ -1,62 +1,23 @@
export { MdJsPreview } from './src/MdJsPreview.js';

// reexport used lit to ensure users can sync html & rendering
export {
html,
CSSResult,
adoptStyles,
css,
getCompatibleStyle,
supportsAdoptingStyleSheets,
unsafeCSS,
UpdatingElement,
notEqual,
ReactiveElement,
svg,
noChange,
nothing,
render,
LitElement,
defaultConverter,
} from 'lit';
export * from 'lit';

export {
customElement,
property,
state,
eventOptions,
query,
queryAll,
queryAsync,
queryAssignedNodes,
} from 'lit/decorators.js';
export * from 'lit/decorators.js';

export { directive, Directive } from 'lit/directive.js';
export * from 'lit/directive.js';

export { AsyncDirective } from 'lit/async-directive.js';
export * from 'lit/async-directive.js';

export {
isPrimitive,
TemplateResultType,
isTemplateResult,
isDirectiveResult,
getDirectiveClass,
isSingleExpression,
insertPart,
setChildPartValue,
setCommittedValue,
getCommittedValue,
removePart,
clearPart,
} from 'lit/directive-helpers.js';
export * from 'lit/directive-helpers.js';

export { asyncAppend } from 'lit/directives/async-append.js';
export { asyncReplace } from 'lit/directives/async-replace.js';
export { cache } from 'lit/directives/cache.js';
export { classMap } from 'lit/directives/class-map.js';
export { guard } from 'lit/directives/guard.js';
export { ifDefined } from 'lit/directives/if-defined.js';
export { repeat } from 'lit/directives/repeat.js';
export { styleMap } from 'lit/directives/style-map.js';
export { unsafeHTML } from 'lit/directives/unsafe-html.js';
export { until } from 'lit/directives/until.js';
export * from 'lit/directives/async-append.js';
export * from 'lit/directives/async-replace.js';
export * from 'lit/directives/cache.js';
export * from 'lit/directives/class-map.js';
export * from 'lit/directives/guard.js';
export * from 'lit/directives/if-defined.js';
export * from 'lit/directives/repeat.js';
export * from 'lit/directives/style-map.js';
export * from 'lit/directives/unsafe-html.js';
export * from 'lit/directives/until.js';
6 changes: 3 additions & 3 deletions packages/mdjs-preview/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@
"src"
],
"dependencies": {
"@lion/accordion": "^0.9.0",
"@open-wc/scoped-elements": "^2.0.0",
"lit": "^2.3.0"
"@lion/ui": "^0.11.2",
"@open-wc/scoped-elements": "^3.0.5",
"lit": "^3.2.1"
},
"types": "dist-types/index.d.ts"
}
4 changes: 2 additions & 2 deletions packages/mdjs-preview/src/MdJsPreview.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { LitElement, html, css, nothing, render } from 'lit';
import { ScopedElementsMixin } from '@open-wc/scoped-elements';
import { LionAccordion } from '@lion/accordion';
import { ScopedElementsMixin } from '@open-wc/scoped-elements/lit-element.js';
import { LionAccordion } from '@lion/ui/accordion';

import {
subscribe,
Expand Down
69 changes: 15 additions & 54 deletions packages/mdjs-story/index.js
Original file line number Diff line number Diff line change
@@ -1,62 +1,23 @@
export { MdJsStory } from './src/MdJsStory.js';

// reexport used lit to ensure users can sync html & rendering
export {
html,
CSSResult,
adoptStyles,
css,
getCompatibleStyle,
supportsAdoptingStyleSheets,
unsafeCSS,
UpdatingElement,
notEqual,
ReactiveElement,
svg,
noChange,
nothing,
render,
LitElement,
defaultConverter,
} from 'lit';
export * from 'lit';

export {
customElement,
property,
state,
eventOptions,
query,
queryAll,
queryAsync,
queryAssignedNodes,
} from 'lit/decorators.js';
export * from 'lit/decorators.js';

export { directive, Directive } from 'lit/directive.js';
export * from 'lit/directive.js';

export { AsyncDirective } from 'lit/async-directive.js';
export * from 'lit/async-directive.js';

export {
isPrimitive,
TemplateResultType,
isTemplateResult,
isDirectiveResult,
getDirectiveClass,
isSingleExpression,
insertPart,
setChildPartValue,
setCommittedValue,
getCommittedValue,
removePart,
clearPart,
} from 'lit/directive-helpers.js';
export * from 'lit/directive-helpers.js';

export { asyncAppend } from 'lit/directives/async-append.js';
export { asyncReplace } from 'lit/directives/async-replace.js';
export { cache } from 'lit/directives/cache.js';
export { classMap } from 'lit/directives/class-map.js';
export { guard } from 'lit/directives/guard.js';
export { ifDefined } from 'lit/directives/if-defined.js';
export { repeat } from 'lit/directives/repeat.js';
export { styleMap } from 'lit/directives/style-map.js';
export { unsafeHTML } from 'lit/directives/unsafe-html.js';
export { until } from 'lit/directives/until.js';
export * from 'lit/directives/async-append.js';
export * from 'lit/directives/async-replace.js';
export * from 'lit/directives/cache.js';
export * from 'lit/directives/class-map.js';
export * from 'lit/directives/guard.js';
export * from 'lit/directives/if-defined.js';
export * from 'lit/directives/repeat.js';
export * from 'lit/directives/style-map.js';
export * from 'lit/directives/unsafe-html.js';
export * from 'lit/directives/until.js';
2 changes: 1 addition & 1 deletion packages/mdjs-story/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"src"
],
"dependencies": {
"lit": "^2.3.0"
"lit": "^3.2.1"
},
"types": "dist-types/index.d.ts"
}
Loading