@blinkk/root 3.4.7 → 3.4.8
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/dist/{chunk-6QWKKJOB.js → chunk-5MAQGC3L.js} +1 -1
- package/dist/chunk-5MAQGC3L.js.map +7 -0
- package/dist/core/components/Html.d.ts +7 -0
- package/dist/core/components/StyleDeps.d.ts +25 -0
- package/dist/core/core.d.ts +1 -0
- package/dist/core.js +27 -11
- package/dist/core.js.map +4 -4
- package/dist/render/asset-map/collect-style-deps.d.ts +11 -0
- package/dist/render.js +27 -2
- package/dist/render.js.map +3 -3
- package/package.json +1 -1
- package/dist/chunk-6QWKKJOB.js.map +0 -7
package/package.json
CHANGED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../src/core/components/Html.tsx", "../src/core/hooks/useAssetMap.ts", "../src/core/hooks/useI18nContext.ts", "../src/core/hooks/useRequestContext.ts", "../src/utils/url-path-params.ts"],
|
|
4
|
-
"sourcesContent": ["import {ComponentChildren, FunctionalComponent, createContext} from 'preact';\nimport {useContext} from 'preact/hooks';\n\nexport interface HtmlContext {\n htmlAttrs: preact.JSX.HTMLAttributes<HTMLHtmlElement>;\n headAttrs: preact.JSX.HTMLAttributes<HTMLHeadElement>;\n headComponents: ComponentChildren[];\n bodyAttrs: preact.JSX.HTMLAttributes<HTMLBodyElement>;\n scriptDeps: Array<preact.JSX.ScriptHTMLAttributes<HTMLScriptElement>>;\n}\n\nexport const HTML_CONTEXT = createContext<HtmlContext | null>(null);\n\nexport type HtmlProps = preact.JSX.HTMLAttributes<HTMLHtmlElement> & {\n children?: ComponentChildren;\n};\n\n/**\n * The `<Html>` component can be used to update attrs in the `<html>` tag.\n *\n * Usage:\n *\n * ```tsx\n * <Html lang=\"en-US\">\n * <h1>Hello world</h1>\n * </Html>\n * ```\n */\nexport const Html: FunctionalComponent<HtmlProps> = ({children, ...attrs}) => {\n const context = useContext(HTML_CONTEXT);\n if (!context) {\n throw new Error(\n 'HTML_CONTEXT not found, double-check usage of the <Html> component'\n );\n }\n context.htmlAttrs = attrs;\n return <>{children}</>;\n};\n", "import {createContext} from 'preact';\nimport {useContext} from 'preact/hooks';\nimport type {Asset, AssetMap} from '../../render/asset-map/asset-map.js';\n\nexport const ASSET_MAP_CONTEXT = createContext<AssetMap | null>(null);\n\n/**\n * Returns the asset map for the current render.\n */\nexport function useAssetMap(): AssetMap {\n const assetMap = useContext(ASSET_MAP_CONTEXT);\n if (!assetMap) {\n throw new Error('ASSET_MAP_CONTEXT not found');\n }\n return assetMap;\n}\n\n/**\n * Returns an asset from the project's module graph. Paths are relative to the\n * project root and may optionally start with `/`.\n */\nexport function useAsset(src: string): Asset {\n const normalizedSrc = src.replace(/^\\/+/, '');\n const asset = useAssetMap().get(normalizedSrc);\n if (!asset) {\n throw new Error(`asset not found: ${src}`);\n }\n return asset;\n}\n\n/**\n * Returns the serving URL for a file compiled from the project's module graph.\n *\n * Usage:\n *\n * ```tsx\n * const customJs = useAssetUrl('/bundles/foo.ts');\n * return <div data-custom-js={customJs} />;\n * ```\n */\nexport function useAssetUrl(src: string): string {\n const assetUrl = useAsset(src).assetUrl;\n if (!assetUrl) {\n throw new Error(`asset not found: ${src}`);\n }\n return assetUrl;\n}\n", "import path from 'node:path';\nimport {createContext} from 'preact';\nimport {useContext} from 'preact/hooks';\n\nexport const I18N_CONTEXT = createContext<I18nContext | null>(null);\n\nexport interface I18nContext {\n locale: string;\n translations: Record<string, string>;\n}\n\n/**\n * A hook that returns information about the current i18n context, including the\n * locale for the given route and a map of translations for that locale.\n */\nexport function useI18nContext() {\n const context = useContext(I18N_CONTEXT);\n if (!context) {\n throw new Error('I18N_CONTEXT not found');\n }\n return context;\n}\n\nexport function getTranslations(locale: string): Record<string, string> {\n const translations: Record<string, Record<string, string>> = {};\n const translationsFiles = import.meta.glob(['/translations/*.json'], {\n eager: true,\n }) as Record<string, {default?: Record<string, string>}>;\n Object.keys(translationsFiles).forEach((translationPath) => {\n const parts = path.parse(translationPath);\n const locale = parts.name;\n const module = translationsFiles[translationPath];\n if (module && module.default) {\n translations[locale] = module.default;\n }\n });\n return translations[locale] || {};\n}\n", "import {createContext} from 'preact';\nimport {useContext} from 'preact/hooks';\nimport {Route} from '../types.js';\n\nexport interface RequestContext {\n /**\n * The current request path, e.g. `/foo/bar` (default route path) or\n * `/{locale}/foo/bar` (localized route path).\n */\n currentPath: string;\n /** The route file. */\n route: Route;\n /**\n * Route param values. E.g. for a route like `routes/blog/[slug].tsx`,\n * visiting `/blog/foo` will pass {slug: 'foo'} here.\n */\n routeParams: Record<string, string>;\n /** Props passed to the route's server component. */\n props: any;\n /** The current locale. */\n locale: string;\n /** Translations map for the current locale. */\n translations: Record<string, string>;\n /** CSP nonce value. */\n nonce?: string;\n}\n\nexport const REQUEST_CONTEXT = createContext<RequestContext | null>(null);\n\n/**\n * A hook that returns information about the current route.\n *\n * Usage:\n *\n * ```ts\n * const ctx = useRequestContext();\n * ctx.route.src;\n * // => 'routes/index.tsx'\n * ```\n */\nexport function useRequestContext() {\n const context = useContext(REQUEST_CONTEXT);\n if (!context) {\n throw new Error('REQUEST_CONTEXT not found');\n }\n return context;\n}\n", "export function replaceParams(\n urlPathFormat: string,\n params: Record<string, string>\n) {\n const urlPath = urlPathFormat.replaceAll(\n /\\[\\[?(\\.\\.\\.)?([\\w\\-_]*)\\]?\\]/g,\n (match: string, _wildcard: string, key: string) => {\n const val = params[key];\n if (!val) {\n throw new Error(`unreplaced param ${match} in url: ${urlPathFormat}`);\n }\n return val;\n }\n );\n return urlPath;\n}\n\nexport function testPathHasParams(urlPath: string) {\n const segments = urlPath.split('/');\n return segments.some((segment) => {\n return segment.startsWith('[') && segment.includes(']');\n });\n}\n"],
|
|
5
|
-
"mappings": ";AAAA,SAAgD,qBAAoB;AACpE,SAAQ,kBAAiB;AAmChB;AAzBF,IAAM,eAAe,cAAkC,IAAI;AAiB3D,IA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AAiB,EAAE,QAAQ,CAAC,oBAAoB;AAC1D,UAAM,QAAQ,KAAK,MAAM,eAAe;AACxC,UAAMC,UAAS,MAAM;AACrB,UAAM,SAAS,kBAAkB,eAAe;AAChD,QAAI,UAAU,OAAO,SAAS;AAC5B,mBAAaA,OAAM,IAAI,OAAO;AAAA,IAChC;AAAA,EACF,CAAC;AACD,SAAO,aAAa,MAAM,KAAK,CAAC;AAClC;;;ACrCA,SAAQ,iBAAAC,sBAAoB;AAC5B,SAAQ,cAAAC,mBAAiB;AA0BlB,IAAM,kBAAkBD,eAAqC,IAAI;AAajE,SAAS,oBAAoB;AAClC,QAAM,UAAUC,YAAW,eAAe;AAC1C,MAAI,CAAC,SAAS;AACZ,UAAM,IAAI,MAAM,2BAA2B;AAAA,EAC7C;AACA,SAAO;AACT;;;AC9CO,SAAS,cACd,eACA,QACA;AACA,QAAM,UAAU,cAAc;AAAA,IAC5B;AAAA,IACA,CAAC,OAAe,WAAmB,QAAgB;AACjD,YAAM,MAAM,OAAO,GAAG;AACtB,UAAI,CAAC,KAAK;AACR,cAAM,IAAI,MAAM,oBAAoB,KAAK,YAAY,aAAa,EAAE;AAAA,MACtE;AACA,aAAO;AAAA,IACT;AAAA,EACF;AACA,SAAO;AACT;AAEO,SAAS,kBAAkB,SAAiB;AACjD,QAAM,WAAW,QAAQ,MAAM,GAAG;AAClC,SAAO,SAAS,KAAK,CAAC,YAAY;AAChC,WAAO,QAAQ,WAAW,GAAG,KAAK,QAAQ,SAAS,GAAG;AAAA,EACxD,CAAC;AACH;",
|
|
6
|
-
"names": ["createContext", "useContext", "createContext", "useContext", "locale", "createContext", "useContext"]
|
|
7
|
-
}
|