diff --git a/crates/swc-plugin-gem/package.json b/crates/swc-plugin-gem/package.json index 2759d0ef..a76f0da1 100644 --- a/crates/swc-plugin-gem/package.json +++ b/crates/swc-plugin-gem/package.json @@ -1,19 +1,28 @@ { "name": "swc-plugin-gem", "version": "0.1.0", - "description": "", - "author": "", - "license": "ISC", + "description": "swc plugin for Gem", "keywords": [ "swc-plugin", "gem", "web components" ], - "main": "swc_gem_plugin.wasm", + "main": "swc_plugin_gem.wasm", + "files": [], "scripts": { - "prepublishOnly": "cargo build-wasi --release && cp ../../target/wasm32-wasip1/release/swc_gem_plugin.wasm .", + "prepublishOnly": "cross-env CARGO_TARGET_DIR=target cargo build-wasi --release && cp target/wasm32-wasip1/release/swc_plugin_gem.wasm .", "test": "cargo watch -x test" }, - "files": [], - "preferUnplugged": true + "preferUnplugged": true, + "author": "mantou132", + "license": "ISC", + "repository": { + "type": "git", + "url": "git+https://github.com/mantou132/gem.git", + "directory": "crates/swc-plugin-gem" + }, + "bugs": { + "url": "https://github.com/mantou132/gem/issues" + }, + "homepage": "https://github.com/mantou132/gem#readme" } diff --git a/crates/swc-plugin-gem/src/auto-import.json b/crates/swc-plugin-gem/src/auto-import.json new file mode 100644 index 00000000..c1cf483a --- /dev/null +++ b/crates/swc-plugin-gem/src/auto-import.json @@ -0,0 +1,62 @@ +{ + "comment1": "SheetToken、UpdateToken、directive、repeat、render、connect 和 version 不自动导入", + "comment2": "types 不自动导入,例如 Emitter", + "members": { + "@mantou/gem": [ + "GemElement", + "TemplateResult", + "css", + "html", + "mathml", + "svg", + + "aria", + "async", + "shadow", + "light", + "adoptedStyle", + "connectStore", + "customElement", + + "part", + "slot", + + "attribute", + "numattribute", + "boolattribute", + "property", + "emitter", + "globalemitter", + "state", + + "effect", + "memo", + "willMount", + "mounted", + "unmounted", + "template", + "fallback", + + "createRef", + "createState", + "createStore", + + "raw", + "styled", + "styleMap", + "classMap", + "partMap", + "exportPartsMap" + ] + }, + "elements": { + "@mantou/gem": { + "gem-(gesture|link|reflect|route|title|unsafe|use)": "/elements/$1" + }, + "duoyun-ui": { + "dy-pat-*": "/patterns/*", + "dy-input-*": "/elements/input", + "dy-*": "/elements/*" + } + } +} diff --git a/packages/duoyun-ui/docs/en/02-elements/coach-mark.md b/packages/duoyun-ui/docs/en/02-elements/coach-mark.md index 3cb02158..3f262d52 100644 --- a/packages/duoyun-ui/docs/en/02-elements/coach-mark.md +++ b/packages/duoyun-ui/docs/en/02-elements/coach-mark.md @@ -5,11 +5,9 @@ ```ts -import { render, html } from '@mantou/gem'; +import { render } from '@mantou/gem'; import { setTours } from 'duoyun-ui/elements/coach-mark'; -import 'duoyun-ui/elements/side-navigation'; - setTours( [ { diff --git a/packages/duoyun-ui/docs/en/02-elements/map.md b/packages/duoyun-ui/docs/en/02-elements/map.md index 9d3b7509..f97e6d8e 100644 --- a/packages/duoyun-ui/docs/en/02-elements/map.md +++ b/packages/duoyun-ui/docs/en/02-elements/map.md @@ -5,11 +5,9 @@ ```ts -import { render, html } from '@mantou/gem'; +import { render } from '@mantou/gem'; import { geoAlbersUsaTerritories } from 'geo-albers-usa-territories'; -import 'duoyun-ui/elements/map'; - const getProjection = (geoCommonProjection: GeoCommonProjection) => { return geoAlbersUsaTerritories().scale(400).translate([0, 0]); }; diff --git a/packages/duoyun-ui/docs/en/02-elements/popover.md b/packages/duoyun-ui/docs/en/02-elements/popover.md index f84ab167..47c32937 100644 --- a/packages/duoyun-ui/docs/en/02-elements/popover.md +++ b/packages/duoyun-ui/docs/en/02-elements/popover.md @@ -5,10 +5,7 @@ ```ts -import { render, html } from '@mantou/gem'; - -import 'duoyun-ui/elements/popover'; -import 'duoyun-ui/elements/button'; +import { render } from '@mantou/gem'; render( html` diff --git a/packages/duoyun-ui/docs/zh/02-elements/coach-mark.md b/packages/duoyun-ui/docs/zh/02-elements/coach-mark.md index 3cb02158..3f262d52 100644 --- a/packages/duoyun-ui/docs/zh/02-elements/coach-mark.md +++ b/packages/duoyun-ui/docs/zh/02-elements/coach-mark.md @@ -5,11 +5,9 @@ ```ts -import { render, html } from '@mantou/gem'; +import { render } from '@mantou/gem'; import { setTours } from 'duoyun-ui/elements/coach-mark'; -import 'duoyun-ui/elements/side-navigation'; - setTours( [ { diff --git a/packages/duoyun-ui/docs/zh/02-elements/map.md b/packages/duoyun-ui/docs/zh/02-elements/map.md index 568e6bf9..9919434f 100644 --- a/packages/duoyun-ui/docs/zh/02-elements/map.md +++ b/packages/duoyun-ui/docs/zh/02-elements/map.md @@ -5,9 +5,7 @@ ```ts -import { render, html } from '@mantou/gem'; - -import 'duoyun-ui/elements/map'; +import { render } from '@mantou/gem'; const getProjection = (geoCommonProjection: GeoCommonProjection) => { return geoCommonProjection() diff --git a/packages/duoyun-ui/docs/zh/02-elements/popover.md b/packages/duoyun-ui/docs/zh/02-elements/popover.md index ffd27d03..31af2252 100644 --- a/packages/duoyun-ui/docs/zh/02-elements/popover.md +++ b/packages/duoyun-ui/docs/zh/02-elements/popover.md @@ -5,10 +5,7 @@ ```ts -import { render, html } from '@mantou/gem'; - -import 'duoyun-ui/elements/popover'; -import 'duoyun-ui/elements/button'; +import { render } from '@mantou/gem'; render( html` diff --git a/packages/gem-book/src/plugins/sandpack.ts b/packages/gem-book/src/plugins/sandpack.ts index fccaa348..a334a3d3 100644 --- a/packages/gem-book/src/plugins/sandpack.ts +++ b/packages/gem-book/src/plugins/sandpack.ts @@ -11,6 +11,7 @@ import type { import type { GemBookElement } from '../element'; import type { Pre } from '../element/elements/pre'; +const AUTO_IMPORT = 'https://raw.githubusercontent.com/mantou132/gem/main/crates/swc-plugin-gem/src/auto-import.json'; const ESBUILD_URL = 'https://esm.sh/esbuild-wasm@0.24.0'; const CSB_URL = 'https://codesandbox.io/api/v1/sandboxes/define?json=1'; const SANDPACK_CLIENT_ESM = 'https://esm.sh/@codesandbox/sandpack-client@2.18.2?bundle'; @@ -79,6 +80,7 @@ const { createState, willMount, mounted, + raw, } = GemBookPluginElement.Gem; const styles = css` @@ -214,7 +216,7 @@ class _GbpSandpackElement extends GemBookPluginElement { get #indexTemplate() { const style = getComputedStyle(document.body); - return ` + return raw`