@plasmicapp/react-web 0.2.97 → 0.2.98
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/react-web.cjs.development.js +8 -8
- package/dist/react-web.cjs.development.js.map +1 -1
- package/dist/react-web.cjs.production.min.js +1 -1
- package/dist/react-web.cjs.production.min.js.map +1 -1
- package/dist/react-web.esm.js +8 -8
- package/dist/react-web.esm.js.map +1 -1
- package/package.json +1 -1
- package/skinny/dist/collection-utils-47e89cbe.js +238 -0
- package/skinny/dist/collection-utils-47e89cbe.js.map +1 -0
- package/skinny/dist/collection-utils-4dae6efa.js +292 -0
- package/skinny/dist/collection-utils-4dae6efa.js.map +1 -0
- package/skinny/dist/collection-utils-57ec40f9.js +292 -0
- package/skinny/dist/collection-utils-57ec40f9.js.map +1 -0
- package/skinny/dist/collection-utils-96cde83c.js +238 -0
- package/skinny/dist/collection-utils-96cde83c.js.map +1 -0
- package/skinny/dist/collection-utils-b0b8f30e.js +291 -0
- package/skinny/dist/collection-utils-b0b8f30e.js.map +1 -0
- package/skinny/dist/plume-utils-5c413fd1.js +35 -0
- package/skinny/dist/plume-utils-5c413fd1.js.map +1 -0
- package/skinny/dist/props-utils-4633caf6.js +8 -0
- package/skinny/dist/props-utils-4633caf6.js.map +1 -0
- package/skinny/dist/props-utils-5c0ad25a.js +59 -0
- package/skinny/dist/props-utils-5c0ad25a.js.map +1 -0
- package/skinny/dist/props-utils-754f655a.js +39 -0
- package/skinny/dist/props-utils-754f655a.js.map +1 -0
- package/skinny/dist/props-utils-c632595f.js +59 -0
- package/skinny/dist/props-utils-c632595f.js.map +1 -0
- package/skinny/dist/props-utils-fd5f444e.js +59 -0
- package/skinny/dist/props-utils-fd5f444e.js.map +1 -0
- package/skinny/dist/react-utils-118d8539.js +190 -0
- package/skinny/dist/react-utils-118d8539.js.map +1 -0
- package/skinny/dist/react-utils-2a2fd6c9.js +339 -0
- package/skinny/dist/react-utils-2a2fd6c9.js.map +1 -0
- package/skinny/dist/react-utils-2d70bbbe.js +172 -0
- package/skinny/dist/react-utils-2d70bbbe.js.map +1 -0
- package/skinny/dist/react-utils-675565b4.js +334 -0
- package/skinny/dist/react-utils-675565b4.js.map +1 -0
- package/skinny/dist/render/PlasmicImg/index.js +8 -5
- package/skinny/dist/render/PlasmicImg/index.js.map +1 -1
- package/skinny/dist/render/PlasmicImg.d.ts +62 -0
- package/skinny/dist/ssr-64e38713.js +108 -0
- package/skinny/dist/ssr-64e38713.js.map +1 -0
- package/skinny/dist/ssr-902d1292.js +105 -0
- package/skinny/dist/ssr-902d1292.js.map +1 -0
- package/skinny/dist/ssr-a8081074.js +108 -0
- package/skinny/dist/ssr-a8081074.js.map +1 -0
- package/skinny/dist/tslib.es6-00014098.js +148 -0
- package/skinny/dist/tslib.es6-00014098.js.map +1 -0
- package/skinny/dist/tslib.es6-73236e8e.js +141 -0
- package/skinny/dist/tslib.es6-73236e8e.js.map +1 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../src/render/PlasmicImg/index.tsx"],"sourcesContent":["/**\n * Responsive `<img/>` replacement, based on `next/image`\n */\n\nimport classNames from \"classnames\";\nimport React, { CSSProperties } from \"react\";\nimport { pick } from \"../../common\";\nimport { mergeRefs } from \"../../react-utils\";\n\nexport interface ImageLoader {\n supportsUrl: (url: string) => boolean;\n transformUrl: (opts: {\n src: string;\n width?: number;\n quality?: number;\n format?: \"webp\";\n }) => string;\n}\n\ntype ImgTagProps = Omit<\n React.ComponentProps<\"img\">,\n \"src\" | \"srcSet\" | \"ref\" | \"style\"\n>;\n\n// Default image sizes to snap to\n// TODO: make this configurable?\nconst IMG_SIZES = [16, 32, 48, 64, 96, 128, 256, 384];\nconst DEVICE_SIZES = [640, 750, 828, 1080, 1200, 1920, 2048, 3840];\nconst ALL_SIZES = [...IMG_SIZES, ...DEVICE_SIZES];\n\nexport interface PlasmicImgProps extends ImgTagProps {\n /**\n * Either an object with the src string, and its full width and height,\n * or just a src string with unknown intrinsic dimensions.\n */\n src?:\n | string\n | {\n src: string;\n fullHeight: number;\n fullWidth: number;\n // We might also get a more precise aspectRatio for SVGs\n // instead of relyiing on fullWidth / fullHeight, because\n // those values might be rounded and not so accurate.\n aspectRatio?: number;\n };\n\n /**\n * className applied to the wrapper element if one is used.\n */\n className?: string;\n\n /**\n * css width\n */\n displayWidth?: number | string;\n\n /**\n * css height\n */\n displayHeight?: number | string;\n\n /**\n * css min-width\n */\n displayMinWidth?: number | string;\n\n /**\n * css min-height\n */\n displayMinHeight?: number | string;\n\n /**\n * css max-width\n */\n displayMaxWidth?: number | string;\n\n /**\n * css max-height\n */\n displayMaxHeight?: number | string;\n\n /**\n * For variable quality formats like jpg, the quality from 0 to 100\n */\n quality?: number;\n\n /**\n * ImageLoader to use for loading different dimensions of the image.\n * If none specified, will not attempt to load different dimensions.\n */\n loader?: \"plasmic\" | ImageLoader;\n\n /**\n * Style applied to the wrapper element. objectFit and objectPosition\n * rules are applied to the img element.\n */\n style?: React.CSSProperties;\n\n /**\n * Ref for the img element. The normal <PlasmicImg ref={...} />\n * prop gives the root element instead, which may be the img element\n * or a wrapper element\n */\n imgRef?: React.Ref<HTMLImageElement>;\n}\n\nexport const PlasmicImg = React.forwardRef(function PlasmicImg(\n props: PlasmicImgProps,\n outerRef: React.Ref<HTMLElement>\n) {\n let {\n src,\n className,\n displayWidth,\n displayHeight,\n displayMinWidth,\n displayMinHeight,\n displayMaxWidth,\n displayMaxHeight,\n quality,\n loader,\n imgRef,\n style,\n loading,\n ...rest\n } = props;\n\n const imgProps = Object.assign({}, rest, {\n // Default loading to \"lazy\" if not specified (which is different from the\n // html img, which defaults to eager!)\n loading: loading ?? \"lazy\",\n });\n\n const { fullWidth, fullHeight, aspectRatio } =\n typeof src === \"string\" || !src\n ? { fullWidth: undefined, fullHeight: undefined, aspectRatio: undefined }\n : src;\n const srcStr = src ? (typeof src === \"string\" ? src : src.src) : \"\";\n\n // Assume external image if either dimension is null and use usual <img>\n if (fullHeight == null || fullWidth == null) {\n return (\n <img\n src={srcStr}\n className={className}\n style={style}\n {...imgProps}\n loading={loading}\n ref={mergeRefs(imgRef, outerRef) as any}\n />\n );\n }\n\n if (\n isSvg(srcStr) &&\n (displayHeight == null || displayHeight === \"auto\") &&\n (displayWidth == null || displayWidth === \"auto\")\n ) {\n displayWidth = \"100%\";\n }\n\n if (\n fullWidth &&\n fullHeight &&\n (!displayWidth || displayWidth === \"auto\") &&\n !!getPixelLength(displayHeight)\n ) {\n // If there's a pixel length specified for displayHeight but not displayWidth,\n // then we can derive the pixel length for displayWidth. Having an explicit\n // displayWidth makes this a fixed-size image, which makes it possible for us to\n // generate better markup!\n if (!isSvg(srcStr)) {\n // We shouldn't do it for SVGs though, because `fullWidth` and\n // `fullHeight` might have rounded values so the final\n // `displayWidth` could differ by 1px or so.\n displayWidth = (getPixelLength(displayHeight)! * fullWidth) / fullHeight;\n }\n }\n\n let spacerWidth = fullWidth;\n let spacerHeight = fullHeight;\n if (aspectRatio && isFinite(aspectRatio) && isSvg(srcStr)) {\n // For SVGs, fullWidth and fullHeight can be rounded values, which would\n // cause some discrepancy between the actual aspect ratio and the aspect\n // ratio from those values. So, for those cases, we set large width / height\n // values to get a more precise ratio from the spacer.\n spacerWidth = DEFAULT_SVG_WIDTH;\n spacerHeight = Math.round(spacerWidth / aspectRatio);\n }\n\n const { sizes, widthDescs } = getWidths(displayWidth, fullWidth, {\n minWidth: displayMinWidth,\n });\n const imageLoader = getImageLoader(loader);\n const spacerSvg = `<svg width=\"${spacerWidth}\" height=\"${spacerHeight}\" xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\"/>`;\n const spacerSvgBase64 =\n typeof window === \"undefined\"\n ? Buffer.from(spacerSvg).toString(\"base64\")\n : window.btoa(spacerSvg);\n\n let wrapperStyle: CSSProperties = { ...(style || {}) };\n let spacerStyle: CSSProperties = pick(\n style || {},\n \"objectFit\",\n \"objectPosition\"\n );\n\n if (displayWidth != null && displayWidth !== \"auto\") {\n // If width is set, set it on the wrapper along with min/max width\n // and just use `width: 100%` on the spacer\n spacerStyle.width = \"100%\";\n wrapperStyle.width = displayWidth;\n wrapperStyle.minWidth = displayMinWidth;\n wrapperStyle.maxWidth = displayMaxWidth;\n } else {\n // Otherwise, we want auto sizing from the spacer, so set width there.\n //\n // But if we have min/max width, it should be set in the wrapper and it\n // can be percentage values (and we add corresponding min/max width to\n // 100% in the spacer). In general it ends up with the correct effect,\n // but some edge cases might make `min-width: 100%` shrink the image more\n // than it should.\n spacerStyle.width = displayWidth;\n wrapperStyle.width = \"auto\";\n if (displayMinWidth) {\n spacerStyle.minWidth = \"100%\";\n wrapperStyle.minWidth = displayMinWidth;\n }\n if (displayMaxWidth != null && displayMaxWidth !== \"none\") {\n spacerStyle.maxWidth = \"100%\";\n wrapperStyle.maxWidth = displayMaxWidth;\n }\n }\n\n if (displayHeight != null && displayHeight !== \"auto\") {\n spacerStyle.height = \"100%\";\n wrapperStyle.height = displayHeight;\n wrapperStyle.minHeight = displayMinHeight;\n wrapperStyle.maxHeight = displayMaxHeight;\n } else {\n spacerStyle.height = displayHeight;\n wrapperStyle.height = \"auto\";\n if (displayMinHeight) {\n spacerStyle.minHeight = \"100%\";\n wrapperStyle.minHeight = displayMinHeight;\n }\n if (displayMaxHeight != null && displayMaxHeight !== \"none\") {\n spacerStyle.maxHeight = \"100%\";\n wrapperStyle.maxHeight = displayMaxHeight;\n }\n }\n\n return (\n <div\n className={classNames(className, \"__wab_img-wrapper\")}\n ref={outerRef as any}\n style={wrapperStyle}\n >\n <img\n alt=\"\"\n aria-hidden\n className=\"__wab_img-spacer-svg\"\n src={`data:image/svg+xml;base64,${spacerSvgBase64}`}\n style={spacerStyle}\n />\n {makePicture({\n imageLoader,\n widthDescs,\n sizes,\n src: srcStr,\n quality,\n ref: imgRef,\n style: style ? pick(style, \"objectFit\", \"objectPosition\") : undefined,\n imgProps,\n className: \"__wab_img\",\n })}\n </div>\n );\n});\n\nfunction makePicture(opts: {\n imageLoader?: ImageLoader;\n widthDescs: WidthDesc[];\n sizes?: string;\n src: string;\n quality?: number;\n style?: React.CSSProperties;\n className?: string;\n imgProps: ImgTagProps;\n ref?: React.Ref<HTMLImageElement>;\n}) {\n // If imageLoader is undefined, then this renders to just a normal\n // <img />. Else it will render to a <picture> with a <source> for\n // webp, and srcSet/sizes set according to width requirements.\n const {\n imageLoader,\n widthDescs,\n src,\n quality,\n style,\n className,\n sizes,\n imgProps,\n ref,\n } = opts;\n return (\n <picture className=\"__wab_picture\">\n {imageLoader && imageLoader.supportsUrl(src) && (\n <source\n type=\"image/webp\"\n srcSet={widthDescs\n .map(\n (wd) =>\n `${imageLoader.transformUrl({\n src,\n quality,\n width: wd.width,\n format: \"webp\",\n })} ${wd.desc}`\n )\n .join(\", \")}\n />\n )}\n <img\n {...imgProps}\n ref={ref}\n className={className}\n decoding=\"async\"\n src={\n imageLoader && imageLoader.supportsUrl(src)\n ? imageLoader.transformUrl({\n src,\n quality,\n width: widthDescs[widthDescs.length - 1].width,\n })\n : src\n }\n srcSet={\n imageLoader && imageLoader.supportsUrl(src)\n ? widthDescs\n .map(\n (wd) =>\n `${imageLoader.transformUrl({\n src,\n quality,\n width: wd.width,\n })} ${wd.desc}`\n )\n .join(\", \")\n : undefined\n }\n sizes={imageLoader && imageLoader.supportsUrl(src) ? sizes : undefined}\n style={{\n ...(style ? pick(style, \"objectFit\", \"objectPosition\") : {}),\n width: 0,\n height: 0,\n }}\n />\n </picture>\n );\n}\n\nconst DEFAULT_SVG_WIDTH = 10000;\n\nfunction isSvg(src: string) {\n return src.endsWith(\".svg\") || src.startsWith(\"data:image/svg\");\n}\n\ninterface WidthDesc {\n width?: number;\n desc: string;\n}\n\nfunction getClosestPresetSize(width: number, fullWidth: number) {\n const nextBiggerIndex =\n ALL_SIZES.findIndex((w) => w >= width) ?? ALL_SIZES.length - 1;\n const nextBigger = ALL_SIZES[nextBiggerIndex];\n if (nextBigger >= fullWidth) {\n // If the requested width is larger than the fullWidth,\n // we just use the original width instead. It's impossible\n // to make an image bigger than fullWidth!\n return undefined;\n } else if (\n nextBiggerIndex + 1 < ALL_SIZES.length &&\n fullWidth <= ALL_SIZES[nextBiggerIndex + 1]\n ) {\n // If the fullWidth is just between nextBigger and the one after that,\n // then also might as well just use the original size (so, width is 30,\n // nextBigger is 32, then we just use the original as long as fullWidth is\n // less than 48)\n return undefined;\n }\n\n return nextBigger;\n}\n\n/**\n * Computes the appropriate srcSet and sizes to use\n */\nfunction getWidths(\n width: number | string | undefined,\n fullWidth: number,\n extra?: { minWidth: string | number | undefined }\n): { sizes: string | undefined; widthDescs: WidthDesc[] } {\n const minWidth = extra?.minWidth;\n const pixelWidth = getPixelLength(width);\n const pixelMinWidth = getPixelLength(minWidth);\n if (pixelWidth != null && (!minWidth || pixelMinWidth != null)) {\n // If there's an exact width, then we just need to display it at 1x and 2x density\n return {\n widthDescs: [\n {\n width: getClosestPresetSize(\n Math.max(pixelWidth, pixelMinWidth ?? 0),\n fullWidth\n ),\n desc: \"1x\",\n },\n {\n width: getClosestPresetSize(\n Math.max(pixelWidth, pixelMinWidth ?? 0) * 2,\n fullWidth\n ),\n desc: \"2x\",\n },\n ],\n sizes: undefined,\n };\n }\n // Otherwise we don't know what sizes we'll end up, so we just cap it at\n // device width. TODO: do better!\n const usefulSizes = DEVICE_SIZES.filter(\n (size) => !fullWidth || size < fullWidth\n );\n if (!!fullWidth && usefulSizes.length === 0) {\n // image fullWidth is smaller than all device sizes. So all we can do\n // is offer 1x\n return {\n widthDescs: [\n {\n width: getClosestPresetSize(fullWidth, fullWidth),\n desc: \"1x\",\n },\n ],\n sizes: undefined,\n };\n }\n return {\n widthDescs: usefulSizes.map((size) => ({\n width: getClosestPresetSize(size, fullWidth),\n // If this is the last (buggest) useful width, but it is\n // still within the bounds set by DEVICE_SIZES, then just\n // use the original, unresized image. This means if we match\n // the largest size, we use unresized and best quality image.\n // We only do this, though, if fullWidth is \"reasonable\" --\n // smaller than the largest size we would consider.\n // i === usefulSizes.length - 1 &&\n // fullWidth < DEVICE_SIZES[DEVICE_SIZES.length - 1]\n // ? undefined\n // : size,\n desc: `${size}w`,\n })),\n sizes: \"100vw\",\n };\n}\n\nfunction getPixelLength(length: number | string | undefined) {\n if (length == null || length == \"\") {\n return undefined;\n }\n\n if (typeof length === \"number\") {\n return length;\n }\n\n const parsed = parseNumeric(length);\n if (parsed && (!parsed.units || parsed.units === \"px\")) {\n return parsed.num;\n }\n\n return undefined;\n}\n\nfunction parseNumeric(val: string) {\n // Parse strings like \"30\", \"30px\", \"30%\", \"30px /* blah blah */\"\n const res = val.match(\n /^\\s*(-?(?:\\d+\\.\\d*|\\d*\\.\\d+|\\d+))\\s*([a-z]*|%)\\s*(?:\\/\\*.*)?$/i\n );\n if (res == null) {\n return undefined;\n }\n const num = res[1];\n const units = res[2];\n return { num: +num, units };\n}\n\nfunction getImageLoader(loader: \"plasmic\" | ImageLoader | undefined) {\n if (loader == null) {\n return undefined;\n } else if (loader === \"plasmic\") {\n return PLASMIC_IMAGE_LOADER;\n } else {\n return loader;\n }\n}\n\nconst PLASMIC_IMAGE_LOADER: ImageLoader = {\n supportsUrl: (src) => {\n return src.startsWith(\"https://img.plasmic.app\") && !isSvg(src);\n },\n transformUrl: (opts) => {\n const params = [\n opts.width ? `w=${opts.width}` : undefined,\n `q=${opts.quality ?? 75}`,\n opts.format ? `f=${opts.format}` : undefined,\n ].filter((x) => !!x);\n return `${opts.src}?${params.join(\"&\")}`;\n },\n};\n"],"names":["React"],"mappings":";;;;;AAAA;;;AAwBA;AACA;AACA,IAAM,SAAS,GAAG,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;AACtD,IAAM,YAAY,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,I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IAAI,GAAG,IAAI,IAAI,EAAE;QACf,OAAO,SAAS,CAAC;KAClB;IACD,IAAM,GAAG,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC;IACnB,IAAM,KAAK,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC;IACrB,OAAO,EAAE,GAAG,EAAE,CAAC,GAAG,EAAE,KAAK,OAAA,EAAE,CAAC;AAC9B,CAAC;AAED,SAAS,cAAc,CAAC,MAA2C;IACjE,IAAI,MAAM,IAAI,IAAI,EAAE;QAClB,OAAO,SAAS,CAAC;KAClB;SAAM,IAAI,MAAM,KAAK,SAAS,EAAE;QAC/B,OAAO,oBAAoB,CAAC;KAC7B;SAAM;QACL,OAAO,MAAM,CAAC;KACf;AACH,CAAC;AAED,IAAM,oBAAoB,GAAgB;IACxC,WAAW,EAAE,UAAC,GAAG;QACf,OAAO,GAAG,CAAC,UAAU,CAAC,yBAAyB,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;KACjE;IACD,YAAY,EAAE,UAAC,IAAI;;QACjB,IAAM,MAAM,GAAG;YACb,IAAI,CAAC,KAAK,GAAG,OAAK,IAAI,CAAC,KAAO,GAAG,SAAS;YAC1C,QAAK,MAAA,IAAI,CAAC,OAAO,mCAAI,EAAE,CAAE;YACzB,IAAI,CAAC,MAAM,GAAG,OAAK,IAAI,CAAC,MAAQ,GAAG,SAAS;SAC7C,CAAC,MAAM,CAAC,UAAC,CAAC,IAAK,OAAA,CAAC,CAAC,CAAC,GAAA,CAAC,CAAC;QACrB,OAAU,IAAI,CAAC,GAAG,SAAI,MAAM,CAAC,IAAI,CAAC,GAAG,CAAG,CAAC;KAC1C;CACF;;;;"}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../src/render/PlasmicImg/index.tsx"],"sourcesContent":["/**\n * Responsive `<img/>` replacement, based on `next/image`\n */\n\nimport classNames from \"classnames\";\nimport React, { CSSProperties } from \"react\";\nimport { pick } from \"../../common\";\nimport { mergeRefs } from \"../../react-utils\";\n\nexport interface ImageLoader {\n supportsUrl: (url: string) => boolean;\n transformUrl: (opts: {\n src: string;\n width?: number;\n quality?: number;\n format?: \"webp\";\n }) => string;\n}\n\ntype ImgTagProps = Omit<\n React.ComponentProps<\"img\">,\n \"src\" | \"srcSet\" | \"ref\" | \"style\"\n>;\n\n// Default image sizes to snap to\n// TODO: make this configurable?\nconst IMG_SIZES = [16, 32, 48, 64, 96, 128, 256, 384];\nconst DEVICE_SIZES = [640, 750, 828, 1080, 1200, 1920, 2048, 3840];\nconst ALL_SIZES = [...IMG_SIZES, ...DEVICE_SIZES];\n\nexport interface PlasmicImgProps extends ImgTagProps {\n /**\n * Either an object with the src string, and its full width and height,\n * or just a src string with unknown intrinsic dimensions.\n */\n src?:\n | string\n | {\n src: string;\n fullHeight: number;\n fullWidth: number;\n // We might also get a more precise aspectRatio for SVGs\n // instead of relyiing on fullWidth / fullHeight, because\n // those values might be rounded and not so accurate.\n aspectRatio?: number;\n };\n\n /**\n * className applied to the wrapper element if one is used.\n */\n className?: string;\n\n /**\n * css width\n */\n displayWidth?: number | string;\n\n /**\n * css height\n */\n displayHeight?: number | string;\n\n /**\n * css min-width\n */\n displayMinWidth?: number | string;\n\n /**\n * css min-height\n */\n displayMinHeight?: number | string;\n\n /**\n * css max-width\n */\n displayMaxWidth?: number | string;\n\n /**\n * css max-height\n */\n displayMaxHeight?: number | string;\n\n /**\n * For variable quality formats like jpg, the quality from 0 to 100\n */\n quality?: number;\n\n /**\n * ImageLoader to use for loading different dimensions of the image.\n * If none specified, will not attempt to load different dimensions.\n */\n loader?: \"plasmic\" | ImageLoader;\n\n /**\n * Style applied to the wrapper element. objectFit and objectPosition\n * rules are applied to the img element.\n */\n style?: React.CSSProperties;\n\n /**\n * Ref for the img element. The normal <PlasmicImg ref={...} />\n * prop gives the root element instead, which may be the img element\n * or a wrapper element\n */\n imgRef?: React.Ref<HTMLImageElement>;\n}\n\nexport const PlasmicImg = React.forwardRef(function PlasmicImg(\n props: PlasmicImgProps,\n outerRef: React.Ref<HTMLElement>\n) {\n let {\n src,\n className,\n displayWidth,\n displayHeight,\n displayMinWidth,\n displayMinHeight,\n displayMaxWidth,\n displayMaxHeight,\n quality,\n loader,\n imgRef,\n style,\n loading,\n ...rest\n } = props;\n\n const imgProps = Object.assign({}, rest, {\n // Default loading to \"lazy\" if not specified (which is different from the\n // html img, which defaults to eager!)\n loading: loading ?? \"lazy\",\n });\n\n const { fullWidth, fullHeight, aspectRatio } =\n typeof src === \"string\" || !src\n ? { fullWidth: undefined, fullHeight: undefined, aspectRatio: undefined }\n : src;\n const srcStr = src ? (typeof src === \"string\" ? src : src.src) : \"\";\n\n // Assume external image if either dimension is null and use usual <img>\n if (fullHeight == null || fullWidth == null) {\n return (\n <img\n src={srcStr}\n className={className}\n style={style}\n {...imgProps}\n loading={loading}\n ref={mergeRefs(imgRef, outerRef) as any}\n />\n );\n }\n\n if (\n isSvg(srcStr) &&\n (displayHeight == null || displayHeight === \"auto\") &&\n (displayWidth == null || displayWidth === \"auto\")\n ) {\n displayWidth = \"100%\";\n }\n\n if (\n fullWidth &&\n fullHeight &&\n (!displayWidth || displayWidth === \"auto\") &&\n !!getPixelLength(displayHeight)\n ) {\n // If there's a pixel length specified for displayHeight but not displayWidth,\n // then we can derive the pixel length for displayWidth. Having an explicit\n // displayWidth makes this a fixed-size image, which makes it possible for us to\n // generate better markup!\n if (!isSvg(srcStr)) {\n // We shouldn't do it for SVGs though, because `fullWidth` and\n // `fullHeight` might have rounded values so the final\n // `displayWidth` could differ by 1px or so.\n displayWidth = (getPixelLength(displayHeight)! * fullWidth) / fullHeight;\n }\n }\n\n let spacerWidth = fullWidth;\n let spacerHeight = fullHeight;\n if (aspectRatio && isFinite(aspectRatio) && isSvg(srcStr)) {\n // For SVGs, fullWidth and fullHeight can be rounded values, which would\n // cause some discrepancy between the actual aspect ratio and the aspect\n // ratio from those values. So, for those cases, we set large width / height\n // values to get a more precise ratio from the spacer.\n spacerWidth = DEFAULT_SVG_WIDTH;\n spacerHeight = Math.round(spacerWidth / aspectRatio);\n }\n\n const { sizes, widthDescs } = getWidths(displayWidth, fullWidth, {\n minWidth: displayMinWidth,\n });\n const imageLoader = getImageLoader(loader);\n const spacerSvg = `<svg width=\"${spacerWidth}\" height=\"${spacerHeight}\" xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\"/>`;\n const spacerSvgBase64 =\n typeof window === \"undefined\"\n ? Buffer.from(spacerSvg).toString(\"base64\")\n : window.btoa(spacerSvg);\n\n let wrapperStyle: CSSProperties = { ...(style || {}) };\n let spacerStyle: CSSProperties = pick(\n style || {},\n \"objectFit\",\n \"objectPosition\"\n );\n\n if (displayWidth != null && displayWidth !== \"auto\") {\n // If width is set, set it on the wrapper along with min/max width\n // and just use `width: 100%` on the spacer\n spacerStyle.width = \"100%\";\n // Rely on the styles set by `classname` on the wrapper:\n // wrapperStyle.width = displayWidth;\n // wrapperStyle.minWidth = displayMinWidth;\n // wrapperStyle.maxWidth = displayMaxWidth;\n } else {\n // Otherwise, we want auto sizing from the spacer, so set width there.\n //\n // But if we have min/max width, it should be set in the wrapper and it\n // can be percentage values (and we add corresponding min/max width to\n // 100% in the spacer). In general it ends up with the correct effect,\n // but some edge cases might make `min-width: 100%` shrink the image more\n // than it should.\n spacerStyle.width = displayWidth;\n wrapperStyle.width = \"auto\";\n if (displayMinWidth) {\n spacerStyle.minWidth = \"100%\";\n // Rely on min-width set by `classname` on the wrapper:\n // wrapperStyle.minWidth = displayMinWidth;\n }\n if (displayMaxWidth != null && displayMaxWidth !== \"none\") {\n spacerStyle.maxWidth = \"100%\";\n // Rely on max-width set by `classname` on the wrapper:\n // wrapperStyle.maxWidth = displayMaxWidth;\n }\n }\n\n if (displayHeight != null && displayHeight !== \"auto\") {\n spacerStyle.height = \"100%\";\n wrapperStyle.height = displayHeight;\n wrapperStyle.minHeight = displayMinHeight;\n wrapperStyle.maxHeight = displayMaxHeight;\n } else {\n spacerStyle.height = displayHeight;\n wrapperStyle.height = \"auto\";\n if (displayMinHeight) {\n spacerStyle.minHeight = \"100%\";\n wrapperStyle.minHeight = displayMinHeight;\n }\n if (displayMaxHeight != null && displayMaxHeight !== \"none\") {\n spacerStyle.maxHeight = \"100%\";\n wrapperStyle.maxHeight = displayMaxHeight;\n }\n }\n\n return (\n <div\n className={classNames(className, \"__wab_img-wrapper\")}\n ref={outerRef as any}\n style={wrapperStyle}\n >\n <img\n alt=\"\"\n aria-hidden\n className=\"__wab_img-spacer-svg\"\n src={`data:image/svg+xml;base64,${spacerSvgBase64}`}\n style={spacerStyle}\n />\n {makePicture({\n imageLoader,\n widthDescs,\n sizes,\n src: srcStr,\n quality,\n ref: imgRef,\n style: style ? pick(style, \"objectFit\", \"objectPosition\") : undefined,\n imgProps,\n className: \"__wab_img\",\n })}\n </div>\n );\n});\n\nfunction makePicture(opts: {\n imageLoader?: ImageLoader;\n widthDescs: WidthDesc[];\n sizes?: string;\n src: string;\n quality?: number;\n style?: React.CSSProperties;\n className?: string;\n imgProps: ImgTagProps;\n ref?: React.Ref<HTMLImageElement>;\n}) {\n // If imageLoader is undefined, then this renders to just a normal\n // <img />. Else it will render to a <picture> with a <source> for\n // webp, and srcSet/sizes set according to width requirements.\n const {\n imageLoader,\n widthDescs,\n src,\n quality,\n style,\n className,\n sizes,\n imgProps,\n ref,\n } = opts;\n return (\n <picture className=\"__wab_picture\">\n {imageLoader && imageLoader.supportsUrl(src) && (\n <source\n type=\"image/webp\"\n srcSet={widthDescs\n .map(\n (wd) =>\n `${imageLoader.transformUrl({\n src,\n quality,\n width: wd.width,\n format: \"webp\",\n })} ${wd.desc}`\n )\n .join(\", \")}\n />\n )}\n <img\n {...imgProps}\n ref={ref}\n className={className}\n decoding=\"async\"\n src={\n imageLoader && imageLoader.supportsUrl(src)\n ? imageLoader.transformUrl({\n src,\n quality,\n width: widthDescs[widthDescs.length - 1].width,\n })\n : src\n }\n srcSet={\n imageLoader && imageLoader.supportsUrl(src)\n ? widthDescs\n .map(\n (wd) =>\n `${imageLoader.transformUrl({\n src,\n quality,\n width: wd.width,\n })} ${wd.desc}`\n )\n .join(\", \")\n : undefined\n }\n sizes={imageLoader && imageLoader.supportsUrl(src) ? sizes : undefined}\n style={{\n ...(style ? pick(style, \"objectFit\", \"objectPosition\") : {}),\n width: 0,\n height: 0,\n }}\n />\n </picture>\n );\n}\n\nconst DEFAULT_SVG_WIDTH = 10000;\n\nfunction isSvg(src: string) {\n return src.endsWith(\".svg\") || src.startsWith(\"data:image/svg\");\n}\n\ninterface WidthDesc {\n width?: number;\n desc: string;\n}\n\nfunction getClosestPresetSize(width: number, fullWidth: number) {\n const nextBiggerIndex =\n ALL_SIZES.findIndex((w) => w >= width) ?? ALL_SIZES.length - 1;\n const nextBigger = ALL_SIZES[nextBiggerIndex];\n if (nextBigger >= fullWidth) {\n // If the requested width is larger than the fullWidth,\n // we just use the original width instead. It's impossible\n // to make an image bigger than fullWidth!\n return undefined;\n } else if (\n nextBiggerIndex + 1 < ALL_SIZES.length &&\n fullWidth <= ALL_SIZES[nextBiggerIndex + 1]\n ) {\n // If the fullWidth is just between nextBigger and the one after that,\n // then also might as well just use the original size (so, width is 30,\n // nextBigger is 32, then we just use the original as long as fullWidth is\n // less than 48)\n return undefined;\n }\n\n return nextBigger;\n}\n\n/**\n * Computes the appropriate srcSet and sizes to use\n */\nfunction getWidths(\n width: number | string | undefined,\n fullWidth: number,\n extra?: { minWidth: string | number | undefined }\n): { sizes: string | undefined; widthDescs: WidthDesc[] } {\n const minWidth = extra?.minWidth;\n const pixelWidth = getPixelLength(width);\n const pixelMinWidth = getPixelLength(minWidth);\n if (pixelWidth != null && (!minWidth || pixelMinWidth != null)) {\n // If there's an exact width, then we just need to display it at 1x and 2x density\n return {\n widthDescs: [\n {\n width: getClosestPresetSize(\n Math.max(pixelWidth, pixelMinWidth ?? 0),\n fullWidth\n ),\n desc: \"1x\",\n },\n {\n width: getClosestPresetSize(\n Math.max(pixelWidth, pixelMinWidth ?? 0) * 2,\n fullWidth\n ),\n desc: \"2x\",\n },\n ],\n sizes: undefined,\n };\n }\n // Otherwise we don't know what sizes we'll end up, so we just cap it at\n // device width. TODO: do better!\n const usefulSizes = DEVICE_SIZES.filter(\n (size) => !fullWidth || size < fullWidth\n );\n if (!!fullWidth && usefulSizes.length === 0) {\n // image fullWidth is smaller than all device sizes. So all we can do\n // is offer 1x\n return {\n widthDescs: [\n {\n width: getClosestPresetSize(fullWidth, fullWidth),\n desc: \"1x\",\n },\n ],\n sizes: undefined,\n };\n }\n return {\n widthDescs: usefulSizes.map((size) => ({\n width: getClosestPresetSize(size, fullWidth),\n // If this is the last (buggest) useful width, but it is\n // still within the bounds set by DEVICE_SIZES, then just\n // use the original, unresized image. This means if we match\n // the largest size, we use unresized and best quality image.\n // We only do this, though, if fullWidth is \"reasonable\" --\n // smaller than the largest size we would consider.\n // i === usefulSizes.length - 1 &&\n // fullWidth < DEVICE_SIZES[DEVICE_SIZES.length - 1]\n // ? undefined\n // : size,\n desc: `${size}w`,\n })),\n sizes: \"100vw\",\n };\n}\n\nfunction getPixelLength(length: number | string | undefined) {\n if (length == null || length == \"\") {\n return undefined;\n }\n\n if (typeof length === \"number\") {\n return length;\n }\n\n const parsed = parseNumeric(length);\n if (parsed && (!parsed.units || parsed.units === \"px\")) {\n return parsed.num;\n }\n\n return undefined;\n}\n\nfunction parseNumeric(val: string) {\n // Parse strings like \"30\", \"30px\", \"30%\", \"30px /* blah blah */\"\n const res = val.match(\n /^\\s*(-?(?:\\d+\\.\\d*|\\d*\\.\\d+|\\d+))\\s*([a-z]*|%)\\s*(?:\\/\\*.*)?$/i\n );\n if (res == null) {\n return undefined;\n }\n const num = res[1];\n const units = res[2];\n return { num: +num, units };\n}\n\nfunction getImageLoader(loader: \"plasmic\" | ImageLoader | undefined) {\n if (loader == null) {\n return undefined;\n } else if (loader === \"plasmic\") {\n return PLASMIC_IMAGE_LOADER;\n } else {\n return loader;\n }\n}\n\nconst PLASMIC_IMAGE_LOADER: ImageLoader = {\n supportsUrl: (src) => {\n return src.startsWith(\"https://img.plasmic.app\") && !isSvg(src);\n },\n transformUrl: (opts) => {\n const params = [\n opts.width ? `w=${opts.width}` : undefined,\n `q=${opts.quality ?? 75}`,\n opts.format ? `f=${opts.format}` : undefined,\n ].filter((x) => !!x);\n return `${opts.src}?${params.join(\"&\")}`;\n },\n};\n"],"names":["React"],"mappings":";;;;;AAAA;;;AAwBA;AACA;AACA,IAAM,SAAS,GAAG,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;AACtD,IAAM,YAAY,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;AACnE,IAAM,SAAS,mCAAO,SAAS,GAAK,YAAY,CAAC,CAAC;IA+ErC,UAAU,GAAGA,cAAK,CAAC,UAAU,CAAC,SAAS,UAAU,CAC5D,KAAsB,EACtB,QAAgC;IAG9B,IAAA,GAAG,GAcD,KAAK,IAdJ,EACH,SAAS,GAaP,KAAK,UAbE,EACT,YAAY,GAYV,KAAK,aAZK,EACZ,aAAa,GAWX,KAAK,cAXM,EACb,eAAe,GAUb,KAAK,gBAVQ,EACf,gBAAgB,GASd,KAAK,iBATS,EAChB,eAAe,GAQb,KAAK,gBARQ,EACf,gBAAgB,GAOd,KAAK,iBAPS,EAChB,OAAO,GAML,KAAK,QANA,EACP,MAAM,GAKJ,KAAK,OALD,EACN,MAAM,GAIJ,KAAK,OAJD,EACN,KAAK,GAGH,KAAK,MAHF,EACL,OAAO,GAEL,KAAK,QAFA,EACJ,IAAI,UACL,KAAK,EAfL,sLAeH,CADQ,CACC;IAEV,IAAM,QAAQ,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,IAAI,EAAE;;;QAGvC,OAAO,EAAE,OAAO,aAAP,OAAO,cAAP,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C,GAAA,CAAC,CAAC;QACrB,OAAU,IAAI,CAAC,GAAG,SAAI,MAAM,CAAC,IAAI,CAAC,GAAG,CAAG,CAAC;KAC1C;CACF;;;;"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Responsive `<img/>` replacement, based on `next/image`
|
|
3
|
+
*/
|
|
4
|
+
import React from "react";
|
|
5
|
+
export declare type ImageLoader = (opts: {
|
|
6
|
+
src: string;
|
|
7
|
+
width: number;
|
|
8
|
+
quality?: number;
|
|
9
|
+
format?: "webp";
|
|
10
|
+
}) => string;
|
|
11
|
+
declare type ImgTagProps = Omit<
|
|
12
|
+
React.ComponentProps<"img">,
|
|
13
|
+
"src" | "srcSet" | "ref" | "style"
|
|
14
|
+
>;
|
|
15
|
+
export interface PlasmicImgProps extends ImgTagProps {
|
|
16
|
+
/**
|
|
17
|
+
* Either an object with the src string, and its full width and height,
|
|
18
|
+
* or just a src string with unknown intrinsic dimensions.
|
|
19
|
+
*/
|
|
20
|
+
src:
|
|
21
|
+
| string
|
|
22
|
+
| {
|
|
23
|
+
src: string;
|
|
24
|
+
fullHeight: number;
|
|
25
|
+
fullWidth: number;
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* className applied to the wrapper element if one is used.
|
|
29
|
+
*/
|
|
30
|
+
className?: string;
|
|
31
|
+
/**
|
|
32
|
+
* css width
|
|
33
|
+
*/
|
|
34
|
+
displayWidth?: number | string;
|
|
35
|
+
/**
|
|
36
|
+
* css height
|
|
37
|
+
*/
|
|
38
|
+
displayHeight?: number | string;
|
|
39
|
+
/**
|
|
40
|
+
* For variable quality formats like jpg, the quality from 0 to 100
|
|
41
|
+
*/
|
|
42
|
+
quality?: number;
|
|
43
|
+
/**
|
|
44
|
+
* ImageLoader to use for loading different dimensions of the image.
|
|
45
|
+
* If none specified, will not attempt to load different dimensions.
|
|
46
|
+
*/
|
|
47
|
+
loader?: "plasmic" | ImageLoader;
|
|
48
|
+
/**
|
|
49
|
+
* Style applied to the wrapper element. objectFit and objectPosition
|
|
50
|
+
* rules are applied to the img element.
|
|
51
|
+
*/
|
|
52
|
+
style?: React.CSSProperties;
|
|
53
|
+
/**
|
|
54
|
+
* Ref for the wrapper element. The normal <PlasmicImg ref={...} />
|
|
55
|
+
* prop gives you the wrap to the img element.
|
|
56
|
+
*/
|
|
57
|
+
containerRef?: React.Ref<HTMLDivElement>;
|
|
58
|
+
}
|
|
59
|
+
export declare const PlasmicImg: React.ForwardRefExoticComponent<
|
|
60
|
+
PlasmicImgProps & React.RefAttributes<HTMLImageElement>
|
|
61
|
+
>;
|
|
62
|
+
export {};
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import React__default from 'react';
|
|
3
|
+
import { SSRProvider, useIsSSR as useIsSSR$1 } from 'react-aria';
|
|
4
|
+
|
|
5
|
+
var PlasmicTranslatorContext = React__default.createContext(undefined);
|
|
6
|
+
function isIterable(val) {
|
|
7
|
+
return val != null && typeof val[Symbol.iterator] === "function";
|
|
8
|
+
}
|
|
9
|
+
function genTranslatableString(elt) {
|
|
10
|
+
var components = {};
|
|
11
|
+
var componentsCount = 0;
|
|
12
|
+
var getText = function (node) {
|
|
13
|
+
if (!node) {
|
|
14
|
+
return "";
|
|
15
|
+
}
|
|
16
|
+
if (typeof node === "number" ||
|
|
17
|
+
typeof node === "boolean" ||
|
|
18
|
+
typeof node === "string") {
|
|
19
|
+
return node.toString();
|
|
20
|
+
}
|
|
21
|
+
if (typeof node !== "object") {
|
|
22
|
+
return "";
|
|
23
|
+
}
|
|
24
|
+
if (Array.isArray(node) || isIterable(node)) {
|
|
25
|
+
return Array.from(node)
|
|
26
|
+
.map(function (child) { return getText(child); })
|
|
27
|
+
.filter(function (child) { return !!child; })
|
|
28
|
+
.join("");
|
|
29
|
+
}
|
|
30
|
+
var nodeChildren = (hasKey(node, "props") &&
|
|
31
|
+
hasKey(node.props, "children") &&
|
|
32
|
+
node.props.children) ||
|
|
33
|
+
(hasKey(node, "children") && node.children) ||
|
|
34
|
+
[];
|
|
35
|
+
var contents = "" + React__default.Children.toArray(nodeChildren)
|
|
36
|
+
.map(function (child) { return getText(child); })
|
|
37
|
+
.filter(function (child) { return !!child; })
|
|
38
|
+
.join("");
|
|
39
|
+
if (React__default.isValidElement(node) && node.type === React__default.Fragment) {
|
|
40
|
+
return contents;
|
|
41
|
+
}
|
|
42
|
+
var componentId = componentsCount + 1;
|
|
43
|
+
componentsCount++;
|
|
44
|
+
components[componentId] = React__default.isValidElement(node)
|
|
45
|
+
? React__default.cloneElement(node, {
|
|
46
|
+
key: componentId,
|
|
47
|
+
children: undefined,
|
|
48
|
+
})
|
|
49
|
+
: node;
|
|
50
|
+
return "<" + componentId + ">" + contents + "</" + componentId + ">";
|
|
51
|
+
};
|
|
52
|
+
var str = getText(elt);
|
|
53
|
+
return {
|
|
54
|
+
str: str,
|
|
55
|
+
components: components,
|
|
56
|
+
componentsCount: componentsCount,
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
function Trans(_a) {
|
|
60
|
+
var children = _a.children;
|
|
61
|
+
var _t = React__default.useContext(PlasmicTranslatorContext);
|
|
62
|
+
if (!_t) {
|
|
63
|
+
warnNoTranslationFunctionAtMostOnce();
|
|
64
|
+
return children;
|
|
65
|
+
}
|
|
66
|
+
var _b = genTranslatableString(children), str = _b.str, components = _b.components, componentsCount = _b.componentsCount;
|
|
67
|
+
return _t(str, componentsCount > 0 ? { components: components } : undefined);
|
|
68
|
+
}
|
|
69
|
+
var hasWarned = false;
|
|
70
|
+
function warnNoTranslationFunctionAtMostOnce() {
|
|
71
|
+
if (!hasWarned) {
|
|
72
|
+
console.warn("Using Plasmic Translation but no translation function has been provided");
|
|
73
|
+
hasWarned = true;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
function hasKey(v, key) {
|
|
77
|
+
return typeof v === "object" && v !== null && key in v;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
var PlasmicRootContext = React.createContext(undefined);
|
|
81
|
+
function PlasmicRootProvider(props) {
|
|
82
|
+
var platform = props.platform, children = props.children;
|
|
83
|
+
var context = React.useMemo(function () { return ({
|
|
84
|
+
platform: platform,
|
|
85
|
+
}); }, [platform]);
|
|
86
|
+
return (React.createElement(PlasmicRootContext.Provider, { value: context },
|
|
87
|
+
React.createElement(SSRProvider, null,
|
|
88
|
+
React.createElement(PlasmicTranslatorContext.Provider, { value: props.translator }, children))));
|
|
89
|
+
}
|
|
90
|
+
var useIsSSR = useIsSSR$1;
|
|
91
|
+
function useHasPlasmicRoot() {
|
|
92
|
+
return !!React.useContext(PlasmicRootContext);
|
|
93
|
+
}
|
|
94
|
+
var hasWarnedSSR = false;
|
|
95
|
+
/**
|
|
96
|
+
* Warns the user if PlasmicRootProvider is not used
|
|
97
|
+
*/
|
|
98
|
+
function useEnsureSSRProvider() {
|
|
99
|
+
var hasRoot = useHasPlasmicRoot();
|
|
100
|
+
if (hasRoot || hasWarnedSSR || process.env.NODE_ENV !== "development") {
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
hasWarnedSSR = true;
|
|
104
|
+
console.warn("Plasmic: To ensure your components work correctly with server-side rendering, please use PlasmicRootProvider at the root of your application. See https://docs.plasmic.app/learn/ssr");
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
export { PlasmicRootProvider as P, Trans as T, useEnsureSSRProvider as a, genTranslatableString as g, useIsSSR as u };
|
|
108
|
+
//# sourceMappingURL=ssr-64e38713.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ssr-64e38713.js","sources":["../../src/render/translation.tsx","../../src/render/ssr.tsx"],"sourcesContent":["import React from \"react\";\n\nexport type PlasmicTranslator = (\n str: string,\n opts?: {\n components?: {\n [key: string]: React.ReactElement;\n };\n }\n) => React.ReactNode;\n\nexport const PlasmicTranslatorContext =\n React.createContext<PlasmicTranslator | undefined>(undefined);\n\nexport interface TransProps {\n children?: React.ReactNode;\n}\n\nfunction isIterable(val: any): val is Iterable<any> {\n return val != null && typeof val[Symbol.iterator] === \"function\";\n}\n\nexport function genTranslatableString(elt: React.ReactNode) {\n const components: {\n [key: string]: React.ReactElement;\n } = {};\n let componentsCount = 0;\n\n const getText = (node: React.ReactNode): string => {\n if (!node) {\n return \"\";\n }\n if (\n typeof node === \"number\" ||\n typeof node === \"boolean\" ||\n typeof node === \"string\"\n ) {\n return node.toString();\n }\n if (typeof node !== \"object\") {\n return \"\";\n }\n if (Array.isArray(node) || isIterable(node)) {\n return Array.from(node)\n .map((child) => getText(child))\n .filter((child) => !!child)\n .join(\"\");\n }\n const nodeChildren: React.ReactNode =\n (hasKey(node, \"props\") &&\n hasKey(node.props, \"children\") &&\n (node.props.children as React.ReactNode | undefined)) ||\n (hasKey(node, \"children\") && node.children) ||\n [];\n const contents = `${React.Children.toArray(nodeChildren)\n .map((child) => getText(child))\n .filter((child) => !!child)\n .join(\"\")}`;\n if (React.isValidElement(node) && node.type === React.Fragment) {\n return contents;\n }\n const componentId = componentsCount + 1;\n componentsCount++;\n components[componentId] = React.isValidElement(node)\n ? React.cloneElement(node as any, {\n key: componentId,\n children: undefined,\n })\n : (node as never);\n return `<${componentId}>${contents}</${componentId}>`;\n };\n\n const str = getText(elt);\n return {\n str,\n components,\n componentsCount,\n };\n}\n\nexport function Trans({ children }: TransProps) {\n const _t = React.useContext(PlasmicTranslatorContext);\n if (!_t) {\n warnNoTranslationFunctionAtMostOnce();\n return children;\n }\n\n const { str, components, componentsCount } = genTranslatableString(children);\n return _t(str, componentsCount > 0 ? { components } : undefined);\n}\n\nlet hasWarned = false;\nfunction warnNoTranslationFunctionAtMostOnce() {\n if (!hasWarned) {\n console.warn(\n \"Using Plasmic Translation but no translation function has been provided\"\n );\n hasWarned = true;\n }\n}\n\nfunction hasKey<K extends string>(v: any, key: K): v is Record<K, any> {\n return typeof v === \"object\" && v !== null && key in v;\n}\n","import * as React from \"react\";\nimport { SSRProvider, useIsSSR as useAriaIsSSR } from \"react-aria\";\nimport { PlasmicTranslator, PlasmicTranslatorContext } from \"./translation\";\n\nexport interface PlasmicRootContextValue {\n platform?: \"nextjs\" | \"gatsby\";\n}\n\nconst PlasmicRootContext =\n React.createContext<PlasmicRootContextValue | undefined>(undefined);\n\nexport interface PlasmicRootProviderProps {\n platform?: \"nextjs\" | \"gatsby\";\n children?: React.ReactNode;\n translator?: PlasmicTranslator;\n}\n\nexport function PlasmicRootProvider(props: PlasmicRootProviderProps) {\n const { platform, children } = props;\n const context = React.useMemo(\n () => ({\n platform,\n }),\n [platform]\n );\n return (\n <PlasmicRootContext.Provider value={context}>\n <SSRProvider>\n <PlasmicTranslatorContext.Provider value={props.translator}>\n {children}\n </PlasmicTranslatorContext.Provider>\n </SSRProvider>\n </PlasmicRootContext.Provider>\n );\n}\n\nexport const useIsSSR = useAriaIsSSR;\n\nexport function useHasPlasmicRoot() {\n return !!React.useContext(PlasmicRootContext);\n}\n\nlet hasWarnedSSR = false;\n/**\n * Warns the user if PlasmicRootProvider is not used\n */\nexport function useEnsureSSRProvider() {\n const hasRoot = useHasPlasmicRoot();\n if (hasRoot || hasWarnedSSR || process.env.NODE_ENV !== \"development\") {\n return;\n }\n\n hasWarnedSSR = true;\n console.warn(\n `Plasmic: To ensure your components work correctly with server-side rendering, please use PlasmicRootProvider at the root of your application. See https://docs.plasmic.app/learn/ssr`\n );\n}\n"],"names":["React","useAriaIsSSR"],"mappings":";;;;AAWO,IAAM,wBAAwB,GACnCA,cAAK,CAAC,aAAa,CAAgC,SAAS,CAAC,CAAC;AAMhE,SAAS,UAAU,CAAC,GAAQ;IAC1B,OAAO,GAAG,IAAI,IAAI,IAAI,OAAO,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,UAAU,CAAC;AACnE,CAAC;SAEe,qBAAqB,CAAC,GAAoB;IACxD,IAAM,UAAU,GAEZ,EAAE,CAAC;IACP,IAAI,eAAe,GAAG,CAAC,CAAC;IAExB,IAAM,OAAO,GAAG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IAAI,CAAC,KAAK,IAAI,IAAI,GAAG,IAAI,CAAC,CAAC;AACzD;;AC/FA,IAAM,kBAAkB,GACtB,KAAK,CAAC,aAAa,CAAsC,SAAS,CAAC,CAAC;SAQtD,mBAAmB,CAAC,KAA+B;IACzD,IAAA,QAAQ,GAAe,KAAK,SAApB,EAAE,QAAQ,GAAK,KAAK,SAAV,CAAW;IACrC,IAAM,OAAO,GAAG,KAAK,CAAC,OAAO,CAC3B,cAAM,QAAC;QACL,QAAQ,UAAA;KACT,IAAC,EACF,CAAC,QAAQ,CAAC,CACX,CAAC;IACF,QACE,oBAAC,kBAAkB,CAAC,QAAQ,IAAC,KAAK,EAAE,OAAO;QACzC,oBAAC,WAAW;YACV,oBAAC,wBAAwB,CAAC,QAAQ,IAAC,KAAK,EAAE,KAAK,CAAC,UAAU,IACvD,QAAQ,CACyB,CACxB,CACc,EAC9B;AACJ,CAAC;IAEY,QAAQ,GAAGC,WAAa;SAErB,iBAAiB;IAC/B,OAAO,CAAC,CAAC,KAAK,CAAC,UAAU,CAAC,kBAAkB,CAAC,CAAC;AAChD,CAAC;AAED,IAAI,YAAY,GAAG,KAAK,CAAC;AACzB;;;SAGgB,oBAAoB;IAClC,IAAM,OAAO,GAAG,iBAAiB,EAAE,CAAC;IACpC,IAAI,OAAO,IAAI,YAAY,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,aAAa,EAAE;QACrE,OAAO;KACR;IAED,YAAY,GAAG,IAAI,CAAC;IACpB,OAAO,CAAC,IAAI,CACV,uLAAuL,CACxL,CAAC;AACJ;;;;"}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import React__default from 'react';
|
|
3
|
+
import { SSRProvider, useIsSSR as useIsSSR$1 } from 'react-aria';
|
|
4
|
+
|
|
5
|
+
var PlasmicTranslatorContext = React__default.createContext(undefined);
|
|
6
|
+
function genTranslatableString(elt) {
|
|
7
|
+
var components = {};
|
|
8
|
+
var componentsCount = 0;
|
|
9
|
+
var getText = function (node) {
|
|
10
|
+
if (!node) {
|
|
11
|
+
return "";
|
|
12
|
+
}
|
|
13
|
+
if (typeof node === "number" ||
|
|
14
|
+
typeof node === "boolean" ||
|
|
15
|
+
typeof node === "string") {
|
|
16
|
+
return node.toString();
|
|
17
|
+
}
|
|
18
|
+
if (typeof node !== "object") {
|
|
19
|
+
return "";
|
|
20
|
+
}
|
|
21
|
+
if (Array.isArray(node)) {
|
|
22
|
+
return node
|
|
23
|
+
.map(function (child) { return getText(child); })
|
|
24
|
+
.filter(function (child) { return !!child; })
|
|
25
|
+
.join("");
|
|
26
|
+
}
|
|
27
|
+
var nodeChildren = (hasKey(node, "props") &&
|
|
28
|
+
hasKey(node.props, "children") &&
|
|
29
|
+
node.props.children) ||
|
|
30
|
+
(hasKey(node, "children") && node.children) ||
|
|
31
|
+
[];
|
|
32
|
+
var contents = "" + React__default.Children.toArray(nodeChildren)
|
|
33
|
+
.map(function (child) { return getText(child); })
|
|
34
|
+
.filter(function (child) { return !!child; })
|
|
35
|
+
.join("");
|
|
36
|
+
if (React__default.isValidElement(node) && node.type === React__default.Fragment) {
|
|
37
|
+
return contents;
|
|
38
|
+
}
|
|
39
|
+
var componentId = componentsCount;
|
|
40
|
+
componentsCount++;
|
|
41
|
+
components["t" + componentId] = React__default.isValidElement(node)
|
|
42
|
+
? React__default.cloneElement(node, {
|
|
43
|
+
key: componentId,
|
|
44
|
+
children: undefined,
|
|
45
|
+
})
|
|
46
|
+
: node;
|
|
47
|
+
return "<t" + componentId + ">" + contents + "</t" + componentId + ">";
|
|
48
|
+
};
|
|
49
|
+
var str = getText(elt);
|
|
50
|
+
return {
|
|
51
|
+
str: str,
|
|
52
|
+
components: components,
|
|
53
|
+
componentsCount: componentsCount,
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
function Trans(_a) {
|
|
57
|
+
var children = _a.children;
|
|
58
|
+
var _t = React__default.useContext(PlasmicTranslatorContext);
|
|
59
|
+
if (!_t) {
|
|
60
|
+
warnNoTranslationFunctionAtMostOnce();
|
|
61
|
+
return children;
|
|
62
|
+
}
|
|
63
|
+
var _b = genTranslatableString(children), str = _b.str, components = _b.components, componentsCount = _b.componentsCount;
|
|
64
|
+
return _t(str, componentsCount > 0 ? { components: components } : undefined);
|
|
65
|
+
}
|
|
66
|
+
var hasWarned = false;
|
|
67
|
+
function warnNoTranslationFunctionAtMostOnce() {
|
|
68
|
+
if (!hasWarned) {
|
|
69
|
+
console.warn("Using Plasmic Translation but no translation function has been provided");
|
|
70
|
+
hasWarned = true;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
function hasKey(v, key) {
|
|
74
|
+
return typeof v === "object" && v !== null && key in v;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
var PlasmicRootContext = React.createContext(undefined);
|
|
78
|
+
function PlasmicRootProvider(props) {
|
|
79
|
+
var platform = props.platform, children = props.children;
|
|
80
|
+
var context = React.useMemo(function () { return ({
|
|
81
|
+
platform: platform,
|
|
82
|
+
}); }, [platform]);
|
|
83
|
+
return (React.createElement(PlasmicRootContext.Provider, { value: context },
|
|
84
|
+
React.createElement(SSRProvider, null,
|
|
85
|
+
React.createElement(PlasmicTranslatorContext.Provider, { value: props.translator }, children))));
|
|
86
|
+
}
|
|
87
|
+
var useIsSSR = useIsSSR$1;
|
|
88
|
+
function useHasPlasmicRoot() {
|
|
89
|
+
return !!React.useContext(PlasmicRootContext);
|
|
90
|
+
}
|
|
91
|
+
var hasWarnedSSR = false;
|
|
92
|
+
/**
|
|
93
|
+
* Warns the user if PlasmicRootProvider is not used
|
|
94
|
+
*/
|
|
95
|
+
function useEnsureSSRProvider() {
|
|
96
|
+
var hasRoot = useHasPlasmicRoot();
|
|
97
|
+
if (hasRoot || hasWarnedSSR || process.env.NODE_ENV !== "development") {
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
hasWarnedSSR = true;
|
|
101
|
+
console.warn("Plasmic: To ensure your components work correctly with server-side rendering, please use PlasmicRootProvider at the root of your application. See https://docs.plasmic.app/learn/ssr");
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export { PlasmicRootProvider as P, Trans as T, useEnsureSSRProvider as a, genTranslatableString as g, useIsSSR as u };
|
|
105
|
+
//# sourceMappingURL=ssr-902d1292.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ssr-902d1292.js","sources":["../../src/render/translation.tsx","../../src/render/ssr.tsx"],"sourcesContent":["import React from \"react\";\n\nexport type PlasmicTranslator = (\n str: string,\n opts?: {\n components?: {\n [key: string]: React.ReactElement;\n };\n }\n) => React.ReactNode;\n\nexport const PlasmicTranslatorContext =\n React.createContext<PlasmicTranslator | undefined>(undefined);\n\nexport interface TransProps {\n children?: React.ReactNode;\n}\n\nexport function genTranslatableString(elt: React.ReactNode) {\n const components: {\n [key: string]: React.ReactElement;\n } = {};\n let componentsCount = 0;\n\n const getText = (node: React.ReactNode): string => {\n if (!node) {\n return \"\";\n }\n if (\n typeof node === \"number\" ||\n typeof node === \"boolean\" ||\n typeof node === \"string\"\n ) {\n return node.toString();\n }\n if (typeof node !== \"object\") {\n return \"\";\n }\n if (Array.isArray(node)) {\n return node\n .map((child) => getText(child))\n .filter((child) => !!child)\n .join(\"\");\n }\n const nodeChildren: React.ReactNode =\n (hasKey(node, \"props\") &&\n hasKey(node.props, \"children\") &&\n (node.props.children as React.ReactNode | undefined)) ||\n (hasKey(node, \"children\") && node.children) ||\n [];\n const contents = `${React.Children.toArray(nodeChildren)\n .map((child) => getText(child))\n .filter((child) => !!child)\n .join(\"\")}`;\n if (React.isValidElement(node) && node.type === React.Fragment) {\n return contents;\n }\n const componentId = componentsCount;\n componentsCount++;\n components[`t${componentId}`] = React.isValidElement(node)\n ? React.cloneElement(node as any, {\n key: componentId,\n children: undefined,\n })\n : (node as never);\n return `<t${componentId}>${contents}</t${componentId}>`;\n };\n\n const str = getText(elt);\n return {\n str,\n components,\n componentsCount,\n };\n}\n\nexport function Trans({ children }: TransProps) {\n const _t = React.useContext(PlasmicTranslatorContext);\n if (!_t) {\n warnNoTranslationFunctionAtMostOnce();\n return children;\n }\n\n const { str, components, componentsCount } = genTranslatableString(children);\n return _t(str, componentsCount > 0 ? { components } : undefined);\n}\n\nlet hasWarned = false;\nfunction warnNoTranslationFunctionAtMostOnce() {\n if (!hasWarned) {\n console.warn(\n \"Using Plasmic Translation but no translation function has been provided\"\n );\n hasWarned = true;\n }\n}\n\nfunction hasKey<K extends string>(v: any, key: K): v is Record<K, any> {\n return typeof v === \"object\" && v !== null && key in v;\n}\n","import * as React from \"react\";\nimport { SSRProvider, useIsSSR as useAriaIsSSR } from \"react-aria\";\nimport { PlasmicTranslator, PlasmicTranslatorContext } from \"./translation\";\n\nexport interface PlasmicRootContextValue {\n platform?: \"nextjs\" | \"gatsby\";\n}\n\nconst PlasmicRootContext =\n React.createContext<PlasmicRootContextValue | undefined>(undefined);\n\nexport interface PlasmicRootProviderProps {\n platform?: \"nextjs\" | \"gatsby\";\n children?: React.ReactNode;\n translator?: PlasmicTranslator;\n}\n\nexport function PlasmicRootProvider(props: PlasmicRootProviderProps) {\n const { platform, children } = props;\n const context = React.useMemo(\n () => ({\n platform,\n }),\n [platform]\n );\n return (\n <PlasmicRootContext.Provider value={context}>\n <SSRProvider>\n <PlasmicTranslatorContext.Provider value={props.translator}>\n {children}\n </PlasmicTranslatorContext.Provider>\n </SSRProvider>\n </PlasmicRootContext.Provider>\n );\n}\n\nexport const useIsSSR = useAriaIsSSR;\n\nexport function useHasPlasmicRoot() {\n return !!React.useContext(PlasmicRootContext);\n}\n\nlet hasWarnedSSR = false;\n/**\n * Warns the user if PlasmicRootProvider is not used\n */\nexport function useEnsureSSRProvider() {\n const hasRoot = useHasPlasmicRoot();\n if (hasRoot || hasWarnedSSR || process.env.NODE_ENV !== \"development\") {\n return;\n }\n\n hasWarnedSSR = true;\n console.warn(\n `Plasmic: To ensure your components work correctly with server-side rendering, please use PlasmicRootProv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react';
|
|
2
|
+
import React__default from 'react';
|
|
3
|
+
import { SSRProvider, useIsSSR as useIsSSR$1 } from 'react-aria';
|
|
4
|
+
|
|
5
|
+
var PlasmicTranslatorContext = React__default.createContext(undefined);
|
|
6
|
+
function isIterable(val) {
|
|
7
|
+
return val != null && typeof val[Symbol.iterator] === "function";
|
|
8
|
+
}
|
|
9
|
+
function genTranslatableString(elt) {
|
|
10
|
+
var components = {};
|
|
11
|
+
var componentsCount = 0;
|
|
12
|
+
var getText = function (node) {
|
|
13
|
+
if (!node) {
|
|
14
|
+
return "";
|
|
15
|
+
}
|
|
16
|
+
if (typeof node === "number" ||
|
|
17
|
+
typeof node === "boolean" ||
|
|
18
|
+
typeof node === "string") {
|
|
19
|
+
return node.toString();
|
|
20
|
+
}
|
|
21
|
+
if (typeof node !== "object") {
|
|
22
|
+
return "";
|
|
23
|
+
}
|
|
24
|
+
if (Array.isArray(node) || isIterable(node)) {
|
|
25
|
+
return Array.from(node)
|
|
26
|
+
.map(function (child) { return getText(child); })
|
|
27
|
+
.filter(function (child) { return !!child; })
|
|
28
|
+
.join("");
|
|
29
|
+
}
|
|
30
|
+
var nodeChildren = (hasKey(node, "props") &&
|
|
31
|
+
hasKey(node.props, "children") &&
|
|
32
|
+
node.props.children) ||
|
|
33
|
+
(hasKey(node, "children") && node.children) ||
|
|
34
|
+
[];
|
|
35
|
+
var contents = "" + React__default.Children.toArray(nodeChildren)
|
|
36
|
+
.map(function (child) { return getText(child); })
|
|
37
|
+
.filter(function (child) { return !!child; })
|
|
38
|
+
.join("");
|
|
39
|
+
if (React__default.isValidElement(node) && node.type === React__default.Fragment) {
|
|
40
|
+
return contents;
|
|
41
|
+
}
|
|
42
|
+
var componentId = componentsCount;
|
|
43
|
+
componentsCount++;
|
|
44
|
+
components["t" + componentId] = React__default.isValidElement(node)
|
|
45
|
+
? React__default.cloneElement(node, {
|
|
46
|
+
key: componentId,
|
|
47
|
+
children: undefined,
|
|
48
|
+
})
|
|
49
|
+
: node;
|
|
50
|
+
return "<t" + componentId + ">" + contents + "</t" + componentId + ">";
|
|
51
|
+
};
|
|
52
|
+
var str = getText(elt);
|
|
53
|
+
return {
|
|
54
|
+
str: str,
|
|
55
|
+
components: components,
|
|
56
|
+
componentsCount: componentsCount,
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
function Trans(_a) {
|
|
60
|
+
var children = _a.children;
|
|
61
|
+
var _t = React__default.useContext(PlasmicTranslatorContext);
|
|
62
|
+
if (!_t) {
|
|
63
|
+
warnNoTranslationFunctionAtMostOnce();
|
|
64
|
+
return children;
|
|
65
|
+
}
|
|
66
|
+
var _b = genTranslatableString(children), str = _b.str, components = _b.components, componentsCount = _b.componentsCount;
|
|
67
|
+
return _t(str, componentsCount > 0 ? { components: components } : undefined);
|
|
68
|
+
}
|
|
69
|
+
var hasWarned = false;
|
|
70
|
+
function warnNoTranslationFunctionAtMostOnce() {
|
|
71
|
+
if (!hasWarned) {
|
|
72
|
+
console.warn("Using Plasmic Translation but no translation function has been provided");
|
|
73
|
+
hasWarned = true;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
function hasKey(v, key) {
|
|
77
|
+
return typeof v === "object" && v !== null && key in v;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
var PlasmicRootContext = React.createContext(undefined);
|
|
81
|
+
function PlasmicRootProvider(props) {
|
|
82
|
+
var platform = props.platform, children = props.children;
|
|
83
|
+
var context = React.useMemo(function () { return ({
|
|
84
|
+
platform: platform,
|
|
85
|
+
}); }, [platform]);
|
|
86
|
+
return (React.createElement(PlasmicRootContext.Provider, { value: context },
|
|
87
|
+
React.createElement(SSRProvider, null,
|
|
88
|
+
React.createElement(PlasmicTranslatorContext.Provider, { value: props.translator }, children))));
|
|
89
|
+
}
|
|
90
|
+
var useIsSSR = useIsSSR$1;
|
|
91
|
+
function useHasPlasmicRoot() {
|
|
92
|
+
return !!React.useContext(PlasmicRootContext);
|
|
93
|
+
}
|
|
94
|
+
var hasWarnedSSR = false;
|
|
95
|
+
/**
|
|
96
|
+
* Warns the user if PlasmicRootProvider is not used
|
|
97
|
+
*/
|
|
98
|
+
function useEnsureSSRProvider() {
|
|
99
|
+
var hasRoot = useHasPlasmicRoot();
|
|
100
|
+
if (hasRoot || hasWarnedSSR || process.env.NODE_ENV !== "development") {
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
hasWarnedSSR = true;
|
|
104
|
+
console.warn("Plasmic: To ensure your components work correctly with server-side rendering, please use PlasmicRootProvider at the root of your application. See https://docs.plasmic.app/learn/ssr");
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
export { PlasmicRootProvider as P, Trans as T, useEnsureSSRProvider as a, genTranslatableString as g, useIsSSR as u };
|
|
108
|
+
//# sourceMappingURL=ssr-a8081074.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ssr-a8081074.js","sources":["../../src/render/translation.tsx","../../src/render/ssr.tsx"],"sourcesContent":["import React from \"react\";\n\nexport type PlasmicTranslator = (\n str: string,\n opts?: {\n components?: {\n [key: string]: React.ReactElement;\n };\n }\n) => React.ReactNode;\n\nexport const PlasmicTranslatorContext =\n React.createContext<PlasmicTranslator | undefined>(undefined);\n\nexport interface TransProps {\n children?: React.ReactNode;\n}\n\nfunction isIterable(val: any): val is Iterable<any> {\n return val != null && typeof val[Symbol.iterator] === \"function\";\n}\n\nexport function genTranslatableString(elt: React.ReactNode) {\n const components: {\n [key: string]: React.ReactElement;\n } = {};\n let componentsCount = 0;\n\n const getText = (node: React.ReactNode): string => {\n if (!node) {\n return \"\";\n }\n if (\n typeof node === \"number\" ||\n typeof node === \"boolean\" ||\n typeof node === \"string\"\n ) {\n return node.toString();\n }\n if (typeof node !== \"object\") {\n return \"\";\n }\n if (Array.isArray(node) || isIterable(node)) {\n return Array.from(node)\n .map((child) => getText(child))\n .filter((child) => !!child)\n .join(\"\");\n }\n const nodeChildren: React.ReactNode =\n (hasKey(node, \"props\") &&\n hasKey(node.props, \"children\") &&\n (node.props.children as React.ReactNode | undefined)) ||\n (hasKey(node, \"children\") && node.children) ||\n [];\n const contents = `${React.Children.toArray(nodeChildren)\n .map((child) => getText(child))\n .filter((child) => !!child)\n .join(\"\")}`;\n if (React.isValidElement(node) && node.type === React.Fragment) {\n return contents;\n }\n const componentId = componentsCount;\n componentsCount++;\n components[`t${componentId}`] = React.isValidElement(node)\n ? React.cloneElement(node as any, {\n key: componentId,\n children: undefined,\n })\n : (node as never);\n return `<t${componentId}>${contents}</t${componentId}>`;\n };\n\n const str = getText(elt);\n return {\n str,\n components,\n componentsCount,\n };\n}\n\nexport function Trans({ children }: TransProps) {\n const _t = React.useContext(PlasmicTranslatorContext);\n if (!_t) {\n warnNoTranslationFunctionAtMostOnce();\n return children;\n }\n\n const { str, components, componentsCount } = genTranslatableString(children);\n return _t(str, componentsCount > 0 ? { components } : undefined);\n}\n\nlet hasWarned = false;\nfunction warnNoTranslationFunctionAtMostOnce() {\n if (!hasWarned) {\n console.warn(\n \"Using Plasmic Translation but no translation function has been provided\"\n );\n hasWarned = true;\n }\n}\n\nfunction hasKey<K extends string>(v: any, key: K): v is Record<K, any> {\n return typeof v === \"object\" && v !== null && key in v;\n}\n","import * as React from \"react\";\nimport { SSRProvider, useIsSSR as useAriaIsSSR } from \"react-aria\";\nimport { PlasmicTranslator, PlasmicTranslatorContext } from \"./translation\";\n\nexport interface PlasmicRootContextValue {\n platform?: \"nextjs\" | \"gatsby\";\n}\n\nconst PlasmicRootContext =\n React.createContext<PlasmicRootContextValue | undefined>(undefined);\n\nexport interface PlasmicRootProviderProps {\n platform?: \"nextjs\" | \"gatsby\";\n children?: React.ReactNode;\n translator?: PlasmicTranslator;\n}\n\nexport function PlasmicRootProvider(props: PlasmicRootProviderProps) {\n const { platform, children } = props;\n const context = React.useMemo(\n () => ({\n platform,\n }),\n [platform]\n );\n return (\n <PlasmicRootContext.Provider value={context}>\n <SSRProvider>\n <PlasmicTranslatorContext.Provider value={props.translator}>\n {children}\n </PlasmicTranslatorContext.Provider>\n </SSRProvider>\n </PlasmicRootContext.Provider>\n );\n}\n\nexport const useIsSSR = useAriaIsSSR;\n\nexport function useHasPlasmicRoot() {\n return !!React.useContext(PlasmicRootContext);\n}\n\nlet hasWarnedSSR = false;\n/**\n * Warns the user if PlasmicRootProvider is not used\n */\nexport function useEnsureSSRProvider() {\n const hasRoot = useHasPlasmicRoot();\n if (hasRoot || hasWarnedSSR || process.env.NODE_ENV !== \"development\") {\n return;\n }\n\n hasWarnedSSR = true;\n console.warn(\n `Plasmic: To ensure your components work correctly with server-side rendering, please use PlasmicRootProvider at the root of your application. See https://docs.plasmic.app/learn/ssr`\n );\n}\n"],"names":["React","useAriaIsSSR"],"mappings":";;;;AAWO,IAAM,wBAAwB,GACnCA,cAAK,CAAC,aAAa,CAAgC,SAAS,CAAC,CAAC;AAMhE,SAAS,UAAU,CAAC,GAAQ;IAC1B,OAAO,GAAG,IAAI,IAAI,IAAI,OAAO,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,UAAU,CAAC;AACnE,CAAC;SAEe,qBAAqB,CAAC,GAAoB;IACxD,IAAM,UAAU,GAEZ,EAAE,CAAC;IACP,IAAI,eAAe,GAAG,CAAC,CAAC;IAExB,IAAM,OAAO,GAAG,UAAC,IAAqB;QACpC,IAAI,CAAC,IAAI,EAAE;YACT,OAAO,EAAE,CAAC;SACX;QACD,IACE,OAAO,IAAI,KAAK,QAAQ;YACxB,OAAO,IAAI,KAAK,SAAS;YACzB,OAAO,IAAI,KAAK,QAAQ,EACxB;YACA,OAAO,IAAI,CAAC,QAAQ,EAAE,CAAC;SACxB;QACD,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE;YAC5B,OAAO,EAAE,CAAC;SACX;QACD,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,UAAU,CAAC,IAAI,CAAC,EAAE;YAC3C,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC;iBACpB,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