Compare commits

...

22 Commits

Author SHA1 Message Date
github-actions[bot]
4ac62106a2 Version Packages 2022-03-28 15:10:10 +02:00
Thomas Allmer
c2c9ecd39a feat(rocket-search): update lion dependencies 2022-03-28 15:08:25 +02:00
github-actions[bot]
c009801164 Version Packages 2022-03-08 14:41:55 +01:00
Thomas Allmer
60310ab3dd fix: improve performance by loading sax-wasm only once 2022-03-08 14:37:31 +01:00
github-actions[bot]
db03f69210 Version Packages 2022-03-07 19:27:03 +01:00
Thomas Allmer
e6c3d274cf feat(mdjs-core): support js client as an alias to js script 2022-03-07 19:19:24 +01:00
github-actions[bot]
f9014c15a6 Version Packages 2022-03-07 18:42:20 +01:00
Thomas Allmer
7e277cd88f feat(plugins-manager): support a wrapPlugin property for adding 2022-03-07 18:35:41 +01:00
Thomas Allmer
bc6106381c chore: lock file maintainance 2022-03-06 21:05:23 +01:00
dependabot[bot]
00bf3882f6 chore(deps-dev): bump node-fetch from 2.6.1 to 2.6.7
Bumps [node-fetch](https://github.com/node-fetch/node-fetch) from 2.6.1 to 2.6.7.
- [Release notes](https://github.com/node-fetch/node-fetch/releases)
- [Commits](https://github.com/node-fetch/node-fetch/compare/v2.6.1...v2.6.7)

---
updated-dependencies:
- dependency-name: node-fetch
  dependency-type: direct:development
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-03-06 20:51:33 +01:00
dependabot[bot]
543e297c5b chore(deps): bump pathval from 1.1.0 to 1.1.1
Bumps [pathval](https://github.com/chaijs/pathval) from 1.1.0 to 1.1.1.
- [Release notes](https://github.com/chaijs/pathval/releases)
- [Changelog](https://github.com/chaijs/pathval/blob/master/CHANGELOG.md)
- [Commits](https://github.com/chaijs/pathval/compare/v1.1.0...v1.1.1)

---
updated-dependencies:
- dependency-name: pathval
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-03-06 20:50:48 +01:00
dependabot[bot]
70b0ce8e1c chore(deps): bump simple-get from 3.1.0 to 3.1.1
Bumps [simple-get](https://github.com/feross/simple-get) from 3.1.0 to 3.1.1.
- [Release notes](https://github.com/feross/simple-get/releases)
- [Commits](https://github.com/feross/simple-get/compare/v3.1.0...v3.1.1)

---
updated-dependencies:
- dependency-name: simple-get
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-03-06 20:50:31 +01:00
github-actions[bot]
9f8785a885 Version Packages 2022-03-06 20:46:44 +01:00
Thomas Allmer
62637a829e chore: add changeset 2022-03-06 20:44:17 +01:00
Westbrook Johnson
81c4d7bf3c Use a more recently published prism converter for rehype 2022-03-06 20:44:17 +01:00
github-actions[bot]
08181194e2 Version Packages 2022-01-31 13:45:06 +01:00
Thomas Allmer
97cb38ccb8 fix(mdjs-core): add missing slash dependency 2022-01-31 13:43:36 +01:00
github-actions[bot]
26d3de1444 Version Packages 2022-01-30 11:48:03 +01:00
Thomas Allmer
1f141058c1 fix(drawer): add export map with /define side effect import 2022-01-30 11:45:47 +01:00
github-actions[bot]
08574c9b31 Version Packages 2022-01-05 09:34:58 +01:00
gvangeest
e81b77f236 fix(mdjs-preview): separate preview and viewer theme styling 2022-01-03 18:36:09 +01:00
qa46hx
456b8e78f0 fix(mdjs-preview): add css variable to border-color of viewer 2021-12-05 13:30:28 +01:00
34 changed files with 500 additions and 689 deletions

View File

@@ -8,25 +8,25 @@ First, create a fork of the [modernweb-dev/rocket](https://github.com/modernweb-
Next, clone our repository onto your computer. Next, clone our repository onto your computer.
```sh ```shell
git clone git@github.com:modernweb-dev/rocket.git git clone git@github.com:modernweb-dev/rocket.git
``` ```
Once cloning is complete, change directory to the repository. Once cloning is complete, change directory to the repository.
```sh ```shell
cd rocket cd rocket
``` ```
Now add your fork as a remote (replacing YOUR_USERNAME with your GitHub username). Now add your fork as a remote (replacing YOUR_USERNAME with your GitHub username).
```sh ```shell
git remote add fork git@github.com:<YOUR_USERNAME>/rocket.git git remote add fork git@github.com:<YOUR_USERNAME>/rocket.git
``` ```
Create a new local branch. Create a new local branch.
```sh ```shell
git checkout -b my-awesome-fix git checkout -b my-awesome-fix
``` ```
@@ -34,7 +34,7 @@ git checkout -b my-awesome-fix
Now that you have cloned the repository, ensure you have [yarn](https://classic.yarnpkg.com/lang/en/) installed, then run the following commands to set up the development environment. Now that you have cloned the repository, ensure you have [yarn](https://classic.yarnpkg.com/lang/en/) installed, then run the following commands to set up the development environment.
```sh ```shell
yarn install yarn install
``` ```
@@ -69,7 +69,7 @@ This documents your intent to release, and allows you to specify a message that
Run Run
```sh ```shell
yarn changeset yarn changeset
``` ```
@@ -92,7 +92,7 @@ Exceptions:
Commit messages must follow the [conventional commit format](https://www.conventionalcommits.org/en/v1.0.0/) Commit messages must follow the [conventional commit format](https://www.conventionalcommits.org/en/v1.0.0/)
Modern-web uses package name as scope. So for example if you fix a _terrible bug_ in the package `@web/test-runner`, the commit message should look like this: Modern-web uses package name as scope. So for example if you fix a _terrible bug_ in the package `@web/test-runner`, the commit message should look like this:
```sh ```shell
fix(test-runner): fix terrible bug fix(test-runner): fix terrible bug
``` ```
@@ -100,7 +100,7 @@ fix(test-runner): fix terrible bug
Now it's time to push your branch that contains your committed changes to your fork. Now it's time to push your branch that contains your committed changes to your fork.
```sh ```shell
git push -u fork my-awesome-fix git push -u fork my-awesome-fix
``` ```

View File

@@ -140,7 +140,7 @@ The features so far are:
It checks your final HTML output so you need to execute it after your Static Site Generator. It checks your final HTML output so you need to execute it after your Static Site Generator.
``` ```shell
npx check-html-links _site npx check-html-links _site
``` ```

View File

@@ -4,7 +4,7 @@ Use mdjs in your Eleventy site.
## Setup ## Setup
``` ```shell
npm install @rocket/eleventy-plugin-mdjs npm install @rocket/eleventy-plugin-mdjs
``` ```

View File

@@ -22,7 +22,7 @@ Read the [Introducing Check HTMl Links - no more bad links](../../blog/introduci
## Installation ## Installation
``` ```shell
npm i -D check-html-links npm i -D check-html-links
``` ```

View File

@@ -112,16 +112,13 @@ addPlugin(MyClass, { otherProp: 'new name' }); // ts error
Many plugin systems require you to either execute a plugin function like in `rollup`. Many plugin systems require you to either execute a plugin function like in `rollup`.
<!-- prettier-ignore-start -->
```js ```js
import json from '@rollup/plugin-json'; import json from '@rollup/plugin-json';
/** @type {import('rocket/cli').RocketCliConfig} */ export default /** @type {import('rocket/cli').RocketCliConfig} */ ({
export default ({
plugins: [json({ preferConst: true })], plugins: [json({ preferConst: true })],
}); });
``` ```
<!-- prettier-ignore-end -->
or add it in a special way like in `eleventy` or add it in a special way like in `eleventy`
@@ -254,6 +251,18 @@ addPlugin(myPlugin, { myFlag: true }); // ts ok
addPlugin(myPlugin, { notExisting: true }); // ts error addPlugin(myPlugin, { notExisting: true }); // ts error
``` ```
Note: There is a "hidden" feature in addPlugin that if you attach a `wrapPlugin` property to the returning function it will call `wrapPlugin` on the plugin before adding it.
```js
// example auto wrap rollup plugins for @web/dev-server
import { fromRollup } from '@web/dev-server-rollup';
const userSetupFunctions = [addPlugin(json)].map(mod => {
mod.wrapPlugin = fromRollup;
return mod;
});
```
## Adjusting Plugin Options ## Adjusting Plugin Options
Adjusting options means to either Adjusting options means to either

View File

@@ -23,7 +23,7 @@ Will be ordered as `First`, `Second`,
Internally `# Foo >> Bar >> Baz ||20` gets converted to. Internally `# Foo >> Bar >> Baz ||20` gets converted to.
``` ```yml
--- ---
title: Bar: Baz title: Bar: Baz
eleventyNavigation: eleventyNavigation:

View File

@@ -47,7 +47,7 @@
"update-package-configs": "node scripts/update-package-configs.mjs && yarn format" "update-package-configs": "node scripts/update-package-configs.mjs && yarn format"
}, },
"devDependencies": { "devDependencies": {
"@changesets/cli": "^2.12.0", "@changesets/cli": "^2.20.0",
"@custom-elements-manifest/analyzer": "^0.4.12", "@custom-elements-manifest/analyzer": "^0.4.12",
"@open-wc/testing": "^3.0.0-next.1", "@open-wc/testing": "^3.0.0-next.1",
"@rollup/plugin-commonjs": "^17.0.0", "@rollup/plugin-commonjs": "^17.0.0",
@@ -75,7 +75,7 @@
"husky": "^4.3.7", "husky": "^4.3.7",
"lint-staged": "^10.5.3", "lint-staged": "^10.5.3",
"mocha": "^8.2.1", "mocha": "^8.2.1",
"node-fetch": "^2.6.1", "node-fetch": "^2.6.7",
"npm-run-all": "^4.1.5", "npm-run-all": "^4.1.5",
"onchange": "^7.1.0", "onchange": "^7.1.0",
"prettier": "^2.2.1", "prettier": "^2.2.1",
@@ -84,8 +84,6 @@
"puppeteer": "^9.0.0", "puppeteer": "^9.0.0",
"remark-emoji": "^2.1.0", "remark-emoji": "^2.1.0",
"rimraf": "^3.0.2", "rimraf": "^3.0.2",
"rocket-preset-code-tabs": "^0.2.6",
"rocket-preset-custom-elements-manifest": "^0.1.7",
"rollup": "^2.36.1", "rollup": "^2.36.1",
"rollup-plugin-terser": "^7.0.2", "rollup-plugin-terser": "^7.0.2",
"sinon": "^9.2.3", "sinon": "^9.2.3",

View File

@@ -4,13 +4,13 @@ A fast checker for broken links/references in HTML.
## Installation ## Installation
``` ```shell
npm i -D check-html-links npm i -D check-html-links
``` ```
## Usage ## Usage
``` ```bash
npx check-html-links _site npx check-html-links _site
``` ```

View File

@@ -1,5 +1,13 @@
# @rocket/cli # @rocket/cli
## 0.10.2
### Patch Changes
- 60310ab: Improve performance by initializing sax-wasm only once even when it is running in parallel
- Updated dependencies [60310ab]
- @rocket/eleventy-rocket-nav@0.3.1
## 0.10.1 ## 0.10.1
### Patch Changes ### Patch Changes

View File

@@ -1,6 +1,6 @@
{ {
"name": "@rocket/cli", "name": "@rocket/cli",
"version": "0.10.1", "version": "0.10.2",
"publishConfig": { "publishConfig": {
"access": "public" "access": "public"
}, },
@@ -60,7 +60,7 @@
"@rocket/building-rollup": "^0.4.0", "@rocket/building-rollup": "^0.4.0",
"@rocket/core": "^0.1.2", "@rocket/core": "^0.1.2",
"@rocket/eleventy-plugin-mdjs-unified": "^0.6.0", "@rocket/eleventy-plugin-mdjs-unified": "^0.6.0",
"@rocket/eleventy-rocket-nav": "^0.3.0", "@rocket/eleventy-rocket-nav": "^0.3.1",
"@rollup/plugin-babel": "^5.2.2", "@rollup/plugin-babel": "^5.2.2",
"@rollup/plugin-node-resolve": "^11.0.1", "@rollup/plugin-node-resolve": "^11.0.1",
"@web/config-loader": "^0.1.3", "@web/config-loader": "^0.1.3",

View File

@@ -243,9 +243,9 @@ async function insertResponsiveImages(html) {
const config = getComputedConfig(); const config = getComputedConfig();
if (!isSetup) { if (!isSetup) {
await parser.prepareWasm(saxWasmBuffer); isSetup = parser.prepareWasm(saxWasmBuffer);
isSetup = true;
} }
await isSetup;
const options = { const options = {
inputPath: this.inputPath, inputPath: this.inputPath,

View File

@@ -1,5 +1,11 @@
# @rocket/drawer # @rocket/drawer
## 0.1.5
### Patch Changes
- 1f14105: Add export map which enables side effect import via `@rocket/drawer/define`
## 0.1.4 ## 0.1.4
### Patch Changes ### Patch Changes

View File

@@ -1,6 +1,6 @@
{ {
"name": "@rocket/drawer", "name": "@rocket/drawer",
"version": "0.1.4", "version": "0.1.5",
"publishConfig": { "publishConfig": {
"access": "public" "access": "public"
}, },
@@ -13,6 +13,11 @@
}, },
"author": "Modern Web <hello@modern-web.dev> (https://modern-web.dev/)", "author": "Modern Web <hello@modern-web.dev> (https://modern-web.dev/)",
"main": "index.js", "main": "index.js",
"exports": {
".": "./index.js",
"./rocket-drawer.js": "./rocket-drawer.js",
"./define": "./rocket-drawer.js"
},
"scripts": { "scripts": {
"dev": "web-dev-server --node-resolve --root-dir ../../ --open packages/drawer/ --watch", "dev": "web-dev-server --node-resolve --root-dir ../../ --open packages/drawer/ --watch",
"rocket:build": "node src/build/cli.js -c demo/docs", "rocket:build": "node src/build/cli.js -c demo/docs",

View File

@@ -1,5 +1,11 @@
# @rocket/eleventy-rocket-nav # @rocket/eleventy-rocket-nav
## 0.3.1
### Patch Changes
- 60310ab: Improve performance by initializing sax-wasm only once even when it is running in parallel
## 0.3.0 ## 0.3.0
### Minor Changes ### Minor Changes

View File

@@ -1,6 +1,6 @@
{ {
"name": "@rocket/eleventy-rocket-nav", "name": "@rocket/eleventy-rocket-nav",
"version": "0.3.0", "version": "0.3.1",
"publishConfig": { "publishConfig": {
"access": "public" "access": "public"
}, },

View File

@@ -97,6 +97,7 @@ function getHeadingsOfHtml(html) {
return { headings, insertPoint }; return { headings, insertPoint };
} }
/** @type {boolean | Promise<unknown>} */
let isSetup = false; let isSetup = false;
/** /**
@@ -104,9 +105,9 @@ let isSetup = false;
*/ */
async function addPageAnchors(content) { async function addPageAnchors(content) {
if (!isSetup) { if (!isSetup) {
await parser.prepareWasm(saxWasmBuffer); isSetup = parser.prepareWasm(saxWasmBuffer);
isSetup = true;
} }
await isSetup;
const { headings, insertPoint } = getHeadingsOfHtml(content); const { headings, insertPoint } = getHeadingsOfHtml(content);
const pageAnchorsHtml = []; const pageAnchorsHtml = [];

View File

@@ -1,5 +1,23 @@
# Change Log # Change Log
## 0.9.4
### Patch Changes
- e6c3d27: Support `js client` as an alias to `js script`
## 0.9.3
### Patch Changes
- 62637a8: Replaces `rehype-prism-template` with `rehype-prism` to get a newer version of prism with essential security updates
## 0.9.2
### Patch Changes
- 97cb38c: Add missing slash dependency
## 0.9.1 ## 0.9.1
### Patch Changes ### Patch Changes

View File

@@ -1,6 +1,6 @@
{ {
"name": "@mdjs/core", "name": "@mdjs/core",
"version": "0.9.1", "version": "0.9.4",
"publishConfig": { "publishConfig": {
"access": "public" "access": "public"
}, },
@@ -52,7 +52,7 @@
"github-markdown-css": "^4.0.0", "github-markdown-css": "^4.0.0",
"plugins-manager": "^0.3.0", "plugins-manager": "^0.3.0",
"rehype-autolink-headings": "^5.0.1", "rehype-autolink-headings": "^5.0.1",
"rehype-prism-template": "^0.4.1", "rehype-prism": "^1.0.0",
"rehype-raw": "^5.0.0", "rehype-raw": "^5.0.0",
"rehype-slug": "^4.0.1", "rehype-slug": "^4.0.1",
"rehype-stringify": "^8.0.0", "rehype-stringify": "^8.0.0",
@@ -60,6 +60,7 @@
"remark-gfm": "^1.0.0", "remark-gfm": "^1.0.0",
"remark-parse": "^9.0.0", "remark-parse": "^9.0.0",
"remark-rehype": "^8.0.0", "remark-rehype": "^8.0.0",
"slash": "^3.0.0",
"unified": "^9.2.0", "unified": "^9.2.0",
"unist-util-remove": "^2.0.1", "unist-util-remove": "^2.0.1",
"unist-util-visit": "^2.0.3" "unist-util-visit": "^2.0.3"

View File

@@ -16,6 +16,9 @@ function mdjsParse() {
if (node.lang === 'js' && node.meta === 'script') { if (node.lang === 'js' && node.meta === 'script') {
jsCode += node.value; jsCode += node.value;
} }
if (node.lang === 'js' && node.meta === 'client') {
jsCode += node.value;
}
}); });
// we can only return/modify the tree but jsCode should not be part of the tree // we can only return/modify the tree but jsCode should not be part of the tree
// so we attach it globally to the file.data // so we attach it globally to the file.data
@@ -26,7 +29,9 @@ function mdjsParse() {
* @param {Node} node * @param {Node} node
*/ */
const removeFunction = node => const removeFunction = node =>
node.type === 'code' && node.lang === 'js' && node.meta === 'script'; node.type === 'code' &&
node.lang === 'js' &&
(node.meta === 'script' || node.meta === 'client');
remove(tree, removeFunction); remove(tree, removeFunction);
return tree; return tree;

View File

@@ -12,14 +12,16 @@ const raw = require('rehype-raw');
const htmlStringify = require('rehype-stringify'); const htmlStringify = require('rehype-stringify');
const htmlSlug = require('rehype-slug'); const htmlSlug = require('rehype-slug');
const htmlHeading = require('rehype-autolink-headings'); const htmlHeading = require('rehype-autolink-headings');
const rehypePrism = require('rehype-prism-template');
// @ts-ignore // @ts-ignore
const { executeSetupFunctions } = require('plugins-manager'); const { executeSetupFunctions } = require('plugins-manager');
const loadLanguages = require('prismjs/components/');
const { mdjsParse } = require('./mdjsParse.js'); const { mdjsParse } = require('./mdjsParse.js');
const { mdjsStoryParse } = require('./mdjsStoryParse.js'); const { mdjsStoryParse } = require('./mdjsStoryParse.js');
const { mdjsSetupCode } = require('./mdjsSetupCode.js'); const { mdjsSetupCode } = require('./mdjsSetupCode.js');
let prismLoaded = false;
/** @type {MdjsProcessPlugin[]} */ /** @type {MdjsProcessPlugin[]} */
const defaultMetaPlugins = [ const defaultMetaPlugins = [
{ plugin: markdown, options: {} }, { plugin: markdown, options: {} },
@@ -30,8 +32,6 @@ const defaultMetaPlugins = [
// @ts-ignore // @ts-ignore
{ plugin: remark2rehype, options: { allowDangerousHtml: true } }, { plugin: remark2rehype, options: { allowDangerousHtml: true } },
// @ts-ignore // @ts-ignore
{ plugin: rehypePrism, options: {} },
// @ts-ignore
{ plugin: raw, options: {} }, { plugin: raw, options: {} },
// @ts-ignore // @ts-ignore
{ plugin: htmlSlug, options: {} }, { plugin: htmlSlug, options: {} },
@@ -54,6 +54,12 @@ const defaultMetaPlugins = [
*/ */
async function mdjsProcess(mdjs, { setupUnifiedPlugins = [] } = {}) { async function mdjsProcess(mdjs, { setupUnifiedPlugins = [] } = {}) {
const parser = unified(); const parser = unified();
if (!prismLoaded) {
prismLoaded = true;
const rehypePrism = (await import('rehype-prism/lib/src/index.js')).default;
loadLanguages(['md', 'shell', 'yml']);
defaultMetaPlugins.splice(6, 0, { plugin: rehypePrism, options: {} });
}
const metaPlugins = executeSetupFunctions(setupUnifiedPlugins, defaultMetaPlugins); const metaPlugins = executeSetupFunctions(setupUnifiedPlugins, defaultMetaPlugins);

View File

@@ -35,7 +35,7 @@ describe('mdjsProcess', () => {
'', '',
'', '',
'', '',
'<pre class="language-js"><code class="language-js"><span class="token keyword module">export</span> <span class="token keyword">const</span> <span class="token function-variable function">fooPreviewStory</span> <span class="token operator">=</span> <span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token arrow operator">=></span> <span class="token punctuation">{</span><span class="token punctuation">}</span>', '<pre class="language-js"><code class="language-js"><span class="token keyword">export</span> <span class="token keyword">const</span> <span class="token function-variable function">fooPreviewStory</span> <span class="token operator">=</span> <span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">=></span> <span class="token punctuation">{</span><span class="token punctuation">}</span>',
'</code></pre>', '</code></pre>',
'', '',
'', '',

View File

@@ -28,6 +28,24 @@ describe('mdjsParse', () => {
expect(/** @type {MDJSVFileData} */ (result.data).jsCode).to.equal('const bar = 22;'); expect(/** @type {MDJSVFileData} */ (result.data).jsCode).to.equal('const bar = 22;');
}); });
it('extracts "js client" code blocks', async () => {
const input = [
'## Intro',
'```js',
'const foo = 1;',
'```',
'```js client',
'const bar = 22;',
'```',
].join('\n');
const parser = unified().use(markdown).use(mdjsParse).use(html, { sanitize: false });
const result = await parser.process(input);
expect(result.contents).to.equal(
'<h2>Intro</h2>\n<pre><code class="language-js">const foo = 1;\n</code></pre>\n',
);
expect(/** @type {MDJSVFileData} */ (result.data).jsCode).to.equal('const bar = 22;');
});
// TODO: fix this bug - maybe something in unified itself 🤔 // TODO: fix this bug - maybe something in unified itself 🤔
it.skip('handling only "js script" code blocks', async () => { it.skip('handling only "js script" code blocks', async () => {
const input = [ const input = [

View File

@@ -28,12 +28,6 @@ declare module 'rehype-autolink-headings' {
export = unified.Plugin; export = unified.Plugin;
} }
declare module 'rehype-prism-template' {
import unified from 'unified';
export = unified.Plugin;
}
declare module 'unist-util-remove' { declare module 'unist-util-remove' {
import unified from 'unified'; import unified from 'unified';

View File

@@ -1,5 +1,12 @@
# @mdjs/mdjs-preview # @mdjs/mdjs-preview
## 0.5.6
### Patch Changes
- e81b77f: Change theme attribute into preview-theme attribute to separate theme styling of the preview section and the full mdjs viewer.
- 456b8e7: Add css variable to style border-color of the mdjs-viewer
## 0.5.5 ## 0.5.5
### Patch Changes ### Patch Changes

View File

@@ -1,6 +1,6 @@
{ {
"name": "@mdjs/mdjs-preview", "name": "@mdjs/mdjs-preview",
"version": "0.5.5", "version": "0.5.6",
"publishConfig": { "publishConfig": {
"access": "public" "access": "public"
}, },
@@ -20,8 +20,8 @@
"./define": "./src/define/define.js" "./define": "./src/define/define.js"
}, },
"scripts": { "scripts": {
"prepublishOnly": "publish-docs --github-url https://github.com/modernweb-dev/rocket/ --git-root-dir ../../",
"debug": "cd ../../ && npm run debug -- --group mdjs-preview", "debug": "cd ../../ && npm run debug -- --group mdjs-preview",
"prepublishOnly": "publish-docs --github-url https://github.com/modernweb-dev/rocket/ --git-root-dir ../../",
"test": "npm run test:web", "test": "npm run test:web",
"test:web": "cd ../../ && npm run test:web -- --group mdjs-preview" "test:web": "cd ../../ && npm run test:web -- --group mdjs-preview"
}, },

View File

@@ -61,7 +61,7 @@ export class MdJsPreview extends ScopedElementsMixin(LitElement) {
platforms: { type: Array }, platforms: { type: Array },
size: { type: String }, size: { type: String },
sizes: { type: Array }, sizes: { type: Array },
theme: { type: String, reflect: true }, previewTheme: { type: String, reflect: true, attribute: 'preview-theme' },
themes: { type: Array }, themes: { type: Array },
language: { type: String }, language: { type: String },
languages: { type: Array }, languages: { type: Array },
@@ -82,7 +82,7 @@ export class MdJsPreview extends ScopedElementsMixin(LitElement) {
this.__supportsClipboard = 'clipboard' in navigator; this.__supportsClipboard = 'clipboard' in navigator;
this.__copyButtonText = 'Copy Code'; this.__copyButtonText = 'Copy Code';
this.theme = 'light'; this.previewTheme = 'light';
/** @type {{ key: string, name: string }[]} */ /** @type {{ key: string, name: string }[]} */
this.themes = [ this.themes = [
// { key: 'light', name: 'Light' }, // { key: 'light', name: 'Light' },
@@ -286,7 +286,7 @@ export class MdJsPreview extends ScopedElementsMixin(LitElement) {
const params = new URLSearchParams(); const params = new URLSearchParams();
params.set('story-file', sanitize(mdjsSetupScript.src, 'js')); params.set('story-file', sanitize(mdjsSetupScript.src, 'js'));
params.set('story-key', this.key); params.set('story-key', this.key);
params.set('theme', this.theme); params.set('theme', this.previewTheme);
params.set('platform', this.platform); params.set('platform', this.platform);
params.set('language', this.language); params.set('language', this.language);
params.set('edge-distance', this.edgeDistance.toString()); params.set('edge-distance', this.edgeDistance.toString());
@@ -439,20 +439,20 @@ export class MdJsPreview extends ScopedElementsMixin(LitElement) {
@change=${ @change=${
/** @param {Event} ev */ ev => { /** @param {Event} ev */ ev => {
if (ev.target) { if (ev.target) {
this.theme = /** @type {HTMLInputElement} */ (ev.target).value; this.previewTheme = /** @type {HTMLInputElement} */ (ev.target).value;
} }
} }
} }
> >
${this.themes.map( ${this.themes.map(
theme => html` previewTheme => html`
<label class="${this.theme === theme.key ? 'selected' : ''}"> <label class="${this.previewTheme === previewTheme.key ? 'selected' : ''}">
<span>${theme.name}</span> <span>${previewTheme.name}</span>
<input <input
type="radio" type="radio"
name="theme" name="theme"
value="${theme.key}" value="${previewTheme.key}"
?checked=${this.theme === theme.key} ?checked=${this.previewTheme === previewTheme.key}
/> />
</label> </label>
`, `,
@@ -686,11 +686,11 @@ export class MdJsPreview extends ScopedElementsMixin(LitElement) {
} }
:host(:not([device-mode])) #wrapper { :host(:not([device-mode])) #wrapper {
border: 2px solid #4caf50; border: 2px solid var(--primary-lines-color, #4caf50);
} }
iframe { iframe {
border: 2px solid #4caf50; border: 2px solid var(--primary-lines-color, #4caf50);
background: #fff; background: #fff;
} }

View File

@@ -1,7 +1,7 @@
const _sharedStates = { const _sharedStates = {
platform: 'web', platform: 'web',
size: 'webSmall', size: 'webSmall',
theme: 'light', previewTheme: 'light',
language: 'en', language: 'en',
autoHeight: true, autoHeight: true,
deviceMode: false, deviceMode: false,

View File

@@ -1,5 +1,11 @@
# plugins-manager # plugins-manager
## 0.3.1
### Patch Changes
- 7e277cd: Add a "hidden" feature in addPlugin that if you attach a `wrapPlugin` property to the returning function it will call `wrapPlugin` on the plugin before adding it.
## 0.3.0 ## 0.3.0
### Minor Changes ### Minor Changes

View File

@@ -1,6 +1,6 @@
{ {
"name": "plugins-manager", "name": "plugins-manager",
"version": "0.3.0", "version": "0.3.1",
"publishConfig": { "publishConfig": {
"access": "public" "access": "public"
}, },

View File

@@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/ban-ts-comment */
/** /**
* @template {import('../types/main').Plugin} T * @template {import('../types/main').Plugin} T
* @param {T} plugin * @param {T} plugin
@@ -12,6 +13,10 @@ export function addPlugin(plugin, options = {}, { how = 'after', location = 'bot
if (plugins === undefined) { if (plugins === undefined) {
plugins = []; plugins = [];
} }
// @ts-ignore
const usePlugin = addPluginFn.wrapPlugin ? addPluginFn.wrapPlugin(plugin) : plugin;
// only add if name is not already in the meta plugin list // only add if name is not already in the meta plugin list
if (plugins.findIndex(pluginObj => pluginObj.plugin === plugin) === -1) { if (plugins.findIndex(pluginObj => pluginObj.plugin === plugin) === -1) {
let index = -1; let index = -1;
@@ -40,7 +45,7 @@ export function addPlugin(plugin, options = {}, { how = 'after', location = 'bot
} }
plugins.splice(index, 0, { plugins.splice(index, 0, {
plugin, plugin: usePlugin,
options, options,
}); });
} }

View File

@@ -109,4 +109,18 @@ describe('addPlugin', () => {
}); });
expect(config.plugins).to.deep.equal(['-- newFirst last Plugin --']); expect(config.plugins).to.deep.equal(['-- newFirst last Plugin --']);
}); });
it('[advanced] can add a `wrapPlugin` property to the function itself which will call it on the plugin on init', async () => {
function myWrapper(plugin) {
return () => 'wrapped' + plugin();
}
const config = applyPlugins({
setupPlugins: [addPlugin(insertPlugin)].map(mod => {
mod.wrapPlugin = myWrapper;
return mod;
}),
});
expect(config.plugins).to.deep.equal(['wrapped-- first last Plugin --']);
});
}); });

View File

@@ -1,5 +1,11 @@
# @rocket/search # @rocket/search
## 0.6.0
### Minor Changes
- c2c9ecd: Update @lion dependencies
## 0.5.1 ## 0.5.1
### Patch Changes ### Patch Changes

View File

@@ -1,6 +1,6 @@
{ {
"name": "@rocket/search", "name": "@rocket/search",
"version": "0.5.1", "version": "0.6.0",
"publishConfig": { "publishConfig": {
"access": "public" "access": "public"
}, },
@@ -42,9 +42,9 @@
"search" "search"
], ],
"dependencies": { "dependencies": {
"@lion/combobox": "^0.8.6", "@lion/combobox": "^0.9.0",
"@lion/core": "^0.19.0", "@lion/core": "^0.21.0",
"@lion/listbox": "^0.10.7", "@lion/listbox": "^0.12.0",
"@open-wc/scoped-elements": "^2.0.0", "@open-wc/scoped-elements": "^2.0.0",
"chalk": "^4.0.0", "chalk": "^4.0.0",
"minisearch": "^3.0.2", "minisearch": "^3.0.2",

950
yarn.lock

File diff suppressed because it is too large Load Diff