@ctx-core/svg-ui-svelte
Advanced tools
Comparing version 1.3.128 to 1.3.129
export * from './Icon/index.js' | ||
export * from './[icon_name].svg/index.js' | ||
export * from './icon_name_svg/index.js' | ||
export * from './markup/index.js' | ||
export * from './markup_/index.js' | ||
export * from './svg_preprocess_/index.js' | ||
export * from './svg_preprocess/index.js' |
export * as Icon from './Icon/index.js' | ||
export * from './[icon_name].svg/index.js' | ||
export * from './icon_name_svg/index.js' | ||
export * from './markup/index.js' | ||
export * from './markup_/index.js' | ||
export * from './svg_preprocess_/index.js' | ||
export * from './svg_preprocess/index.js' |
@@ -1,2 +0,22 @@ | ||
import { markup_T } from '../markup_/index.js' | ||
export const markup:markup_T | ||
// export type markup_fn_T = | ||
export interface markup_builder_opts__T { | ||
match_?:(opts:match_opts__T)=>string | ||
} | ||
export function markup_(builder_opts?:markup_builder_opts__T):markup_T | ||
export type _markup_builder_opts_T = markup_builder_opts__T | ||
export type _markup_builder_opts_type = markup_builder_opts__T | ||
export interface match_opts__T { | ||
filename:string | ||
content:string | ||
} | ||
export type _match_opts_T = match_opts__T | ||
export type _match_opts_type = match_opts__T | ||
export interface markup_fn_return__T { | ||
code:any | ||
map:null | ||
} | ||
export type _markup_fn_return_T = markup_fn_return__T | ||
export type _markup_fn_return_type = markup_fn_return__T | ||
export type markup_T = (opts:match_opts__T)=>Promise<markup_fn_return__T|undefined> | ||
export type markup_type = markup_T |
@@ -1,3 +0,64 @@ | ||
import { markup_ } from '../markup_/index.js' | ||
export const markup = markup_() | ||
export { markup as markup__markdown } | ||
/** @typedef {import('domhandler').NodeWithChildren} */ | ||
/** | ||
* Returns a svg preprocessor for svelte-rollup. | ||
*/ | ||
export const markup_ = ( | ||
/** @type {markup_builder_opts__T} */builder_opts = {} | ||
)=>{ | ||
const { | ||
match_ = ({ filename })=>extname(filename) === '.svg', | ||
} = builder_opts | ||
return async (/** @type {match_opts__T} */opts)=>{ | ||
if (!match_(opts)) return | ||
const { content } = opts | ||
let code | ||
const handler = new DomHandler((error, dom_a)=>{ | ||
if (error) throw error | ||
const dom0 = /** @type {NodeWithChildren} */(dom_a[0]) | ||
/** @type {Element} */ | ||
const { attribs } = dom0 | ||
const attribs_txt = | ||
map( | ||
keys(attribs), | ||
key=>`${key}=${JSON.stringify(attribs[key])}`).join(' ') | ||
code = ` | ||
<script context="module"> | ||
export async function preload({ params, query }) { | ||
return Object.assign({}, query, params) | ||
} | ||
</script> | ||
<script> | ||
let svg_node | ||
$: { | ||
Object.keys($$props).forEach( | ||
prop => svg_node && svg_node.setAttribute(prop, $$props[prop])) | ||
} | ||
</script> | ||
<svelte:options namespace="svg"></svelte:options> | ||
<svg bind:this={svg_node} ${attribs_txt}>${getInnerHTML(dom0)}</svg> | ||
`.trim() | ||
}) | ||
const parser = new Parser(handler) | ||
parser.write(content.slice(content.indexOf('<svg'))) | ||
parser.end() | ||
return /** @type {markup_fn_return__T} */({ | ||
code, | ||
map: null, | ||
}) | ||
} | ||
} | ||
export { markup_ as _markup } | ||
/** | ||
* @param {NodeWithChildren} node | ||
* @param {import('dom-serializer').DomSerializerOptions}[options] | ||
* @returns {*|string} | ||
*/ | ||
function getInnerHTML(node, options) { | ||
return hasChildren(node) | ||
? node.children.map(function(node) { | ||
return getOuterHTML(node, options) | ||
}).join('') | ||
: '' | ||
} |
{ | ||
"name": "@ctx-core/svg-ui-svelte", | ||
"version": "1.3.128", | ||
"version": "1.3.129", | ||
"description": "ctx-core svg", | ||
@@ -25,7 +25,7 @@ "keywords": [ | ||
"*.json", | ||
"./[icon_name].svg", | ||
"./Icon", | ||
"./markup", | ||
"./markup_", | ||
"./svg_preprocess_" | ||
"Icon", | ||
"icon_name_svg", | ||
"markup", | ||
"markup_", | ||
"svg_preprocess" | ||
], | ||
@@ -32,0 +32,0 @@ "types": "./index.d.ts", |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
12205
228
1