@vitus-labs/core 1.2.1 → 1.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/analysis/index.js.html +1 -1
- package/lib/index.js.map +1 -1
- package/package.json +9 -9
|
@@ -5386,7 +5386,7 @@ var drawChart = (function (exports) {
|
|
|
5386
5386
|
</script>
|
|
5387
5387
|
<script>
|
|
5388
5388
|
/*<!--*/
|
|
5389
|
-
const data = {"version":2,"tree":{"name":"root","children":[{"name":"index.js","children":[{"name":"src","children":[{"uid":"
|
|
5389
|
+
const data = {"version":2,"tree":{"name":"root","children":[{"name":"index.js","children":[{"name":"src","children":[{"uid":"c989073a-1","name":"config.ts"},{"uid":"c989073a-3","name":"isEmpty.ts"},{"uid":"c989073a-5","name":"context.tsx"},{"uid":"c989073a-7","name":"compose.ts"},{"uid":"c989073a-9","name":"render.ts"},{"name":"html/htmlTags.ts","uid":"c989073a-11"},{"uid":"c989073a-13","name":"index.ts"}]}]}],"isRoot":true},"nodeParts":{"c989073a-1":{"renderedLength":1010,"gzipLength":312,"brotliLength":0,"metaUid":"c989073a-0"},"c989073a-3":{"renderedLength":426,"gzipLength":228,"brotliLength":0,"metaUid":"c989073a-2"},"c989073a-5":{"renderedLength":717,"gzipLength":320,"brotliLength":0,"metaUid":"c989073a-4"},"c989073a-7":{"renderedLength":178,"gzipLength":142,"brotliLength":0,"metaUid":"c989073a-6"},"c989073a-9":{"renderedLength":835,"gzipLength":328,"brotliLength":0,"metaUid":"c989073a-8"},"c989073a-11":{"renderedLength":2052,"gzipLength":565,"brotliLength":0,"metaUid":"c989073a-10"},"c989073a-13":{"renderedLength":0,"gzipLength":0,"brotliLength":0,"metaUid":"c989073a-12"}},"nodeMetas":{"c989073a-0":{"id":"/src/config.ts","moduleParts":{"index.js":"c989073a-1"},"imported":[{"uid":"c989073a-17"}],"importedBy":[{"uid":"c989073a-12"},{"uid":"c989073a-4"}]},"c989073a-2":{"id":"/src/isEmpty.ts","moduleParts":{"index.js":"c989073a-3"},"imported":[],"importedBy":[{"uid":"c989073a-12"},{"uid":"c989073a-4"},{"uid":"c989073a-8"}]},"c989073a-4":{"id":"/src/context.tsx","moduleParts":{"index.js":"c989073a-5"},"imported":[{"uid":"c989073a-18"},{"uid":"c989073a-0"},{"uid":"c989073a-2"}],"importedBy":[{"uid":"c989073a-12"}]},"c989073a-6":{"id":"/src/compose.ts","moduleParts":{"index.js":"c989073a-7"},"imported":[],"importedBy":[{"uid":"c989073a-12"}]},"c989073a-8":{"id":"/src/render.ts","moduleParts":{"index.js":"c989073a-9"},"imported":[{"uid":"c989073a-18"},{"uid":"c989073a-19"},{"uid":"c989073a-2"}],"importedBy":[{"uid":"c989073a-12"}]},"c989073a-10":{"id":"/src/html/htmlTags.ts","moduleParts":{"index.js":"c989073a-11"},"imported":[],"importedBy":[{"uid":"c989073a-16"}]},"c989073a-12":{"id":"/src/index.ts","moduleParts":{"index.js":"c989073a-13"},"imported":[{"uid":"c989073a-14"},{"uid":"c989073a-15"},{"uid":"c989073a-0"},{"uid":"c989073a-4"},{"uid":"c989073a-6"},{"uid":"c989073a-2"},{"uid":"c989073a-8"},{"uid":"c989073a-16"}],"importedBy":[],"isEntry":true},"c989073a-14":{"id":"lodash-es","moduleParts":{},"imported":[],"importedBy":[{"uid":"c989073a-12"}],"isExternal":true},"c989073a-15":{"id":"moize","moduleParts":{},"imported":[],"importedBy":[{"uid":"c989073a-12"}],"isExternal":true},"c989073a-16":{"id":"/src/html/index.ts","moduleParts":{},"imported":[{"uid":"c989073a-10"}],"importedBy":[{"uid":"c989073a-12"}]},"c989073a-17":{"id":"styled-components","moduleParts":{},"imported":[],"importedBy":[{"uid":"c989073a-0"}],"isExternal":true},"c989073a-18":{"id":"react","moduleParts":{},"imported":[],"importedBy":[{"uid":"c989073a-4"},{"uid":"c989073a-8"}],"isExternal":true},"c989073a-19":{"id":"react-is","moduleParts":{},"imported":[],"importedBy":[{"uid":"c989073a-8"}],"isExternal":true}},"env":{"rollup":"4.55.1"},"options":{"gzip":true,"brotli":false,"sourcemap":false}};
|
|
5390
5390
|
|
|
5391
5391
|
const run = () => {
|
|
5392
5392
|
const width = window.innerWidth;
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../src/config.ts","../src/isEmpty.ts","../src/context.tsx","../src/compose.ts","../src/render.ts","../src/html/htmlTags.ts"],"sourcesContent":["import { styled, css, ThemeProvider } from 'styled-components'\nimport type { ComponentType } from 'react'\nimport type { HTMLTags } from '~/html'\n\ninterface Internal {\n css: typeof css\n styled: typeof styled\n provider: typeof ThemeProvider\n component: ComponentType | HTMLTags\n textComponent: ComponentType | HTMLTags\n}\n\nclass Configuration {\n css: Internal['css']\n\n styled: Internal['styled']\n\n ExternalProvider: Internal['provider']\n\n component: Internal['component'] = 'div'\n\n textComponent: Internal['textComponent'] = 'span'\n\n constructor(props: Internal) {\n this.css = props.css\n this.styled = props.styled\n this.ExternalProvider = props.provider\n this.component = props.component\n this.textComponent = props.textComponent\n }\n\n init = (props: Partial<Internal>) => {\n if (props.css) {\n this.css = props.css\n }\n\n if (props.styled) {\n this.styled = props.styled\n }\n\n if (props.provider) {\n this.ExternalProvider = props.provider\n }\n\n if (props.component) {\n this.component = props.component\n }\n\n if (props.textComponent) {\n this.textComponent = props.textComponent\n }\n }\n}\n\nconst defaultParams = {\n css,\n styled,\n provider: ThemeProvider,\n component: 'div',\n textComponent: 'span',\n} as const\n\nconst config = new Configuration(defaultParams)\n\nconst { init } = config\n\nexport default config\nexport { init }\n","export type IsEmpty = <\n T extends Record<number | string, any> | any[] | null | undefined,\n>(\n param: T,\n) => T extends null | undefined\n ? true\n : keyof T extends never\n ? true\n : T extends T[]\n ? T[number] extends never\n ? true\n : false\n : false\n\nconst isEmpty: IsEmpty = (param) => {\n if (!param || param === null) return true\n\n if (typeof param !== 'object') {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return true as any\n }\n\n if (Array.isArray(param) && param.length === 0) {\n return true\n }\n\n if (Object.entries(param).length === 0 && param.constructor === Object) {\n return true\n }\n\n return false\n}\n\nexport default isEmpty\n","import React, { createContext, useMemo } from 'react'\nimport type { FC, ReactNode } from 'react'\nimport config from '~/config'\nimport isEmpty from '~/isEmpty'\nimport type { Breakpoints } from '~/types'\n\nconst context = createContext<any>({})\nconst VitusLabsProvider = context.Provider\n\ntype Theme = Partial<\n {\n rootSize: number\n breakpoints: Breakpoints\n } & Record<string, any>\n>\n\ntype ProviderType = Partial<\n {\n theme: Theme\n children: ReactNode\n } & Record<string, any>\n>\n\nconst Provider: FC<ProviderType> = ({ theme, children, ...props }) => {\n const ExternalProvider = useMemo(() => config.ExternalProvider, [])\n const context = useMemo(() => ({ theme, ...props }), [theme, props])\n\n // eslint-disable-next-line react/jsx-no-useless-fragment\n if (isEmpty(theme) || !theme) return <>{children}</>\n\n if (ExternalProvider) {\n return (\n <VitusLabsProvider value={context}>\n <ExternalProvider theme={theme}>{children}</ExternalProvider>\n </VitusLabsProvider>\n )\n }\n\n return <VitusLabsProvider value={context}>{children}</VitusLabsProvider>\n}\n\nexport { context }\n\nexport default Provider\n","type ArityOneFn = (arg: any) => any\ntype PickLastInTuple<T extends any[]> = T extends [\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n ...rest: infer U,\n argn: infer L,\n]\n ? L\n : any\n\ntype FirstFnParameterType<T extends any[]> = Parameters<PickLastInTuple<T>>[any]\ntype LastFnReturnType<T extends any[]> = ReturnType<T[0]>\n\nconst compose =\n <T extends ArityOneFn[]>(...fns: T) =>\n (p: FirstFnParameterType<T>): LastFnReturnType<T> =>\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-call\n fns.reduceRight((acc: any, cur: any) => cur(acc), p)\n\nexport default compose\n","import { createElement, isValidElement, cloneElement } from 'react'\nimport type { ReactNode } from 'react'\nimport { isValidElementType, isFragment } from 'react-is'\nimport isEmpty from './isEmpty'\n\ntype CreateTypes = Parameters<typeof createElement>[0]\ntype CloneTypes = Parameters<typeof cloneElement>[0]\ntype RenderProps<T extends Record<string, unknown> | undefined> = (\n props: Partial<T>,\n) => ReactNode\n\nexport type Render = <T extends Record<string, any> | undefined>(\n content?: CreateTypes | CloneTypes | ReactNode | ReactNode[] | RenderProps<T>,\n attachProps?: T,\n) => ReturnType<typeof createElement> | ReturnType<typeof cloneElement> | null\n\nconst render: Render = (content, attachProps) => {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n if (!content) return null as any\n\n const isValidEl = isValidElement(content)\n\n const render = (child: Parameters<typeof createElement>[0]) =>\n attachProps ? createElement(child, attachProps) : createElement(child)\n\n if (typeof content === 'string' && isValidEl) {\n return render(content)\n }\n\n if (['number', 'boolean', 'bigint', 'string'].includes(typeof content)) {\n return content\n }\n\n if (Array.isArray(content) || isFragment(content)) {\n return content\n }\n\n if (isValidElementType(content)) {\n return render(content)\n }\n\n if (isValidEl) {\n if (isEmpty(attachProps)) {\n return content\n }\n\n return cloneElement(content, attachProps)\n }\n\n return content\n}\n\nexport default render\n","const HTML_TAGS = [\n 'a',\n 'abbr',\n // 'acronym',\n 'address',\n // 'applet',\n 'area',\n 'article',\n 'aside',\n 'audio',\n 'b',\n // 'base',\n // 'basefont',\n 'bdi',\n 'bdo',\n 'big',\n 'blockquote',\n 'body',\n 'br',\n 'button',\n 'canvas',\n 'caption',\n // 'center',\n 'cite',\n 'code',\n 'col',\n 'colgroup',\n 'data',\n 'datalist',\n 'dd',\n 'del',\n 'details',\n 'dfn',\n 'dialog',\n // 'dir',\n 'div',\n 'dl',\n 'dt',\n 'em',\n 'embed',\n 'fieldset',\n 'figcaption',\n 'figure',\n // 'font',\n 'footer',\n 'form',\n // 'frame',\n // 'frameset',\n 'h1',\n 'h2',\n 'h3',\n 'h4',\n 'h5',\n 'h6',\n // 'head',\n 'header',\n 'hr',\n 'html',\n 'i',\n 'iframe',\n 'img',\n 'input',\n 'ins',\n 'kbd',\n 'label',\n 'legend',\n 'li',\n // 'link',\n 'main',\n 'map',\n 'mark',\n // 'meta',\n 'meter',\n 'nav',\n // 'noframes',\n // 'noscript',\n 'object',\n 'ol',\n 'optgroup',\n 'option',\n 'output',\n 'p',\n // 'param',\n 'picture',\n 'pre',\n 'progress',\n 'q',\n 'rp',\n 'rt',\n 'ruby',\n 's',\n 'samp',\n // 'script',\n 'section',\n 'select',\n 'small',\n 'source',\n 'span',\n // 'strike',\n 'strong',\n // 'style',\n 'sub',\n 'summary',\n 'sup',\n 'svg',\n 'table',\n 'tbody',\n 'td',\n 'template',\n 'textarea',\n 'tfoot',\n 'th',\n 'thead',\n 'time',\n // 'title',\n 'tr',\n 'track',\n // 'tt',\n 'u',\n 'ul',\n 'var',\n 'video',\n 'wbr',\n] as const\n\nconst HTML_TEXT_TAGS = [\n 'abbr',\n 'b',\n 'bdi',\n 'bdo',\n 'big',\n 'blockquote',\n 'cite',\n 'code',\n 'dl',\n 'dt',\n 'em',\n 'figcaption',\n 'h1',\n 'h2',\n 'h3',\n 'h4',\n 'h5',\n 'h6',\n 'i',\n 'ins',\n 'kbd',\n 'label',\n 'legend',\n 'li',\n 'p',\n 'pre',\n 'q',\n 'rp',\n 'rt',\n 's',\n 'small',\n 'span',\n 'strong',\n 'sub',\n 'summary',\n 'sup',\n 'time',\n 'u',\n] as const\n\nexport type HTMLTags = (typeof HTML_TAGS)[number]\n\nexport type HTMLTextTags = (typeof HTML_TEXT_TAGS)[number]\n\nexport { HTML_TAGS, HTML_TEXT_TAGS }\n"],"names":[],"mappings":";;;;;;AAYA,MAAM,aAAa,CAAA;AACjB,IAAA,GAAG;AAEH,IAAA,MAAM;AAEN,IAAA,gBAAgB;IAEhB,SAAS,GAA0B,KAAK;IAExC,aAAa,GAA8B,MAAM;AAEjD,IAAA,WAAA,CAAY,KAAe,EAAA;AACzB,QAAA,IAAI,CAAC,GAAG,GAAG,KAAK,CAAC,GAAG;AACpB,QAAA,IAAI,CAAC,MAAM,GAA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L,OAAO;IACP,QAAQ;IACR,IAAI;IACJ,GAAG;IACH,KAAK;IACL,GAAG;IACH,IAAI;IACJ,IAAI;IACJ,GAAG;IACH,OAAO;IACP,MAAM;IACN,QAAQ;IACR,KAAK;IACL,SAAS;IACT,KAAK;IACL,MAAM;IACN,GAAG;;;;;"}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/config.ts","../src/isEmpty.ts","../src/context.tsx","../src/compose.ts","../src/render.ts","../src/html/htmlTags.ts"],"sourcesContent":["import { styled, css, ThemeProvider } from 'styled-components'\nimport type { ComponentType } from 'react'\nimport type { HTMLTags } from '~/html'\n\ninterface Internal {\n css: typeof css\n styled: typeof styled\n provider: typeof ThemeProvider\n component: ComponentType | HTMLTags\n textComponent: ComponentType | HTMLTags\n}\n\nclass Configuration {\n css: Internal['css']\n\n styled: Internal['styled']\n\n ExternalProvider: Internal['provider']\n\n component: Internal['component'] = 'div'\n\n textComponent: Internal['textComponent'] = 'span'\n\n constructor(props: Internal) {\n this.css = props.css\n this.styled = props.styled\n this.ExternalProvider = props.provider\n this.component = props.component\n this.textComponent = props.textComponent\n }\n\n init = (props: Partial<Internal>) => {\n if (props.css) {\n this.css = props.css\n }\n\n if (props.styled) {\n this.styled = props.styled\n }\n\n if (props.provider) {\n this.ExternalProvider = props.provider\n }\n\n if (props.component) {\n this.component = props.component\n }\n\n if (props.textComponent) {\n this.textComponent = props.textComponent\n }\n }\n}\n\nconst defaultParams = {\n css,\n styled,\n provider: ThemeProvider,\n component: 'div',\n textComponent: 'span',\n} as const\n\nconst config = new Configuration(defaultParams)\n\nconst { init } = config\n\nexport default config\nexport { init }\n","export type IsEmpty = <\n T extends Record<number | string, any> | any[] | null | undefined,\n>(\n param: T,\n) => T extends null | undefined\n ? true\n : keyof T extends never\n ? true\n : T extends T[]\n ? T[number] extends never\n ? true\n : false\n : false\n\nconst isEmpty: IsEmpty = (param) => {\n if (!param || param === null) return true\n\n if (typeof param !== 'object') {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return true as any\n }\n\n if (Array.isArray(param) && param.length === 0) {\n return true\n }\n\n if (Object.entries(param).length === 0 && param.constructor === Object) {\n return true\n }\n\n return false\n}\n\nexport default isEmpty\n","import React, { createContext, useMemo } from 'react'\nimport type { FC, ReactNode } from 'react'\nimport config from '~/config'\nimport isEmpty from '~/isEmpty'\nimport type { Breakpoints } from '~/types'\n\nconst context = createContext<any>({})\nconst VitusLabsProvider = context.Provider\n\ntype Theme = Partial<\n {\n rootSize: number\n breakpoints: Breakpoints\n } & Record<string, any>\n>\n\ntype ProviderType = Partial<\n {\n theme: Theme\n children: ReactNode\n } & Record<string, any>\n>\n\nconst Provider: FC<ProviderType> = ({ theme, children, ...props }) => {\n const ExternalProvider = useMemo(() => config.ExternalProvider, [])\n const context = useMemo(() => ({ theme, ...props }), [theme, props])\n\n // eslint-disable-next-line react/jsx-no-useless-fragment\n if (isEmpty(theme) || !theme) return <>{children}</>\n\n if (ExternalProvider) {\n return (\n <VitusLabsProvider value={context}>\n <ExternalProvider theme={theme}>{children}</ExternalProvider>\n </VitusLabsProvider>\n )\n }\n\n return <VitusLabsProvider value={context}>{children}</VitusLabsProvider>\n}\n\nexport { context }\n\nexport default Provider\n","type ArityOneFn = (arg: any) => any\ntype PickLastInTuple<T extends any[]> = T extends [\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n ...rest: infer U,\n argn: infer L,\n]\n ? L\n : any\n\ntype FirstFnParameterType<T extends any[]> = Parameters<PickLastInTuple<T>>[any]\ntype LastFnReturnType<T extends any[]> = ReturnType<T[0]>\n\nconst compose =\n <T extends ArityOneFn[]>(...fns: T) =>\n (p: FirstFnParameterType<T>): LastFnReturnType<T> =>\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-call\n fns.reduceRight((acc: any, cur: any) => cur(acc), p)\n\nexport default compose\n","import { createElement, isValidElement, cloneElement } from 'react'\nimport type { ReactNode } from 'react'\nimport { isValidElementType, isFragment } from 'react-is'\nimport isEmpty from './isEmpty'\n\ntype CreateTypes = Parameters<typeof createElement>[0]\ntype CloneTypes = Parameters<typeof cloneElement>[0]\ntype RenderProps<T extends Record<string, unknown> | undefined> = (\n props: Partial<T>,\n) => ReactNode\n\nexport type Render = <T extends Record<string, any> | undefined>(\n content?: CreateTypes | CloneTypes | ReactNode | ReactNode[] | RenderProps<T>,\n attachProps?: T,\n) => ReturnType<typeof createElement> | ReturnType<typeof cloneElement> | null\n\nconst render: Render = (content, attachProps) => {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n if (!content) return null as any\n\n const isValidEl = isValidElement(content)\n\n const render = (child: Parameters<typeof createElement>[0]) =>\n attachProps ? createElement(child, attachProps) : createElement(child)\n\n if (typeof content === 'string' && isValidEl) {\n return render(content)\n }\n\n if (['number', 'boolean', 'bigint', 'string'].includes(typeof content)) {\n return content\n }\n\n if (Array.isArray(content) || isFragment(content)) {\n return content\n }\n\n if (isValidElementType(content)) {\n return render(content)\n }\n\n if (isValidEl) {\n if (isEmpty(attachProps)) {\n return content\n }\n\n return cloneElement(content, attachProps)\n }\n\n return content\n}\n\nexport default render\n","const HTML_TAGS = [\n 'a',\n 'abbr',\n // 'acronym',\n 'address',\n // 'applet',\n 'area',\n 'article',\n 'aside',\n 'audio',\n 'b',\n // 'base',\n // 'basefont',\n 'bdi',\n 'bdo',\n 'big',\n 'blockquote',\n 'body',\n 'br',\n 'button',\n 'canvas',\n 'caption',\n // 'center',\n 'cite',\n 'code',\n 'col',\n 'colgroup',\n 'data',\n 'datalist',\n 'dd',\n 'del',\n 'details',\n 'dfn',\n 'dialog',\n // 'dir',\n 'div',\n 'dl',\n 'dt',\n 'em',\n 'embed',\n 'fieldset',\n 'figcaption',\n 'figure',\n // 'font',\n 'footer',\n 'form',\n // 'frame',\n // 'frameset',\n 'h1',\n 'h2',\n 'h3',\n 'h4',\n 'h5',\n 'h6',\n // 'head',\n 'header',\n 'hr',\n 'html',\n 'i',\n 'iframe',\n 'img',\n 'input',\n 'ins',\n 'kbd',\n 'label',\n 'legend',\n 'li',\n // 'link',\n 'main',\n 'map',\n 'mark',\n // 'meta',\n 'meter',\n 'nav',\n // 'noframes',\n // 'noscript',\n 'object',\n 'ol',\n 'optgroup',\n 'option',\n 'output',\n 'p',\n // 'param',\n 'picture',\n 'pre',\n 'progress',\n 'q',\n 'rp',\n 'rt',\n 'ruby',\n 's',\n 'samp',\n // 'script',\n 'section',\n 'select',\n 'small',\n 'source',\n 'span',\n // 'strike',\n 'strong',\n // 'style',\n 'sub',\n 'summary',\n 'sup',\n 'svg',\n 'table',\n 'tbody',\n 'td',\n 'template',\n 'textarea',\n 'tfoot',\n 'th',\n 'thead',\n 'time',\n // 'title',\n 'tr',\n 'track',\n // 'tt',\n 'u',\n 'ul',\n 'var',\n 'video',\n 'wbr',\n] as const\n\nconst HTML_TEXT_TAGS = [\n 'abbr',\n 'b',\n 'bdi',\n 'bdo',\n 'big',\n 'blockquote',\n 'cite',\n 'code',\n 'dl',\n 'dt',\n 'em',\n 'figcaption',\n 'h1',\n 'h2',\n 'h3',\n 'h4',\n 'h5',\n 'h6',\n 'i',\n 'ins',\n 'kbd',\n 'label',\n 'legend',\n 'li',\n 'p',\n 'pre',\n 'q',\n 'rp',\n 'rt',\n 's',\n 'small',\n 'span',\n 'strong',\n 'sub',\n 'summary',\n 'sup',\n 'time',\n 'u',\n] as const\n\nexport type HTMLTags = (typeof HTML_TAGS)[number]\n\nexport type HTMLTextTags = (typeof HTML_TEXT_TAGS)[number]\n\nexport { HTML_TAGS, HTML_TEXT_TAGS }\n"],"names":[],"mappings":";;;;;;AAYA,MAAM,aAAa,CAAA;AACjB,IAAA,GAAG;AAEH,IAAA,MAAM;AAEN,IAAA,gBAAgB;IAEhB,SAAS,GAA0B,KAAK;IAExC,aAAa,GAA8B,MAAM;AAEjD,IAAA,WAAA,CAAY,KAAe,EAAA;AACzB,QAAA,IAAI,CAAC,GAAG,GAAG,KAAK,CAAC,GAAG;AACpB,QA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,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,GAAG;IACH,KAAK;IACL,KAAK;IACL,OAAO;IACP,QAAQ;IACR,IAAI;IACJ,GAAG;IACH,KAAK;IACL,GAAG;IACH,IAAI;IACJ,IAAI;IACJ,GAAG;IACH,OAAO;IACP,MAAM;IACN,QAAQ;IACR,KAAK;IACL,SAAS;IACT,KAAK;IACL,MAAM;IACN,GAAG;;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vitus-labs/core",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.2",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "Vit Bokisch <vit@bokisch.cz>",
|
|
6
6
|
"maintainers": [
|
|
@@ -49,16 +49,16 @@
|
|
|
49
49
|
"styled-components": ">= 6"
|
|
50
50
|
},
|
|
51
51
|
"dependencies": {
|
|
52
|
-
"lodash-es": "^4.17.
|
|
53
|
-
"moize": "^6.1.
|
|
54
|
-
"react-is": "^19.
|
|
52
|
+
"lodash-es": "^4.17.22",
|
|
53
|
+
"moize": "^6.1.7",
|
|
54
|
+
"react-is": "^19.2.3"
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|
|
57
57
|
"@types/lodash-es": "^4.17.12",
|
|
58
|
-
"@vitus-labs/tools-babel": "^1.5.
|
|
59
|
-
"@vitus-labs/tools-rollup": "^1.5.
|
|
60
|
-
"@vitus-labs/tools-typescript": "^1.5.
|
|
61
|
-
"styled-components": "^6.
|
|
58
|
+
"@vitus-labs/tools-babel": "^1.5.1",
|
|
59
|
+
"@vitus-labs/tools-rollup": "^1.5.1",
|
|
60
|
+
"@vitus-labs/tools-typescript": "^1.5.1",
|
|
61
|
+
"styled-components": "^6.2.0"
|
|
62
62
|
},
|
|
63
|
-
"gitHead": "
|
|
63
|
+
"gitHead": "7a4d4d7560941675c866162c77a63218684ff850"
|
|
64
64
|
}
|