resuxjs 0.4.0-beta.7 → 0.4.0
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/README.md +4 -2
- package/dist/_virtual/_rolldown/runtime.js +4 -0
- package/dist/build/index.d.ts +1 -2
- package/dist/cli.d.ts +3 -3
- package/dist/cli.js +125 -31
- package/dist/cli.js.map +1 -1
- package/dist/compiler/adapter.d.ts +2 -3
- package/dist/compiler/adapter.js +2 -2
- package/dist/compiler/dev-warnings.d.ts +1 -2
- package/dist/compiler/directives.d.ts +1 -2
- package/dist/compiler/directives.js +7 -3
- package/dist/compiler/directives.js.map +1 -1
- package/dist/compiler/implementation.d.ts +4 -2
- package/dist/compiler/implementation.js +101 -43
- package/dist/compiler/index.d.ts +2 -3
- package/dist/compiler/index.js +2 -2
- package/dist/compiler/index.js.map +1 -1
- package/dist/core/config.d.ts +1 -2
- package/dist/core/hooks.d.ts +10 -2
- package/dist/core/hooks.js.map +1 -1
- package/dist/core/index.d.ts +2 -2
- package/dist/core/module-container.d.ts +1 -2
- package/dist/core/module-container.js +2 -1
- package/dist/core/module-container.js.map +1 -1
- package/dist/core/resux.d.ts +1 -2
- package/dist/create.d.ts +1 -2
- package/dist/create.js +110 -33
- package/dist/create.js.map +1 -1
- package/dist/deploy/cloudflare.d.ts +1 -2
- package/dist/deploy/common.d.ts +1 -2
- package/dist/deploy/common.js +19 -3
- package/dist/deploy/common.js.map +1 -1
- package/dist/deploy/framework-runtime.d.ts +1 -2
- package/dist/deploy/index.d.ts +1 -2
- package/dist/deploy/netlify.d.ts +1 -2
- package/dist/deploy/node.d.ts +1 -2
- package/dist/deploy/production-report.d.ts +1 -2
- package/dist/deploy/runtime-dependencies.d.ts +1 -2
- package/dist/deploy/static.d.ts +1 -2
- package/dist/deploy/types.d.ts +1 -2
- package/dist/deploy/vercel.d.ts +1 -2
- package/dist/deploy/vercel.js +3 -3
- package/dist/deploy/vercel.js.map +1 -1
- package/dist/fonts/index.d.ts +1 -2
- package/dist/fonts/index.js.map +1 -1
- package/dist/globals.d.ts +1 -2
- package/dist/halal-core/ai/classifyProject.d.ts +1 -2
- package/dist/halal-core/ai/classifyRuntimeContent.d.ts +1 -2
- package/dist/halal-core/ai/createProjectSummary.d.ts +1 -2
- package/dist/halal-core/ai/halalClassifierPrompt.d.ts +1 -2
- package/dist/halal-core/ai/redactSensitiveData.d.ts +1 -2
- package/dist/halal-core/ai/validateAiResponse.d.ts +1 -2
- package/dist/halal-core/cli/check.d.ts +1 -2
- package/dist/halal-core/cli/explain.d.ts +1 -2
- package/dist/halal-core/cli/report.d.ts +1 -2
- package/dist/halal-core/cli/submitReview.d.ts +1 -2
- package/dist/halal-core/cli/verifyReview.d.ts +1 -2
- package/dist/halal-core/config.d.ts +2 -2
- package/dist/halal-core/config.js.map +1 -1
- package/dist/halal-core/crypto/integrity.d.ts +1 -2
- package/dist/halal-core/crypto/integrity.js +1 -1
- package/dist/halal-core/crypto/integrity.js.map +1 -1
- package/dist/halal-core/enforce.d.ts +4 -3
- package/dist/halal-core/enforce.js +31 -4
- package/dist/halal-core/enforce.js.map +1 -1
- package/dist/halal-core/lifecycle.d.ts +1 -2
- package/dist/halal-core/policy.d.ts +1 -2
- package/dist/halal-core/report/formatBrowserOverlay.d.ts +1 -2
- package/dist/halal-core/report/formatTerminalReport.d.ts +1 -2
- package/dist/halal-core/report/generateHalalReport.d.ts +1 -2
- package/dist/halal-core/report/signReport.d.ts +1 -2
- package/dist/halal-core/report/verifyReport.d.ts +1 -2
- package/dist/halal-core/review/createReviewRequest.d.ts +1 -2
- package/dist/halal-core/review/reviewPolicy.d.ts +1 -2
- package/dist/halal-core/review/signedReviewFile.d.ts +1 -2
- package/dist/halal-core/review/verifyReviewApproval.d.ts +1 -2
- package/dist/halal-core/rules/adultContentRules.d.ts +1 -2
- package/dist/halal-core/rules/alcoholDrugVapeRules.d.ts +1 -2
- package/dist/halal-core/rules/childSafetyRules.d.ts +1 -2
- package/dist/halal-core/rules/coreCategories.d.ts +1 -2
- package/dist/halal-core/rules/cyberAbuseRules.d.ts +1 -2
- package/dist/halal-core/rules/defaultBlockedRules.d.ts +1 -2
- package/dist/halal-core/rules/dependencyRules.d.ts +1 -2
- package/dist/halal-core/rules/endpointRules.d.ts +1 -2
- package/dist/halal-core/rules/environmentalHarmRules.d.ts +1 -2
- package/dist/halal-core/rules/financeRibaRules.d.ts +1 -2
- package/dist/halal-core/rules/gamblingRules.d.ts +1 -2
- package/dist/halal-core/rules/generalHarmRules.d.ts +1 -2
- package/dist/halal-core/rules/healthHarmRules.d.ts +1 -2
- package/dist/halal-core/rules/keywordRules.d.ts +1 -2
- package/dist/halal-core/rules/privacyAbuseRules.d.ts +1 -2
- package/dist/halal-core/rules/scamFraudRules.d.ts +1 -2
- package/dist/halal-core/rules/selfHarmRules.d.ts +1 -2
- package/dist/halal-core/rules/violenceExtremismRules.d.ts +1 -2
- package/dist/halal-core/runtime/guard.d.ts +1 -2
- package/dist/halal-core/runtime/guard.js.map +1 -1
- package/dist/halal-core/runtime/reviewedMemory.d.ts +1 -2
- package/dist/halal-core/runtime/serializeRuntimeContent.d.ts +1 -2
- package/dist/halal-core/runtime/types.d.ts +1 -2
- package/dist/halal-core/scanner/scanApiRoutes.d.ts +1 -2
- package/dist/halal-core/scanner/scanComponents.d.ts +1 -2
- package/dist/halal-core/scanner/scanContent.d.ts +1 -2
- package/dist/halal-core/scanner/scanDependencies.d.ts +1 -2
- package/dist/halal-core/scanner/scanDomains.d.ts +1 -2
- package/dist/halal-core/scanner/scanEnvNames.d.ts +1 -2
- package/dist/halal-core/scanner/scanMetadata.d.ts +1 -2
- package/dist/halal-core/scanner/scanPages.d.ts +1 -2
- package/dist/halal-core/scanner/scanProject.d.ts +1 -2
- package/dist/halal-core/scanner/scanRoutes.d.ts +1 -2
- package/dist/halal-core/scanner/scanTranslations.d.ts +1 -2
- package/dist/halal-core/status.d.ts +1 -2
- package/dist/halal-core/tamper/verifyCoreIntegrity.d.ts +1 -2
- package/dist/halal-core/tamper/verifyLifecycleHooks.d.ts +1 -2
- package/dist/halal-core/tamper/verifyReportSignature.d.ts +1 -2
- package/dist/head/utils.d.ts +15 -0
- package/dist/head/utils.js +52 -0
- package/dist/head/utils.js.map +1 -0
- package/dist/i18n/index.d.ts +1 -2
- package/dist/i18n/index.js.map +1 -1
- package/dist/i18n/shared.d.ts +1 -2
- package/dist/icons/api-fetcher.d.ts +1 -2
- package/dist/icons/cache.d.ts +1 -2
- package/dist/icons/cache.js.map +1 -1
- package/dist/icons/component.d.ts +7 -8
- package/dist/icons/constants.d.ts +1 -2
- package/dist/icons/css-mode.d.ts +1 -2
- package/dist/icons/index.d.ts +1 -2
- package/dist/icons/index.js.map +1 -1
- package/dist/icons/local-svg.d.ts +1 -2
- package/dist/icons/normalize.d.ts +1 -2
- package/dist/icons/offline-loader.d.ts +1 -2
- package/dist/icons/parser.d.ts +1 -2
- package/dist/icons/registry.d.ts +1 -2
- package/dist/icons/resolver.d.ts +1 -2
- package/dist/icons/svg-mode.d.ts +1 -2
- package/dist/icons/transform.d.ts +1 -2
- package/dist/icons/types.d.ts +1 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/kit/index.d.ts +1 -2
- package/dist/nitro-server/index.d.ts +1 -2
- package/dist/node.d.ts +1 -2
- package/dist/reactivity/computed.d.ts +1 -2
- package/dist/reactivity/computed.js.map +1 -1
- package/dist/reactivity/effect.d.ts +3 -3
- package/dist/reactivity/effect.js +8 -3
- package/dist/reactivity/effect.js.map +1 -1
- package/dist/reactivity/reactive.d.ts +1 -2
- package/dist/reactivity/reactive.js +221 -11
- package/dist/reactivity/reactive.js.map +1 -1
- package/dist/reactivity/ref.d.ts +1 -2
- package/dist/reactivity/ref.js.map +1 -1
- package/dist/reactivity/scheduler.d.ts +1 -2
- package/dist/reactivity/scheduler.js +2 -0
- package/dist/reactivity/scheduler.js.map +1 -1
- package/dist/reactivity/types.d.ts +1 -2
- package/dist/reactivity/utils.d.ts +1 -2
- package/dist/reactivity/watch.d.ts +1 -2
- package/dist/reactivity/watch.js.map +1 -1
- package/dist/runtime/core.d.ts +1 -2
- package/dist/runtime/core.js.map +1 -1
- package/dist/runtime/index.d.ts +19 -2
- package/dist/runtime/index.js +921 -170
- package/dist/runtime/index.js.map +1 -1
- package/dist/runtime/resume.d.ts +1 -2
- package/dist/runtime/resume.js.map +1 -1
- package/dist/runtime/router.d.ts +1 -2
- package/dist/runtime/router.js.map +1 -1
- package/dist/runtime/streaming.d.ts +1 -2
- package/dist/runtime/streaming.js.map +1 -1
- package/dist/runtime/view-transitions/detect.d.ts +1 -2
- package/dist/runtime/view-transitions/transition.d.ts +1 -2
- package/dist/runtime/view-transitions/types.d.ts +1 -2
- package/dist/security/media-fetch.d.ts +1 -2
- package/dist/security/media-fetch.js.map +1 -1
- package/dist/security/path-boundary.d.ts +1 -2
- package/dist/security/path-boundary.js +10 -4
- package/dist/security/path-boundary.js.map +1 -1
- package/dist/ui/index.d.ts +41 -42
- package/dist/ui/verification-code.d.ts +9 -10
- package/dist/ui/verification-code.js.map +1 -1
- package/dist/vite-builder/index.d.ts +1 -2
- package/package.json +2 -2
- package/templates/default/.env.example +3 -0
- package/templates/default/nitro.config.ts +16 -4
package/dist/i18n/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../src/i18n/index.ts"],"sourcesContent":["import { readFile } from \"node:fs/promises\";\nimport path from \"node:path\";\nimport { fileURLToPath, pathToFileURL } from \"node:url\";\nimport {\n computed,\n ref,\n defineResuxModule,\n type ResuxModuleContext,\n type Ref,\n useResuxApp,\n type ResuxRouter,\n type RuntimeConfig\n} from \"../runtime/index.js\";\nimport {\n buildLocalePath,\n createI18nHead,\n normalizeI18nRuntimeConfig,\n normalizeI18nStrategy,\n resolveI18nRoute,\n resolveLocaleDirection,\n resolveLocalizedValue,\n translateRaw,\n translateText,\n type ResuxI18nLocale,\n type ResuxI18nRuntimeConfig,\n type ResuxI18nStrategy,\n type ResuxI18nTranslationParams\n} from \"./shared.js\";\n\ntype MessageRecord = Record<string, unknown>;\n\nexport interface ResuxI18nLocaleInput {\n code: string;\n name?: string;\n dir?: \"ltr\" | \"rtl\";\n}\n\nexport type ResuxI18nMessageSource =\n | MessageRecord\n | string\n | (() => unknown | Promise<unknown>);\n\nexport interface ResuxI18nConfigInput {\n defaultLocale: string;\n fallbackLocale?: string;\n strategy?: ResuxI18nStrategy;\n locales: ResuxI18nLocaleInput[];\n messages?: Record<string, ResuxI18nMessageSource>;\n seo?: {\n hreflang?: boolean;\n };\n}\n\nexport interface ResuxI18nModuleOptions extends Partial<ResuxI18nConfigInput> {}\n\nexport interface UseI18nResult {\n locale: ReturnType<typeof computed<string>>;\n dir: ReturnType<typeof computed<\"ltr\" | \"rtl\">>;\n locales: ResuxI18nLocale[];\n defaultLocale: string;\n fallbackLocale: string;\n strategy: ResuxI18nStrategy;\n t: (key: string, params?: ResuxI18nTranslationParams) => string;\n tm: (key: string) => unknown;\n resolveLocalized: (value: unknown) => string | null;\n localePath: (to: string, localeCode?: string) => string;\n switchLocalePath: (localeCode: string, to?: string) => string;\n setLocale: (localeCode: string, to?: string) => Promise<void> | void;\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return Boolean(value && typeof value === \"object\" && !Array.isArray(value));\n}\n\nfunction readCurrentRoutePath(): string {\n if (typeof window !== \"undefined\" && typeof location !== \"undefined\") {\n return `${location.pathname}${location.search}${location.hash}`;\n }\n\n const app = useResuxApp();\n const currentRoute = app.route;\n if (currentRoute && typeof currentRoute.path === \"string\" && currentRoute.path.trim()) {\n return currentRoute.path;\n }\n\n return \"/\";\n}\n\nfunction readClientRouter(): ResuxRouter | null {\n const maybeRouter = (globalThis as { __RESUX_ROUTER__?: unknown }).__RESUX_ROUTER__;\n if (!isRecord(maybeRouter)) {\n return null;\n }\n const push = maybeRouter.push;\n const replace = maybeRouter.replace;\n const back = maybeRouter.back;\n const forward = maybeRouter.forward;\n const go = maybeRouter.go;\n if (\n typeof push !== \"function\"\n || typeof replace !== \"function\"\n || typeof back !== \"function\"\n || typeof forward !== \"function\"\n || typeof go !== \"function\"\n ) {\n return null;\n }\n return maybeRouter as unknown as ResuxRouter;\n}\n\nfunction extractDynamicImportPath(fn: () => unknown): string | null {\n const source = String(fn);\n const match = source.match(/import\\(([\"'`])(.+?)\\1\\)/);\n if (!match) {\n return null;\n }\n return match[2] ?? null;\n}\n\nfunction normalizeMessageModule(value: unknown): MessageRecord {\n if (isRecord(value) && isRecord(value.default)) {\n return value.default;\n }\n return isRecord(value) ? value : {};\n}\n\nasync function loadMessageFromPath(rootDir: string, filePath: string): Promise<MessageRecord> {\n let absolute = filePath;\n if (filePath.startsWith(\"file://\")) {\n try {\n absolute = fileURLToPath(filePath);\n } catch {\n absolute = filePath;\n }\n } else if (!path.isAbsolute(filePath)) {\n absolute = path.resolve(rootDir, filePath);\n }\n\n const cleanPath = absolute.split(\"?\")[0].split(\"#\")[0];\n if (cleanPath.toLowerCase().endsWith(\".json\")) {\n try {\n return JSON.parse(await readFile(cleanPath, \"utf8\")) as MessageRecord;\n } catch {\n return {};\n }\n }\n try {\n const imported = await import(filePath.startsWith(\"file://\") ? filePath : pathToFileURL(absolute).href);\n return normalizeMessageModule(imported.default ?? imported);\n } catch {\n return {};\n }\n}\n\nasync function resolveMessageSource(rootDir: string, source: ResuxI18nMessageSource | undefined): Promise<MessageRecord> {\n if (!source) {\n return {};\n }\n\n if (typeof source === \"string\") {\n return loadMessageFromPath(rootDir, source);\n }\n\n if (typeof source === \"function\") {\n const dynamicPath = extractDynamicImportPath(source);\n if (dynamicPath) {\n const absolute = path.isAbsolute(dynamicPath) ? dynamicPath : path.resolve(rootDir, dynamicPath);\n if (absolute.toLowerCase().endsWith(\".json\")) {\n return loadMessageFromPath(rootDir, absolute);\n }\n }\n try {\n const loaded = await source();\n return normalizeMessageModule(loaded);\n } catch {\n if (dynamicPath) {\n return loadMessageFromPath(rootDir, dynamicPath);\n }\n return {};\n }\n }\n\n return normalizeMessageModule(source);\n}\n\nasync function resolveMessages(\n rootDir: string,\n locales: ResuxI18nLocaleInput[],\n messages: Record<string, ResuxI18nMessageSource> | undefined\n): Promise<Record<string, MessageRecord>> {\n const resolved: Record<string, MessageRecord> = {};\n for (const locale of locales) {\n const code = String(locale.code || \"\").trim().toLowerCase();\n if (!code) {\n continue;\n }\n resolved[code] = await resolveMessageSource(rootDir, messages?.[code]);\n }\n return resolved;\n}\n\nasync function buildRuntimeI18nConfig(\n context: ResuxModuleContext,\n inlineOptions: ResuxI18nModuleOptions\n): Promise<ResuxI18nRuntimeConfig | null> {\n const configFromResux = isRecord(context.options.i18n) ? context.options.i18n : {};\n const inline = isRecord(inlineOptions) ? inlineOptions : {};\n const rawLocales = Array.isArray(inline.locales)\n ? inline.locales\n : Array.isArray(configFromResux.locales)\n ? configFromResux.locales\n : [];\n const mergedMessages = {\n ...(isRecord(configFromResux.messages) ? configFromResux.messages : {}),\n ...(isRecord(inline.messages) ? inline.messages : {})\n };\n const mergedSeo = {\n ...(isRecord(configFromResux.seo) ? configFromResux.seo : {}),\n ...(isRecord(inline.seo) ? inline.seo : {})\n };\n const merged = {\n ...configFromResux,\n ...inline,\n locales: rawLocales,\n messages: mergedMessages,\n seo: mergedSeo\n } as ResuxI18nConfigInput;\n\n if (!Array.isArray(merged.locales) || !merged.locales.length) {\n return null;\n }\n\n const locales: ResuxI18nLocaleInput[] = merged.locales\n .filter((locale) => isRecord(locale))\n .map((locale) => ({\n code: String(locale.code ?? \"\").trim().toLowerCase(),\n name: typeof locale.name === \"string\" ? locale.name : undefined,\n dir: locale.dir === \"rtl\" ? \"rtl\" as const : \"ltr\" as const\n }))\n .filter((locale) => locale.code.length > 0);\n\n if (!locales.length) {\n return null;\n }\n\n const firstLocale = locales[0].code;\n const rawConfig: Record<string, unknown> = {\n defaultLocale: typeof merged.defaultLocale === \"string\" ? merged.defaultLocale.toLowerCase() : firstLocale,\n fallbackLocale: typeof merged.fallbackLocale === \"string\" ? merged.fallbackLocale.toLowerCase() : undefined,\n strategy: normalizeI18nStrategy(merged.strategy),\n locales,\n messages: await resolveMessages(context.rootDir, locales, merged.messages),\n seo: {\n hreflang: !isRecord(merged.seo) || merged.seo.hreflang !== false\n }\n };\n\n return normalizeI18nRuntimeConfig(rawConfig);\n}\n\nfunction readRuntimeI18nConfig(): ResuxI18nRuntimeConfig | null {\n const runtimeConfig = useResuxApp().$config as RuntimeConfig;\n const publicConfig = isRecord(runtimeConfig.public) ? runtimeConfig.public : {};\n return normalizeI18nRuntimeConfig(publicConfig.i18n);\n}\n\nconst I18N_LOCALE_STATE_KEY = \"__resux_i18n_locale_state\";\n\nfunction resolveConfiguredLocale(config: ResuxI18nRuntimeConfig, localeCode: string): ResuxI18nLocale | null {\n const normalized = String(localeCode || \"\").trim().toLowerCase();\n return config.locales.find((locale) => locale.code === normalized) ?? null;\n}\n\nfunction useI18nLocaleState(config: ResuxI18nRuntimeConfig): Ref<string> {\n const app = useResuxApp();\n const existing = app.provides[I18N_LOCALE_STATE_KEY];\n if (isRecord(existing) && typeof existing.value === \"string\") {\n return existing as unknown as Ref<string>;\n }\n\n const initialLocale = resolveI18nRoute(readCurrentRoutePath(), config).locale.code;\n const state = ref(initialLocale);\n app.provide(I18N_LOCALE_STATE_KEY, state);\n return state;\n}\n\nfunction applyNoPrefixDocumentLocale(config: ResuxI18nRuntimeConfig, localeCode: string): void {\n if (typeof document === \"undefined\") {\n return;\n }\n const html = document.documentElement;\n if (!html) {\n return;\n }\n html.setAttribute(\"lang\", localeCode);\n html.setAttribute(\"dir\", resolveLocaleDirection(config, localeCode));\n}\n\nfunction fallbackI18nConfig(): ResuxI18nRuntimeConfig {\n return {\n defaultLocale: \"en\",\n fallbackLocale: \"en\",\n strategy: \"prefix_except_default\",\n locales: [{ code: \"en\", dir: \"ltr\", name: \"English\" }],\n messages: { en: {} }\n };\n}\n\nexport function useI18n(): UseI18nResult {\n const runtimeI18n = readRuntimeI18nConfig() ?? fallbackI18nConfig();\n const localeState = useI18nLocaleState(runtimeI18n);\n const locale = computed(() => runtimeI18n.strategy === \"no_prefix\"\n ? localeState.value\n : resolveI18nRoute(readCurrentRoutePath(), runtimeI18n).locale.code);\n const dir = computed(() => resolveLocaleDirection(runtimeI18n, locale.value));\n\n return {\n locale,\n dir,\n locales: runtimeI18n.locales,\n defaultLocale: runtimeI18n.defaultLocale,\n fallbackLocale: runtimeI18n.fallbackLocale,\n strategy: runtimeI18n.strategy,\n t(key: string, params: ResuxI18nTranslationParams = {}): string {\n return translateText(runtimeI18n, locale.value, key, params);\n },\n tm(key: string): unknown {\n return translateRaw(runtimeI18n, locale.value, key);\n },\n resolveLocalized(value: unknown): string | null {\n return resolveLocalizedValue(value, locale.value, runtimeI18n.fallbackLocale);\n },\n localePath(to: string, localeCode?: string): string {\n return buildLocalePath(to, localeCode ?? locale.value, runtimeI18n);\n },\n switchLocalePath(localeCode: string, to?: string): string {\n return buildLocalePath(to ?? readCurrentRoutePath(), localeCode, runtimeI18n);\n },\n setLocale(localeCode: string, to?: string): Promise<void> | void {\n const targetLocale = resolveConfiguredLocale(runtimeI18n, localeCode);\n if (!targetLocale) {\n return;\n }\n if (runtimeI18n.strategy === \"no_prefix\") {\n localeState.value = targetLocale.code;\n applyNoPrefixDocumentLocale(runtimeI18n, targetLocale.code);\n return;\n }\n\n const target = buildLocalePath(to ?? readCurrentRoutePath(), targetLocale.code, runtimeI18n);\n const router = readClientRouter();\n if (router) {\n return router.push(target);\n }\n if (typeof window !== \"undefined\" && typeof location !== \"undefined\") {\n location.assign(target);\n }\n }\n };\n}\n\nexport function useLocalePath(): (to: string, localeCode?: string) => string {\n const { localePath } = useI18n();\n return localePath;\n}\n\nexport function useSwitchLocalePath(): (localeCode: string, to?: string) => string {\n const { switchLocalePath } = useI18n();\n return switchLocalePath;\n}\n\nexport function defineI18nConfig<T extends ResuxI18nConfigInput>(config: T): T {\n return config;\n}\n\nexport function createI18nHeadEntry(routePath: string, routeOrigin?: string): { htmlAttrs: Record<string, string>; link: Array<Record<string, string>> } {\n const runtimeI18n = readRuntimeI18nConfig();\n if (!runtimeI18n) {\n return { htmlAttrs: { lang: \"en\", dir: \"ltr\" }, link: [] };\n }\n return createI18nHead(routePath, routeOrigin, runtimeI18n);\n}\n\nexport default defineResuxModule<ResuxI18nModuleOptions>({\n defaults: {\n strategy: \"prefix_except_default\"\n },\n async setup(options, context) {\n const runtimeI18n = await buildRuntimeI18nConfig(context, options ?? {});\n if (!runtimeI18n) {\n return;\n }\n\n const sourceI18n = isRecord((context.options as Record<string, unknown>).i18n)\n ? (context.options as Record<string, unknown>).i18n as Record<string, unknown>\n : {};\n const sourceSeo = isRecord(sourceI18n.seo) ? sourceI18n.seo : {};\n const inlineSeoSource = isRecord(options) ? options : {};\n const inlineSeo = isRecord(inlineSeoSource.seo) ? inlineSeoSource.seo : {};\n const hreflangEnabled = sourceSeo.hreflang !== false;\n const hreflangInline = inlineSeo.hreflang !== false;\n\n context.extendRuntimeConfig({\n public: {\n i18n: {\n ...runtimeI18n,\n seo: {\n hreflang: hreflangEnabled && hreflangInline\n }\n }\n }\n });\n\n // Under the \"prefix\" strategy every locale is prefixed, so the bare root\n // path has no matching page. Redirect it to the default locale instead of\n // 404ing.\n if (runtimeI18n.strategy === \"prefix\") {\n context.addRouteRule(\"/\", {\n redirect: { to: `/${runtimeI18n.defaultLocale}`, statusCode: 302 }\n });\n }\n }\n});\n\nif (typeof globalThis !== \"undefined\") {\n (globalThis as any).__RESUX_USE_I18N__ ??= useI18n;\n (globalThis as any).__RESUX_USE_LOCALE_PATH__ ??= useLocalePath;\n (globalThis as any).__RESUX_USE_SWITCH_LOCALE_PATH__ ??= useSwitchLocalePath;\n}\n"],"mappings":";;;;;;;;AAsEA,SAAS,SAAS,OAAkD;CAClE,OAAO,QAAQ,SAAS,OAAO,UAAU,YAAY,CAAC,MAAM,QAAQ,KAAK,CAAC;AAC5E;AAEA,SAAS,uBA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B,oBAAoB,WAAmB,aAAkG;CACvJ,MAAM,cAAc,sBAAsB;CAC1C,IAAI,CAAC,aACH,OAAO;EAAE,WAAW;GAAE,MAAM;GAAM,KAAK;EAAM;EAAG,MAAM,CAAC;CAAE;CAE3D,OAAO,eAAe,WAAW,aAAa,WAAW;AAC3D;AAEA,IAAA,eAAe,kBAA0C;CACvD,UAAU,EACR,UAAU,wBACZ;CACA,MAAM,MAAM,SAAS,SAAS;EAC5B,MAAM,cAAc,MAAM,uBAAuB,SAAS,WAAW,CAAC,CAAC;EACvE,IAAI,CAAC,aACH;EAGF,MAAM,aAAa,SAAU,QAAQ,QAAoC,IAAI,IACxE,QAAQ,QAAoC,OAC7C,CAAC;EACL,MAAM,YAAY,SAAS,WAAW,GAAG,IAAI,WAAW,MAAM,CAAC;EAC/D,MAAM,kBAAkB,SAAS,OAAO,IAAI,UAAU,CAAC;EACvD,MAAM,YAAY,SAAS,gBAAgB,GAAG,IAAI,gBAAgB,MAAM,CAAC;EACzE,MAAM,kBAAkB,UAAU,aAAa;EAC/C,MAAM,iBAAiB,UAAU,aAAa;EAE9C,QAAQ,oBAAoB,EAC1B,QAAQ,EACN,MAAM;GACJ,GAAG;GACH,KAAK,EACH,UAAU,mBAAmB,eAC/B;EACF,EACF,EACF,CAAC;EAKD,IAAI,YAAY,aAAa,UAC3B,QAAQ,aAAa,KAAK,EACxB,UAAU;GAAE,IAAI,IAAI,YAAY;GAAiB,YAAY;EAAI,EACnE,CAAC;CAEL;AACF,CAAC;AAED,IAAI,OAAO,eAAe,aAAa;CACrC,WAAoB,uBAAuB;CAC3C,WAAoB,8BAA8B;CAClD,WAAoB,qCAAqC;AAC3D"}
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../src/i18n/index.ts"],"sourcesContent":["import { readFile } from \"node:fs/promises\";\nimport path from \"node:path\";\nimport { fileURLToPath, pathToFileURL } from \"node:url\";\nimport {\n computed,\n ref,\n defineResuxModule,\n type ResuxModuleContext,\n type Ref,\n useResuxApp,\n type ResuxRouter,\n type RuntimeConfig\n} from \"../runtime/index.js\";\nimport {\n buildLocalePath,\n createI18nHead,\n normalizeI18nRuntimeConfig,\n normalizeI18nStrategy,\n resolveI18nRoute,\n resolveLocaleDirection,\n resolveLocalizedValue,\n translateRaw,\n translateText,\n type ResuxI18nLocale,\n type ResuxI18nRuntimeConfig,\n type ResuxI18nStrategy,\n type ResuxI18nTranslationParams\n} from \"./shared.js\";\n\ntype MessageRecord = Record<string, unknown>;\n\nexport interface ResuxI18nLocaleInput {\n code: string;\n name?: string;\n dir?: \"ltr\" | \"rtl\";\n}\n\nexport type ResuxI18nMessageSource =\n | MessageRecord\n | string\n | (() => unknown | Promise<unknown>);\n\nexport interface ResuxI18nConfigInput {\n defaultLocale: string;\n fallbackLocale?: string;\n strategy?: ResuxI18nStrategy;\n locales: ResuxI18nLocaleInput[];\n messages?: Record<string, ResuxI18nMessageSource>;\n seo?: {\n hreflang?: boolean;\n };\n}\n\nexport interface ResuxI18nModuleOptions extends Partial<ResuxI18nConfigInput> {}\n\nexport interface UseI18nResult {\n locale: ReturnType<typeof computed<string>>;\n dir: ReturnType<typeof computed<\"ltr\" | \"rtl\">>;\n locales: ResuxI18nLocale[];\n defaultLocale: string;\n fallbackLocale: string;\n strategy: ResuxI18nStrategy;\n t: (key: string, params?: ResuxI18nTranslationParams) => string;\n tm: (key: string) => unknown;\n resolveLocalized: (value: unknown) => string | null;\n localePath: (to: string, localeCode?: string) => string;\n switchLocalePath: (localeCode: string, to?: string) => string;\n setLocale: (localeCode: string, to?: string) => Promise<void> | void;\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return Boolean(value && typeof value === \"object\" && !Array.isArray(value));\n}\n\nfunction readCurrentRoutePath(): string {\n if (typeof window !== \"undefined\" && typeof location !== \"undefined\") {\n return `${location.pathname}${location.search}${location.hash}`;\n }\n\n const app = useResuxApp();\n const currentRoute = app.route;\n if (currentRoute && typeof currentRoute.path === \"string\" && currentRoute.path.trim()) {\n return currentRoute.path;\n }\n\n return \"/\";\n}\n\nfunction readClientRouter(): ResuxRouter | null {\n const maybeRouter = (globalThis as { __RESUX_ROUTER__?: unknown }).__RESUX_ROUTER__;\n if (!isRecord(maybeRouter)) {\n return null;\n }\n const push = maybeRouter.push;\n const replace = maybeRouter.replace;\n const back = maybeRouter.back;\n const forward = maybeRouter.forward;\n const go = maybeRouter.go;\n if (\n typeof push !== \"function\"\n || typeof replace !== \"function\"\n || typeof back !== \"function\"\n || typeof forward !== \"function\"\n || typeof go !== \"function\"\n ) {\n return null;\n }\n return maybeRouter as unknown as ResuxRouter;\n}\n\nfunction extractDynamicImportPath(fn: () => unknown): string | null {\n const source = String(fn);\n const match = source.match(/import\\(([\"'`])(.+?)\\1\\)/);\n if (!match) {\n return null;\n }\n return match[2] ?? null;\n}\n\nfunction normalizeMessageModule(value: unknown): MessageRecord {\n if (isRecord(value) && isRecord(value.default)) {\n return value.default;\n }\n return isRecord(value) ? value : {};\n}\n\nasync function loadMessageFromPath(rootDir: string, filePath: string): Promise<MessageRecord> {\n let absolute = filePath;\n if (filePath.startsWith(\"file://\")) {\n try {\n absolute = fileURLToPath(filePath);\n } catch {\n absolute = filePath;\n }\n } else if (!path.isAbsolute(filePath)) {\n absolute = path.resolve(rootDir, filePath);\n }\n\n const cleanPath = absolute.split(\"?\")[0].split(\"#\")[0];\n if (cleanPath.toLowerCase().endsWith(\".json\")) {\n try {\n return JSON.parse(await readFile(cleanPath, \"utf8\")) as MessageRecord;\n } catch {\n return {};\n }\n }\n try {\n const imported = await import(filePath.startsWith(\"file://\") ? filePath : pathToFileURL(absolute).href);\n return normalizeMessageModule(imported.default ?? imported);\n } catch {\n return {};\n }\n}\n\nasync function resolveMessageSource(rootDir: string, source: ResuxI18nMessageSource | undefined): Promise<MessageRecord> {\n if (!source) {\n return {};\n }\n\n if (typeof source === \"string\") {\n return loadMessageFromPath(rootDir, source);\n }\n\n if (typeof source === \"function\") {\n const dynamicPath = extractDynamicImportPath(source);\n if (dynamicPath) {\n const absolute = path.isAbsolute(dynamicPath) ? dynamicPath : path.resolve(rootDir, dynamicPath);\n if (absolute.toLowerCase().endsWith(\".json\")) {\n return loadMessageFromPath(rootDir, absolute);\n }\n }\n try {\n const loaded = await source();\n return normalizeMessageModule(loaded);\n } catch {\n if (dynamicPath) {\n return loadMessageFromPath(rootDir, dynamicPath);\n }\n return {};\n }\n }\n\n return normalizeMessageModule(source);\n}\n\nasync function resolveMessages(\n rootDir: string,\n locales: ResuxI18nLocaleInput[],\n messages: Record<string, ResuxI18nMessageSource> | undefined\n): Promise<Record<string, MessageRecord>> {\n const resolved: Record<string, MessageRecord> = {};\n for (const locale of locales) {\n const code = String(locale.code || \"\").trim().toLowerCase();\n if (!code) {\n continue;\n }\n resolved[code] = await resolveMessageSource(rootDir, messages?.[code]);\n }\n return resolved;\n}\n\nasync function buildRuntimeI18nConfig(\n context: ResuxModuleContext,\n inlineOptions: ResuxI18nModuleOptions\n): Promise<ResuxI18nRuntimeConfig | null> {\n const configFromResux = isRecord(context.options.i18n) ? context.options.i18n : {};\n const inline = isRecord(inlineOptions) ? inlineOptions : {};\n const rawLocales = Array.isArray(inline.locales)\n ? inline.locales\n : Array.isArray(configFromResux.locales)\n ? configFromResux.locales\n : [];\n const mergedMessages = {\n ...(isRecord(configFromResux.messages) ? configFromResux.messages : {}),\n ...(isRecord(inline.messages) ? inline.messages : {})\n };\n const mergedSeo = {\n ...(isRecord(configFromResux.seo) ? configFromResux.seo : {}),\n ...(isRecord(inline.seo) ? inline.seo : {})\n };\n const merged = {\n ...configFromResux,\n ...inline,\n locales: rawLocales,\n messages: mergedMessages,\n seo: mergedSeo\n } as ResuxI18nConfigInput;\n\n if (!Array.isArray(merged.locales) || !merged.locales.length) {\n return null;\n }\n\n const locales: ResuxI18nLocaleInput[] = merged.locales\n .filter((locale) => isRecord(locale))\n .map((locale) => ({\n code: String(locale.code ?? \"\").trim().toLowerCase(),\n name: typeof locale.name === \"string\" ? locale.name : undefined,\n dir: locale.dir === \"rtl\" ? \"rtl\" as const : \"ltr\" as const\n }))\n .filter((locale) => locale.code.length > 0);\n\n if (!locales.length) {\n return null;\n }\n\n const firstLocale = locales[0].code;\n const rawConfig: Record<string, unknown> = {\n defaultLocale: typeof merged.defaultLocale === \"string\" ? merged.defaultLocale.toLowerCase() : firstLocale,\n fallbackLocale: typeof merged.fallbackLocale === \"string\" ? merged.fallbackLocale.toLowerCase() : undefined,\n strategy: normalizeI18nStrategy(merged.strategy),\n locales,\n messages: await resolveMessages(context.rootDir, locales, merged.messages),\n seo: {\n hreflang: !isRecord(merged.seo) || merged.seo.hreflang !== false\n }\n };\n\n return normalizeI18nRuntimeConfig(rawConfig);\n}\n\nfunction readRuntimeI18nConfig(): ResuxI18nRuntimeConfig | null {\n const runtimeConfig = useResuxApp().$config as RuntimeConfig;\n const publicConfig = isRecord(runtimeConfig.public) ? runtimeConfig.public : {};\n return normalizeI18nRuntimeConfig(publicConfig.i18n);\n}\n\nconst I18N_LOCALE_STATE_KEY = \"__resux_i18n_locale_state\";\n\nfunction resolveConfiguredLocale(config: ResuxI18nRuntimeConfig, localeCode: string): ResuxI18nLocale | null {\n const normalized = String(localeCode || \"\").trim().toLowerCase();\n return config.locales.find((locale) => locale.code === normalized) ?? null;\n}\n\nfunction useI18nLocaleState(config: ResuxI18nRuntimeConfig): Ref<string> {\n const app = useResuxApp();\n const existing = app.provides[I18N_LOCALE_STATE_KEY];\n if (isRecord(existing) && typeof existing.value === \"string\") {\n return existing as unknown as Ref<string>;\n }\n\n const initialLocale = resolveI18nRoute(readCurrentRoutePath(), config).locale.code;\n const state = ref(initialLocale);\n app.provide(I18N_LOCALE_STATE_KEY, state);\n return state;\n}\n\nfunction applyNoPrefixDocumentLocale(config: ResuxI18nRuntimeConfig, localeCode: string): void {\n if (typeof document === \"undefined\") {\n return;\n }\n const html = document.documentElement;\n if (!html) {\n return;\n }\n html.setAttribute(\"lang\", localeCode);\n html.setAttribute(\"dir\", resolveLocaleDirection(config, localeCode));\n}\n\nfunction fallbackI18nConfig(): ResuxI18nRuntimeConfig {\n return {\n defaultLocale: \"en\",\n fallbackLocale: \"en\",\n strategy: \"prefix_except_default\",\n locales: [{ code: \"en\", dir: \"ltr\", name: \"English\" }],\n messages: { en: {} }\n };\n}\n\nexport function useI18n(): UseI18nResult {\n const runtimeI18n = readRuntimeI18nConfig() ?? fallbackI18nConfig();\n const localeState = useI18nLocaleState(runtimeI18n);\n const locale = computed(() => runtimeI18n.strategy === \"no_prefix\"\n ? localeState.value\n : resolveI18nRoute(readCurrentRoutePath(), runtimeI18n).locale.code);\n const dir = computed(() => resolveLocaleDirection(runtimeI18n, locale.value));\n\n return {\n locale,\n dir,\n locales: runtimeI18n.locales,\n defaultLocale: runtimeI18n.defaultLocale,\n fallbackLocale: runtimeI18n.fallbackLocale,\n strategy: runtimeI18n.strategy,\n t(key: string, params: ResuxI18nTranslationParams = {}): string {\n return translateText(runtimeI18n, locale.value, key, params);\n },\n tm(key: string): unknown {\n return translateRaw(runtimeI18n, locale.value, key);\n },\n resolveLocalized(value: unknown): string | null {\n return resolveLocalizedValue(value, locale.value, runtimeI18n.fallbackLocale);\n },\n localePath(to: string, localeCode?: string): string {\n return buildLocalePath(to, localeCode ?? locale.value, runtimeI18n);\n },\n switchLocalePath(localeCode: string, to?: string): string {\n return buildLocalePath(to ?? readCurrentRoutePath(), localeCode, runtimeI18n);\n },\n setLocale(localeCode: string, to?: string): Promise<void> | void {\n const targetLocale = resolveConfiguredLocale(runtimeI18n, localeCode);\n if (!targetLocale) {\n return;\n }\n if (runtimeI18n.strategy === \"no_prefix\") {\n localeState.value = targetLocale.code;\n applyNoPrefixDocumentLocale(runtimeI18n, targetLocale.code);\n return;\n }\n\n const target = buildLocalePath(to ?? readCurrentRoutePath(), targetLocale.code, runtimeI18n);\n const router = readClientRouter();\n if (router) {\n return router.push(target);\n }\n if (typeof window !== \"undefined\" && typeof location !== \"undefined\") {\n location.assign(target);\n }\n }\n };\n}\n\nexport function useLocalePath(): (to: string, localeCode?: string) => string {\n const { localePath } = useI18n();\n return localePath;\n}\n\nexport function useSwitchLocalePath(): (localeCode: string, to?: string) => string {\n const { switchLocalePath } = useI18n();\n return switchLocalePath;\n}\n\nexport function defineI18nConfig<T extends ResuxI18nConfigInput>(config: T): T {\n return config;\n}\n\nexport function createI18nHeadEntry(routePath: string, routeOrigin?: string): { htmlAttrs: Record<string, string>; link: Array<Record<string, string>> } {\n const runtimeI18n = readRuntimeI18nConfig();\n if (!runtimeI18n) {\n return { htmlAttrs: { lang: \"en\", dir: \"ltr\" }, link: [] };\n }\n return createI18nHead(routePath, routeOrigin, runtimeI18n);\n}\n\nexport default defineResuxModule<ResuxI18nModuleOptions>({\n defaults: {\n strategy: \"prefix_except_default\"\n },\n async setup(options, context) {\n const runtimeI18n = await buildRuntimeI18nConfig(context, options ?? {});\n if (!runtimeI18n) {\n return;\n }\n\n const sourceI18n = isRecord((context.options as Record<string, unknown>).i18n)\n ? (context.options as Record<string, unknown>).i18n as Record<string, unknown>\n : {};\n const sourceSeo = isRecord(sourceI18n.seo) ? sourceI18n.seo : {};\n const inlineSeoSource = isRecord(options) ? options : {};\n const inlineSeo = isRecord(inlineSeoSource.seo) ? inlineSeoSource.seo : {};\n const hreflangEnabled = sourceSeo.hreflang !== false;\n const hreflangInline = inlineSeo.hreflang !== false;\n\n context.extendRuntimeConfig({\n public: {\n i18n: {\n ...runtimeI18n,\n seo: {\n hreflang: hreflangEnabled && hreflangInline\n }\n }\n }\n });\n\n // Under the \"prefix\" strategy every locale is prefixed, so the bare root\n // path has no matching page. Redirect it to the default locale instead of\n // 404ing.\n if (runtimeI18n.strategy === \"prefix\") {\n context.addRouteRule(\"/\", {\n redirect: { to: `/${runtimeI18n.defaultLocale}`, statusCode: 302 }\n });\n }\n }\n});\n\nif (typeof globalThis !== \"undefined\") {\n (globalThis as any).__RESUX_USE_I18N__ ??= useI18n;\n (globalThis as any).__RESUX_USE_LOCALE_PATH__ ??= useL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,qCAAqC;AAC3D"}
|
package/dist/i18n/shared.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
import { IconCacheManager } from "./cache.js";
|
|
2
2
|
import { IconData } from "./types.js";
|
|
3
|
-
export declare function fetchIconifyIcon(rawName: string, apiProvider?: string, cache?: IconCacheManager): Promise<IconData | null>;
|
|
4
|
-
//# sourceMappingURL=api-fetcher.d.ts.map
|
|
3
|
+
export declare function fetchIconifyIcon(rawName: string, apiProvider?: string, cache?: IconCacheManager): Promise<IconData | null>;
|
package/dist/icons/cache.d.ts
CHANGED
|
@@ -18,5 +18,4 @@ export declare class IconCacheManager {
|
|
|
18
18
|
deletePending(key: string): void;
|
|
19
19
|
runWithSlot<T>(task: () => Promise<T>): Promise<T | null>;
|
|
20
20
|
}
|
|
21
|
-
export declare const defaultIconCache: IconCacheManager;
|
|
22
|
-
//# sourceMappingURL=cache.d.ts.map
|
|
21
|
+
export declare const defaultIconCache: IconCacheManager;
|
package/dist/icons/cache.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cache.js","names":[],"sources":["../../src/icons/cache.ts"],"sourcesContent":["import {\n ICON_FETCH_CACHE_MAX_ENTRIES,\n ICON_FETCH_MAX_IN_FLIGHT,\n ICON_FETCH_QUEUE_MAX_ENTRIES,\n} from \"./constants.js\";\nimport type { IconData } from \"./types.js\";\n\nexport interface IconCacheOptions {\n maxEntries?: number;\n maxInFlight?: number;\n maxQueue?: number;\n}\n\nexport class IconCacheManager {\n readonly #maxEntries: number;\n readonly #maxInFlight: number;\n readonly #maxQueue: number;\n\n readonly #dataCache = new Map<string, IconData>();\n readonly #pendingFetches = new Map<string, Promise<IconData | null>>();\n readonly #queue: Array<() => void> = [];\n #activeCount = 0;\n\n constructor(options: IconCacheOptions = {}) {\n this.#maxEntries = options.maxEntries ?? ICON_FETCH_CACHE_MAX_ENTRIES;\n this.#maxInFlight = options.maxInFlight ?? ICON_FETCH_MAX_IN_FLIGHT;\n this.#maxQueue = options.maxQueue ?? ICON_FETCH_QUEUE_MAX_ENTRIES;\n }\n\n get size(): number {\n return this.#dataCache.size;\n }\n\n get(key: string): IconData | undefined {\n const value = this.#dataCache.get(key);\n if (!value) return undefined;\n // Refresh LRU order\n this.#dataCache.delete(key);\n this.#dataCache.set(key, value);\n return value;\n }\n\n set(key: string, data: IconData): void {\n this.#dataCache.delete(key);\n this.#dataCache.set(key, data);\n while (this.#dataCache.size > this.#maxEntries) {\n const oldestKey = this.#dataCache.keys().next().value;\n if (oldestKey === undefined) break;\n this.#dataCache.delete(oldestKey);\n }\n }\n\n has(key: string): boolean {\n return this.#dataCache.has(key);\n }\n\n delete(key: string): boolean {\n return this.#dataCache.delete(key);\n }\n\n clear(): void {\n this.#dataCache.clear();\n this.#pendingFetches.clear();\n this.#queue.length = 0;\n this.#activeCount = 0;\n }\n\n getPending(key: string): Promise<IconData | null> | undefined {\n return this.#pendingFetches.get(key);\n }\n\n setPending(key: string, promise: Promise<IconData | null>): void {\n this.#pendingFetches.set(key, promise);\n }\n\n deletePending(key: string): void {\n this.#pendingFetches.delete(key);\n }\n\n runWithSlot<T>(task: () => Promise<T>): Promise<T | null> {\n if (this.#activeCount >= this.#maxInFlight && this.#queue.length >= this.#maxQueue) {\n return Promise.resolve(null);\n }\n\n return new Promise((resolve) => {\n const execute = () => {\n this.#activeCount += 1;\n void task()\n .then(resolve, () => resolve(null))\n .finally(() => {\n this.#activeCount = Math.max(0, this.#activeCount - 1);\n this.#queue.shift()?.();\n });\n };\n\n if (this.#activeCount < this.#maxInFlight) {\n execute();\n } else {\n this.#queue.push(execute);\n }\n });\n }\n}\n\nexport const defaultIconCache = new IconCacheManager();\n"],"mappings":";;AAaA,IAAa,mBAAb,MAA8B;
|
|
1
|
+
{"version":3,"file":"cache.js","names":[],"sources":["../../src/icons/cache.ts"],"sourcesContent":["import {\n ICON_FETCH_CACHE_MAX_ENTRIES,\n ICON_FETCH_MAX_IN_FLIGHT,\n ICON_FETCH_QUEUE_MAX_ENTRIES,\n} from \"./constants.js\";\nimport type { IconData } from \"./types.js\";\n\nexport interface IconCacheOptions {\n maxEntries?: number;\n maxInFlight?: number;\n maxQueue?: number;\n}\n\nexport class IconCacheManager {\n readonly #maxEntries: number;\n readonly #maxInFlight: number;\n readonly #maxQueue: number;\n\n readonly #dataCache = new Map<string, IconData>();\n readonly #pendingFetches = new Map<string, Promise<IconData | null>>();\n readonly #queue: Array<() => void> = [];\n #activeCount = 0;\n\n constructor(options: IconCacheOptions = {}) {\n this.#maxEntries = options.maxEntries ?? ICON_FETCH_CACHE_MAX_ENTRIES;\n this.#maxInFlight = options.maxInFlight ?? ICON_FETCH_MAX_IN_FLIGHT;\n this.#maxQueue = options.maxQueue ?? ICON_FETCH_QUEUE_MAX_ENTRIES;\n }\n\n get size(): number {\n return this.#dataCache.size;\n }\n\n get(key: string): IconData | undefined {\n const value = this.#dataCache.get(key);\n if (!value) return undefined;\n // Refresh LRU order\n this.#dataCache.delete(key);\n this.#dataCache.set(key, value);\n return value;\n }\n\n set(key: string, data: IconData): void {\n this.#dataCache.delete(key);\n this.#dataCache.set(key, data);\n while (this.#dataCache.size > this.#maxEntries) {\n const oldestKey = this.#dataCache.keys().next().value;\n if (oldestKey === undefined) break;\n this.#dataCache.delete(oldestKey);\n }\n }\n\n has(key: string): boolean {\n return this.#dataCache.has(key);\n }\n\n delete(key: string): boolean {\n return this.#dataCache.delete(key);\n }\n\n clear(): void {\n this.#dataCache.clear();\n this.#pendingFetches.clear();\n this.#queue.length = 0;\n this.#activeCount = 0;\n }\n\n getPending(key: string): Promise<IconData | null> | undefined {\n return this.#pendingFetches.get(key);\n }\n\n setPending(key: string, promise: Promise<IconData | null>): void {\n this.#pendingFetches.set(key, promise);\n }\n\n deletePending(key: string): void {\n this.#pendingFetches.delete(key);\n }\n\n runWithSlot<T>(task: () => Promise<T>): Promise<T | null> {\n if (this.#activeCount >= this.#maxInFlight && this.#queue.length >= this.#maxQueue) {\n return Promise.resolve(null);\n }\n\n return new Promise((resolve) => {\n const execute = () => {\n this.#activeCount += 1;\n void task()\n .then(resolve, () => resolve(null))\n .finally(() => {\n this.#activeCount = Math.max(0, this.#activeCount - 1);\n this.#queue.shift()?.();\n });\n };\n\n if (this.#activeCount < this.#maxInFlight) {\n execute();\n } else {\n this.#queue.push(execute);\n }\n });\n }\n}\n\nexport const defaultIconCache = new IconCacheManager();\n"],"mappings":";;AAaA,IAAa,mBAAb,MAA8B;CACnB;CACA;CACA;CAEA,6BAAa,IAAI,IAAsB;CACvC,kCAAkB,IAAI,IAAsC;CAC5D,SAA4B,CAAC;CACtC,eAAe;CAEf,YAAY,UAA4B,CAAC,GAAG;EAC1C,KAAK,cAAc,QAAQ,cAAA;EAC3B,KAAK,eAAe,QAAQ,eAAA;EAC5B,KAAK,YAAY,QAAQ,YAAA;CAC3B;CAEA,IAAI,OAAe;EACjB,OAAO,KAAK,WAAW;CACzB;CAEA,IAAI,KAAmC;EACrC,MAAM,QAAQ,KAAK,WAAW,IAAI,GAAG;EACrC,IAAI,CAAC,OAAO,OAAO,KAAA;EAEnB,KAAK,WAAW,OAAO,GAAG;EAC1B,KAAK,WAAW,IAAI,KAAK,KAAK;EAC9B,OAAO;CACT;CAEA,IAAI,KAAa,MAAsB;EACrC,KAAK,WAAW,OAAO,GAAG;EAC1B,KAAK,WAAW,IAAI,KAAK,IAAI;EAC7B,OAAO,KAAK,WAAW,OAAO,KAAK,aAAa;GAC9C,MAAM,YAAY,KAAK,WAAW,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC;GAChD,IAAI,cAAc,KAAA,GAAW;GAC7B,KAAK,WAAW,OAAO,SAAS;EAClC;CACF;CAEA,IAAI,KAAsB;EACxB,OAAO,KAAK,WAAW,IAAI,GAAG;CAChC;CAEA,OAAO,KAAsB;EAC3B,OAAO,KAAK,WAAW,OAAO,GAAG;CACnC;CAEA,QAAc;EACZ,KAAK,WAAW,MAAM;EACtB,KAAK,gBAAgB,MAAM;EAC3B,KAAK,OAAO,SAAS;EACrB,KAAK,eAAe;CACtB;CAEA,WAAW,KAAmD;EAC5D,OAAO,KAAK,gBAAgB,IAAI,GAAG;CACrC;CAEA,WAAW,KAAa,SAAyC;EAC/D,KAAK,gBAAgB,IAAI,KAAK,OAAO;CACvC;CAEA,cAAc,KAAmB;EAC/B,KAAK,gBAAgB,OAAO,GAAG;CACjC;CAEA,YAAe,MAA2C;EACxD,IAAI,KAAK,gBAAgB,KAAK,gBAAgB,KAAK,OAAO,UAAU,KAAK,WACvE,OAAO,QAAQ,QAAQ,IAAI;EAG7B,OAAO,IAAI,SAAS,YAAY;GAC9B,MAAM,gBAAgB;IACpB,KAAK,gBAAgB;IAChB,KAAK,CAAC,CACR,KAAK,eAAe,QAAQ,IAAI,CAAC,CAAC,CAClC,cAAc;KACb,KAAK,eAAe,KAAK,IAAI,GAAG,KAAK,eAAe,CAAC;KACrD,KAAK,OAAO,MAAM,CAAC,GAAG;IACxB,CAAC;GACL;GAEA,IAAI,KAAK,eAAe,KAAK,cAC3B,QAAQ;QAER,KAAK,OAAO,KAAK,OAAO;EAE5B,CAAC;CACH;AACF;AAEA,MAAa,mBAAmB,IAAI,iBAAiB"}
|
|
@@ -69,13 +69,13 @@ export declare const Icon: import("vue").DefineComponent<import("vue").ExtractPr
|
|
|
69
69
|
default: string;
|
|
70
70
|
};
|
|
71
71
|
}>> & Readonly<{}>, {
|
|
72
|
-
lazy: boolean;
|
|
73
|
-
size: string | number;
|
|
74
72
|
mode: IconMode;
|
|
73
|
+
class: string;
|
|
74
|
+
size: string | number;
|
|
75
|
+
lazy: boolean;
|
|
75
76
|
ssr: boolean;
|
|
76
77
|
loading: IconLoadingMode;
|
|
77
78
|
apiProvider: string;
|
|
78
|
-
class: string;
|
|
79
79
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
80
80
|
export declare const ResuxIcon: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
81
81
|
name: {
|
|
@@ -146,12 +146,11 @@ export declare const ResuxIcon: import("vue").DefineComponent<import("vue").Extr
|
|
|
146
146
|
default: string;
|
|
147
147
|
};
|
|
148
148
|
}>> & Readonly<{}>, {
|
|
149
|
-
lazy: boolean;
|
|
150
|
-
size: string | number;
|
|
151
149
|
mode: IconMode;
|
|
150
|
+
class: string;
|
|
151
|
+
size: string | number;
|
|
152
|
+
lazy: boolean;
|
|
152
153
|
ssr: boolean;
|
|
153
154
|
loading: IconLoadingMode;
|
|
154
155
|
apiProvider: string;
|
|
155
|
-
|
|
156
|
-
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
157
|
-
//# sourceMappingURL=component.d.ts.map
|
|
156
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
@@ -10,5 +10,4 @@ export declare const ICON_FETCH_CACHE_MAX_ENTRIES = 256;
|
|
|
10
10
|
export declare const ICON_FETCH_MAX_IN_FLIGHT = 32;
|
|
11
11
|
export declare const ICON_FETCH_QUEUE_MAX_ENTRIES = 512;
|
|
12
12
|
export declare const DEFAULT_FALLBACK_SVG_PATH = "M12 22c5.523 0 10-4.477 10-10S17.523 2 12 2S2 6.477 2 12s4.477 10 10 10zm0-2a8 8 0 1 1 0-16 8 8 0 0 1 0 16z";
|
|
13
|
-
export declare const DEFAULT_FALLBACK_VIEWBOX = "0 0 24 24";
|
|
14
|
-
//# sourceMappingURL=constants.d.ts.map
|
|
13
|
+
export declare const DEFAULT_FALLBACK_VIEWBOX = "0 0 24 24";
|
package/dist/icons/css-mode.d.ts
CHANGED
|
@@ -3,5 +3,4 @@ import { VNode } from "vue";
|
|
|
3
3
|
export declare function iconDataToSvgString(data: IconData): string;
|
|
4
4
|
export declare function svgToDataUri(svg: string): string;
|
|
5
5
|
export declare function buildCssMaskStyle(data: IconData, size: string): Record<string, string>;
|
|
6
|
-
export declare function renderCssMaskIcon(data: IconData, size: string, customClass?: string, attrs?: Record<string, unknown>): VNode;
|
|
7
|
-
//# sourceMappingURL=css-mode.d.ts.map
|
|
6
|
+
export declare function renderCssMaskIcon(data: IconData, size: string, customClass?: string, attrs?: Record<string, unknown>): VNode;
|
package/dist/icons/index.d.ts
CHANGED
|
@@ -13,5 +13,4 @@ import { Icon, ResuxIcon } from "./component.js";
|
|
|
13
13
|
export interface ResuxIconsModuleOptions extends ResuxIconsConfig {}
|
|
14
14
|
export declare function defineIconCollections(collections: string[]): ResuxIconsModuleOptions;
|
|
15
15
|
declare const _default: ResuxModuleDefinition<ResuxIconsModuleOptions>;
|
|
16
|
-
export { Icon, type IconData, type IconLoadingMode, type IconMode, type IconPathData, type IconProps, ResuxIcon, type ResuxIconsConfig, buildCssMaskStyle, clearLocalSvgCache, clearOfflineCollectionCache, createIconsVitePlugin, _default as default, fetchIconifyIcon, getStaticIcon, iconAliases, iconDataToSvgString, iconRegistry, loadLocalSvgIcon, loadLocalSvgIconSync, loadOfflineIcon, normalizeIconApiProvider, parseIconName, registerOfflineCollection, registerStaticIcon, renderCssMaskIcon, renderSvgIcon, resolveIconAsync, resolveIconSync, stripTrailingSlashes, svgToDataUri, transformStaticIcons };
|
|
17
|
-
//# sourceMappingURL=index.d.ts.map
|
|
16
|
+
export { Icon, type IconData, type IconLoadingMode, type IconMode, type IconPathData, type IconProps, ResuxIcon, type ResuxIconsConfig, buildCssMaskStyle, clearLocalSvgCache, clearOfflineCollectionCache, createIconsVitePlugin, _default as default, fetchIconifyIcon, getStaticIcon, iconAliases, iconDataToSvgString, iconRegistry, loadLocalSvgIcon, loadLocalSvgIconSync, loadOfflineIcon, normalizeIconApiProvider, parseIconName, registerOfflineCollection, registerStaticIcon, renderCssMaskIcon, renderSvgIcon, resolveIconAsync, resolveIconSync, stripTrailingSlashes, svgToDataUri, transformStaticIcons };
|
package/dist/icons/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../src/icons/index.ts"],"sourcesContent":["import { defineResuxModule, addVitePlugin } from \"../kit/index.js\";\nimport { DEFAULT_CUSTOM_COLLECTIONS_DIR, DEFAULT_ICON_API_PROVIDER, DEFAULT_ICON_SIZE } from \"./constants.js\";\nimport { normalizeIconApiProvider } from \"./normalize.js\";\nimport { iconRegistry } from \"./registry.js\";\nimport { createIconsVitePlugin } from \"./transform.js\";\nimport type { IconMode, ResuxIconsConfig } from \"./types.js\";\n\nexport interface ResuxIconsModuleOptions extends ResuxIconsConfig {}\n\nexport function defineIconCollections(collections: string[]): ResuxIconsModuleOptions {\n return { collections };\n}\n\n// Re-export modular subsystem interfaces and functions\nexport { iconRegistry, iconAliases, registerStaticIcon, getStaticIcon } from \"./registry.js\";\nexport type { IconData, IconPathData, IconProps, IconMode, IconLoadingMode, ResuxIconsConfig } from \"./types.js\";\nexport { normalizeIconApiProvider, parseIconName, stripTrailingSlashes } from \"./normalize.js\";\nexport { fetchIconifyIcon } from \"./api-fetcher.js\";\nexport { resolveIconSync, resolveIconAsync } from \"./resolver.js\";\nexport { loadLocalSvgIcon, loadLocalSvgIconSync, clearLocalSvgCache } from \"./local-svg.js\";\nexport { loadOfflineIcon, registerOfflineCollection, clearOfflineCollectionCache } from \"./offline-loader.js\";\nexport { renderCssMaskIcon, buildCssMaskStyle, svgToDataUri, iconDataToSvgString } from \"./css-mode.js\";\nexport { renderSvgIcon } from \"./svg-mode.js\";\nexport { transformStaticIcons, createIconsVitePlugin } from \"./transform.js\";\nexport { Icon, ResuxIcon } from \"./component.js\";\n\nif (typeof globalThis !== \"undefined\") {\n (globalThis as any).__RESUX_ICON_REGISTRY__ = iconRegistry;\n}\n\nexport default defineResuxModule<ResuxIconsModuleOptions>({\n defaults: {\n collections: [],\n component: \"Icon\",\n mode: \"svg\" as IconMode,\n ssr: true,\n apiProvider: DEFAULT_ICON_API_PROVIDER,\n lazy: false,\n defaultSize: DEFAULT_ICON_SIZE,\n aliases: {},\n customCollectionsDir: DEFAULT_CUSTOM_COLLECTIONS_DIR,\n },\n setup(options, resux) {\n const collections = Array.isArray(options.collections)\n ? [...new Set(options.collections.map((entry) => String(entry).trim()).filter(Boolean))]\n : [];\n\n const normalizedConfig: ResuxIconsConfig = {\n component: typeof options.component === \"string\" ? options.component : \"Icon\",\n collections,\n mode: options.mode || \"svg\",\n ssr: options.ssr !== false,\n apiProvider: normalizeIconApiProvider(options.apiProvider),\n lazy: options.lazy === true,\n defaultSize: options.defaultSize || DEFAULT_ICON_SIZE,\n aliases: options.aliases || {},\n customCollectionsDir: options.customCollectionsDir || DEFAULT_CUSTOM_COLLECTIONS_DIR,\n };\n\n resux.extendRuntimeConfig({\n public: {\n icons: normalizedConfig,\n },\n });\n\n try {\n addVitePlugin(createIconsVitePlugin(normalizedConfig));\n } catch {\n // If outside Vite context, ignore\n }\n },\n});\n"],"mappings":";;;;;;;;;;;;;AASA,SAAgB,sBAAsB,aAAgD;CACpF,OAAO,EAAE,YAAY;AACvB;AAeA,IAAI,OAAO,eAAe,
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../src/icons/index.ts"],"sourcesContent":["import { defineResuxModule, addVitePlugin } from \"../kit/index.js\";\nimport { DEFAULT_CUSTOM_COLLECTIONS_DIR, DEFAULT_ICON_API_PROVIDER, DEFAULT_ICON_SIZE } from \"./constants.js\";\nimport { normalizeIconApiProvider } from \"./normalize.js\";\nimport { iconRegistry } from \"./registry.js\";\nimport { createIconsVitePlugin } from \"./transform.js\";\nimport type { IconMode, ResuxIconsConfig } from \"./types.js\";\n\nexport interface ResuxIconsModuleOptions extends ResuxIconsConfig {}\n\nexport function defineIconCollections(collections: string[]): ResuxIconsModuleOptions {\n return { collections };\n}\n\n// Re-export modular subsystem interfaces and functions\nexport { iconRegistry, iconAliases, registerStaticIcon, getStaticIcon } from \"./registry.js\";\nexport type { IconData, IconPathData, IconProps, IconMode, IconLoadingMode, ResuxIconsConfig } from \"./types.js\";\nexport { normalizeIconApiProvider, parseIconName, stripTrailingSlashes } from \"./normalize.js\";\nexport { fetchIconifyIcon } from \"./api-fetcher.js\";\nexport { resolveIconSync, resolveIconAsync } from \"./resolver.js\";\nexport { loadLocalSvgIcon, loadLocalSvgIconSync, clearLocalSvgCache } from \"./local-svg.js\";\nexport { loadOfflineIcon, registerOfflineCollection, clearOfflineCollectionCache } from \"./offline-loader.js\";\nexport { renderCssMaskIcon, buildCssMaskStyle, svgToDataUri, iconDataToSvgString } from \"./css-mode.js\";\nexport { renderSvgIcon } from \"./svg-mode.js\";\nexport { transformStaticIcons, createIconsVitePlugin } from \"./transform.js\";\nexport { Icon, ResuxIcon } from \"./component.js\";\n\nif (typeof globalThis !== \"undefined\") {\n (globalThis as any).__RESUX_ICON_REGISTRY__ = iconRegistry;\n}\n\nexport default defineResuxModule<ResuxIconsModuleOptions>({\n defaults: {\n collections: [],\n component: \"Icon\",\n mode: \"svg\" as IconMode,\n ssr: true,\n apiProvider: DEFAULT_ICON_API_PROVIDER,\n lazy: false,\n defaultSize: DEFAULT_ICON_SIZE,\n aliases: {},\n customCollectionsDir: DEFAULT_CUSTOM_COLLECTIONS_DIR,\n },\n setup(options, resux) {\n const collections = Array.isArray(options.collections)\n ? [...new Set(options.collections.map((entry) => String(entry).trim()).filter(Boolean))]\n : [];\n\n const normalizedConfig: ResuxIconsConfig = {\n component: typeof options.component === \"string\" ? options.component : \"Icon\",\n collections,\n mode: options.mode || \"svg\",\n ssr: options.ssr !== false,\n apiProvider: normalizeIconApiProvider(options.apiProvider),\n lazy: options.lazy === true,\n defaultSize: options.defaultSize || DEFAULT_ICON_SIZE,\n aliases: options.aliases || {},\n customCollectionsDir: options.customCollectionsDir || DEFAULT_CUSTOM_COLLECTIONS_DIR,\n };\n\n resux.extendRuntimeConfig({\n public: {\n icons: normalizedConfig,\n },\n });\n\n try {\n addVitePlugin(createIconsVitePlugin(normalizedConfig));\n } catch {\n // If outside Vite context, ignore\n }\n },\n});\n"],"mappings":";;;;;;;;;;;;;AASA,SAAgB,sBAAsB,aAAgD;CACpF,OAAO,EAAE,YAAY;AACvB;AAeA,IAAI,OAAO,eAAe,aACvB,WAAmB,0BAA0B;AAGhD,IAAA,gBAAe,kBAA2C;CACxD,UAAU;EACR,aAAa,CAAC;EACd,WAAW;EACX,MAAM;EACN,KAAK;EACL,aAAa;EACb,MAAM;EACN,aAAa;EACb,SAAS,CAAC;EACV,sBAAsB;CACxB;CACA,MAAM,SAAS,OAAO;EACpB,MAAM,cAAc,MAAM,QAAQ,QAAQ,WAAW,IACjD,CAAC,GAAG,IAAI,IAAI,QAAQ,YAAY,KAAK,UAAU,OAAO,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,OAAO,CAAC,CAAC,IACrF,CAAC;EAEL,MAAM,mBAAqC;GACzC,WAAW,OAAO,QAAQ,cAAc,WAAW,QAAQ,YAAY;GACvE;GACA,MAAM,QAAQ,QAAQ;GACtB,KAAK,QAAQ,QAAQ;GACrB,aAAa,yBAAyB,QAAQ,WAAW;GACzD,MAAM,QAAQ,SAAS;GACvB,aAAa,QAAQ,eAAA;GACrB,SAAS,QAAQ,WAAW,CAAC;GAC7B,sBAAsB,QAAQ,wBAAA;EAChC;EAEA,MAAM,oBAAoB,EACxB,QAAQ,EACN,OAAO,iBACT,EACF,CAAC;EAED,IAAI;GACF,cAAc,sBAAsB,gBAAgB,CAAC;EACvD,QAAQ,CAER;CACF;AACF,CAAC"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { IconData } from "./types.js";
|
|
2
2
|
export declare function loadLocalSvgIconSync(name: string, dir?: string, rootDir?: string): IconData | null;
|
|
3
3
|
export declare function loadLocalSvgIcon(name: string, dir?: string, rootDir?: string): Promise<IconData | null>;
|
|
4
|
-
export declare function clearLocalSvgCache(): void;
|
|
5
|
-
//# sourceMappingURL=local-svg.d.ts.map
|
|
4
|
+
export declare function clearLocalSvgCache(): void;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { ParsedIconName } from "./types.js";
|
|
2
2
|
export declare function stripTrailingSlashes(value: string): string;
|
|
3
3
|
export declare function normalizeIconApiProvider(value: unknown): string;
|
|
4
|
-
export declare function parseIconName(rawName: string, aliases?: Record<string, string>, knownCollections?: string[], depth?: number, visited?: Set<string>): ParsedIconName | null;
|
|
5
|
-
//# sourceMappingURL=normalize.d.ts.map
|
|
4
|
+
export declare function parseIconName(rawName: string, aliases?: Record<string, string>, knownCollections?: string[], depth?: number, visited?: Set<string>): ParsedIconName | null;
|
|
@@ -17,5 +17,4 @@ export interface IconifyJsonCollection {
|
|
|
17
17
|
}
|
|
18
18
|
export declare function registerOfflineCollection(prefix: string, data: IconifyJsonCollection): void;
|
|
19
19
|
export declare function clearOfflineCollectionCache(): void;
|
|
20
|
-
export declare function loadOfflineIcon(prefix: string, name: string): IconData | null;
|
|
21
|
-
//# sourceMappingURL=offline-loader.d.ts.map
|
|
20
|
+
export declare function loadOfflineIcon(prefix: string, name: string): IconData | null;
|
package/dist/icons/parser.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { IconData } from "./types.js";
|
|
2
2
|
export declare function readSvgAttribute(source: string, name: string): string;
|
|
3
3
|
export declare function readSvgPresentationAttributes(source: string): Partial<IconData>;
|
|
4
|
-
export declare function parseSvgText(svgText: string): IconData | null;
|
|
5
|
-
//# sourceMappingURL=parser.d.ts.map
|
|
4
|
+
export declare function parseSvgText(svgText: string): IconData | null;
|
package/dist/icons/registry.d.ts
CHANGED
|
@@ -3,5 +3,4 @@ export declare const iconRegistry: Record<string, IconData>;
|
|
|
3
3
|
export declare const iconAliases: Record<string, string>;
|
|
4
4
|
export declare function registerStaticIcon(name: string, data: IconData): void;
|
|
5
5
|
export declare function getStaticIcon(name: string): IconData | undefined;
|
|
6
|
-
export type { IconData, IconPathData };
|
|
7
|
-
//# sourceMappingURL=registry.d.ts.map
|
|
6
|
+
export type { IconData, IconPathData };
|
package/dist/icons/resolver.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
import { IconData, ResuxIconsConfig } from "./types.js";
|
|
2
2
|
export declare function resolveIconSync(rawName: string, config?: ResuxIconsConfig): IconData | null;
|
|
3
|
-
export declare function resolveIconAsync(rawName: string, config?: ResuxIconsConfig): Promise<IconData | null>;
|
|
4
|
-
//# sourceMappingURL=resolver.d.ts.map
|
|
3
|
+
export declare function resolveIconAsync(rawName: string, config?: ResuxIconsConfig): Promise<IconData | null>;
|
package/dist/icons/svg-mode.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
import { IconData } from "./types.js";
|
|
2
2
|
import { Ref, VNode } from "vue";
|
|
3
|
-
export declare function renderSvgIcon(data: IconData, size: string, customClass?: string, attrs?: Record<string, unknown>, nodeRef?: Ref<HTMLElement | null>): VNode;
|
|
4
|
-
//# sourceMappingURL=svg-mode.d.ts.map
|
|
3
|
+
export declare function renderSvgIcon(data: IconData, size: string, customClass?: string, attrs?: Record<string, unknown>, nodeRef?: Ref<HTMLElement | null>): VNode;
|
package/dist/icons/types.d.ts
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -6,5 +6,5 @@ import { watch, watchEffect } from "./reactivity/watch.js";
|
|
|
6
6
|
import { nextTick } from "./reactivity/scheduler.js";
|
|
7
7
|
import { ResuxViewTransition, ResuxViewTransitionOptions } from "./runtime/view-transitions/types.js";
|
|
8
8
|
import { useViewTransition } from "./runtime/view-transitions/transition.js";
|
|
9
|
-
import { AsyncDataError, AsyncDataHandlerContext, AsyncDataResource, AsyncResuxRenderer, AwaitedAsyncDataResource, ClientEnhancementContext, ClientEnhancementSetup, ClientEnhancementTrigger, ClientPluginManifestRecord, ClientRouteMiddlewareManifestRecord, ClientRuntimeSourceOptions, ComponentDefinition, ComponentStyle, DeviceInfo, ElementTemplateNode, EventHandler, EventHandlerEvent, ForDirective, HeadAttributePrimitive, HeadAttributeStyle, HeadAttributeValue, HeadAttributes, HeadEntry, HeadInput, HeadTextContentStyle, HtmlDirective, IfDirective, InterpolationTemplateNode, JsonValue, PackageAdapterContext, PackageAdapterDefinition, PageMeta, RenderAppOptions, RenderDocumentOptions, RenderResult, ResuxAppInjections, ResuxAppLike, ResuxAppProvides, ResuxClientBootMode, ResuxClientBootPlan, ResuxClientPackageImportRegistry, ResuxConfigInput, ResuxDeployOptions, ResuxDeployTarget, ResuxError, ResuxImageBuilder, ResuxImageCacheInput, ResuxImageConfig, ResuxImageFit, ResuxImageModifiers, ResuxImageProviderConfig, ResuxLazyPackageLoader, ResuxLazyPackageOptions, ResuxModule, ResuxModuleContext, ResuxPackageCssMap, ResuxPackageMode, ResuxPackageModeMap, ResuxPackagesConfig, ResuxPayload, ResuxPlugin, ResuxRouteMiddleware, ResuxRouter, ResuxSupportMode, RouteContext, RouteMiddlewareResult, RouteRecord, RuntimeConfig, SeoMetaInput, SeoMetaValue, SerializedAsyncData, SerializedScope, ServerMiddleware, ServerMiddlewareResult, SetupContext, TemplateAttribute, TemplateEvent, TemplateNode, TextTemplateNode, UseClientEnhancementOptions, UseResuxImageOptions, abortNavigation, clearError, createError, createServerSetupContext, defineClientEnhancement, defineClientOnlyPackage, defineComponent, defineEventHandler, defineLazyPackage, definePackageAdapter, defineResuxConfig, defineResuxModule, defineResuxPlugin, defineResuxRouteMiddleware, defineServerMiddleware, disposeClientEnhancements, evaluateExpression, eventHandler, getClientEnhancement, getClientRuntimeBootPlan, getClientRuntimeSource, getQuery, hasClientEnhancement, navigateTo, parseUserAgent, readBody, renderApp, renderAppAsync, renderClientPatches, renderDocument, renderTemplateNodesAsync, scanClientEnhancements, setHeader, shouldLoadClientRuntime, showError, useClientEnhancement, useClientPackage, useDevice, useError, useLazyPackage, usePackageReady, useResuxApp, useResuxImage, useRoute, useRouter, useRuntimeConfig } from "./runtime/index.js";
|
|
10
|
-
export { AsyncDataError, AsyncDataHandlerContext, AsyncDataResource, AsyncResuxRenderer, AwaitedAsyncDataResource, ClientEnhancementContext, ClientEnhancementSetup, ClientEnhancementTrigger, ClientPluginManifestRecord, ClientRouteMiddlewareManifestRecord, ClientRuntimeSourceOptions, ComponentDefinition, ComponentStyle, type ComputedRef, DeviceInfo, ElementTemplateNode, EventHandler, EventHandlerEvent, ForDirective, HeadAttributePrimitive, HeadAttributeStyle, HeadAttributeValue, HeadAttributes, HeadEntry, HeadInput, HeadTextContentStyle, HtmlDirective, IfDirective, InterpolationTemplateNode, JsonValue, type MaybeRef, type MaybeRefOrGetter, PackageAdapterContext, PackageAdapterDefinition, PageMeta, type ReactiveEffectOptions, type ReactiveEffectRunner, type Ref, RenderAppOptions, RenderDocumentOptions, RenderResult, ResuxAppInjections, ResuxAppLike, ResuxAppProvides, ResuxClientBootMode, ResuxClientBootPlan, ResuxClientPackageImportRegistry, ResuxConfigInput, ResuxDeployOptions, ResuxDeployTarget, ResuxError, ResuxImageBuilder, ResuxImageCacheInput, ResuxImageConfig, ResuxImageFit, ResuxImageModifiers, ResuxImageProviderConfig, ResuxLazyPackageLoader, ResuxLazyPackageOptions, ResuxModule, ResuxModuleContext, ResuxPackageCssMap, ResuxPackageMode, ResuxPackageModeMap, ResuxPackagesConfig, ResuxPayload, ResuxPlugin, ResuxRouteMiddleware, ResuxRouter, ResuxSupportMode, type ResuxViewTransition, type ResuxViewTransitionOptions, RouteContext, RouteMiddlewareResult, RouteRecord, RuntimeConfig, SeoMetaInput, SeoMetaValue, SerializedAsyncData, SerializedScope, ServerMiddleware, ServerMiddlewareResult, SetupContext, TemplateAttribute, TemplateEvent, TemplateNode, TextTemplateNode, UseClientEnhancementOptions, UseResuxImageOptions, type WatchCallback, type WatchOptions, type WatchSource, type WatchStopHandle, abortNavigation, clearError, computed, createError, createServerSetupContext, defineClientEnhancement, defineClientOnlyPackage, defineComponent, defineEventHandler, defineLazyPackage, definePackageAdapter, defineResuxConfig, defineResuxModule, defineResuxPlugin, defineResuxRouteMiddleware, defineServerMiddleware, disposeClientEnhancements, evaluateExpression, eventHandler, getClientEnhancement, getClientRuntimeBootPlan, getClientRuntimeSource, getQuery, hasClientEnhancement, isReactive, isReadonly, isRef, navigateTo, nextTick, parseUserAgent, reactive, readBody, readonly, ref, renderApp, renderAppAsync, renderClientPatches, renderDocument, renderTemplateNodesAsync, scanClientEnhancements, setHeader, shouldLoadClientRuntime, showError, toRef, toRefs, unref, useClientEnhancement, useClientPackage, useDevice, useError, useLazyPackage, usePackageReady, useResuxApp, useResuxImage, useRoute, useRouter, useRuntimeConfig, useViewTransition, watch, watchEffect };
|
|
9
|
+
import { AsyncDataError, AsyncDataHandlerContext, AsyncDataResource, AsyncResuxRenderer, AwaitedAsyncDataResource, ClientEnhancementContext, ClientEnhancementSetup, ClientEnhancementTrigger, ClientPluginManifestRecord, ClientRouteMiddlewareManifestRecord, ClientRuntimeSourceOptions, ComponentDefinition, ComponentStyle, DeviceInfo, ElementTemplateNode, EventHandler, EventHandlerEvent, ForDirective, HeadAttributePrimitive, HeadAttributeStyle, HeadAttributeValue, HeadAttributes, HeadEntry, HeadInput, HeadTextContentStyle, HtmlDirective, IfDirective, InterpolationTemplateNode, JsonValue, PackageAdapterContext, PackageAdapterDefinition, PageMeta, RenderAppOptions, RenderDocumentOptions, RenderHtmlContext, RenderResult, ResuxAppInjections, ResuxAppLike, ResuxAppProvides, ResuxClientBootMode, ResuxClientBootPlan, ResuxClientPackageImportRegistry, ResuxConfigInput, ResuxDeployOptions, ResuxDeployTarget, ResuxError, ResuxImageBuilder, ResuxImageCacheInput, ResuxImageConfig, ResuxImageFit, ResuxImageModifiers, ResuxImageProviderConfig, ResuxLazyPackageLoader, ResuxLazyPackageOptions, ResuxModule, ResuxModuleContext, ResuxPackageCssMap, ResuxPackageMode, ResuxPackageModeMap, ResuxPackagesConfig, ResuxPayload, ResuxPlugin, ResuxRouteMiddleware, ResuxRouter, ResuxSupportMode, RouteContext, RouteMiddlewareResult, RouteRecord, RuntimeConfig, SeoMetaInput, SeoMetaValue, SerializedAsyncData, SerializedScope, ServerMiddleware, ServerMiddlewareResult, SetupContext, TemplateAttribute, TemplateEvent, TemplateNode, TextTemplateNode, UseClientEnhancementOptions, UseResuxImageOptions, abortNavigation, clearError, createError, createServerSetupContext, defineClientEnhancement, defineClientOnlyPackage, defineComponent, defineEventHandler, defineLazyPackage, definePackageAdapter, defineResuxConfig, defineResuxModule, defineResuxPlugin, defineResuxRouteMiddleware, defineServerMiddleware, disposeClientEnhancements, evaluateExpression, eventHandler, getClientEnhancement, getClientRuntimeBootPlan, getClientRuntimeSource, getQuery, hasClientEnhancement, navigateTo, parseUserAgent, readBody, renderApp, renderAppAsync, renderClientPatches, renderDocument, renderDocumentAsync, renderTemplateNodesAsync, scanClientEnhancements, setHeader, shouldLoadClientRuntime, showError, useClientEnhancement, useClientPackage, useDevice, useError, useLazyPackage, usePackageReady, useResuxApp, useResuxImage, useRoute, useRouter, useRuntimeConfig } from "./runtime/index.js";
|
|
10
|
+
export { AsyncDataError, AsyncDataHandlerContext, AsyncDataResource, AsyncResuxRenderer, AwaitedAsyncDataResource, ClientEnhancementContext, ClientEnhancementSetup, ClientEnhancementTrigger, ClientPluginManifestRecord, ClientRouteMiddlewareManifestRecord, ClientRuntimeSourceOptions, ComponentDefinition, ComponentStyle, type ComputedRef, DeviceInfo, ElementTemplateNode, EventHandler, EventHandlerEvent, ForDirective, HeadAttributePrimitive, HeadAttributeStyle, HeadAttributeValue, HeadAttributes, HeadEntry, HeadInput, HeadTextContentStyle, HtmlDirective, IfDirective, InterpolationTemplateNode, JsonValue, type MaybeRef, type MaybeRefOrGetter, PackageAdapterContext, PackageAdapterDefinition, PageMeta, type ReactiveEffectOptions, type ReactiveEffectRunner, type Ref, RenderAppOptions, RenderDocumentOptions, RenderHtmlContext, RenderResult, ResuxAppInjections, ResuxAppLike, ResuxAppProvides, ResuxClientBootMode, ResuxClientBootPlan, ResuxClientPackageImportRegistry, ResuxConfigInput, ResuxDeployOptions, ResuxDeployTarget, ResuxError, ResuxImageBuilder, ResuxImageCacheInput, ResuxImageConfig, ResuxImageFit, ResuxImageModifiers, ResuxImageProviderConfig, ResuxLazyPackageLoader, ResuxLazyPackageOptions, ResuxModule, ResuxModuleContext, ResuxPackageCssMap, ResuxPackageMode, ResuxPackageModeMap, ResuxPackagesConfig, ResuxPayload, ResuxPlugin, ResuxRouteMiddleware, ResuxRouter, ResuxSupportMode, type ResuxViewTransition, type ResuxViewTransitionOptions, RouteContext, RouteMiddlewareResult, RouteRecord, RuntimeConfig, SeoMetaInput, SeoMetaValue, SerializedAsyncData, SerializedScope, ServerMiddleware, ServerMiddlewareResult, SetupContext, TemplateAttribute, TemplateEvent, TemplateNode, TextTemplateNode, UseClientEnhancementOptions, UseResuxImageOptions, type WatchCallback, type WatchOptions, type WatchSource, type WatchStopHandle, abortNavigation, clearError, computed, createError, createServerSetupContext, defineClientEnhancement, defineClientOnlyPackage, defineComponent, defineEventHandler, defineLazyPackage, definePackageAdapter, defineResuxConfig, defineResuxModule, defineResuxPlugin, defineResuxRouteMiddleware, defineServerMiddleware, disposeClientEnhancements, evaluateExpression, eventHandler, getClientEnhancement, getClientRuntimeBootPlan, getClientRuntimeSource, getQuery, hasClientEnhancement, isReactive, isReadonly, isRef, navigateTo, nextTick, parseUserAgent, reactive, readBody, readonly, ref, renderApp, renderAppAsync, renderClientPatches, renderDocument, renderDocumentAsync, renderTemplateNodesAsync, scanClientEnhancements, setHeader, shouldLoadClientRuntime, showError, toRef, toRefs, unref, useClientEnhancement, useClientPackage, useDevice, useError, useLazyPackage, usePackageReady, useResuxApp, useResuxImage, useRoute, useRouter, useRuntimeConfig, useViewTransition, watch, watchEffect };
|
package/dist/index.js
CHANGED
|
@@ -4,5 +4,5 @@ import { computed } from "./reactivity/computed.js";
|
|
|
4
4
|
import { nextTick } from "./reactivity/scheduler.js";
|
|
5
5
|
import { watch, watchEffect } from "./reactivity/watch.js";
|
|
6
6
|
import { useViewTransition } from "./runtime/view-transitions/transition.js";
|
|
7
|
-
import { AsyncResuxRenderer, abortNavigation, clearError, createError, createServerSetupContext, defineClientEnhancement, defineClientOnlyPackage, defineComponent, defineEventHandler, defineLazyPackage, definePackageAdapter, defineResuxConfig, defineResuxModule, defineResuxPlugin, defineResuxRouteMiddleware, defineServerMiddleware, disposeClientEnhancements, evaluateExpression, eventHandler, getClientEnhancement, getClientRuntimeBootPlan, getClientRuntimeSource, getQuery, hasClientEnhancement, navigateTo, parseUserAgent, readBody, renderApp, renderAppAsync, renderClientPatches, renderDocument, renderTemplateNodesAsync, scanClientEnhancements, setHeader, shouldLoadClientRuntime, showError, useClientEnhancement, useClientPackage, useDevice, useError, useLazyPackage, usePackageReady, useResuxApp, useResuxImage, useRoute, useRouter, useRuntimeConfig } from "./runtime/index.js";
|
|
8
|
-
export { AsyncResuxRenderer, abortNavigation, clearError, computed, createError, createServerSetupContext, defineClientEnhancement, defineClientOnlyPackage, defineComponent, defineEventHandler, defineLazyPackage, definePackageAdapter, defineResuxConfig, defineResuxModule, defineResuxPlugin, defineResuxRouteMiddleware, defineServerMiddleware, disposeClientEnhancements, evaluateExpression, eventHandler, getClientEnhancement, getClientRuntimeBootPlan, getClientRuntimeSource, getQuery, hasClientEnhancement, isReactive, isReadonly, isRef, navigateTo, nextTick, parseUserAgent, reactive, readBody, readonly, ref, renderApp, renderAppAsync, renderClientPatches, renderDocument, renderTemplateNodesAsync, scanClientEnhancements, setHeader, shouldLoadClientRuntime, showError, toRef, toRefs, unref, useClientEnhancement, useClientPackage, useDevice, useError, useLazyPackage, usePackageReady, useResuxApp, useResuxImage, useRoute, useRouter, useRuntimeConfig, useViewTransition, watch, watchEffect };
|
|
7
|
+
import { AsyncResuxRenderer, abortNavigation, clearError, createError, createServerSetupContext, defineClientEnhancement, defineClientOnlyPackage, defineComponent, defineEventHandler, defineLazyPackage, definePackageAdapter, defineResuxConfig, defineResuxModule, defineResuxPlugin, defineResuxRouteMiddleware, defineServerMiddleware, disposeClientEnhancements, evaluateExpression, eventHandler, getClientEnhancement, getClientRuntimeBootPlan, getClientRuntimeSource, getQuery, hasClientEnhancement, navigateTo, parseUserAgent, readBody, renderApp, renderAppAsync, renderClientPatches, renderDocument, renderDocumentAsync, renderTemplateNodesAsync, scanClientEnhancements, setHeader, shouldLoadClientRuntime, showError, useClientEnhancement, useClientPackage, useDevice, useError, useLazyPackage, usePackageReady, useResuxApp, useResuxImage, useRoute, useRouter, useRuntimeConfig } from "./runtime/index.js";
|
|
8
|
+
export { AsyncResuxRenderer, abortNavigation, clearError, computed, createError, createServerSetupContext, defineClientEnhancement, defineClientOnlyPackage, defineComponent, defineEventHandler, defineLazyPackage, definePackageAdapter, defineResuxConfig, defineResuxModule, defineResuxPlugin, defineResuxRouteMiddleware, defineServerMiddleware, disposeClientEnhancements, evaluateExpression, eventHandler, getClientEnhancement, getClientRuntimeBootPlan, getClientRuntimeSource, getQuery, hasClientEnhancement, isReactive, isReadonly, isRef, navigateTo, nextTick, parseUserAgent, reactive, readBody, readonly, ref, renderApp, renderAppAsync, renderClientPatches, renderDocument, renderDocumentAsync, renderTemplateNodesAsync, scanClientEnhancements, setHeader, shouldLoadClientRuntime, showError, toRef, toRefs, unref, useClientEnhancement, useClientPackage, useDevice, useError, useLazyPackage, usePackageReady, useResuxApp, useResuxImage, useRoute, useRouter, useRuntimeConfig, useViewTransition, watch, watchEffect };
|
package/dist/kit/index.d.ts
CHANGED
|
@@ -26,5 +26,4 @@ export declare function extendViteConfig(extender: ViteConfigExtender): void;
|
|
|
26
26
|
export declare function extendNitroConfig(extender: NitroConfigExtender): void;
|
|
27
27
|
export declare function addVitePlugin(plugin: unknown): void;
|
|
28
28
|
export declare function addRouteRule(path: string, rule: Record<string, unknown>): void;
|
|
29
|
-
export declare function addPrerenderRoutes(route: string | string[]): void;
|
|
30
|
-
//# sourceMappingURL=index.d.ts.map
|
|
29
|
+
export declare function addPrerenderRoutes(route: string | string[]): void;
|
|
@@ -4,5 +4,4 @@ export interface ResuxNitroServerOptions {
|
|
|
4
4
|
preset?: string;
|
|
5
5
|
compatibilityDate?: string;
|
|
6
6
|
}
|
|
7
|
-
export declare function createNitroServerOptions(options: ResuxNitroServerOptions): ResuxNitroServerOptions;
|
|
8
|
-
//# sourceMappingURL=index.d.ts.map
|
|
7
|
+
export declare function createNitroServerOptions(options: ResuxNitroServerOptions): ResuxNitroServerOptions;
|
package/dist/node.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { ResuxNodeHandlerOptions } from "./cli.js";
|
|
2
2
|
import { ServerResponse } from "node:http";
|
|
3
3
|
export declare function createResuxNodeHandler(options?: ResuxNodeHandlerOptions): (request: import("http").IncomingMessage, response: ServerResponse) => void;
|
|
4
|
-
export type { ResuxNodeHandlerOptions };
|
|
5
|
-
//# sourceMappingURL=node.d.ts.map
|
|
4
|
+
export type { ResuxNodeHandlerOptions };
|
|
@@ -4,5 +4,4 @@ export declare function computed<T>(options: {
|
|
|
4
4
|
get: () => T;
|
|
5
5
|
set?: (value: T) => void;
|
|
6
6
|
}): ComputedRef<T>;
|
|
7
|
-
export declare function isComputed(value: unknown): boolean;
|
|
8
|
-
//# sourceMappingURL=computed.d.ts.map
|
|
7
|
+
export declare function isComputed(value: unknown): boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"computed.js","names":[],"sources":["../../src/reactivity/computed.ts"],"sourcesContent":["import { effect, isTracking, trackEffects, triggerEffects, type Dep } from \"./effect.js\";\nimport type { ComputedRef } from \"./types.js\";\nimport { ReactiveFlags } from \"./utils.js\";\n\nclass ComputedRefImpl<T> implements ComputedRef<T> {\n readonly __v_isRef = true as const;\n readonly __v_isReadonly = true as const;\n\n private readonly setter?: (value: T) => void;\n private readonly runner;\n private dep?: Dep;\n private dirty = true;\n private _value!: T;\n\n constructor(getter: () => T, setter?: (value: T) => void) {\n this.setter = setter;\n this.runner = effect(getter, {\n lazy: true,\n scheduler: () => {\n if (!this.dirty) {\n this.dirty = true;\n if (this.dep) {\n triggerEffects(this.dep);\n }\n }\n }\n });\n }\n\n get value(): T {\n if (isTracking()) {\n trackEffects(this._dep());\n }\n if (this.dirty) {\n const value = this.runner();\n this._value = value;\n this.dirty = false;\n }\n return this._value;\n }\n\n set value(newValue: T) {\n this.setter?.(newValue);\n }\n\n private _dep(): Dep {\n if (!this.dep) {\n this.dep = new Set();\n }\n return this.dep;\n }\n}\n\nexport function computed<T>(getter: () => T): ComputedRef<T>;\nexport function computed<T>(options: { get: () => T; set?: (value: T) => void }): ComputedRef<T>;\nexport function computed<T>(\n getterOrOptions: (() => T) | { get: () => T; set?: (value: T) => void }\n): ComputedRef<T> {\n if (typeof getterOrOptions === \"function\") {\n return new ComputedRefImpl(getterOrOptions);\n }\n return new ComputedRefImpl(getterOrOptions.get, getterOrOptions.set);\n}\n\nexport function isComputed(value: unknown): boolean {\n return Boolean(\n value\n && typeof value === \"object\"\n && (value as Record<string, unknown>)[ReactiveFlags.IS_REF] === true\n && (value as Record<string, unknown>)[ReactiveFlags.IS_READONLY] === true\n );\n}\n"],"mappings":";;;AAIA,IAAM,kBAAN,MAAmD;
|
|
1
|
+
{"version":3,"file":"computed.js","names":[],"sources":["../../src/reactivity/computed.ts"],"sourcesContent":["import { effect, isTracking, trackEffects, triggerEffects, type Dep } from \"./effect.js\";\nimport type { ComputedRef } from \"./types.js\";\nimport { ReactiveFlags } from \"./utils.js\";\n\nclass ComputedRefImpl<T> implements ComputedRef<T> {\n readonly __v_isRef = true as const;\n readonly __v_isReadonly = true as const;\n\n private readonly setter?: (value: T) => void;\n private readonly runner;\n private dep?: Dep;\n private dirty = true;\n private _value!: T;\n\n constructor(getter: () => T, setter?: (value: T) => void) {\n this.setter = setter;\n this.runner = effect(getter, {\n lazy: true,\n scheduler: () => {\n if (!this.dirty) {\n this.dirty = true;\n if (this.dep) {\n triggerEffects(this.dep);\n }\n }\n }\n });\n }\n\n get value(): T {\n if (isTracking()) {\n trackEffects(this._dep());\n }\n if (this.dirty) {\n const value = this.runner();\n this._value = value;\n this.dirty = false;\n }\n return this._value;\n }\n\n set value(newValue: T) {\n this.setter?.(newValue);\n }\n\n private _dep(): Dep {\n if (!this.dep) {\n this.dep = new Set();\n }\n return this.dep;\n }\n}\n\nexport function computed<T>(getter: () => T): ComputedRef<T>;\nexport function computed<T>(options: { get: () => T; set?: (value: T) => void }): ComputedRef<T>;\nexport function computed<T>(\n getterOrOptions: (() => T) | { get: () => T; set?: (value: T) => void }\n): ComputedRef<T> {\n if (typeof getterOrOptions === \"function\") {\n return new ComputedRefImpl(getterOrOptions);\n }\n return new ComputedRefImpl(getterOrOptions.get, getterOrOptions.set);\n}\n\nexport function isComputed(value: unknown): boolean {\n return Boolean(\n value\n && typeof value === \"object\"\n && (value as Record<string, unknown>)[ReactiveFlags.IS_REF] === true\n && (value as Record<string, unknown>)[ReactiveFlags.IS_READONLY] === true\n );\n}\n"],"mappings":";;;AAIA,IAAM,kBAAN,MAAmD;CACxC,YAAY;CACZ,iBAAiB;CAET;CACA;CACT;CACA,QAAQ;CACR;CAER,YAAY,QAAiB,QAA6B;EACxD,KAAK,SAAS;EACd,KAAK,SAAS,OAAO,QAAQ;GAC3B,MAAM;GACN,iBAAiB;IACf,IAAI,CAAC,KAAK,OAAO;KACf,KAAK,QAAQ;KACb,IAAI,KAAK,KACP,eAAe,KAAK,GAAG;IAE3B;GACF;EACF,CAAC;CACH;CAEA,IAAI,QAAW;EACb,IAAI,WAAW,GACb,aAAa,KAAK,KAAK,CAAC;EAE1B,IAAI,KAAK,OAAO;GACd,MAAM,QAAQ,KAAK,OAAO;GAC1B,KAAK,SAAS;GACd,KAAK,QAAQ;EACf;EACA,OAAO,KAAK;CACd;CAEA,IAAI,MAAM,UAAa;EACrB,KAAK,SAAS,QAAQ;CACxB;CAEQ,OAAY;EAClB,IAAI,CAAC,KAAK,KACR,KAAK,sBAAM,IAAI,IAAI;EAErB,OAAO,KAAK;CACd;AACF;AAIA,SAAgB,SACd,iBACgB;CAChB,IAAI,OAAO,oBAAoB,YAC7B,OAAO,IAAI,gBAAgB,eAAe;CAE5C,OAAO,IAAI,gBAAgB,gBAAgB,KAAK,gBAAgB,GAAG;AACrE;AAEA,SAAgB,WAAW,OAAyB;CAClD,OAAO,QACL,SACK,OAAO,UAAU,YAChB,MAAkC,cAAc,YAAY,QAC5D,MAAkC,cAAc,iBAAiB,IACzE;AACF"}
|
|
@@ -6,8 +6,9 @@ export interface ReactiveEffectLike {
|
|
|
6
6
|
deps: Dep[];
|
|
7
7
|
}
|
|
8
8
|
export type Dep = Set<ReactiveEffectLike>;
|
|
9
|
-
export type TriggerOperation = "set" | "add" | "delete";
|
|
9
|
+
export type TriggerOperation = "set" | "add" | "delete" | "clear";
|
|
10
10
|
export declare const ITERATE_KEY: unique symbol;
|
|
11
|
+
export declare const MAP_KEY_ITERATE_KEY: unique symbol;
|
|
11
12
|
export declare function effect<T = unknown>(fn: () => T, options?: ReactiveEffectOptions): ReactiveEffectRunner<T>;
|
|
12
13
|
export declare function stop(runner: ReactiveEffectRunner): void;
|
|
13
14
|
export declare function track(target: object, key: PropertyKey): void;
|
|
@@ -16,5 +17,4 @@ export declare function trigger(target: object, key: PropertyKey, operation?: Tr
|
|
|
16
17
|
export declare function triggerEffects(dep: Dep): void;
|
|
17
18
|
export declare function isTracking(): boolean;
|
|
18
19
|
export declare function pauseTracking(): void;
|
|
19
|
-
export declare function resetTracking(): void;
|
|
20
|
-
//# sourceMappingURL=effect.d.ts.map
|
|
20
|
+
export declare function resetTracking(): void;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// src/reactivity/effect.ts
|
|
2
2
|
const ITERATE_KEY = Symbol("resux-iterate");
|
|
3
|
+
const MAP_KEY_ITERATE_KEY = Symbol("resux-map-key-iterate");
|
|
3
4
|
const targetMap = /* @__PURE__ */ new WeakMap();
|
|
4
5
|
let activeEffect;
|
|
5
6
|
let shouldTrack = true;
|
|
@@ -84,12 +85,16 @@ function trigger(target, key, operation = "set", newValue, oldLength) {
|
|
|
84
85
|
if (!dep) return;
|
|
85
86
|
for (const effect of dep) effects.add(effect);
|
|
86
87
|
};
|
|
87
|
-
if (
|
|
88
|
+
if (operation === "clear") for (const dep of depsMap.values()) addEffects(dep);
|
|
89
|
+
else if (Array.isArray(target) && key === "length") {
|
|
88
90
|
const nextLength = Number(newValue);
|
|
89
91
|
for (const [depKey, dep] of depsMap) if (depKey === "length" || depKey === ITERATE_KEY || isArrayIndex(depKey) && Number(depKey) >= nextLength) addEffects(dep);
|
|
90
92
|
} else {
|
|
91
93
|
addEffects(depsMap.get(key));
|
|
92
|
-
if (operation === "add" || operation === "delete")
|
|
94
|
+
if (operation === "add" || operation === "delete") {
|
|
95
|
+
addEffects(depsMap.get(ITERATE_KEY));
|
|
96
|
+
if (target instanceof Map) addEffects(depsMap.get(MAP_KEY_ITERATE_KEY));
|
|
97
|
+
} else if (operation === "set" && target instanceof Map) addEffects(depsMap.get(ITERATE_KEY));
|
|
93
98
|
if (operation === "add" && Array.isArray(target) && isArrayIndex(key) && typeof oldLength === "number" && Number(key) >= oldLength) addEffects(depsMap.get("length"));
|
|
94
99
|
}
|
|
95
100
|
triggerEffects(effects);
|
|
@@ -116,6 +121,6 @@ function isArrayIndex(key) {
|
|
|
116
121
|
const value = String(key);
|
|
117
122
|
return /^(?:0|[1-9]\d*)$/.test(value) && Number(value) < 4294967295;
|
|
118
123
|
}
|
|
119
|
-
export { ITERATE_KEY, effect, isTracking, pauseTracking, resetTracking, stop, track, trackEffects, trigger, triggerEffects };
|
|
124
|
+
export { ITERATE_KEY, MAP_KEY_ITERATE_KEY, effect, isTracking, pauseTracking, resetTracking, stop, track, trackEffects, trigger, triggerEffects };
|
|
120
125
|
|
|
121
126
|
//# sourceMappingURL=effect.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"effect.js","names":[],"sources":["../../src/reactivity/effect.ts"],"sourcesContent":["import type { ReactiveEffectOptions, ReactiveEffectRunner } from \"./types.js\";\n\nexport interface ReactiveEffectLike {\n active: boolean;\n run(): unknown;\n scheduler?: () => void;\n deps: Dep[];\n}\n\nexport type Dep = Set<ReactiveEffectLike>;\ntype KeyToDepMap = Map<PropertyKey, Dep>;\nexport type TriggerOperation = \"set\" | \"add\" | \"delete\";\n\nexport const ITERATE_KEY = Symbol(\"resux-iterate\");\n\nconst targetMap = new WeakMap<object, KeyToDepMap>();\n\nlet activeEffect: ReactiveEffectImpl | undefined;\nlet shouldTrack = true;\n\nconst trackStack: boolean[] = [];\n\nclass ReactiveEffectImpl implements ReactiveEffectLike {\n active = true;\n deps: Dep[] = [];\n readonly scheduler?: () => void;\n readonly onStop?: () => void;\n private parent?: ReactiveEffectImpl;\n\n constructor(\n private readonly fn: () => unknown,\n options: ReactiveEffectOptions = {}\n ) {\n this.scheduler = options.scheduler;\n this.onStop = options.onStop;\n }\n\n run(): unknown {\n if (!this.active) {\n return this.fn();\n }\n\n let parent = activeEffect;\n while (parent) {\n if (parent === this) {\n return undefined;\n }\n parent = parent.parent;\n }\n\n cleanupEffect(this);\n this.parent = activeEffect;\n activeEffect = this;\n trackStack.push(shouldTrack);\n shouldTrack = true;\n\n try {\n return this.fn();\n } finally {\n shouldTrack = trackStack.pop() ?? true;\n activeEffect = this.parent;\n this.parent = undefined;\n }\n }\n\n stop(): void {\n if (!this.active) {\n return;\n }\n cleanupEffect(this);\n this.onStop?.();\n this.active = false;\n }\n}\n\nfunction cleanupEffect(effect: ReactiveEffectImpl): void {\n for (const dep of effect.deps) {\n dep.delete(effect);\n }\n effect.deps.length = 0;\n}\n\nexport function effect<T = unknown>(\n fn: () => T,\n options: ReactiveEffectOptions = {}\n): ReactiveEffectRunner<T> {\n const _effect = new ReactiveEffectImpl(fn as () => unknown, options);\n if (!options.lazy) {\n _effect.run();\n }\n\n const runner = _effect.run.bind(_effect) as ReactiveEffectRunner<T>;\n runner.effect = _effect;\n return runner;\n}\n\nexport function stop(runner: ReactiveEffectRunner): void {\n runner.effect.stop();\n}\n\nexport function track(target: object, key: PropertyKey): void {\n if (!isTracking()) {\n return;\n }\n\n let depsMap = targetMap.get(target);\n if (!depsMap) {\n depsMap = new Map();\n targetMap.set(target, depsMap);\n }\n\n let dep = depsMap.get(key);\n if (!dep) {\n dep = new Set();\n depsMap.set(key, dep);\n }\n\n trackEffects(dep);\n}\n\nexport function trackEffects(dep: Dep): void {\n if (!activeEffect || dep.has(activeEffect)) {\n return;\n }\n dep.add(activeEffect);\n activeEffect.deps.push(dep);\n}\n\nexport function trigger(\n target: object,\n key: PropertyKey,\n operation: TriggerOperation = \"set\",\n newValue?: unknown,\n oldLength?: number\n): void {\n const depsMap = targetMap.get(target);\n if (!depsMap) {\n return;\n }\n\n const effects: Dep = new Set();\n const addEffects = (dep?: Dep) => {\n if (!dep) {\n return;\n }\n for (const effect of dep) {\n effects.add(effect);\n }\n };\n\n if (Array.isArray(target) && key === \"length\") {\n const nextLength = Number(newValue);\n for (const [depKey, dep] of depsMap) {\n if (\n depKey === \"length\"\n || depKey === ITERATE_KEY\n || (isArrayIndex(depKey) && Number(depKey) >= nextLength)\n ) {\n addEffects(dep);\n }\n }\n } else {\n addEffects(depsMap.get(key));\n\n if (operation === \"add\" || operation === \"delete\") {\n addEffects(depsMap.get(ITERATE_KEY));\n }\n\n if (\n operation === \"add\"\n && Array.isArray(target)\n && isArrayIndex(key)\n && typeof oldLength === \"number\"\n && Number(key) >= oldLength\n ) {\n addEffects(depsMap.get(\"length\"));\n }\n }\n\n triggerEffects(effects);\n}\n\nexport function triggerEffects(dep: Dep): void {\n for (const effect of [...dep]) {\n if (effect === activeEffect) {\n continue;\n }\n if (effect.scheduler) {\n effect.scheduler();\n } else {\n effect.run();\n }\n }\n}\n\nexport function isTracking(): boolean {\n return shouldTrack && activeEffect !== undefined;\n}\n\nexport function pauseTracking(): void {\n trackStack.push(shouldTrack);\n shouldTrack = false;\n}\n\nexport function resetTracking(): void {\n shouldTrack = trackStack.pop() ?? true;\n}\n\nfunction isArrayIndex(key: PropertyKey): boolean {\n if (typeof key === \"symbol\" || key === \"length\") {\n return false;\n }\n const value = String(key);\n return /^(?:0|[1-9]\\d*)$/.test(value)\n && Number(value) < 4_294_967_295;\n}\n"],"mappings":";AAaA,MAAa,cAAc,OAAO,eAAe;
|
|
1
|
+
{"version":3,"file":"effect.js","names":[],"sources":["../../src/reactivity/effect.ts"],"sourcesContent":["import type { ReactiveEffectOptions, ReactiveEffectRunner } from \"./types.js\";\n\nexport interface ReactiveEffectLike {\n active: boolean;\n run(): unknown;\n scheduler?: () => void;\n deps: Dep[];\n}\n\nexport type Dep = Set<ReactiveEffectLike>;\ntype KeyToDepMap = Map<PropertyKey, Dep>;\nexport type TriggerOperation = \"set\" | \"add\" | \"delete\" | \"clear\";\n\nexport const ITERATE_KEY = Symbol(\"resux-iterate\");\nexport const MAP_KEY_ITERATE_KEY = Symbol(\"resux-map-key-iterate\");\n\nconst targetMap = new WeakMap<object, KeyToDepMap>();\n\nlet activeEffect: ReactiveEffectImpl | undefined;\nlet shouldTrack = true;\n\nconst trackStack: boolean[] = [];\n\nclass ReactiveEffectImpl implements ReactiveEffectLike {\n active = true;\n deps: Dep[] = [];\n readonly scheduler?: () => void;\n readonly onStop?: () => void;\n private parent?: ReactiveEffectImpl;\n\n constructor(\n private readonly fn: () => unknown,\n options: ReactiveEffectOptions = {}\n ) {\n this.scheduler = options.scheduler;\n this.onStop = options.onStop;\n }\n\n run(): unknown {\n if (!this.active) {\n return this.fn();\n }\n\n let parent = activeEffect;\n while (parent) {\n if (parent === this) {\n return undefined;\n }\n parent = parent.parent;\n }\n\n cleanupEffect(this);\n this.parent = activeEffect;\n activeEffect = this;\n trackStack.push(shouldTrack);\n shouldTrack = true;\n\n try {\n return this.fn();\n } finally {\n shouldTrack = trackStack.pop() ?? true;\n activeEffect = this.parent;\n this.parent = undefined;\n }\n }\n\n stop(): void {\n if (!this.active) {\n return;\n }\n cleanupEffect(this);\n this.onStop?.();\n this.active = false;\n }\n}\n\nfunction cleanupEffect(effect: ReactiveEffectImpl): void {\n for (const dep of effect.deps) {\n dep.delete(effect);\n }\n effect.deps.length = 0;\n}\n\nexport function effect<T = unknown>(\n fn: () => T,\n options: ReactiveEffectOptions = {}\n): ReactiveEffectRunner<T> {\n const _effect = new ReactiveEffectImpl(fn as () => unknown, options);\n if (!options.lazy) {\n _effect.run();\n }\n\n const runner = _effect.run.bind(_effect) as ReactiveEffectRunner<T>;\n runner.effect = _effect;\n return runner;\n}\n\nexport function stop(runner: ReactiveEffectRunner): void {\n runner.effect.stop();\n}\n\nexport function track(target: object, key: PropertyKey): void {\n if (!isTracking()) {\n return;\n }\n\n let depsMap = targetMap.get(target);\n if (!depsMap) {\n depsMap = new Map();\n targetMap.set(target, depsMap);\n }\n\n let dep = depsMap.get(key);\n if (!dep) {\n dep = new Set();\n depsMap.set(key, dep);\n }\n\n trackEffects(dep);\n}\n\nexport function trackEffects(dep: Dep): void {\n if (!activeEffect || dep.has(activeEffect)) {\n return;\n }\n dep.add(activeEffect);\n activeEffect.deps.push(dep);\n}\n\nexport function trigger(\n target: object,\n key: PropertyKey,\n operation: TriggerOperation = \"set\",\n newValue?: unknown,\n oldLength?: number\n): void {\n const depsMap = targetMap.get(target);\n if (!depsMap) {\n return;\n }\n\n const effects: Dep = new Set();\n const addEffects = (dep?: Dep) => {\n if (!dep) {\n return;\n }\n for (const effect of dep) {\n effects.add(effect);\n }\n };\n\n if (operation === \"clear\") {\n // Clearing a collection invalidates every dependency it owns.\n for (const dep of depsMap.values()) {\n addEffects(dep);\n }\n } else if (Array.isArray(target) && key === \"length\") {\n const nextLength = Number(newValue);\n for (const [depKey, dep] of depsMap) {\n if (\n depKey === \"length\"\n || depKey === ITERATE_KEY\n || (isArrayIndex(depKey) && Number(depKey) >= nextLength)\n ) {\n addEffects(dep);\n }\n }\n } else {\n addEffects(depsMap.get(key));\n\n if (operation === \"add\" || operation === \"delete\") {\n addEffects(depsMap.get(ITERATE_KEY));\n if (target instanceof Map) {\n addEffects(depsMap.get(MAP_KEY_ITERATE_KEY));\n }\n } else if (operation === \"set\" && target instanceof Map) {\n // A changed value is visible to values()/entries()/forEach iteration and\n // size, which all track ITERATE_KEY on maps. keys() iteration is not\n // affected by value changes.\n addEffects(depsMap.get(ITERATE_KEY));\n }\n\n if (\n operation === \"add\"\n && Array.isArray(target)\n && isArrayIndex(key)\n && typeof oldLength === \"number\"\n && Number(key) >= oldLength\n ) {\n addEffects(depsMap.get(\"length\"));\n }\n }\n\n triggerEffects(effects);\n}\n\nexport function triggerEffects(dep: Dep): void {\n for (const effect of [...dep]) {\n if (effect === activeEffect) {\n continue;\n }\n if (effect.scheduler) {\n effect.scheduler();\n } else {\n effect.run();\n }\n }\n}\n\nexport function isTracking(): boolean {\n return shouldTrack && activeEffect !== undefined;\n}\n\nexport function pauseTracking(): void {\n trackStack.push(shouldTrack);\n shouldTrack = false;\n}\n\nexport function resetTracking(): void {\n shouldTrack = trackStack.pop() ?? true;\n}\n\nfunction isArrayIndex(key: PropertyKey): boolean {\n if (typeof key === \"symbol\" || key === \"length\") {\n return false;\n }\n const value = String(key);\n return /^(?:0|[1-9]\\d*)$/.test(value)\n && Number(value) < 4_294_967_295;\n}\n"],"mappings":";AAaA,MAAa,cAAc,OAAO,eAAe;AACjD,MAAa,sBAAsB,OAAO,uBAAuB;AAEjE,MAAM,4BAAY,IAAI,QAA6B;AAEnD,IAAI;AACJ,IAAI,cAAc;AAElB,MAAM,aAAwB,CAAC;AAE/B,IAAM,qBAAN,MAAuD;CAQlC;CAPnB,SAAS;CACT,OAAc,CAAC;CACN;CACA;CACD;CAER,YACmB,IACjB,UAAiC,CAAC,GAClC;EAFiB,KAAA,KAAA;EAGjB,KAAK,YAAY,QAAQ;EACzB,KAAK,SAAS,QAAQ;CACxB;CAEA,MAAe;EACb,IAAI,CAAC,KAAK,QACR,OAAO,KAAK,GAAG;EAGjB,IAAI,SAAS;EACb,OAAO,QAAQ;GACb,IAAI,WAAW,MACb;GAEF,SAAS,OAAO;EAClB;EAEA,cAAc,IAAI;EAClB,KAAK,SAAS;EACd,eAAe;EACf,WAAW,KAAK,WAAW;EAC3B,cAAc;EAEd,IAAI;GACF,OAAO,KAAK,GAAG;EACjB,UAAU;GACR,cAAc,WAAW,IAAI,KAAK;GACl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,KAAK,IAAI;AACvB"}
|
|
@@ -2,5 +2,4 @@ export declare function reactive<T extends object>(target: T): T;
|
|
|
2
2
|
export declare function readonly<T>(target: T): Readonly<T>;
|
|
3
3
|
export declare function isReactive(value: unknown): boolean;
|
|
4
4
|
export declare function isReadonly(value: unknown): boolean;
|
|
5
|
-
export declare function toRaw<T>(value: T): T;
|
|
6
|
-
//# sourceMappingURL=reactive.d.ts.map
|
|
5
|
+
export declare function toRaw<T>(value: T): T;
|