@moneko/solid 1.0.3 → 1.0.5
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/env.d.ts +56 -0
- package/lib/entry.d.ts +9 -1
- package/lib/entry.js +1 -1
- package/lib/entry.js.map +1 -1
- package/package.json +1 -1
package/env.d.ts
CHANGED
|
@@ -154,6 +154,57 @@ declare module '@app/coverage' {
|
|
|
154
154
|
|
|
155
155
|
export default coverage;
|
|
156
156
|
}
|
|
157
|
+
declare module '@app/locales' {
|
|
158
|
+
import type { SetStoreFunction } from 'solid-js/store';
|
|
159
|
+
export type LocaleConfig = {
|
|
160
|
+
/** 语言名称 (未设置时使用文件名)*/
|
|
161
|
+
language?: string;
|
|
162
|
+
/** 描述 */
|
|
163
|
+
title: string;
|
|
164
|
+
/** Icon */
|
|
165
|
+
icon?: string;
|
|
166
|
+
/** 翻译字典 */
|
|
167
|
+
translation: Record<string, string>;
|
|
168
|
+
};
|
|
169
|
+
type LocaleConfigMap = Record<string, Locale>;
|
|
170
|
+
export type InterpolationType<T extends string> = {
|
|
171
|
+
[K in T]?: string | number | symbol | boolean;
|
|
172
|
+
};
|
|
173
|
+
export interface Locale extends LocaleConfig {
|
|
174
|
+
language: string;
|
|
175
|
+
}
|
|
176
|
+
/** 获取当前项目的语言列表 */
|
|
177
|
+
export const locales: Pick<Locale, 'language' | 'icon' | 'title'>[] = [];
|
|
178
|
+
export const resources: Partial<LocaleConfigMap> = {};
|
|
179
|
+
/**
|
|
180
|
+
* 插值字符串; 替换字符串中的占位符 `${}` 为对应的值
|
|
181
|
+
* @param {string} str 包含占位符的字符串
|
|
182
|
+
* @param {Argument} values 用于替换占位符的值,按照占位符出现的顺序排列
|
|
183
|
+
* @returns {string} 替换后的字符串
|
|
184
|
+
*/
|
|
185
|
+
export function interpolateString<T extends string>(
|
|
186
|
+
str: string,
|
|
187
|
+
values: InterpolationType<T>,
|
|
188
|
+
): string;
|
|
189
|
+
/** 设置语言
|
|
190
|
+
* @param {string} localeName 语言名称
|
|
191
|
+
* @returns {void}
|
|
192
|
+
* @example
|
|
193
|
+
* ```js
|
|
194
|
+
* setLang('zh_CN');
|
|
195
|
+
* ```
|
|
196
|
+
*/
|
|
197
|
+
export function setLang(localeName: string): void;
|
|
198
|
+
/** 使用的语言 */
|
|
199
|
+
export const lang: Omit<Locale, 'translation'>;
|
|
200
|
+
/** 映射 */
|
|
201
|
+
export const t: Record<string, string>;
|
|
202
|
+
/** 设置 */
|
|
203
|
+
export const setLocalizable: SetStoreFunction<{
|
|
204
|
+
lang: Omit<Locale, 'translation'>;
|
|
205
|
+
t: Record<string, string>;
|
|
206
|
+
}>;
|
|
207
|
+
}
|
|
157
208
|
declare module '@app/fallback' {
|
|
158
209
|
import { JSX } from 'solid-js';
|
|
159
210
|
const Fallback: null | (() => JSX.Element);
|
|
@@ -166,6 +217,11 @@ declare let __webpack_public_path__: string | undefined;
|
|
|
166
217
|
interface Window {
|
|
167
218
|
areaPaddingTop?: number;
|
|
168
219
|
areaPaddingBottom?: number;
|
|
220
|
+
__POWERED_BY_QIANKUN__?: boolean;
|
|
221
|
+
mainApp: {
|
|
222
|
+
container: HTMLElement;
|
|
223
|
+
[key: string]: any;
|
|
224
|
+
};
|
|
169
225
|
}
|
|
170
226
|
interface ICustomElement {
|
|
171
227
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
package/lib/entry.d.ts
CHANGED
|
@@ -1 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
import { type JSXElement } from 'solid-js';
|
|
2
|
+
type RenderAppProps = {
|
|
3
|
+
container?: HTMLElement;
|
|
4
|
+
base?: string;
|
|
5
|
+
fallback?: JSXElement;
|
|
6
|
+
language?: string;
|
|
7
|
+
};
|
|
8
|
+
declare function renderApp(props?: RenderAppProps): () => void;
|
|
9
|
+
export default renderApp;
|
package/lib/entry.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{createComponent as
|
|
1
|
+
import{createComponent as o}from"solid-js/web";import{Router as r,useRoutes as e}from"@solidjs/router";import{createRoot as t,getOwner as i}from"solid-js";import{render as n}from"solid-js/web";import m from"@app";import p from"@app/routes";export default function(l={}){let{container:s,base:a,fallback:d,language:u,...f}=l,c=a||m.base,b=s?.querySelector("#root")||document.getElementById("root");return window.mainApp={...f,container:b},t(()=>(b.replaceChildren(),n(function(){let t=e(p,c);return o(r,{base:c,get children(){return o(t,{})}})},b)),i())};
|
|
2
2
|
//# sourceMappingURL=entry.js.map
|
package/lib/entry.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/entry.tsx"],"sourcesContent":["import { type RouteDefinition, Router, useRoutes } from '@solidjs/router';\nimport { createRoot, getOwner } from 'solid-js';\nimport { render } from 'solid-js/web';\nimport app from '@app';\nimport routeDefinition from '@app/routes';\n\
|
|
1
|
+
{"version":3,"sources":["../src/entry.tsx"],"sourcesContent":["import { type RouteDefinition, Router, useRoutes } from '@solidjs/router';\nimport { type JSXElement, createRoot, getOwner } from 'solid-js';\nimport { render } from 'solid-js/web';\nimport app from '@app';\nimport routeDefinition from '@app/routes';\n\ntype RenderAppProps = {\n container?: HTMLElement;\n base?: string;\n fallback?: JSXElement;\n language?: string;\n};\n\nfunction renderApp(props: RenderAppProps = {}) {\n const { container, base, fallback, language, ...args } = props;\n const basename = base || app.base;\n const _container =\n (container?.querySelector('#root') as HTMLElement) ||\n (document.getElementById('root') as HTMLElement);\n\n window.mainApp = {\n ...args,\n container: _container,\n };\n return createRoot(() => {\n function App() {\n const Routes = useRoutes(routeDefinition as RouteDefinition[], basename);\n\n return (\n <Router base={basename}>\n <Routes />\n </Router>\n );\n }\n _container.replaceChildren();\n return render(App, _container);\n }, getOwner());\n}\n\nexport default renderApp;\n"],"names":["Router","useRoutes","createRoot","getOwner","render","app","routeDefinition","props","container","base","fallback","language","args","basename","_container","querySelector","document","getElementById","window","mainApp","replaceChildren","Routes"],"mappings":"8CAAA,QAA+BA,UAAAA,CAAM,CAAEC,aAAAA,CAAS,KAAQ,iBAAkB,AAC1E,QAA0BC,cAAAA,CAAU,CAAEC,YAAAA,CAAQ,KAAQ,UAAW,AACjE,QAASC,UAAAA,CAAM,KAAQ,cAAe,AACtC,QAAOC,MAAS,MAAO,AACvB,QAAOC,MAAqB,aAAc,AAmC1C,gBA1BA,SAAmBC,EAAwB,CAAC,CAAC,EAC3C,GAAM,CAAEC,UAAAA,CAAS,CAAEC,KAAAA,CAAI,CAAEC,SAAAA,CAAQ,CAAEC,SAAAA,CAAQ,CAAE,GAAGC,EAAM,CAAGL,EACnDM,EAAWJ,GAAQJ,EAAII,KACvBK,EACJ,AAACN,GAAWO,cAAc,UACzBC,SAASC,eAAe,QAM3B,OAJAC,OAAOC,QAAU,CACf,GAAGP,CAAI,CACPJ,UAAWM,CACb,EACOZ,EAAW,KAUhBY,EAAWM,kBACJhB,EAVP,WACE,IAAMiB,EAASpB,EAAUK,EAAsCO,GAE/D,SACGb,QAAaa,0BACXQ,QAGP,EAEmBP,IAClBX,IACL,CAEyB"}
|