@prismicio/vue 4.1.0 → 4.2.1
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/components/PrismicEmbed.cjs.map +1 -1
- package/dist/components/PrismicEmbed.d.ts +1 -1
- package/dist/components/PrismicEmbed.js.map +1 -1
- package/dist/components/PrismicImage.cjs.map +1 -1
- package/dist/components/PrismicImage.d.ts +1 -1
- package/dist/components/PrismicImage.js.map +1 -1
- package/dist/components/PrismicLink.cjs.map +1 -1
- package/dist/components/PrismicLink.d.ts +1 -1
- package/dist/components/PrismicLink.js.map +1 -1
- package/dist/components/PrismicRichText.cjs.map +1 -1
- package/dist/components/PrismicRichText.d.ts +1 -1
- package/dist/components/PrismicRichText.js.map +1 -1
- package/dist/components/PrismicText.cjs.map +1 -1
- package/dist/components/PrismicText.d.ts +1 -1
- package/dist/components/PrismicText.js.map +1 -1
- package/dist/components/SliceZone.cjs +34 -12
- package/dist/components/SliceZone.cjs.map +1 -1
- package/dist/components/SliceZone.d.ts +22 -15
- package/dist/components/SliceZone.js +34 -12
- package/dist/components/SliceZone.js.map +1 -1
- package/dist/createPrismic.cjs.map +1 -1
- package/dist/createPrismic.js.map +1 -1
- package/dist/lib/__PRODUCTION__.cjs.map +1 -1
- package/dist/lib/__PRODUCTION__.js.map +1 -1
- package/dist/lib/getSlots.cjs.map +1 -1
- package/dist/lib/getSlots.js.map +1 -1
- package/dist/useStatefulPrismicClientMethod.cjs.map +1 -1
- package/dist/useStatefulPrismicClientMethod.js.map +1 -1
- package/package.json +17 -17
- package/src/components/SliceZone.ts +74 -32
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SliceZone.cjs","sources":["../../../src/components/SliceZone.ts"],"sourcesContent":["import { Slice } from \"@prismicio/client\";\nimport {\n\tAllowedComponentProps,\n\tComponentCustomProps,\n\tConcreteComponent,\n\tDefineComponent,\n\tFunctionalComponent,\n\tPropType,\n\tRaw,\n\tVNodeProps,\n\tcomputed,\n\tdefineAsyncComponent,\n\tdefineComponent,\n\th,\n\tmarkRaw,\n\twatchEffect,\n} from \"vue\";\n\nimport { __PRODUCTION__ } from \"../lib/__PRODUCTION__\";\nimport { simplyResolveComponent } from \"../lib/simplyResolveComponent\";\n\nimport { usePrismic } from \"../usePrismic\";\n\n/**\n * Returns the type of a `SliceLike` type.\n *\n * @typeParam TSlice - The Slice from which the type will be extracted.\n */\ntype ExtractSliceType<TSlice extends SliceLike> = TSlice extends SliceLikeRestV2\n\t? TSlice[\"slice_type\"]\n\t: TSlice extends SliceLikeGraphQL\n\t? TSlice[\"type\"]\n\t: never;\n\n/**\n * The minimum required properties to represent a Prismic Slice from the Prismic\n * Rest API V2 for the `<SliceZone>` component.\n *\n * If using Prismic's Rest API V2, use the `Slice` export from\n * `@prismicio/client` for a full interface.\n *\n * @typeParam TSliceType - Type name of the Slice.\n */\nexport type SliceLikeRestV2<TSliceType extends string = string> = {\n\tslice_type: Slice<TSliceType>[\"slice_type\"];\n\tid?: string;\n};\n\n/**\n * The minimum required properties to represent a Prismic Slice from the Prismic\n * GraphQL API for the `<SliceZone>` component.\n *\n * @typeParam TSliceType - Type name of the Slice.\n */\nexport type SliceLikeGraphQL<TSliceType extends string = string> = {\n\ttype: Slice<TSliceType>[\"slice_type\"];\n};\n\n/**\n * The minimum required properties to represent a Prismic Slice for the\n * `<SliceZone />` component.\n *\n * If using Prismic's REST API, use the `Slice` export from `@prismicio/client`\n * for a full interface.\n *\n * @typeParam TSliceType - Type name of the Slice\n */\nexport type SliceLike<TSliceType extends string = string> =\n\t| SliceLikeRestV2<TSliceType>\n\t| SliceLikeGraphQL<TSliceType>;\n\n/**\n * A looser version of the `SliceZone` type from `@prismicio/client` using\n * `SliceLike`.\n *\n * If using Prismic's REST API, use the `SliceZone` export from\n * `@prismicio/client` for the full type.\n *\n * @typeParam TSlice - The type(s) of slices in the Slice Zone\n */\nexport type SliceZoneLike<TSlice extends SliceLike = SliceLike> =\n\treadonly TSlice[];\n\n/**\n * Vue props for a component rendering content from a Prismic Slice using the\n * `<SliceZone />` component.\n *\n * @typeParam TSlice - The type(s) of slices in the Slice Zone\n * @typeParam TContext - Arbitrary data passed to `<SliceZone />` and made\n * available to all Slice components\n */\nexport type SliceComponentProps<\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tTSlice extends SliceLike = any,\n\tTContext = unknown,\n> = {\n\t/**\n\t * Slice data for this component.\n\t */\n\tslice: TSlice;\n\n\t/**\n\t * The index of the Slice in the Slice Zone.\n\t */\n\tindex: number;\n\n\t/**\n\t * All Slices from the Slice Zone to which the Slice belongs.\n\t */\n\t// TODO: We have to keep this list of Slices general due to circular\n\t// reference limtiations. If we had another generic to determine the full\n\t// union of Slice types, it would include TSlice. This causes TypeScript to\n\t// throw a compilation error.\n\tslices: SliceZoneLike<SliceLike>;\n\n\t/**\n\t * Arbitrary data passed to `<SliceZone />` and made available to all Slice\n\t * components.\n\t */\n\tcontext: TContext;\n};\n\n/**\n * Native Vue props for a component rendering content from a Prismic Slice using\n * the `<SliceZone />` component.\n *\n * @typeParam TSlice - The Slice type\n * @typeParam TContext - Arbitrary data passed to `<SliceZone />` and made\n * available to all Slice components\n */\nexport type DefineComponentSliceComponentProps<\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tTSlice extends SliceLike = any,\n\tTContext = unknown,\n> = {\n\tslice: {\n\t\ttype: PropType<SliceComponentProps<TSlice, TContext>[\"slice\"]>;\n\t\trequired: true;\n\t};\n\tindex: {\n\t\ttype: PropType<SliceComponentProps<TSlice, TContext>[\"index\"]>;\n\t\trequired: true;\n\t};\n\tslices: {\n\t\ttype: PropType<SliceComponentProps<TSlice, TContext>[\"slices\"]>;\n\t\trequired: true;\n\t};\n\tcontext: {\n\t\ttype: PropType<SliceComponentProps<TSlice, TContext>[\"context\"]>;\n\t\trequired: true;\n\t};\n};\n\n/**\n * Gets native Vue props for a component rendering content from a Prismic Slice\n * using the `<SliceZone />` component.\n *\n * Props are: `[\"slice\", \"index\", \"slices\", \"context\"]`\n *\n * @example\n *\n * ```javascript\n * // Defining a new slice component\n * import { getSliceComponentProps } from \"@prismicio/vue\";\n *\n * export default {\n * \tprops: getSliceComponentProps(),\n * };\n * ```\n *\n * @example\n *\n * ```javascript\n * // Defining a new slice component with visual hint\n * import { getSliceComponentProps } from \"@prismicio/vue\";\n *\n * export default {\n * \tprops: getSliceComponentProps([\"slice\", \"index\", \"slices\", \"context\"]),\n * };\n * ```\n *\n * @typeParam TSlice - The Slice type\n * @typeParam TContext - Arbitrary data passed to `<SliceZone />` and made\n * available to all Slice components\n * @param propsHint - An optional array of prop names used for the sole purpose\n * of having a visual hint of which props are made available to the slice,\n * this parameters doesn't have any effect\n *\n * @returns Props object to use with {@link defineComponent}\n */\nexport const getSliceComponentProps = <\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tTSlice extends SliceLike = any,\n\tTContext = unknown,\n>(\n\t// eslint-disable-next-line @typescript-eslint/no-unused-vars\n\tpropsHint?: [\"slice\", \"index\", \"slices\", \"context\"],\n): DefineComponentSliceComponentProps<TSlice, TContext> => ({\n\tslice: {\n\t\ttype: Object as PropType<SliceComponentProps<TSlice, TContext>[\"slice\"]>,\n\t\trequired: true,\n\t},\n\tindex: {\n\t\ttype: Number as PropType<SliceComponentProps<TSlice, TContext>[\"index\"]>,\n\t\trequired: true,\n\t},\n\tslices: {\n\t\ttype: Array as PropType<SliceComponentProps<TSlice, TContext>[\"slices\"]>,\n\t\trequired: true,\n\t},\n\tcontext: {\n\t\ttype: null as unknown as PropType<\n\t\t\tSliceComponentProps<TSlice, TContext>[\"context\"]\n\t\t>,\n\t\trequired: true,\n\t},\n});\n\n/**\n * A Vue component to be rendered for each instance of its Slice.\n *\n * @typeParam TSlice - The type(s) of slices in the Slice Zone\n * @typeParam TContext - Arbitrary data made available to all Slice components\n */\nexport type SliceComponentType<\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tTSlice extends SliceLike = any,\n\tTContext = unknown,\n> =\n\t// For reference within TypeScript files when `*.vue` type cannot be inferred\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/ban-types\n\t| DefineComponent<{}, {}, any>\n\t// Likewise, for reference with TypeScript files.\n\t| ReturnType<typeof defineAsyncComponent>\n\t| DefineComponent<SliceComponentProps<TSlice, TContext>>\n\t| FunctionalComponent<SliceComponentProps<TSlice, TContext>>;\n\n/**\n * This Slice component can be used as a reminder to provide a proper\n * implementation.\n *\n * This is also the default Vue component rendered when a component mapping\n * cannot be found in `<SliceZone />`.\n */\nexport const TODOSliceComponent = __PRODUCTION__\n\t? ((() => null) as FunctionalComponent<SliceComponentProps>)\n\t: /*#__PURE__*/ (defineComponent({\n\t\t\tname: \"TODOSliceComponent\",\n\t\t\tprops: getSliceComponentProps(),\n\t\t\tsetup(props) {\n\t\t\t\tconst type = computed(() =>\n\t\t\t\t\t\"slice_type\" in props.slice\n\t\t\t\t\t\t? props.slice.slice_type\n\t\t\t\t\t\t: props.slice.type,\n\t\t\t\t);\n\n\t\t\t\twatchEffect(() => {\n\t\t\t\t\tconsole.warn(\n\t\t\t\t\t\t`[SliceZone] Could not find a component for Slice type \"${type.value}\"`,\n\t\t\t\t\t\tprops.slice,\n\t\t\t\t\t);\n\t\t\t\t});\n\n\t\t\t\treturn () => {\n\t\t\t\t\treturn h(\n\t\t\t\t\t\t\"section\",\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\"data-slice-zone-todo-component\": \"\",\n\t\t\t\t\t\t\t\"data-slice-type\": type.value,\n\t\t\t\t\t\t},\n\t\t\t\t\t\t[`Could not find a component for Slice type \"${type.value}\"`],\n\t\t\t\t\t);\n\t\t\t\t};\n\t\t\t},\n\t }) as SliceComponentType);\n\n/**\n * A record of Slice types mapped to Vue components. Each components will be\n * rendered for each instance of their Slice type.\n *\n * @typeParam TSlice - The type(s) of slices in the Slice Zone\n * @typeParam TContext - Arbitrary data made available to all Slice components\n */\nexport type SliceZoneComponents<\n\tTSlice extends SliceLike = SliceLike,\n\tTContext = unknown,\n> =\n\t// This is purposely not wrapped in Partial to ensure a component is provided\n\t// for all Slice types. <SliceZone /> will render a default component if one is\n\t// not provided, but it *should* be a type error if an explicit component is\n\t// missing.\n\t//\n\t// If a developer purposely does not want to provide a component, they can\n\t// assign it to the TODOSliceComponent exported from this package. This\n\t// signals to future developers that it is a placeholder and should be\n\t// implemented.\n\t{\n\t\t[SliceType in ExtractSliceType<TSlice>]:\n\t\t\t| SliceComponentType<Extract<TSlice, SliceLike<SliceType>>, TContext>\n\t\t\t| string;\n\t};\n\n/**\n * Gets an optimized record of Slice types mapped to Vue components. Each\n * components will be rendered for each instance of their Slice type.\n *\n * @remarks\n * This is essentially an helper function to ensure {@link markRaw} is correctly\n * applied on each components, improving performances.\n * @example\n *\n * ```javascript\n * // Defining a slice components\n * import { defineSliceZoneComponents } from \"@prismicio/vue\";\n *\n * export default {\n * data() {\n * components: defineSliceZoneComponents({\n * foo: Foo,\n * bar: defineAsyncComponent(\n * () => new Promise((res) => res(Bar)),\n * ),\n * baz: \"Baz\",\n * }),\n * }\n * };\n * ```\n *\n * @typeParam TSlice - The type(s) of slices in the Slice Zone\n * @typeParam TContext - Arbitrary data made available to all Slice components\n *\n * @param components - {@link SliceZoneComponents}\n *\n * @returns A new optimized record of {@link SliceZoneComponents}\n */\nexport const defineSliceZoneComponents = <\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tTSlice extends SliceLike = any,\n\tTContext = unknown,\n>(\n\tcomponents: SliceZoneComponents<TSlice, TContext>,\n): SliceZoneComponents<TSlice, TContext> => {\n\tconst result = {} as SliceZoneComponents<TSlice, TContext>;\n\n\tlet type: keyof typeof components;\n\tfor (type in components) {\n\t\tconst component = components[type];\n\t\tresult[type] =\n\t\t\ttypeof component === \"string\"\n\t\t\t\t? component\n\t\t\t\t: markRaw(\n\t\t\t\t\t\tcomponent as SliceComponentType<\n\t\t\t\t\t\t\tExtract<TSlice, SliceLike<typeof type>>,\n\t\t\t\t\t\t\tTContext\n\t\t\t\t\t\t>,\n\t\t\t\t );\n\t}\n\n\treturn result;\n};\n\n/**\n * Arguments for a `<SliceZone>` `resolver` function.\n */\nexport type SliceZoneResolverArgs<TSlice extends SliceLike = SliceLike> = {\n\t/**\n\t * The Slice to resolve to a Vue component..\n\t */\n\tslice: TSlice;\n\n\t/**\n\t * The name of the Slice.\n\t */\n\tsliceName: ExtractSliceType<TSlice>;\n\n\t/**\n\t * The index of the Slice in the Slice Zone.\n\t */\n\ti: number;\n};\n\n/**\n * A function that determines the rendered Vue component for each Slice in the\n * Slice Zone. If a nullish value is returned, the component will fallback to\n * the `components` or `defaultComponent` props to determine the rendered\n * component.\n *\n * @deprecated Use the `components` prop instead.\n *\n * @param args - Arguments for the resolver function.\n *\n * @returns The Vue component to render for a Slice.\n */\nexport type SliceZoneResolver<\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tTSlice extends SliceLike = any,\n\tTContext = unknown,\n> = (\n\targs: SliceZoneResolverArgs<TSlice>,\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n) => SliceComponentType<any, TContext> | string | undefined | null;\n\n/**\n * Props for `<SliceZone />`.\n *\n * @typeParam TContext - Arbitrary data made available to all Slice components\n */\nexport type SliceZoneProps<TContext = unknown> = {\n\t/**\n\t * List of Slice data from the Slice Zone.\n\t */\n\tslices: SliceZoneLike;\n\n\t/**\n\t * A record mapping Slice types to Vue components.\n\t */\n\tcomponents?: SliceZoneComponents;\n\n\t/**\n\t * A function that determines the rendered Vue component for each Slice in the\n\t * Slice Zone.\n\t *\n\t * @deprecated Use the `components` prop instead.\n\t *\n\t * @param args - Arguments for the resolver function.\n\t *\n\t * @returns The Vue component to render for a Slice.\n\t */\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tresolver?: SliceZoneResolver<any, TContext>;\n\n\t/**\n\t * Arbitrary data made available to all Slice components.\n\t */\n\tcontext?: TContext;\n\n\t/**\n\t * A component or a functional component rendered if a component mapping from\n\t * the `components` prop cannot be found.\n\t *\n\t * @remarks\n\t * Components will be rendered using the {@link SliceComponentProps} interface.\n\t *\n\t * @defaultValue The Slice Zone default component provided to `@prismicio/vue` plugin if configured, otherwise `null` when `process.env.NODE_ENV === \"production\"` else {@link TODOSliceComponent}.\n\t */\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tdefaultComponent?: SliceComponentType<any, TContext>;\n\n\t/**\n\t * An HTML tag name, a component, or a functional component used to wrap the\n\t * output. The Slice Zone is not wrapped by default.\n\t */\n\twrapper?: string | ConcreteComponent | Raw<DefineComponent>;\n};\n\n/**\n * `<SliceZone />` implementation.\n *\n * @internal\n */\nexport const SliceZoneImpl = /*#__PURE__*/ defineComponent({\n\tname: \"SliceZone\",\n\tprops: {\n\t\tslices: {\n\t\t\ttype: Array as PropType<SliceZoneLike>,\n\t\t\trequired: true,\n\t\t},\n\t\tcomponents: {\n\t\t\ttype: Object as PropType<SliceZoneComponents>,\n\t\t\tdefault: undefined,\n\t\t\trequired: false,\n\t\t},\n\t\tresolver: {\n\t\t\ttype: Function as PropType<SliceZoneResolver>,\n\t\t\tdefault: undefined,\n\t\t\trequired: false,\n\t\t},\n\t\tcontext: {\n\t\t\ttype: null,\n\t\t\tdefault: undefined,\n\t\t\trequired: false,\n\t\t},\n\t\tdefaultComponent: {\n\t\t\ttype: Object as PropType<SliceComponentType>,\n\t\t\tdefault: undefined,\n\t\t\trequired: false,\n\t\t},\n\t\twrapper: {\n\t\t\ttype: [String, Object, Function] as PropType<\n\t\t\t\tstring | ConcreteComponent | Raw<DefineComponent>\n\t\t\t>,\n\t\t\tdefault: undefined,\n\t\t\trequired: false,\n\t\t},\n\t},\n\tsetup(props) {\n\t\t// Prevent fatal if user didn't check for field, throws `Invalid prop` warn\n\t\tif (!props.slices) {\n\t\t\treturn () => null;\n\t\t}\n\n\t\tconst { options } = usePrismic();\n\n\t\tconst renderedSlices = computed(() => {\n\t\t\treturn props.slices.map((slice, index) => {\n\t\t\t\tconst type = \"slice_type\" in slice ? slice.slice_type : slice.type;\n\n\t\t\t\tlet component =\n\t\t\t\t\tprops.components && type in props.components\n\t\t\t\t\t\t? props.components[type]\n\t\t\t\t\t\t: props.defaultComponent ||\n\t\t\t\t\t\t options.components?.sliceZoneDefaultComponent ||\n\t\t\t\t\t\t TODOSliceComponent;\n\n\t\t\t\t// TODO: Remove `resolver` in v3 in favor of `components`.\n\t\t\t\tif (props.resolver) {\n\t\t\t\t\tconst resolvedComponent = props.resolver({\n\t\t\t\t\t\tslice,\n\t\t\t\t\t\tsliceName: type,\n\t\t\t\t\t\ti: index,\n\t\t\t\t\t});\n\n\t\t\t\t\tif (resolvedComponent) {\n\t\t\t\t\t\tcomponent = resolvedComponent;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tconst key =\n\t\t\t\t\t\"id\" in slice && slice.id\n\t\t\t\t\t\t? slice.id\n\t\t\t\t\t\t: `${index}-${JSON.stringify(slice)}`;\n\n\t\t\t\tconst p = {\n\t\t\t\t\tkey,\n\t\t\t\t\tslice,\n\t\t\t\t\tindex,\n\t\t\t\t\tcontext: props.context,\n\t\t\t\t\tslices: props.slices,\n\t\t\t\t};\n\n\t\t\t\treturn h(simplyResolveComponent(component as ConcreteComponent), p);\n\t\t\t});\n\t\t});\n\n\t\treturn () => {\n\t\t\tif (props.wrapper) {\n\t\t\t\tconst parent = simplyResolveComponent(props.wrapper);\n\n\t\t\t\tif (typeof parent === \"string\") {\n\t\t\t\t\treturn h(parent, null, renderedSlices.value);\n\t\t\t\t} else {\n\t\t\t\t\treturn h(parent, null, { default: () => renderedSlices.value });\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\treturn renderedSlices.value;\n\t\t\t}\n\t\t};\n\t},\n});\n\n// export the public type for h/tsx inference\n// also to avoid inline import() in generated d.ts files\n/**\n * Component to render a Prismic Slice Zone.\n *\n * @see Component props {@link SliceZoneProps}\n * @see Templating Slice Zones {@link https://prismic.io/docs/technologies/vue-template-content#slices-and-groups}\n */\nexport const SliceZone = SliceZoneImpl as unknown as {\n\tnew (): {\n\t\t$props: AllowedComponentProps &\n\t\t\tComponentCustomProps &\n\t\t\tVNodeProps &\n\t\t\tSliceZoneProps;\n\t};\n};\n"],"names":["__PRODUCTION__","defineComponent","computed","watchEffect","h","markRaw","usePrismic","simplyResolveComponent"],"mappings":"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"}
|
|
1
|
+
{"version":3,"file":"SliceZone.cjs","sources":["../../../src/components/SliceZone.ts"],"sourcesContent":["import { Slice } from \"@prismicio/client\";\nimport {\n\tAllowedComponentProps,\n\tComponentCustomProps,\n\tConcreteComponent,\n\tDefineComponent,\n\tFunctionalComponent,\n\tPropType,\n\tRaw,\n\tVNodeProps,\n\tcomputed,\n\tdefineAsyncComponent,\n\tdefineComponent,\n\th,\n\tmarkRaw,\n\twatchEffect,\n} from \"vue\";\n\nimport { __PRODUCTION__ } from \"../lib/__PRODUCTION__\";\nimport { simplyResolveComponent } from \"../lib/simplyResolveComponent\";\n\nimport { usePrismic } from \"../usePrismic\";\n\n/**\n * Returns the type of a `SliceLike` type.\n *\n * @typeParam TSlice - The Slice from which the type will be extracted.\n */\ntype ExtractSliceType<TSlice extends SliceLike> = TSlice extends SliceLikeRestV2\n\t? TSlice[\"slice_type\"]\n\t: TSlice extends SliceLikeGraphQL\n\t? TSlice[\"type\"]\n\t: never;\n\n/**\n * The minimum required properties to represent a Prismic Slice from the Prismic\n * Rest API V2 for the `<SliceZone>` component.\n *\n * If using Prismic's Rest API V2, use the `Slice` export from\n * `@prismicio/client` for a full interface.\n *\n * @typeParam TSliceType - Type name of the Slice.\n */\nexport type SliceLikeRestV2<TSliceType extends string = string> = Pick<\n\tSlice<TSliceType>,\n\t\"id\" | \"slice_type\"\n>;\n\n/**\n * The minimum required properties to represent a Prismic Slice from the Prismic\n * GraphQL API for the `<SliceZone>` component.\n *\n * @typeParam TSliceType - Type name of the Slice.\n */\nexport type SliceLikeGraphQL<TSliceType extends string = string> = {\n\ttype: Slice<TSliceType>[\"slice_type\"];\n};\n\n/**\n * The minimum required properties to represent a Prismic Slice for the\n * `<SliceZone />` component.\n *\n * If using Prismic's Rest API V2, use the `Slice` export from\n * `@prismicio/client` for a full interface.\n *\n * @typeParam TSliceType - Type name of the Slice\n */\nexport type SliceLike<TSliceType extends string = string> = (\n\t| SliceLikeRestV2<TSliceType>\n\t| SliceLikeGraphQL<TSliceType>\n) & {\n\t/**\n\t * If `true`, this Slice has been modified from its original value using a\n\t * mapper and `@prismicio/client`'s `mapSliceZone()`.\n\t *\n\t * @internal\n\t */\n\t__mapped?: true;\n};\n\n/**\n * A looser version of the `SliceZone` type from `@prismicio/client` using\n * `SliceLike`.\n *\n * If using Prismic's REST API, use the `SliceZone` export from\n * `@prismicio/client` for the full type.\n *\n * @typeParam TSlice - The type(s) of slices in the Slice Zone\n */\nexport type SliceZoneLike<\n\tTSlice extends SliceLike = SliceLike & Record<string, unknown>,\n> = readonly TSlice[];\n\n/**\n * Vue props for a component rendering content from a Prismic Slice using the\n * `<SliceZone />` component.\n *\n * @typeParam TSlice - The type(s) of slices in the Slice Zone\n * @typeParam TContext - Arbitrary data passed to `<SliceZone />` and made\n * available to all Slice components\n */\nexport type SliceComponentProps<\n\tTSlice extends SliceLike = SliceLike,\n\tTContext = unknown,\n> = {\n\t/**\n\t * Slice data for this component.\n\t */\n\tslice: TSlice;\n\n\t/**\n\t * The index of the Slice in the Slice Zone.\n\t */\n\tindex: number;\n\n\t/**\n\t * All Slices from the Slice Zone to which the Slice belongs.\n\t */\n\t// TODO: We have to keep this list of Slices general due to circular\n\t// reference limtiations. If we had another generic to determine the full\n\t// union of Slice types, it would include TSlice. This causes TypeScript to\n\t// throw a compilation error.\n\tslices: SliceZoneLike<\n\t\tTSlice extends SliceLikeGraphQL ? SliceLikeGraphQL : SliceLikeRestV2\n\t>;\n\n\t/**\n\t * Arbitrary data passed to `<SliceZone />` and made available to all Slice\n\t * components.\n\t */\n\tcontext: TContext;\n};\n\n/**\n * Native Vue props for a component rendering content from a Prismic Slice using\n * the `<SliceZone />` component.\n *\n * @typeParam TSlice - The Slice type\n * @typeParam TContext - Arbitrary data passed to `<SliceZone />` and made\n * available to all Slice components\n */\nexport type DefineComponentSliceComponentProps<\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tTSlice extends SliceLike = any,\n\tTContext = unknown,\n> = {\n\tslice: {\n\t\ttype: PropType<SliceComponentProps<TSlice, TContext>[\"slice\"]>;\n\t\trequired: true;\n\t};\n\tindex: {\n\t\ttype: PropType<SliceComponentProps<TSlice, TContext>[\"index\"]>;\n\t\trequired: true;\n\t};\n\tslices: {\n\t\ttype: PropType<SliceComponentProps<TSlice, TContext>[\"slices\"]>;\n\t\trequired: true;\n\t};\n\tcontext: {\n\t\ttype: PropType<SliceComponentProps<TSlice, TContext>[\"context\"]>;\n\t\trequired: true;\n\t};\n};\n\n/**\n * Gets native Vue props for a component rendering content from a Prismic Slice\n * using the `<SliceZone />` component.\n *\n * Props are: `[\"slice\", \"index\", \"slices\", \"context\"]`\n *\n * @example\n *\n * ```javascript\n * // Defining a new slice component\n * import { getSliceComponentProps } from \"@prismicio/vue\";\n *\n * export default {\n * \tprops: getSliceComponentProps(),\n * };\n * ```\n *\n * @example\n *\n * ```javascript\n * // Defining a new slice component with visual hint\n * import { getSliceComponentProps } from \"@prismicio/vue\";\n *\n * export default {\n * \tprops: getSliceComponentProps([\"slice\", \"index\", \"slices\", \"context\"]),\n * };\n * ```\n *\n * @typeParam TSlice - The Slice type\n * @typeParam TContext - Arbitrary data passed to `<SliceZone />` and made\n * available to all Slice components\n * @param propsHint - An optional array of prop names used for the sole purpose\n * of having a visual hint of which props are made available to the slice,\n * this parameters doesn't have any effect\n *\n * @returns Props object to use with {@link defineComponent}\n */\nexport const getSliceComponentProps = <\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tTSlice extends SliceLike = any,\n\tTContext = unknown,\n>(\n\t// eslint-disable-next-line @typescript-eslint/no-unused-vars\n\tpropsHint?: [\"slice\", \"index\", \"slices\", \"context\"],\n): DefineComponentSliceComponentProps<TSlice, TContext> => ({\n\tslice: {\n\t\ttype: Object as PropType<SliceComponentProps<TSlice, TContext>[\"slice\"]>,\n\t\trequired: true,\n\t},\n\tindex: {\n\t\ttype: Number as PropType<SliceComponentProps<TSlice, TContext>[\"index\"]>,\n\t\trequired: true,\n\t},\n\tslices: {\n\t\ttype: Array as PropType<SliceComponentProps<TSlice, TContext>[\"slices\"]>,\n\t\trequired: true,\n\t},\n\tcontext: {\n\t\ttype: null as unknown as PropType<\n\t\t\tSliceComponentProps<TSlice, TContext>[\"context\"]\n\t\t>,\n\t\trequired: true,\n\t},\n});\n\n/**\n * A Vue component to be rendered for each instance of its Slice.\n *\n * @typeParam TSlice - The type(s) of slices in the Slice Zone\n * @typeParam TContext - Arbitrary data made available to all Slice components\n */\nexport type SliceComponentType<\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tTSlice extends SliceLike = any,\n\tTContext = unknown,\n> =\n\t// For reference within TypeScript files when `*.vue` type cannot be inferred\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/ban-types\n\t| DefineComponent<{}, {}, any>\n\t// Likewise, for reference with TypeScript files.\n\t| ReturnType<typeof defineAsyncComponent>\n\t| DefineComponent<SliceComponentProps<TSlice, TContext>>\n\t| FunctionalComponent<SliceComponentProps<TSlice, TContext>>;\n\n/**\n * This Slice component can be used as a reminder to provide a proper\n * implementation.\n *\n * This is also the default Vue component rendered when a component mapping\n * cannot be found in `<SliceZone />`.\n */\nexport const TODOSliceComponent = __PRODUCTION__\n\t? ((() => null) as FunctionalComponent<{\n\t\t\tslice: SliceLike;\n\t }>)\n\t: /*#__PURE__*/ (defineComponent({\n\t\t\tname: \"TODOSliceComponent\",\n\t\t\tprops: {\n\t\t\t\tslice: {\n\t\t\t\t\ttype: Object as PropType<SliceLike>,\n\t\t\t\t\trequired: true,\n\t\t\t\t},\n\t\t\t},\n\t\t\tsetup(props) {\n\t\t\t\tconst type = computed(() => {\n\t\t\t\t\treturn \"slice_type\" in props.slice\n\t\t\t\t\t\t? props.slice.slice_type\n\t\t\t\t\t\t: props.slice.type;\n\t\t\t\t});\n\n\t\t\t\twatchEffect(() => {\n\t\t\t\t\tconsole.warn(\n\t\t\t\t\t\t`[SliceZone] Could not find a component for Slice type \"${type.value}\"`,\n\t\t\t\t\t\tprops.slice,\n\t\t\t\t\t);\n\t\t\t\t});\n\n\t\t\t\treturn () => {\n\t\t\t\t\treturn h(\n\t\t\t\t\t\t\"section\",\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\"data-slice-zone-todo-component\": \"\",\n\t\t\t\t\t\t\t\"data-slice-type\": type.value,\n\t\t\t\t\t\t},\n\t\t\t\t\t\t[`Could not find a component for Slice type \"${type.value}\"`],\n\t\t\t\t\t);\n\t\t\t\t};\n\t\t\t},\n\t }) as SliceComponentType);\n\n/**\n * A record of Slice types mapped to Vue components. Each components will be\n * rendered for each instance of their Slice type.\n *\n * @typeParam TSlice - The type(s) of slices in the Slice Zone\n * @typeParam TContext - Arbitrary data made available to all Slice components\n */\nexport type SliceZoneComponents<\n\tTSlice extends SliceLike = SliceLike,\n\tTContext = unknown,\n> =\n\t// This is purposely not wrapped in Partial to ensure a component is provided\n\t// for all Slice types. <SliceZone /> will render a default component if one is\n\t// not provided, but it *should* be a type error if an explicit component is\n\t// missing.\n\t//\n\t// If a developer purposely does not want to provide a component, they can\n\t// assign it to the TODOSliceComponent exported from this package. This\n\t// signals to future developers that it is a placeholder and should be\n\t// implemented.\n\t{\n\t\t[SliceType in ExtractSliceType<TSlice>]:\n\t\t\t| SliceComponentType<Extract<TSlice, SliceLike<SliceType>>, TContext>\n\t\t\t| string;\n\t};\n\n/**\n * Gets an optimized record of Slice types mapped to Vue components. Each\n * components will be rendered for each instance of their Slice type.\n *\n * @remarks\n * This is essentially an helper function to ensure {@link markRaw} is correctly\n * applied on each components, improving performances.\n * @example\n *\n * ```javascript\n * // Defining a slice components\n * import { defineSliceZoneComponents } from \"@prismicio/vue\";\n *\n * export default {\n * data() {\n * components: defineSliceZoneComponents({\n * foo: Foo,\n * bar: defineAsyncComponent(\n * () => new Promise((res) => res(Bar)),\n * ),\n * baz: \"Baz\",\n * }),\n * }\n * };\n * ```\n *\n * @typeParam TSlice - The type(s) of slices in the Slice Zone\n * @typeParam TContext - Arbitrary data made available to all Slice components\n *\n * @param components - {@link SliceZoneComponents}\n *\n * @returns A new optimized record of {@link SliceZoneComponents}\n */\nexport const defineSliceZoneComponents = <\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tTSlice extends SliceLike = any,\n\tTContext = unknown,\n>(\n\tcomponents: SliceZoneComponents<TSlice, TContext>,\n): SliceZoneComponents<TSlice, TContext> => {\n\tconst result = {} as SliceZoneComponents<TSlice, TContext>;\n\n\tlet type: keyof typeof components;\n\tfor (type in components) {\n\t\tconst component = components[type];\n\t\tresult[type] =\n\t\t\ttypeof component === \"string\"\n\t\t\t\t? component\n\t\t\t\t: markRaw(\n\t\t\t\t\t\tcomponent as SliceComponentType<\n\t\t\t\t\t\t\tExtract<TSlice, SliceLike<typeof type>>,\n\t\t\t\t\t\t\tTContext\n\t\t\t\t\t\t>,\n\t\t\t\t );\n\t}\n\n\treturn result;\n};\n\n/**\n * Arguments for a `<SliceZone>` `resolver` function.\n */\nexport type SliceZoneResolverArgs<TSlice extends SliceLike = SliceLike> = {\n\t/**\n\t * The Slice to resolve to a Vue component..\n\t */\n\tslice: TSlice;\n\n\t/**\n\t * The name of the Slice.\n\t */\n\tsliceName: ExtractSliceType<TSlice>;\n\n\t/**\n\t * The index of the Slice in the Slice Zone.\n\t */\n\ti: number;\n};\n\n/**\n * A function that determines the rendered Vue component for each Slice in the\n * Slice Zone. If a nullish value is returned, the component will fallback to\n * the `components` or `defaultComponent` props to determine the rendered\n * component.\n *\n * @deprecated Use the `components` prop instead.\n *\n * @param args - Arguments for the resolver function.\n *\n * @returns The Vue component to render for a Slice.\n */\nexport type SliceZoneResolver<\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tTSlice extends SliceLike = any,\n\tTContext = unknown,\n> = (\n\targs: SliceZoneResolverArgs<TSlice>,\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n) => SliceComponentType<any, TContext> | string | undefined | null;\n\n/**\n * Props for `<SliceZone />`.\n *\n * @typeParam TContext - Arbitrary data made available to all Slice components\n */\nexport type SliceZoneProps<TContext = unknown> = {\n\t/**\n\t * List of Slice data from the Slice Zone.\n\t */\n\tslices: SliceZoneLike;\n\n\t/**\n\t * A record mapping Slice types to Vue components.\n\t */\n\tcomponents?: SliceZoneComponents;\n\n\t/**\n\t * A function that determines the rendered Vue component for each Slice in the\n\t * Slice Zone.\n\t *\n\t * @deprecated Use the `components` prop instead.\n\t *\n\t * @param args - Arguments for the resolver function.\n\t *\n\t * @returns The Vue component to render for a Slice.\n\t */\n\t// TODO: Remove in v5 when the `resolver` prop is removed.\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tresolver?: SliceZoneResolver<any, TContext>;\n\n\t/**\n\t * Arbitrary data made available to all Slice components.\n\t */\n\tcontext?: TContext;\n\n\t/**\n\t * A component or a functional component rendered if a component mapping from\n\t * the `components` prop cannot be found.\n\t *\n\t * @remarks\n\t * Components will be rendered using the {@link SliceComponentProps} interface.\n\t *\n\t * @defaultValue The Slice Zone default component provided to `@prismicio/vue` plugin if configured, otherwise `null` when `process.env.NODE_ENV === \"production\"` else {@link TODOSliceComponent}.\n\t */\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tdefaultComponent?: SliceComponentType<any, TContext>;\n\n\t/**\n\t * An HTML tag name, a component, or a functional component used to wrap the\n\t * output. The Slice Zone is not wrapped by default.\n\t */\n\twrapper?: string | ConcreteComponent | Raw<DefineComponent>;\n};\n\n/**\n * `<SliceZone />` implementation.\n *\n * @internal\n */\nexport const SliceZoneImpl = /*#__PURE__*/ defineComponent({\n\tname: \"SliceZone\",\n\tprops: {\n\t\tslices: {\n\t\t\ttype: Array as PropType<SliceZoneLike>,\n\t\t\trequired: true,\n\t\t},\n\t\tcomponents: {\n\t\t\ttype: Object as PropType<SliceZoneComponents>,\n\t\t\tdefault: undefined,\n\t\t\trequired: false,\n\t\t},\n\t\tresolver: {\n\t\t\ttype: Function as PropType<SliceZoneResolver>,\n\t\t\tdefault: undefined,\n\t\t\trequired: false,\n\t\t},\n\t\tcontext: {\n\t\t\ttype: null,\n\t\t\tdefault: undefined,\n\t\t\trequired: false,\n\t\t},\n\t\tdefaultComponent: {\n\t\t\ttype: Object as PropType<SliceComponentType>,\n\t\t\tdefault: undefined,\n\t\t\trequired: false,\n\t\t},\n\t\twrapper: {\n\t\t\ttype: [String, Object, Function] as PropType<\n\t\t\t\tstring | ConcreteComponent | Raw<DefineComponent>\n\t\t\t>,\n\t\t\tdefault: undefined,\n\t\t\trequired: false,\n\t\t},\n\t},\n\tsetup(props) {\n\t\t// Prevent fatal if user didn't check for field, throws `Invalid prop` warn\n\t\tif (!props.slices) {\n\t\t\treturn () => null;\n\t\t}\n\n\t\t// TODO: Remove in v3 when the `resolver` prop is removed.\n\t\tif (!__PRODUCTION__) {\n\t\t\tif (props.resolver) {\n\t\t\t\tconsole.warn(\n\t\t\t\t\t\"The `resolver` prop is deprecated. Please replace it with a components map using the `components` prop.\",\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\tconst { options } = usePrismic();\n\n\t\tconst renderedSlices = computed(() => {\n\t\t\treturn props.slices.map((slice, index) => {\n\t\t\t\tconst type =\n\t\t\t\t\t\"slice_type\" in slice ? (slice.slice_type as string) : slice.type;\n\n\t\t\t\tlet component =\n\t\t\t\t\tprops.components && type in props.components\n\t\t\t\t\t\t? props.components[type]\n\t\t\t\t\t\t: props.defaultComponent ||\n\t\t\t\t\t\t options.components?.sliceZoneDefaultComponent;\n\n\t\t\t\t// TODO: Remove `resolver` in v5 in favor of `components`.\n\t\t\t\tif (props.resolver) {\n\t\t\t\t\tconst resolvedComponent = props.resolver({\n\t\t\t\t\t\tslice,\n\t\t\t\t\t\tsliceName: type,\n\t\t\t\t\t\ti: index,\n\t\t\t\t\t});\n\n\t\t\t\t\tif (resolvedComponent) {\n\t\t\t\t\t\tcomponent = resolvedComponent;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tconst key =\n\t\t\t\t\t\"id\" in slice && typeof slice.id === \"string\"\n\t\t\t\t\t\t? slice.id\n\t\t\t\t\t\t: `${index}-${JSON.stringify(slice)}`;\n\n\t\t\t\tif (component) {\n\t\t\t\t\tif (slice.__mapped) {\n\t\t\t\t\t\tconst { __mapped, ...mappedProps } = slice;\n\n\t\t\t\t\t\treturn h(simplyResolveComponent(component as ConcreteComponent), {\n\t\t\t\t\t\t\tkey,\n\t\t\t\t\t\t\t...mappedProps,\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\n\t\t\t\t\treturn h(simplyResolveComponent(component as ConcreteComponent), {\n\t\t\t\t\t\tkey,\n\t\t\t\t\t\tslice,\n\t\t\t\t\t\tindex,\n\t\t\t\t\t\tcontext: props.context,\n\t\t\t\t\t\tslices: props.slices,\n\t\t\t\t\t});\n\t\t\t\t} else {\n\t\t\t\t\treturn h(\n\t\t\t\t\t\tsimplyResolveComponent(TODOSliceComponent as ConcreteComponent),\n\t\t\t\t\t\t{ key, slice },\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t});\n\t\t});\n\n\t\treturn () => {\n\t\t\tif (props.wrapper) {\n\t\t\t\tconst parent = simplyResolveComponent(props.wrapper);\n\n\t\t\t\tif (typeof parent === \"string\") {\n\t\t\t\t\treturn h(parent, null, renderedSlices.value);\n\t\t\t\t} else {\n\t\t\t\t\treturn h(parent, null, { default: () => renderedSlices.value });\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\treturn renderedSlices.value;\n\t\t\t}\n\t\t};\n\t},\n});\n\n// export the public type for h/tsx inference\n// also to avoid inline import() in generated d.ts files\n/**\n * Component to render a Prismic Slice Zone.\n *\n * @see Component props {@link SliceZoneProps}\n * @see Templating Slice Zones {@link https://prismic.io/docs/technologies/vue-template-content#slices-and-groups}\n */\nexport const SliceZone = SliceZoneImpl as unknown as {\n\tnew (): {\n\t\t$props: AllowedComponentProps &\n\t\t\tComponentCustomProps &\n\t\t\tVNodeProps &\n\t\t\tSliceZoneProps;\n\t};\n};\n"],"names":["__PRODUCTION__","defineComponent","computed","watchEffect","h","markRaw","usePrismic","simplyResolveComponent"],"mappings":"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"}
|
|
@@ -15,10 +15,7 @@ type ExtractSliceType<TSlice extends SliceLike> = TSlice extends SliceLikeRestV2
|
|
|
15
15
|
*
|
|
16
16
|
* @typeParam TSliceType - Type name of the Slice.
|
|
17
17
|
*/
|
|
18
|
-
export type SliceLikeRestV2<TSliceType extends string = string> =
|
|
19
|
-
slice_type: Slice<TSliceType>["slice_type"];
|
|
20
|
-
id?: string;
|
|
21
|
-
};
|
|
18
|
+
export type SliceLikeRestV2<TSliceType extends string = string> = Pick<Slice<TSliceType>, "id" | "slice_type">;
|
|
22
19
|
/**
|
|
23
20
|
* The minimum required properties to represent a Prismic Slice from the Prismic
|
|
24
21
|
* GraphQL API for the `<SliceZone>` component.
|
|
@@ -32,12 +29,20 @@ export type SliceLikeGraphQL<TSliceType extends string = string> = {
|
|
|
32
29
|
* The minimum required properties to represent a Prismic Slice for the
|
|
33
30
|
* `<SliceZone />` component.
|
|
34
31
|
*
|
|
35
|
-
* If using Prismic's
|
|
36
|
-
* for a full interface.
|
|
32
|
+
* If using Prismic's Rest API V2, use the `Slice` export from
|
|
33
|
+
* `@prismicio/client` for a full interface.
|
|
37
34
|
*
|
|
38
35
|
* @typeParam TSliceType - Type name of the Slice
|
|
39
36
|
*/
|
|
40
|
-
export type SliceLike<TSliceType extends string = string> = SliceLikeRestV2<TSliceType> | SliceLikeGraphQL<TSliceType
|
|
37
|
+
export type SliceLike<TSliceType extends string = string> = (SliceLikeRestV2<TSliceType> | SliceLikeGraphQL<TSliceType>) & {
|
|
38
|
+
/**
|
|
39
|
+
* If `true`, this Slice has been modified from its original value using a
|
|
40
|
+
* mapper and `@prismicio/client`'s `mapSliceZone()`.
|
|
41
|
+
*
|
|
42
|
+
* @internal
|
|
43
|
+
*/
|
|
44
|
+
__mapped?: true;
|
|
45
|
+
};
|
|
41
46
|
/**
|
|
42
47
|
* A looser version of the `SliceZone` type from `@prismicio/client` using
|
|
43
48
|
* `SliceLike`.
|
|
@@ -47,7 +52,7 @@ export type SliceLike<TSliceType extends string = string> = SliceLikeRestV2<TSli
|
|
|
47
52
|
*
|
|
48
53
|
* @typeParam TSlice - The type(s) of slices in the Slice Zone
|
|
49
54
|
*/
|
|
50
|
-
export type SliceZoneLike<TSlice extends SliceLike = SliceLike
|
|
55
|
+
export type SliceZoneLike<TSlice extends SliceLike = SliceLike & Record<string, unknown>> = readonly TSlice[];
|
|
51
56
|
/**
|
|
52
57
|
* Vue props for a component rendering content from a Prismic Slice using the
|
|
53
58
|
* `<SliceZone />` component.
|
|
@@ -56,7 +61,7 @@ export type SliceZoneLike<TSlice extends SliceLike = SliceLike> = readonly TSlic
|
|
|
56
61
|
* @typeParam TContext - Arbitrary data passed to `<SliceZone />` and made
|
|
57
62
|
* available to all Slice components
|
|
58
63
|
*/
|
|
59
|
-
export type SliceComponentProps<TSlice extends SliceLike =
|
|
64
|
+
export type SliceComponentProps<TSlice extends SliceLike = SliceLike, TContext = unknown> = {
|
|
60
65
|
/**
|
|
61
66
|
* Slice data for this component.
|
|
62
67
|
*/
|
|
@@ -68,7 +73,7 @@ export type SliceComponentProps<TSlice extends SliceLike = any, TContext = unkno
|
|
|
68
73
|
/**
|
|
69
74
|
* All Slices from the Slice Zone to which the Slice belongs.
|
|
70
75
|
*/
|
|
71
|
-
slices: SliceZoneLike<
|
|
76
|
+
slices: SliceZoneLike<TSlice extends SliceLikeGraphQL ? SliceLikeGraphQL : SliceLikeRestV2>;
|
|
72
77
|
/**
|
|
73
78
|
* Arbitrary data passed to `<SliceZone />` and made available to all Slice
|
|
74
79
|
* components.
|
|
@@ -153,12 +158,14 @@ export type SliceComponentType<TSlice extends SliceLike = any, TContext = unknow
|
|
|
153
158
|
* This is also the default Vue component rendered when a component mapping
|
|
154
159
|
* cannot be found in `<SliceZone />`.
|
|
155
160
|
*/
|
|
156
|
-
export declare const TODOSliceComponent: import("vue").ComponentOptions<any, any, any, import("vue").ComputedOptions, import("vue").MethodOptions, any, any, any, any> | FunctionalComponent<any, any,
|
|
161
|
+
export declare const TODOSliceComponent: import("vue").ComponentOptions<any, any, any, import("vue").ComputedOptions, import("vue").MethodOptions, any, any, any, any> | FunctionalComponent<any, {}, any, {}> | {
|
|
157
162
|
new (...args: any[]): any;
|
|
158
163
|
__isFragment?: undefined;
|
|
159
164
|
__isTeleport?: undefined;
|
|
160
165
|
__isSuspense?: undefined;
|
|
161
|
-
} | FunctionalComponent<
|
|
166
|
+
} | FunctionalComponent<{
|
|
167
|
+
slice: SliceLike;
|
|
168
|
+
}, {}, any, {}> | FunctionalComponent<SliceComponentProps<any, unknown>, {}, any, {}>;
|
|
162
169
|
/**
|
|
163
170
|
* A record of Slice types mapped to Vue components. Each components will be
|
|
164
171
|
* rendered for each instance of their Slice type.
|
|
@@ -285,7 +292,7 @@ export type SliceZoneProps<TContext = unknown> = {
|
|
|
285
292
|
*/
|
|
286
293
|
export declare const SliceZoneImpl: DefineComponent<{
|
|
287
294
|
slices: {
|
|
288
|
-
type: PropType<SliceZoneLike<SliceLike<string>>>;
|
|
295
|
+
type: PropType<SliceZoneLike<SliceLike<string> & Record<string, unknown>>>;
|
|
289
296
|
required: true;
|
|
290
297
|
};
|
|
291
298
|
components: {
|
|
@@ -317,9 +324,9 @@ export declare const SliceZoneImpl: DefineComponent<{
|
|
|
317
324
|
[key: string]: any;
|
|
318
325
|
}> | import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
319
326
|
[key: string]: any;
|
|
320
|
-
}>[]), unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string,
|
|
327
|
+
}>[]), unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
321
328
|
slices: {
|
|
322
|
-
type: PropType<SliceZoneLike<SliceLike<string>>>;
|
|
329
|
+
type: PropType<SliceZoneLike<SliceLike<string> & Record<string, unknown>>>;
|
|
323
330
|
required: true;
|
|
324
331
|
};
|
|
325
332
|
components: {
|
|
@@ -22,9 +22,16 @@ const getSliceComponentProps = (propsHint) => ({
|
|
|
22
22
|
});
|
|
23
23
|
const TODOSliceComponent = __PRODUCTION__ ? () => null : /* @__PURE__ */ defineComponent({
|
|
24
24
|
name: "TODOSliceComponent",
|
|
25
|
-
props:
|
|
25
|
+
props: {
|
|
26
|
+
slice: {
|
|
27
|
+
type: Object,
|
|
28
|
+
required: true
|
|
29
|
+
}
|
|
30
|
+
},
|
|
26
31
|
setup(props) {
|
|
27
|
-
const type = computed(() =>
|
|
32
|
+
const type = computed(() => {
|
|
33
|
+
return "slice_type" in props.slice ? props.slice.slice_type : props.slice.type;
|
|
34
|
+
});
|
|
28
35
|
watchEffect(() => {
|
|
29
36
|
console.warn(`[SliceZone] Could not find a component for Slice type "${type.value}"`, props.slice);
|
|
30
37
|
});
|
|
@@ -82,12 +89,17 @@ const SliceZoneImpl = /* @__PURE__ */ defineComponent({
|
|
|
82
89
|
if (!props.slices) {
|
|
83
90
|
return () => null;
|
|
84
91
|
}
|
|
92
|
+
if (!__PRODUCTION__) {
|
|
93
|
+
if (props.resolver) {
|
|
94
|
+
console.warn("The `resolver` prop is deprecated. Please replace it with a components map using the `components` prop.");
|
|
95
|
+
}
|
|
96
|
+
}
|
|
85
97
|
const { options } = usePrismic();
|
|
86
98
|
const renderedSlices = computed(() => {
|
|
87
99
|
return props.slices.map((slice, index) => {
|
|
88
100
|
var _a;
|
|
89
101
|
const type = "slice_type" in slice ? slice.slice_type : slice.type;
|
|
90
|
-
let component = props.components && type in props.components ? props.components[type] : props.defaultComponent || ((_a = options.components) == null ? void 0 : _a.sliceZoneDefaultComponent)
|
|
102
|
+
let component = props.components && type in props.components ? props.components[type] : props.defaultComponent || ((_a = options.components) == null ? void 0 : _a.sliceZoneDefaultComponent);
|
|
91
103
|
if (props.resolver) {
|
|
92
104
|
const resolvedComponent = props.resolver({
|
|
93
105
|
slice,
|
|
@@ -98,15 +110,25 @@ const SliceZoneImpl = /* @__PURE__ */ defineComponent({
|
|
|
98
110
|
component = resolvedComponent;
|
|
99
111
|
}
|
|
100
112
|
}
|
|
101
|
-
const key = "id" in slice && slice.id ? slice.id : `${index}-${JSON.stringify(slice)}`;
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
113
|
+
const key = "id" in slice && typeof slice.id === "string" ? slice.id : `${index}-${JSON.stringify(slice)}`;
|
|
114
|
+
if (component) {
|
|
115
|
+
if (slice.__mapped) {
|
|
116
|
+
const { __mapped, ...mappedProps } = slice;
|
|
117
|
+
return h(simplyResolveComponent(component), {
|
|
118
|
+
key,
|
|
119
|
+
...mappedProps
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
return h(simplyResolveComponent(component), {
|
|
123
|
+
key,
|
|
124
|
+
slice,
|
|
125
|
+
index,
|
|
126
|
+
context: props.context,
|
|
127
|
+
slices: props.slices
|
|
128
|
+
});
|
|
129
|
+
} else {
|
|
130
|
+
return h(simplyResolveComponent(TODOSliceComponent), { key, slice });
|
|
131
|
+
}
|
|
110
132
|
});
|
|
111
133
|
});
|
|
112
134
|
return () => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SliceZone.js","sources":["../../../src/components/SliceZone.ts"],"sourcesContent":["import { Slice } from \"@prismicio/client\";\nimport {\n\tAllowedComponentProps,\n\tComponentCustomProps,\n\tConcreteComponent,\n\tDefineComponent,\n\tFunctionalComponent,\n\tPropType,\n\tRaw,\n\tVNodeProps,\n\tcomputed,\n\tdefineAsyncComponent,\n\tdefineComponent,\n\th,\n\tmarkRaw,\n\twatchEffect,\n} from \"vue\";\n\nimport { __PRODUCTION__ } from \"../lib/__PRODUCTION__\";\nimport { simplyResolveComponent } from \"../lib/simplyResolveComponent\";\n\nimport { usePrismic } from \"../usePrismic\";\n\n/**\n * Returns the type of a `SliceLike` type.\n *\n * @typeParam TSlice - The Slice from which the type will be extracted.\n */\ntype ExtractSliceType<TSlice extends SliceLike> = TSlice extends SliceLikeRestV2\n\t? TSlice[\"slice_type\"]\n\t: TSlice extends SliceLikeGraphQL\n\t? TSlice[\"type\"]\n\t: never;\n\n/**\n * The minimum required properties to represent a Prismic Slice from the Prismic\n * Rest API V2 for the `<SliceZone>` component.\n *\n * If using Prismic's Rest API V2, use the `Slice` export from\n * `@prismicio/client` for a full interface.\n *\n * @typeParam TSliceType - Type name of the Slice.\n */\nexport type SliceLikeRestV2<TSliceType extends string = string> = {\n\tslice_type: Slice<TSliceType>[\"slice_type\"];\n\tid?: string;\n};\n\n/**\n * The minimum required properties to represent a Prismic Slice from the Prismic\n * GraphQL API for the `<SliceZone>` component.\n *\n * @typeParam TSliceType - Type name of the Slice.\n */\nexport type SliceLikeGraphQL<TSliceType extends string = string> = {\n\ttype: Slice<TSliceType>[\"slice_type\"];\n};\n\n/**\n * The minimum required properties to represent a Prismic Slice for the\n * `<SliceZone />` component.\n *\n * If using Prismic's REST API, use the `Slice` export from `@prismicio/client`\n * for a full interface.\n *\n * @typeParam TSliceType - Type name of the Slice\n */\nexport type SliceLike<TSliceType extends string = string> =\n\t| SliceLikeRestV2<TSliceType>\n\t| SliceLikeGraphQL<TSliceType>;\n\n/**\n * A looser version of the `SliceZone` type from `@prismicio/client` using\n * `SliceLike`.\n *\n * If using Prismic's REST API, use the `SliceZone` export from\n * `@prismicio/client` for the full type.\n *\n * @typeParam TSlice - The type(s) of slices in the Slice Zone\n */\nexport type SliceZoneLike<TSlice extends SliceLike = SliceLike> =\n\treadonly TSlice[];\n\n/**\n * Vue props for a component rendering content from a Prismic Slice using the\n * `<SliceZone />` component.\n *\n * @typeParam TSlice - The type(s) of slices in the Slice Zone\n * @typeParam TContext - Arbitrary data passed to `<SliceZone />` and made\n * available to all Slice components\n */\nexport type SliceComponentProps<\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tTSlice extends SliceLike = any,\n\tTContext = unknown,\n> = {\n\t/**\n\t * Slice data for this component.\n\t */\n\tslice: TSlice;\n\n\t/**\n\t * The index of the Slice in the Slice Zone.\n\t */\n\tindex: number;\n\n\t/**\n\t * All Slices from the Slice Zone to which the Slice belongs.\n\t */\n\t// TODO: We have to keep this list of Slices general due to circular\n\t// reference limtiations. If we had another generic to determine the full\n\t// union of Slice types, it would include TSlice. This causes TypeScript to\n\t// throw a compilation error.\n\tslices: SliceZoneLike<SliceLike>;\n\n\t/**\n\t * Arbitrary data passed to `<SliceZone />` and made available to all Slice\n\t * components.\n\t */\n\tcontext: TContext;\n};\n\n/**\n * Native Vue props for a component rendering content from a Prismic Slice using\n * the `<SliceZone />` component.\n *\n * @typeParam TSlice - The Slice type\n * @typeParam TContext - Arbitrary data passed to `<SliceZone />` and made\n * available to all Slice components\n */\nexport type DefineComponentSliceComponentProps<\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tTSlice extends SliceLike = any,\n\tTContext = unknown,\n> = {\n\tslice: {\n\t\ttype: PropType<SliceComponentProps<TSlice, TContext>[\"slice\"]>;\n\t\trequired: true;\n\t};\n\tindex: {\n\t\ttype: PropType<SliceComponentProps<TSlice, TContext>[\"index\"]>;\n\t\trequired: true;\n\t};\n\tslices: {\n\t\ttype: PropType<SliceComponentProps<TSlice, TContext>[\"slices\"]>;\n\t\trequired: true;\n\t};\n\tcontext: {\n\t\ttype: PropType<SliceComponentProps<TSlice, TContext>[\"context\"]>;\n\t\trequired: true;\n\t};\n};\n\n/**\n * Gets native Vue props for a component rendering content from a Prismic Slice\n * using the `<SliceZone />` component.\n *\n * Props are: `[\"slice\", \"index\", \"slices\", \"context\"]`\n *\n * @example\n *\n * ```javascript\n * // Defining a new slice component\n * import { getSliceComponentProps } from \"@prismicio/vue\";\n *\n * export default {\n * \tprops: getSliceComponentProps(),\n * };\n * ```\n *\n * @example\n *\n * ```javascript\n * // Defining a new slice component with visual hint\n * import { getSliceComponentProps } from \"@prismicio/vue\";\n *\n * export default {\n * \tprops: getSliceComponentProps([\"slice\", \"index\", \"slices\", \"context\"]),\n * };\n * ```\n *\n * @typeParam TSlice - The Slice type\n * @typeParam TContext - Arbitrary data passed to `<SliceZone />` and made\n * available to all Slice components\n * @param propsHint - An optional array of prop names used for the sole purpose\n * of having a visual hint of which props are made available to the slice,\n * this parameters doesn't have any effect\n *\n * @returns Props object to use with {@link defineComponent}\n */\nexport const getSliceComponentProps = <\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tTSlice extends SliceLike = any,\n\tTContext = unknown,\n>(\n\t// eslint-disable-next-line @typescript-eslint/no-unused-vars\n\tpropsHint?: [\"slice\", \"index\", \"slices\", \"context\"],\n): DefineComponentSliceComponentProps<TSlice, TContext> => ({\n\tslice: {\n\t\ttype: Object as PropType<SliceComponentProps<TSlice, TContext>[\"slice\"]>,\n\t\trequired: true,\n\t},\n\tindex: {\n\t\ttype: Number as PropType<SliceComponentProps<TSlice, TContext>[\"index\"]>,\n\t\trequired: true,\n\t},\n\tslices: {\n\t\ttype: Array as PropType<SliceComponentProps<TSlice, TContext>[\"slices\"]>,\n\t\trequired: true,\n\t},\n\tcontext: {\n\t\ttype: null as unknown as PropType<\n\t\t\tSliceComponentProps<TSlice, TContext>[\"context\"]\n\t\t>,\n\t\trequired: true,\n\t},\n});\n\n/**\n * A Vue component to be rendered for each instance of its Slice.\n *\n * @typeParam TSlice - The type(s) of slices in the Slice Zone\n * @typeParam TContext - Arbitrary data made available to all Slice components\n */\nexport type SliceComponentType<\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tTSlice extends SliceLike = any,\n\tTContext = unknown,\n> =\n\t// For reference within TypeScript files when `*.vue` type cannot be inferred\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/ban-types\n\t| DefineComponent<{}, {}, any>\n\t// Likewise, for reference with TypeScript files.\n\t| ReturnType<typeof defineAsyncComponent>\n\t| DefineComponent<SliceComponentProps<TSlice, TContext>>\n\t| FunctionalComponent<SliceComponentProps<TSlice, TContext>>;\n\n/**\n * This Slice component can be used as a reminder to provide a proper\n * implementation.\n *\n * This is also the default Vue component rendered when a component mapping\n * cannot be found in `<SliceZone />`.\n */\nexport const TODOSliceComponent = __PRODUCTION__\n\t? ((() => null) as FunctionalComponent<SliceComponentProps>)\n\t: /*#__PURE__*/ (defineComponent({\n\t\t\tname: \"TODOSliceComponent\",\n\t\t\tprops: getSliceComponentProps(),\n\t\t\tsetup(props) {\n\t\t\t\tconst type = computed(() =>\n\t\t\t\t\t\"slice_type\" in props.slice\n\t\t\t\t\t\t? props.slice.slice_type\n\t\t\t\t\t\t: props.slice.type,\n\t\t\t\t);\n\n\t\t\t\twatchEffect(() => {\n\t\t\t\t\tconsole.warn(\n\t\t\t\t\t\t`[SliceZone] Could not find a component for Slice type \"${type.value}\"`,\n\t\t\t\t\t\tprops.slice,\n\t\t\t\t\t);\n\t\t\t\t});\n\n\t\t\t\treturn () => {\n\t\t\t\t\treturn h(\n\t\t\t\t\t\t\"section\",\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\"data-slice-zone-todo-component\": \"\",\n\t\t\t\t\t\t\t\"data-slice-type\": type.value,\n\t\t\t\t\t\t},\n\t\t\t\t\t\t[`Could not find a component for Slice type \"${type.value}\"`],\n\t\t\t\t\t);\n\t\t\t\t};\n\t\t\t},\n\t }) as SliceComponentType);\n\n/**\n * A record of Slice types mapped to Vue components. Each components will be\n * rendered for each instance of their Slice type.\n *\n * @typeParam TSlice - The type(s) of slices in the Slice Zone\n * @typeParam TContext - Arbitrary data made available to all Slice components\n */\nexport type SliceZoneComponents<\n\tTSlice extends SliceLike = SliceLike,\n\tTContext = unknown,\n> =\n\t// This is purposely not wrapped in Partial to ensure a component is provided\n\t// for all Slice types. <SliceZone /> will render a default component if one is\n\t// not provided, but it *should* be a type error if an explicit component is\n\t// missing.\n\t//\n\t// If a developer purposely does not want to provide a component, they can\n\t// assign it to the TODOSliceComponent exported from this package. This\n\t// signals to future developers that it is a placeholder and should be\n\t// implemented.\n\t{\n\t\t[SliceType in ExtractSliceType<TSlice>]:\n\t\t\t| SliceComponentType<Extract<TSlice, SliceLike<SliceType>>, TContext>\n\t\t\t| string;\n\t};\n\n/**\n * Gets an optimized record of Slice types mapped to Vue components. Each\n * components will be rendered for each instance of their Slice type.\n *\n * @remarks\n * This is essentially an helper function to ensure {@link markRaw} is correctly\n * applied on each components, improving performances.\n * @example\n *\n * ```javascript\n * // Defining a slice components\n * import { defineSliceZoneComponents } from \"@prismicio/vue\";\n *\n * export default {\n * data() {\n * components: defineSliceZoneComponents({\n * foo: Foo,\n * bar: defineAsyncComponent(\n * () => new Promise((res) => res(Bar)),\n * ),\n * baz: \"Baz\",\n * }),\n * }\n * };\n * ```\n *\n * @typeParam TSlice - The type(s) of slices in the Slice Zone\n * @typeParam TContext - Arbitrary data made available to all Slice components\n *\n * @param components - {@link SliceZoneComponents}\n *\n * @returns A new optimized record of {@link SliceZoneComponents}\n */\nexport const defineSliceZoneComponents = <\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tTSlice extends SliceLike = any,\n\tTContext = unknown,\n>(\n\tcomponents: SliceZoneComponents<TSlice, TContext>,\n): SliceZoneComponents<TSlice, TContext> => {\n\tconst result = {} as SliceZoneComponents<TSlice, TContext>;\n\n\tlet type: keyof typeof components;\n\tfor (type in components) {\n\t\tconst component = components[type];\n\t\tresult[type] =\n\t\t\ttypeof component === \"string\"\n\t\t\t\t? component\n\t\t\t\t: markRaw(\n\t\t\t\t\t\tcomponent as SliceComponentType<\n\t\t\t\t\t\t\tExtract<TSlice, SliceLike<typeof type>>,\n\t\t\t\t\t\t\tTContext\n\t\t\t\t\t\t>,\n\t\t\t\t );\n\t}\n\n\treturn result;\n};\n\n/**\n * Arguments for a `<SliceZone>` `resolver` function.\n */\nexport type SliceZoneResolverArgs<TSlice extends SliceLike = SliceLike> = {\n\t/**\n\t * The Slice to resolve to a Vue component..\n\t */\n\tslice: TSlice;\n\n\t/**\n\t * The name of the Slice.\n\t */\n\tsliceName: ExtractSliceType<TSlice>;\n\n\t/**\n\t * The index of the Slice in the Slice Zone.\n\t */\n\ti: number;\n};\n\n/**\n * A function that determines the rendered Vue component for each Slice in the\n * Slice Zone. If a nullish value is returned, the component will fallback to\n * the `components` or `defaultComponent` props to determine the rendered\n * component.\n *\n * @deprecated Use the `components` prop instead.\n *\n * @param args - Arguments for the resolver function.\n *\n * @returns The Vue component to render for a Slice.\n */\nexport type SliceZoneResolver<\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tTSlice extends SliceLike = any,\n\tTContext = unknown,\n> = (\n\targs: SliceZoneResolverArgs<TSlice>,\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n) => SliceComponentType<any, TContext> | string | undefined | null;\n\n/**\n * Props for `<SliceZone />`.\n *\n * @typeParam TContext - Arbitrary data made available to all Slice components\n */\nexport type SliceZoneProps<TContext = unknown> = {\n\t/**\n\t * List of Slice data from the Slice Zone.\n\t */\n\tslices: SliceZoneLike;\n\n\t/**\n\t * A record mapping Slice types to Vue components.\n\t */\n\tcomponents?: SliceZoneComponents;\n\n\t/**\n\t * A function that determines the rendered Vue component for each Slice in the\n\t * Slice Zone.\n\t *\n\t * @deprecated Use the `components` prop instead.\n\t *\n\t * @param args - Arguments for the resolver function.\n\t *\n\t * @returns The Vue component to render for a Slice.\n\t */\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tresolver?: SliceZoneResolver<any, TContext>;\n\n\t/**\n\t * Arbitrary data made available to all Slice components.\n\t */\n\tcontext?: TContext;\n\n\t/**\n\t * A component or a functional component rendered if a component mapping from\n\t * the `components` prop cannot be found.\n\t *\n\t * @remarks\n\t * Components will be rendered using the {@link SliceComponentProps} interface.\n\t *\n\t * @defaultValue The Slice Zone default component provided to `@prismicio/vue` plugin if configured, otherwise `null` when `process.env.NODE_ENV === \"production\"` else {@link TODOSliceComponent}.\n\t */\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tdefaultComponent?: SliceComponentType<any, TContext>;\n\n\t/**\n\t * An HTML tag name, a component, or a functional component used to wrap the\n\t * output. The Slice Zone is not wrapped by default.\n\t */\n\twrapper?: string | ConcreteComponent | Raw<DefineComponent>;\n};\n\n/**\n * `<SliceZone />` implementation.\n *\n * @internal\n */\nexport const SliceZoneImpl = /*#__PURE__*/ defineComponent({\n\tname: \"SliceZone\",\n\tprops: {\n\t\tslices: {\n\t\t\ttype: Array as PropType<SliceZoneLike>,\n\t\t\trequired: true,\n\t\t},\n\t\tcomponents: {\n\t\t\ttype: Object as PropType<SliceZoneComponents>,\n\t\t\tdefault: undefined,\n\t\t\trequired: false,\n\t\t},\n\t\tresolver: {\n\t\t\ttype: Function as PropType<SliceZoneResolver>,\n\t\t\tdefault: undefined,\n\t\t\trequired: false,\n\t\t},\n\t\tcontext: {\n\t\t\ttype: null,\n\t\t\tdefault: undefined,\n\t\t\trequired: false,\n\t\t},\n\t\tdefaultComponent: {\n\t\t\ttype: Object as PropType<SliceComponentType>,\n\t\t\tdefault: undefined,\n\t\t\trequired: false,\n\t\t},\n\t\twrapper: {\n\t\t\ttype: [String, Object, Function] as PropType<\n\t\t\t\tstring | ConcreteComponent | Raw<DefineComponent>\n\t\t\t>,\n\t\t\tdefault: undefined,\n\t\t\trequired: false,\n\t\t},\n\t},\n\tsetup(props) {\n\t\t// Prevent fatal if user didn't check for field, throws `Invalid prop` warn\n\t\tif (!props.slices) {\n\t\t\treturn () => null;\n\t\t}\n\n\t\tconst { options } = usePrismic();\n\n\t\tconst renderedSlices = computed(() => {\n\t\t\treturn props.slices.map((slice, index) => {\n\t\t\t\tconst type = \"slice_type\" in slice ? slice.slice_type : slice.type;\n\n\t\t\t\tlet component =\n\t\t\t\t\tprops.components && type in props.components\n\t\t\t\t\t\t? props.components[type]\n\t\t\t\t\t\t: props.defaultComponent ||\n\t\t\t\t\t\t options.components?.sliceZoneDefaultComponent ||\n\t\t\t\t\t\t TODOSliceComponent;\n\n\t\t\t\t// TODO: Remove `resolver` in v3 in favor of `components`.\n\t\t\t\tif (props.resolver) {\n\t\t\t\t\tconst resolvedComponent = props.resolver({\n\t\t\t\t\t\tslice,\n\t\t\t\t\t\tsliceName: type,\n\t\t\t\t\t\ti: index,\n\t\t\t\t\t});\n\n\t\t\t\t\tif (resolvedComponent) {\n\t\t\t\t\t\tcomponent = resolvedComponent;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tconst key =\n\t\t\t\t\t\"id\" in slice && slice.id\n\t\t\t\t\t\t? slice.id\n\t\t\t\t\t\t: `${index}-${JSON.stringify(slice)}`;\n\n\t\t\t\tconst p = {\n\t\t\t\t\tkey,\n\t\t\t\t\tslice,\n\t\t\t\t\tindex,\n\t\t\t\t\tcontext: props.context,\n\t\t\t\t\tslices: props.slices,\n\t\t\t\t};\n\n\t\t\t\treturn h(simplyResolveComponent(component as ConcreteComponent), p);\n\t\t\t});\n\t\t});\n\n\t\treturn () => {\n\t\t\tif (props.wrapper) {\n\t\t\t\tconst parent = simplyResolveComponent(props.wrapper);\n\n\t\t\t\tif (typeof parent === \"string\") {\n\t\t\t\t\treturn h(parent, null, renderedSlices.value);\n\t\t\t\t} else {\n\t\t\t\t\treturn h(parent, null, { default: () => renderedSlices.value });\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\treturn renderedSlices.value;\n\t\t\t}\n\t\t};\n\t},\n});\n\n// export the public type for h/tsx inference\n// also to avoid inline import() in generated d.ts files\n/**\n * Component to render a Prismic Slice Zone.\n *\n * @see Component props {@link SliceZoneProps}\n * @see Templating Slice Zones {@link https://prismic.io/docs/technologies/vue-template-content#slices-and-groups}\n */\nexport const SliceZone = SliceZoneImpl as unknown as {\n\tnew (): {\n\t\t$props: AllowedComponentProps &\n\t\t\tComponentCustomProps &\n\t\t\tVNodeProps &\n\t\t\tSliceZoneProps;\n\t};\n};\n"],"names":[],"mappings":"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"}
|
|
1
|
+
{"version":3,"file":"SliceZone.js","sources":["../../../src/components/SliceZone.ts"],"sourcesContent":["import { Slice } from \"@prismicio/client\";\nimport {\n\tAllowedComponentProps,\n\tComponentCustomProps,\n\tConcreteComponent,\n\tDefineComponent,\n\tFunctionalComponent,\n\tPropType,\n\tRaw,\n\tVNodeProps,\n\tcomputed,\n\tdefineAsyncComponent,\n\tdefineComponent,\n\th,\n\tmarkRaw,\n\twatchEffect,\n} from \"vue\";\n\nimport { __PRODUCTION__ } from \"../lib/__PRODUCTION__\";\nimport { simplyResolveComponent } from \"../lib/simplyResolveComponent\";\n\nimport { usePrismic } from \"../usePrismic\";\n\n/**\n * Returns the type of a `SliceLike` type.\n *\n * @typeParam TSlice - The Slice from which the type will be extracted.\n */\ntype ExtractSliceType<TSlice extends SliceLike> = TSlice extends SliceLikeRestV2\n\t? TSlice[\"slice_type\"]\n\t: TSlice extends SliceLikeGraphQL\n\t? TSlice[\"type\"]\n\t: never;\n\n/**\n * The minimum required properties to represent a Prismic Slice from the Prismic\n * Rest API V2 for the `<SliceZone>` component.\n *\n * If using Prismic's Rest API V2, use the `Slice` export from\n * `@prismicio/client` for a full interface.\n *\n * @typeParam TSliceType - Type name of the Slice.\n */\nexport type SliceLikeRestV2<TSliceType extends string = string> = Pick<\n\tSlice<TSliceType>,\n\t\"id\" | \"slice_type\"\n>;\n\n/**\n * The minimum required properties to represent a Prismic Slice from the Prismic\n * GraphQL API for the `<SliceZone>` component.\n *\n * @typeParam TSliceType - Type name of the Slice.\n */\nexport type SliceLikeGraphQL<TSliceType extends string = string> = {\n\ttype: Slice<TSliceType>[\"slice_type\"];\n};\n\n/**\n * The minimum required properties to represent a Prismic Slice for the\n * `<SliceZone />` component.\n *\n * If using Prismic's Rest API V2, use the `Slice` export from\n * `@prismicio/client` for a full interface.\n *\n * @typeParam TSliceType - Type name of the Slice\n */\nexport type SliceLike<TSliceType extends string = string> = (\n\t| SliceLikeRestV2<TSliceType>\n\t| SliceLikeGraphQL<TSliceType>\n) & {\n\t/**\n\t * If `true`, this Slice has been modified from its original value using a\n\t * mapper and `@prismicio/client`'s `mapSliceZone()`.\n\t *\n\t * @internal\n\t */\n\t__mapped?: true;\n};\n\n/**\n * A looser version of the `SliceZone` type from `@prismicio/client` using\n * `SliceLike`.\n *\n * If using Prismic's REST API, use the `SliceZone` export from\n * `@prismicio/client` for the full type.\n *\n * @typeParam TSlice - The type(s) of slices in the Slice Zone\n */\nexport type SliceZoneLike<\n\tTSlice extends SliceLike = SliceLike & Record<string, unknown>,\n> = readonly TSlice[];\n\n/**\n * Vue props for a component rendering content from a Prismic Slice using the\n * `<SliceZone />` component.\n *\n * @typeParam TSlice - The type(s) of slices in the Slice Zone\n * @typeParam TContext - Arbitrary data passed to `<SliceZone />` and made\n * available to all Slice components\n */\nexport type SliceComponentProps<\n\tTSlice extends SliceLike = SliceLike,\n\tTContext = unknown,\n> = {\n\t/**\n\t * Slice data for this component.\n\t */\n\tslice: TSlice;\n\n\t/**\n\t * The index of the Slice in the Slice Zone.\n\t */\n\tindex: number;\n\n\t/**\n\t * All Slices from the Slice Zone to which the Slice belongs.\n\t */\n\t// TODO: We have to keep this list of Slices general due to circular\n\t// reference limtiations. If we had another generic to determine the full\n\t// union of Slice types, it would include TSlice. This causes TypeScript to\n\t// throw a compilation error.\n\tslices: SliceZoneLike<\n\t\tTSlice extends SliceLikeGraphQL ? SliceLikeGraphQL : SliceLikeRestV2\n\t>;\n\n\t/**\n\t * Arbitrary data passed to `<SliceZone />` and made available to all Slice\n\t * components.\n\t */\n\tcontext: TContext;\n};\n\n/**\n * Native Vue props for a component rendering content from a Prismic Slice using\n * the `<SliceZone />` component.\n *\n * @typeParam TSlice - The Slice type\n * @typeParam TContext - Arbitrary data passed to `<SliceZone />` and made\n * available to all Slice components\n */\nexport type DefineComponentSliceComponentProps<\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tTSlice extends SliceLike = any,\n\tTContext = unknown,\n> = {\n\tslice: {\n\t\ttype: PropType<SliceComponentProps<TSlice, TContext>[\"slice\"]>;\n\t\trequired: true;\n\t};\n\tindex: {\n\t\ttype: PropType<SliceComponentProps<TSlice, TContext>[\"index\"]>;\n\t\trequired: true;\n\t};\n\tslices: {\n\t\ttype: PropType<SliceComponentProps<TSlice, TContext>[\"slices\"]>;\n\t\trequired: true;\n\t};\n\tcontext: {\n\t\ttype: PropType<SliceComponentProps<TSlice, TContext>[\"context\"]>;\n\t\trequired: true;\n\t};\n};\n\n/**\n * Gets native Vue props for a component rendering content from a Prismic Slice\n * using the `<SliceZone />` component.\n *\n * Props are: `[\"slice\", \"index\", \"slices\", \"context\"]`\n *\n * @example\n *\n * ```javascript\n * // Defining a new slice component\n * import { getSliceComponentProps } from \"@prismicio/vue\";\n *\n * export default {\n * \tprops: getSliceComponentProps(),\n * };\n * ```\n *\n * @example\n *\n * ```javascript\n * // Defining a new slice component with visual hint\n * import { getSliceComponentProps } from \"@prismicio/vue\";\n *\n * export default {\n * \tprops: getSliceComponentProps([\"slice\", \"index\", \"slices\", \"context\"]),\n * };\n * ```\n *\n * @typeParam TSlice - The Slice type\n * @typeParam TContext - Arbitrary data passed to `<SliceZone />` and made\n * available to all Slice components\n * @param propsHint - An optional array of prop names used for the sole purpose\n * of having a visual hint of which props are made available to the slice,\n * this parameters doesn't have any effect\n *\n * @returns Props object to use with {@link defineComponent}\n */\nexport const getSliceComponentProps = <\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tTSlice extends SliceLike = any,\n\tTContext = unknown,\n>(\n\t// eslint-disable-next-line @typescript-eslint/no-unused-vars\n\tpropsHint?: [\"slice\", \"index\", \"slices\", \"context\"],\n): DefineComponentSliceComponentProps<TSlice, TContext> => ({\n\tslice: {\n\t\ttype: Object as PropType<SliceComponentProps<TSlice, TContext>[\"slice\"]>,\n\t\trequired: true,\n\t},\n\tindex: {\n\t\ttype: Number as PropType<SliceComponentProps<TSlice, TContext>[\"index\"]>,\n\t\trequired: true,\n\t},\n\tslices: {\n\t\ttype: Array as PropType<SliceComponentProps<TSlice, TContext>[\"slices\"]>,\n\t\trequired: true,\n\t},\n\tcontext: {\n\t\ttype: null as unknown as PropType<\n\t\t\tSliceComponentProps<TSlice, TContext>[\"context\"]\n\t\t>,\n\t\trequired: true,\n\t},\n});\n\n/**\n * A Vue component to be rendered for each instance of its Slice.\n *\n * @typeParam TSlice - The type(s) of slices in the Slice Zone\n * @typeParam TContext - Arbitrary data made available to all Slice components\n */\nexport type SliceComponentType<\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tTSlice extends SliceLike = any,\n\tTContext = unknown,\n> =\n\t// For reference within TypeScript files when `*.vue` type cannot be inferred\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/ban-types\n\t| DefineComponent<{}, {}, any>\n\t// Likewise, for reference with TypeScript files.\n\t| ReturnType<typeof defineAsyncComponent>\n\t| DefineComponent<SliceComponentProps<TSlice, TContext>>\n\t| FunctionalComponent<SliceComponentProps<TSlice, TContext>>;\n\n/**\n * This Slice component can be used as a reminder to provide a proper\n * implementation.\n *\n * This is also the default Vue component rendered when a component mapping\n * cannot be found in `<SliceZone />`.\n */\nexport const TODOSliceComponent = __PRODUCTION__\n\t? ((() => null) as FunctionalComponent<{\n\t\t\tslice: SliceLike;\n\t }>)\n\t: /*#__PURE__*/ (defineComponent({\n\t\t\tname: \"TODOSliceComponent\",\n\t\t\tprops: {\n\t\t\t\tslice: {\n\t\t\t\t\ttype: Object as PropType<SliceLike>,\n\t\t\t\t\trequired: true,\n\t\t\t\t},\n\t\t\t},\n\t\t\tsetup(props) {\n\t\t\t\tconst type = computed(() => {\n\t\t\t\t\treturn \"slice_type\" in props.slice\n\t\t\t\t\t\t? props.slice.slice_type\n\t\t\t\t\t\t: props.slice.type;\n\t\t\t\t});\n\n\t\t\t\twatchEffect(() => {\n\t\t\t\t\tconsole.warn(\n\t\t\t\t\t\t`[SliceZone] Could not find a component for Slice type \"${type.value}\"`,\n\t\t\t\t\t\tprops.slice,\n\t\t\t\t\t);\n\t\t\t\t});\n\n\t\t\t\treturn () => {\n\t\t\t\t\treturn h(\n\t\t\t\t\t\t\"section\",\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\"data-slice-zone-todo-component\": \"\",\n\t\t\t\t\t\t\t\"data-slice-type\": type.value,\n\t\t\t\t\t\t},\n\t\t\t\t\t\t[`Could not find a component for Slice type \"${type.value}\"`],\n\t\t\t\t\t);\n\t\t\t\t};\n\t\t\t},\n\t }) as SliceComponentType);\n\n/**\n * A record of Slice types mapped to Vue components. Each components will be\n * rendered for each instance of their Slice type.\n *\n * @typeParam TSlice - The type(s) of slices in the Slice Zone\n * @typeParam TContext - Arbitrary data made available to all Slice components\n */\nexport type SliceZoneComponents<\n\tTSlice extends SliceLike = SliceLike,\n\tTContext = unknown,\n> =\n\t// This is purposely not wrapped in Partial to ensure a component is provided\n\t// for all Slice types. <SliceZone /> will render a default component if one is\n\t// not provided, but it *should* be a type error if an explicit component is\n\t// missing.\n\t//\n\t// If a developer purposely does not want to provide a component, they can\n\t// assign it to the TODOSliceComponent exported from this package. This\n\t// signals to future developers that it is a placeholder and should be\n\t// implemented.\n\t{\n\t\t[SliceType in ExtractSliceType<TSlice>]:\n\t\t\t| SliceComponentType<Extract<TSlice, SliceLike<SliceType>>, TContext>\n\t\t\t| string;\n\t};\n\n/**\n * Gets an optimized record of Slice types mapped to Vue components. Each\n * components will be rendered for each instance of their Slice type.\n *\n * @remarks\n * This is essentially an helper function to ensure {@link markRaw} is correctly\n * applied on each components, improving performances.\n * @example\n *\n * ```javascript\n * // Defining a slice components\n * import { defineSliceZoneComponents } from \"@prismicio/vue\";\n *\n * export default {\n * data() {\n * components: defineSliceZoneComponents({\n * foo: Foo,\n * bar: defineAsyncComponent(\n * () => new Promise((res) => res(Bar)),\n * ),\n * baz: \"Baz\",\n * }),\n * }\n * };\n * ```\n *\n * @typeParam TSlice - The type(s) of slices in the Slice Zone\n * @typeParam TContext - Arbitrary data made available to all Slice components\n *\n * @param components - {@link SliceZoneComponents}\n *\n * @returns A new optimized record of {@link SliceZoneComponents}\n */\nexport const defineSliceZoneComponents = <\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tTSlice extends SliceLike = any,\n\tTContext = unknown,\n>(\n\tcomponents: SliceZoneComponents<TSlice, TContext>,\n): SliceZoneComponents<TSlice, TContext> => {\n\tconst result = {} as SliceZoneComponents<TSlice, TContext>;\n\n\tlet type: keyof typeof components;\n\tfor (type in components) {\n\t\tconst component = components[type];\n\t\tresult[type] =\n\t\t\ttypeof component === \"string\"\n\t\t\t\t? component\n\t\t\t\t: markRaw(\n\t\t\t\t\t\tcomponent as SliceComponentType<\n\t\t\t\t\t\t\tExtract<TSlice, SliceLike<typeof type>>,\n\t\t\t\t\t\t\tTContext\n\t\t\t\t\t\t>,\n\t\t\t\t );\n\t}\n\n\treturn result;\n};\n\n/**\n * Arguments for a `<SliceZone>` `resolver` function.\n */\nexport type SliceZoneResolverArgs<TSlice extends SliceLike = SliceLike> = {\n\t/**\n\t * The Slice to resolve to a Vue component..\n\t */\n\tslice: TSlice;\n\n\t/**\n\t * The name of the Slice.\n\t */\n\tsliceName: ExtractSliceType<TSlice>;\n\n\t/**\n\t * The index of the Slice in the Slice Zone.\n\t */\n\ti: number;\n};\n\n/**\n * A function that determines the rendered Vue component for each Slice in the\n * Slice Zone. If a nullish value is returned, the component will fallback to\n * the `components` or `defaultComponent` props to determine the rendered\n * component.\n *\n * @deprecated Use the `components` prop instead.\n *\n * @param args - Arguments for the resolver function.\n *\n * @returns The Vue component to render for a Slice.\n */\nexport type SliceZoneResolver<\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tTSlice extends SliceLike = any,\n\tTContext = unknown,\n> = (\n\targs: SliceZoneResolverArgs<TSlice>,\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n) => SliceComponentType<any, TContext> | string | undefined | null;\n\n/**\n * Props for `<SliceZone />`.\n *\n * @typeParam TContext - Arbitrary data made available to all Slice components\n */\nexport type SliceZoneProps<TContext = unknown> = {\n\t/**\n\t * List of Slice data from the Slice Zone.\n\t */\n\tslices: SliceZoneLike;\n\n\t/**\n\t * A record mapping Slice types to Vue components.\n\t */\n\tcomponents?: SliceZoneComponents;\n\n\t/**\n\t * A function that determines the rendered Vue component for each Slice in the\n\t * Slice Zone.\n\t *\n\t * @deprecated Use the `components` prop instead.\n\t *\n\t * @param args - Arguments for the resolver function.\n\t *\n\t * @returns The Vue component to render for a Slice.\n\t */\n\t// TODO: Remove in v5 when the `resolver` prop is removed.\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tresolver?: SliceZoneResolver<any, TContext>;\n\n\t/**\n\t * Arbitrary data made available to all Slice components.\n\t */\n\tcontext?: TContext;\n\n\t/**\n\t * A component or a functional component rendered if a component mapping from\n\t * the `components` prop cannot be found.\n\t *\n\t * @remarks\n\t * Components will be rendered using the {@link SliceComponentProps} interface.\n\t *\n\t * @defaultValue The Slice Zone default component provided to `@prismicio/vue` plugin if configured, otherwise `null` when `process.env.NODE_ENV === \"production\"` else {@link TODOSliceComponent}.\n\t */\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tdefaultComponent?: SliceComponentType<any, TContext>;\n\n\t/**\n\t * An HTML tag name, a component, or a functional component used to wrap the\n\t * output. The Slice Zone is not wrapped by default.\n\t */\n\twrapper?: string | ConcreteComponent | Raw<DefineComponent>;\n};\n\n/**\n * `<SliceZone />` implementation.\n *\n * @internal\n */\nexport const SliceZoneImpl = /*#__PURE__*/ defineComponent({\n\tname: \"SliceZone\",\n\tprops: {\n\t\tslices: {\n\t\t\ttype: Array as PropType<SliceZoneLike>,\n\t\t\trequired: true,\n\t\t},\n\t\tcomponents: {\n\t\t\ttype: Object as PropType<SliceZoneComponents>,\n\t\t\tdefault: undefined,\n\t\t\trequired: false,\n\t\t},\n\t\tresolver: {\n\t\t\ttype: Function as PropType<SliceZoneResolver>,\n\t\t\tdefault: undefined,\n\t\t\trequired: false,\n\t\t},\n\t\tcontext: {\n\t\t\ttype: null,\n\t\t\tdefault: undefined,\n\t\t\trequired: false,\n\t\t},\n\t\tdefaultComponent: {\n\t\t\ttype: Object as PropType<SliceComponentType>,\n\t\t\tdefault: undefined,\n\t\t\trequired: false,\n\t\t},\n\t\twrapper: {\n\t\t\ttype: [String, Object, Function] as PropType<\n\t\t\t\tstring | ConcreteComponent | Raw<DefineComponent>\n\t\t\t>,\n\t\t\tdefault: undefined,\n\t\t\trequired: false,\n\t\t},\n\t},\n\tsetup(props) {\n\t\t// Prevent fatal if user didn't check for field, throws `Invalid prop` warn\n\t\tif (!props.slices) {\n\t\t\treturn () => null;\n\t\t}\n\n\t\t// TODO: Remove in v3 when the `resolver` prop is removed.\n\t\tif (!__PRODUCTION__) {\n\t\t\tif (props.resolver) {\n\t\t\t\tconsole.warn(\n\t\t\t\t\t\"The `resolver` prop is deprecated. Please replace it with a components map using the `components` prop.\",\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\tconst { options } = usePrismic();\n\n\t\tconst renderedSlices = computed(() => {\n\t\t\treturn props.slices.map((slice, index) => {\n\t\t\t\tconst type =\n\t\t\t\t\t\"slice_type\" in slice ? (slice.slice_type as string) : slice.type;\n\n\t\t\t\tlet component =\n\t\t\t\t\tprops.components && type in props.components\n\t\t\t\t\t\t? props.components[type]\n\t\t\t\t\t\t: props.defaultComponent ||\n\t\t\t\t\t\t options.components?.sliceZoneDefaultComponent;\n\n\t\t\t\t// TODO: Remove `resolver` in v5 in favor of `components`.\n\t\t\t\tif (props.resolver) {\n\t\t\t\t\tconst resolvedComponent = props.resolver({\n\t\t\t\t\t\tslice,\n\t\t\t\t\t\tsliceName: type,\n\t\t\t\t\t\ti: index,\n\t\t\t\t\t});\n\n\t\t\t\t\tif (resolvedComponent) {\n\t\t\t\t\t\tcomponent = resolvedComponent;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tconst key =\n\t\t\t\t\t\"id\" in slice && typeof slice.id === \"string\"\n\t\t\t\t\t\t? slice.id\n\t\t\t\t\t\t: `${index}-${JSON.stringify(slice)}`;\n\n\t\t\t\tif (component) {\n\t\t\t\t\tif (slice.__mapped) {\n\t\t\t\t\t\tconst { __mapped, ...mappedProps } = slice;\n\n\t\t\t\t\t\treturn h(simplyResolveComponent(component as ConcreteComponent), {\n\t\t\t\t\t\t\tkey,\n\t\t\t\t\t\t\t...mappedProps,\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\n\t\t\t\t\treturn h(simplyResolveComponent(component as ConcreteComponent), {\n\t\t\t\t\t\tkey,\n\t\t\t\t\t\tslice,\n\t\t\t\t\t\tindex,\n\t\t\t\t\t\tcontext: props.context,\n\t\t\t\t\t\tslices: props.slices,\n\t\t\t\t\t});\n\t\t\t\t} else {\n\t\t\t\t\treturn h(\n\t\t\t\t\t\tsimplyResolveComponent(TODOSliceComponent as ConcreteComponent),\n\t\t\t\t\t\t{ key, slice },\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t});\n\t\t});\n\n\t\treturn () => {\n\t\t\tif (props.wrapper) {\n\t\t\t\tconst parent = simplyResolveComponent(props.wrapper);\n\n\t\t\t\tif (typeof parent === \"string\") {\n\t\t\t\t\treturn h(parent, null, renderedSlices.value);\n\t\t\t\t} else {\n\t\t\t\t\treturn h(parent, null, { default: () => renderedSlices.value });\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\treturn renderedSlices.value;\n\t\t\t}\n\t\t};\n\t},\n});\n\n// export the public type for h/tsx inference\n// also to avoid inline import() in generated d.ts files\n/**\n * Component to render a Prismic Slice Zone.\n *\n * @see Component props {@link SliceZoneProps}\n * @see Templating Slice Zones {@link https://prismic.io/docs/technologies/vue-template-content#slices-and-groups}\n */\nexport const SliceZone = SliceZoneImpl as unknown as {\n\tnew (): {\n\t\t$props: AllowedComponentProps &\n\t\t\tComponentCustomProps &\n\t\t\tVNodeProps &\n\t\t\tSliceZoneProps;\n\t};\n};\n"],"names":[],"mappings":"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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createPrismic.cjs","sources":["../../src/createPrismic.ts"],"sourcesContent":["import {\n\tClient,\n\tFetchLike,\n\tLinkResolverFunction,\n\tasDate,\n\tasHTML,\n\tasImagePixelDensitySrcSet,\n\tasImageSrc,\n\tasImageWidthSrcSet,\n\tasLink,\n\tasLinkAttrs,\n\tasText,\n\tcookie,\n\tcreateClient,\n\tdocumentToLinkField,\n\tfilter,\n\tisFilled,\n} from \"@prismicio/client\";\nimport { App } from \"vue\";\n\nimport type {\n\tPrismicPlugin,\n\tPrismicPluginClient,\n\tPrismicPluginHelpers,\n\tPrismicPluginOptions,\n} from \"./types\";\n\nimport {\n\tPrismicEmbed,\n\tPrismicImage,\n\tPrismicLink,\n\tPrismicRichText,\n\tPrismicText,\n\tSliceZone,\n} from \"./components\";\nimport { prismicKey } from \"./injectionSymbols\";\n\n/**\n * Creates a `@prismicio/vue` plugin instance that can be used by a Vue app.\n *\n * @param options - {@link PrismicPluginOptions}\n *\n * @returns `@prismicio/vue` plugin instance {@link PrismicPlugin}\n *\n * @see Prismic Official Vue.js documentation: {@link https://prismic.io/docs/technologies/vuejs}\n * @see Plugin repository: {@link https://github.com/prismicio/prismic-vue}\n */\nexport const createPrismic = (options: PrismicPluginOptions): PrismicPlugin => {\n\t// Create plugin client\n\tlet client: Client;\n\tif (options.client) {\n\t\tclient = options.client;\n\t} else {\n\t\tclient = createClient(options.endpoint, {\n\t\t\tfetch: async (endpoint, options) => {\n\t\t\t\tlet fetchFunction: FetchLike;\n\t\t\t\tif (typeof globalThis.fetch === \"function\") {\n\t\t\t\t\tfetchFunction = globalThis.fetch;\n\t\t\t\t} else {\n\t\t\t\t\tfetchFunction = (await import(\"isomorphic-unfetch\")).default;\n\t\t\t\t}\n\n\t\t\t\treturn await fetchFunction(endpoint, options);\n\t\t\t},\n\t\t\t...options.clientConfig,\n\t\t});\n\t}\n\n\tconst prismicClient: PrismicPluginClient = {\n\t\tclient,\n\t\tfilter,\n\t\tcookie,\n\t};\n\n\t// Create plugin helpers\n\tconst prismicHelpers: PrismicPluginHelpers = {\n\t\tasText,\n\t\tasHTML: (richTextField, ...config) => {\n\t\t\tconst [configOrLinkResolver, maybeHTMLSerializer] = config;\n\n\t\t\treturn asHTML(\n\t\t\t\trichTextField,\n\t\t\t\ttypeof configOrLinkResolver === \"function\" ||\n\t\t\t\t\tconfigOrLinkResolver == null\n\t\t\t\t\t? {\n\t\t\t\t\t\t\tlinkResolver: configOrLinkResolver || options.linkResolver,\n\t\t\t\t\t\t\tserializer:\n\t\t\t\t\t\t\t\tmaybeHTMLSerializer ||\n\t\t\t\t\t\t\t\toptions.richTextSerializer ||\n\t\t\t\t\t\t\t\toptions.htmlSerializer,\n\t\t\t\t\t }\n\t\t\t\t\t: {\n\t\t\t\t\t\t\tlinkResolver: options.linkResolver,\n\t\t\t\t\t\t\tserializer: options.richTextSerializer || options.htmlSerializer,\n\t\t\t\t\t\t\t...configOrLinkResolver,\n\t\t\t\t\t },\n\t\t\t);\n\t\t},\n\t\tasLink: (linkField, config) => {\n\t\t\treturn asLink(\n\t\t\t\tlinkField,\n\t\t\t\ttypeof config === \"function\"\n\t\t\t\t\t? { linkResolver: config }\n\t\t\t\t\t: {\n\t\t\t\t\t\t\tlinkResolver: options.linkResolver,\n\t\t\t\t\t\t\t// TODO: For some reasons, TypeScript narrows the type to \"unknown\" where it's supposed to be a union\n\t\t\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\t\t\t\t\t\t\t...(config as any),\n\t\t\t\t\t },\n\t\t\t);\n\t\t},\n\t\tasLinkAttrs: (linkField, config) => {\n\t\t\treturn asLinkAttrs(linkField, {\n\t\t\t\t// TODO: We can't really retrieve the generic type here, this might cause some unexpected type error in some edge-case scenario\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\t\t\t\tlinkResolver: options.linkResolver as LinkResolverFunction<any>,\n\t\t\t\t...config,\n\t\t\t});\n\t\t},\n\t\tasDate,\n\t\tasImageSrc,\n\t\tasImageWidthSrcSet,\n\t\tasImagePixelDensitySrcSet,\n\t\tisFilled,\n\t\tdocumentToLinkField,\n\t};\n\n\t// Create plugin interface\n\tconst prismic: PrismicPlugin = {\n\t\toptions,\n\n\t\t...prismicClient,\n\t\t...prismicHelpers,\n\n\t\tinstall(app: App): void {\n\t\t\tapp.provide(prismicKey, this);\n\t\t\tapp.config.globalProperties.$prismic = this;\n\n\t\t\tif (options.injectComponents !== false) {\n\t\t\t\tapp.component(PrismicLink.name, PrismicLink);\n\t\t\t\tapp.component(PrismicEmbed.name, PrismicEmbed);\n\t\t\t\tapp.component(PrismicImage.name, PrismicImage);\n\t\t\t\tapp.component(PrismicText.name, PrismicText);\n\t\t\t\tapp.component(PrismicRichText.name, PrismicRichText);\n\t\t\t\tapp.component(SliceZone.name, SliceZone);\n\t\t\t}\n\t\t},\n\t};\n\n\treturn prismic;\n};\n"],"names":["client","createClient","options","filter","cookie","asText","asHTML","asLink","asLinkAttrs","asDate","asImageSrc","asImageWidthSrcSet","asImagePixelDensitySrcSet","isFilled","documentToLinkField","prismicKey","PrismicLink","PrismicEmbed","PrismicImage","PrismicText","PrismicRichText","SliceZone"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+Ca,MAAA,gBAAgB,CAAC,YAAgD;AAEzE,MAAAA;AACJ,MAAI,QAAQ,QAAQ;AACnBA,eAAS,QAAQ;AAAA,EAAA,OACX;AACGA,eAAAC,OAAAA,aAAa,QAAQ,UAAU;AAAA,MACvC,OAAO,OAAO,UAAUC,aAAW;AAC9B,YAAA;AACA,YAAA,OAAO,WAAW,UAAU,YAAY;AAC3C,0BAAgB,WAAW;AAAA,QAAA,OACrB;AACW,2BAAA,MAAM,OAAO,oBAAoB,GAAG;AAAA,
|
|
1
|
+
{"version":3,"file":"createPrismic.cjs","sources":["../../src/createPrismic.ts"],"sourcesContent":["import {\n\tClient,\n\tFetchLike,\n\tLinkResolverFunction,\n\tasDate,\n\tasHTML,\n\tasImagePixelDensitySrcSet,\n\tasImageSrc,\n\tasImageWidthSrcSet,\n\tasLink,\n\tasLinkAttrs,\n\tasText,\n\tcookie,\n\tcreateClient,\n\tdocumentToLinkField,\n\tfilter,\n\tisFilled,\n} from \"@prismicio/client\";\nimport { App } from \"vue\";\n\nimport type {\n\tPrismicPlugin,\n\tPrismicPluginClient,\n\tPrismicPluginHelpers,\n\tPrismicPluginOptions,\n} from \"./types\";\n\nimport {\n\tPrismicEmbed,\n\tPrismicImage,\n\tPrismicLink,\n\tPrismicRichText,\n\tPrismicText,\n\tSliceZone,\n} from \"./components\";\nimport { prismicKey } from \"./injectionSymbols\";\n\n/**\n * Creates a `@prismicio/vue` plugin instance that can be used by a Vue app.\n *\n * @param options - {@link PrismicPluginOptions}\n *\n * @returns `@prismicio/vue` plugin instance {@link PrismicPlugin}\n *\n * @see Prismic Official Vue.js documentation: {@link https://prismic.io/docs/technologies/vuejs}\n * @see Plugin repository: {@link https://github.com/prismicio/prismic-vue}\n */\nexport const createPrismic = (options: PrismicPluginOptions): PrismicPlugin => {\n\t// Create plugin client\n\tlet client: Client;\n\tif (options.client) {\n\t\tclient = options.client;\n\t} else {\n\t\tclient = createClient(options.endpoint, {\n\t\t\tfetch: async (endpoint, options) => {\n\t\t\t\tlet fetchFunction: FetchLike;\n\t\t\t\tif (typeof globalThis.fetch === \"function\") {\n\t\t\t\t\tfetchFunction = globalThis.fetch;\n\t\t\t\t} else {\n\t\t\t\t\tfetchFunction = (await import(\"isomorphic-unfetch\")).default;\n\t\t\t\t}\n\n\t\t\t\treturn await fetchFunction(endpoint, options);\n\t\t\t},\n\t\t\t...options.clientConfig,\n\t\t});\n\t}\n\n\tconst prismicClient: PrismicPluginClient = {\n\t\tclient,\n\t\tfilter,\n\t\tcookie,\n\t};\n\n\t// Create plugin helpers\n\tconst prismicHelpers: PrismicPluginHelpers = {\n\t\tasText,\n\t\tasHTML: (richTextField, ...config) => {\n\t\t\tconst [configOrLinkResolver, maybeHTMLSerializer] = config;\n\n\t\t\treturn asHTML(\n\t\t\t\trichTextField,\n\t\t\t\ttypeof configOrLinkResolver === \"function\" ||\n\t\t\t\t\tconfigOrLinkResolver == null\n\t\t\t\t\t? {\n\t\t\t\t\t\t\tlinkResolver: configOrLinkResolver || options.linkResolver,\n\t\t\t\t\t\t\tserializer:\n\t\t\t\t\t\t\t\tmaybeHTMLSerializer ||\n\t\t\t\t\t\t\t\toptions.richTextSerializer ||\n\t\t\t\t\t\t\t\toptions.htmlSerializer,\n\t\t\t\t\t }\n\t\t\t\t\t: {\n\t\t\t\t\t\t\tlinkResolver: options.linkResolver,\n\t\t\t\t\t\t\tserializer: options.richTextSerializer || options.htmlSerializer,\n\t\t\t\t\t\t\t...configOrLinkResolver,\n\t\t\t\t\t },\n\t\t\t);\n\t\t},\n\t\tasLink: (linkField, config) => {\n\t\t\treturn asLink(\n\t\t\t\tlinkField,\n\t\t\t\ttypeof config === \"function\"\n\t\t\t\t\t? { linkResolver: config }\n\t\t\t\t\t: {\n\t\t\t\t\t\t\tlinkResolver: options.linkResolver,\n\t\t\t\t\t\t\t// TODO: For some reasons, TypeScript narrows the type to \"unknown\" where it's supposed to be a union\n\t\t\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\t\t\t\t\t\t\t...(config as any),\n\t\t\t\t\t },\n\t\t\t);\n\t\t},\n\t\tasLinkAttrs: (linkField, config) => {\n\t\t\treturn asLinkAttrs(linkField, {\n\t\t\t\t// TODO: We can't really retrieve the generic type here, this might cause some unexpected type error in some edge-case scenario\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\t\t\t\tlinkResolver: options.linkResolver as LinkResolverFunction<any>,\n\t\t\t\t...config,\n\t\t\t});\n\t\t},\n\t\tasDate,\n\t\tasImageSrc,\n\t\tasImageWidthSrcSet,\n\t\tasImagePixelDensitySrcSet,\n\t\tisFilled,\n\t\tdocumentToLinkField,\n\t};\n\n\t// Create plugin interface\n\tconst prismic: PrismicPlugin = {\n\t\toptions,\n\n\t\t...prismicClient,\n\t\t...prismicHelpers,\n\n\t\tinstall(app: App): void {\n\t\t\tapp.provide(prismicKey, this);\n\t\t\tapp.config.globalProperties.$prismic = this;\n\n\t\t\tif (options.injectComponents !== false) {\n\t\t\t\tapp.component(PrismicLink.name, PrismicLink);\n\t\t\t\tapp.component(PrismicEmbed.name, PrismicEmbed);\n\t\t\t\tapp.component(PrismicImage.name, PrismicImage);\n\t\t\t\tapp.component(PrismicText.name, PrismicText);\n\t\t\t\tapp.component(PrismicRichText.name, PrismicRichText);\n\t\t\t\tapp.component(SliceZone.name, SliceZone);\n\t\t\t}\n\t\t},\n\t};\n\n\treturn prismic;\n};\n"],"names":["client","createClient","options","filter","cookie","asText","asHTML","asLink","asLinkAttrs","asDate","asImageSrc","asImageWidthSrcSet","asImagePixelDensitySrcSet","isFilled","documentToLinkField","prismicKey","PrismicLink","PrismicEmbed","PrismicImage","PrismicText","PrismicRichText","SliceZone"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+Ca,MAAA,gBAAgB,CAAC,YAAgD;AAEzE,MAAAA;AACJ,MAAI,QAAQ,QAAQ;AACnBA,eAAS,QAAQ;AAAA,EAAA,OACX;AACGA,eAAAC,OAAAA,aAAa,QAAQ,UAAU;AAAA,MACvC,OAAO,OAAO,UAAUC,aAAW;AAC9B,YAAA;AACA,YAAA,OAAO,WAAW,UAAU,YAAY;AAC3C,0BAAgB,WAAW;AAAA,QAAA,OACrB;AACW,2BAAA,MAAM,OAAO,oBAAoB,GAAG;AAAA,QACtD;AAEO,eAAA,MAAM,cAAc,UAAUA,QAAO;AAAA,MAC7C;AAAA,MACA,GAAG,QAAQ;AAAA,IAAA,CACX;AAAA,EACF;AAEA,QAAM,gBAAqC;AAAA,IAAA,QAC1CF;AAAAA,IAAA,QACAG,OAAA;AAAA,IAAA,QACAC,OAAA;AAAA,EAAA;AAID,QAAM,iBAAuC;AAAA,IAAA,QAC5CC,OAAA;AAAA,IACA,QAAQ,CAAC,kBAAkB,WAAU;AAC9B,YAAA,CAAC,sBAAsB,mBAAmB,IAAI;AAEpD,aAAOC,OAAAA,OACN,eACA,OAAO,yBAAyB,cAC/B,wBAAwB,OACtB;AAAA,QACA,cAAc,wBAAwB,QAAQ;AAAA,QAC9C,YACC,uBACA,QAAQ,sBACR,QAAQ;AAAA,MAAA,IAET;AAAA,QACA,cAAc,QAAQ;AAAA,QACtB,YAAY,QAAQ,sBAAsB,QAAQ;AAAA,QAClD,GAAG;AAAA,MAAA,CACF;AAAA,IAEN;AAAA,IACA,QAAQ,CAAC,WAAW,WAAU;AACtB,aAAAC,OAAAA,OACN,WACA,OAAO,WAAW,aACf,EAAE,cAAc,WAChB;AAAA,QACA,cAAc,QAAQ;AAAA;AAAA;AAAA,QAGtB,GAAI;AAAA,MAAA,CACH;AAAA,IAEN;AAAA,IACA,aAAa,CAAC,WAAW,WAAU;AAClC,aAAOC,OAAAA,YAAY,WAAW;AAAA;AAAA;AAAA,QAG7B,cAAc,QAAQ;AAAA,QACtB,GAAG;AAAA,MAAA,CACH;AAAA,IACF;AAAA,IAAA,QACAC,OAAA;AAAA,IAAA,YACAC,OAAA;AAAA,IAAA,oBACAC,OAAA;AAAA,IAAA,2BACAC,OAAA;AAAA,IAAA,UACAC,OAAA;AAAA,IAAA,qBACAC,OAAA;AAAA,EAAA;AAID,QAAM,UAAyB;AAAA,IAC9B;AAAA,IAEA,GAAG;AAAA,IACH,GAAG;AAAA,IAEH,QAAQ,KAAQ;AACX,UAAA,QAAQC,6BAAY,IAAI;AACxB,UAAA,OAAO,iBAAiB,WAAW;AAEnC,UAAA,QAAQ,qBAAqB,OAAO;AACnC,YAAA,UAAUC,YAAAA,YAAY,MAAMA,YAAW,WAAA;AACvC,YAAA,UAAUC,aAAAA,aAAa,MAAMA,aAAY,YAAA;AACzC,YAAA,UAAUC,aAAAA,aAAa,MAAMA,aAAY,YAAA;AACzC,YAAA,UAAUC,YAAAA,YAAY,MAAMA,YAAW,WAAA;AACvC,YAAA,UAAUC,gBAAAA,gBAAgB,MAAMA,gBAAe,eAAA;AAC/C,YAAA,UAAUC,UAAAA,UAAU,MAAMA,UAAS,SAAA;AAAA,MACxC;AAAA,IACD;AAAA,EAAA;AAGM,SAAA;AACR;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createPrismic.js","sources":["../../src/createPrismic.ts"],"sourcesContent":["import {\n\tClient,\n\tFetchLike,\n\tLinkResolverFunction,\n\tasDate,\n\tasHTML,\n\tasImagePixelDensitySrcSet,\n\tasImageSrc,\n\tasImageWidthSrcSet,\n\tasLink,\n\tasLinkAttrs,\n\tasText,\n\tcookie,\n\tcreateClient,\n\tdocumentToLinkField,\n\tfilter,\n\tisFilled,\n} from \"@prismicio/client\";\nimport { App } from \"vue\";\n\nimport type {\n\tPrismicPlugin,\n\tPrismicPluginClient,\n\tPrismicPluginHelpers,\n\tPrismicPluginOptions,\n} from \"./types\";\n\nimport {\n\tPrismicEmbed,\n\tPrismicImage,\n\tPrismicLink,\n\tPrismicRichText,\n\tPrismicText,\n\tSliceZone,\n} from \"./components\";\nimport { prismicKey } from \"./injectionSymbols\";\n\n/**\n * Creates a `@prismicio/vue` plugin instance that can be used by a Vue app.\n *\n * @param options - {@link PrismicPluginOptions}\n *\n * @returns `@prismicio/vue` plugin instance {@link PrismicPlugin}\n *\n * @see Prismic Official Vue.js documentation: {@link https://prismic.io/docs/technologies/vuejs}\n * @see Plugin repository: {@link https://github.com/prismicio/prismic-vue}\n */\nexport const createPrismic = (options: PrismicPluginOptions): PrismicPlugin => {\n\t// Create plugin client\n\tlet client: Client;\n\tif (options.client) {\n\t\tclient = options.client;\n\t} else {\n\t\tclient = createClient(options.endpoint, {\n\t\t\tfetch: async (endpoint, options) => {\n\t\t\t\tlet fetchFunction: FetchLike;\n\t\t\t\tif (typeof globalThis.fetch === \"function\") {\n\t\t\t\t\tfetchFunction = globalThis.fetch;\n\t\t\t\t} else {\n\t\t\t\t\tfetchFunction = (await import(\"isomorphic-unfetch\")).default;\n\t\t\t\t}\n\n\t\t\t\treturn await fetchFunction(endpoint, options);\n\t\t\t},\n\t\t\t...options.clientConfig,\n\t\t});\n\t}\n\n\tconst prismicClient: PrismicPluginClient = {\n\t\tclient,\n\t\tfilter,\n\t\tcookie,\n\t};\n\n\t// Create plugin helpers\n\tconst prismicHelpers: PrismicPluginHelpers = {\n\t\tasText,\n\t\tasHTML: (richTextField, ...config) => {\n\t\t\tconst [configOrLinkResolver, maybeHTMLSerializer] = config;\n\n\t\t\treturn asHTML(\n\t\t\t\trichTextField,\n\t\t\t\ttypeof configOrLinkResolver === \"function\" ||\n\t\t\t\t\tconfigOrLinkResolver == null\n\t\t\t\t\t? {\n\t\t\t\t\t\t\tlinkResolver: configOrLinkResolver || options.linkResolver,\n\t\t\t\t\t\t\tserializer:\n\t\t\t\t\t\t\t\tmaybeHTMLSerializer ||\n\t\t\t\t\t\t\t\toptions.richTextSerializer ||\n\t\t\t\t\t\t\t\toptions.htmlSerializer,\n\t\t\t\t\t }\n\t\t\t\t\t: {\n\t\t\t\t\t\t\tlinkResolver: options.linkResolver,\n\t\t\t\t\t\t\tserializer: options.richTextSerializer || options.htmlSerializer,\n\t\t\t\t\t\t\t...configOrLinkResolver,\n\t\t\t\t\t },\n\t\t\t);\n\t\t},\n\t\tasLink: (linkField, config) => {\n\t\t\treturn asLink(\n\t\t\t\tlinkField,\n\t\t\t\ttypeof config === \"function\"\n\t\t\t\t\t? { linkResolver: config }\n\t\t\t\t\t: {\n\t\t\t\t\t\t\tlinkResolver: options.linkResolver,\n\t\t\t\t\t\t\t// TODO: For some reasons, TypeScript narrows the type to \"unknown\" where it's supposed to be a union\n\t\t\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\t\t\t\t\t\t\t...(config as any),\n\t\t\t\t\t },\n\t\t\t);\n\t\t},\n\t\tasLinkAttrs: (linkField, config) => {\n\t\t\treturn asLinkAttrs(linkField, {\n\t\t\t\t// TODO: We can't really retrieve the generic type here, this might cause some unexpected type error in some edge-case scenario\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\t\t\t\tlinkResolver: options.linkResolver as LinkResolverFunction<any>,\n\t\t\t\t...config,\n\t\t\t});\n\t\t},\n\t\tasDate,\n\t\tasImageSrc,\n\t\tasImageWidthSrcSet,\n\t\tasImagePixelDensitySrcSet,\n\t\tisFilled,\n\t\tdocumentToLinkField,\n\t};\n\n\t// Create plugin interface\n\tconst prismic: PrismicPlugin = {\n\t\toptions,\n\n\t\t...prismicClient,\n\t\t...prismicHelpers,\n\n\t\tinstall(app: App): void {\n\t\t\tapp.provide(prismicKey, this);\n\t\t\tapp.config.globalProperties.$prismic = this;\n\n\t\t\tif (options.injectComponents !== false) {\n\t\t\t\tapp.component(PrismicLink.name, PrismicLink);\n\t\t\t\tapp.component(PrismicEmbed.name, PrismicEmbed);\n\t\t\t\tapp.component(PrismicImage.name, PrismicImage);\n\t\t\t\tapp.component(PrismicText.name, PrismicText);\n\t\t\t\tapp.component(PrismicRichText.name, PrismicRichText);\n\t\t\t\tapp.component(SliceZone.name, SliceZone);\n\t\t\t}\n\t\t},\n\t};\n\n\treturn prismic;\n};\n"],"names":["options"],"mappings":";;;;;;;;AA+Ca,MAAA,gBAAgB,CAAC,YAAgD;AAEzE,MAAA;AACJ,MAAI,QAAQ,QAAQ;AACnB,aAAS,QAAQ;AAAA,EAAA,OACX;AACG,aAAA,aAAa,QAAQ,UAAU;AAAA,MACvC,OAAO,OAAO,UAAUA,aAAW;AAC9B,YAAA;AACA,YAAA,OAAO,WAAW,UAAU,YAAY;AAC3C,0BAAgB,WAAW;AAAA,QAAA,OACrB;AACW,2BAAA,MAAM,OAAO,oBAAoB,GAAG;AAAA,
|
|
1
|
+
{"version":3,"file":"createPrismic.js","sources":["../../src/createPrismic.ts"],"sourcesContent":["import {\n\tClient,\n\tFetchLike,\n\tLinkResolverFunction,\n\tasDate,\n\tasHTML,\n\tasImagePixelDensitySrcSet,\n\tasImageSrc,\n\tasImageWidthSrcSet,\n\tasLink,\n\tasLinkAttrs,\n\tasText,\n\tcookie,\n\tcreateClient,\n\tdocumentToLinkField,\n\tfilter,\n\tisFilled,\n} from \"@prismicio/client\";\nimport { App } from \"vue\";\n\nimport type {\n\tPrismicPlugin,\n\tPrismicPluginClient,\n\tPrismicPluginHelpers,\n\tPrismicPluginOptions,\n} from \"./types\";\n\nimport {\n\tPrismicEmbed,\n\tPrismicImage,\n\tPrismicLink,\n\tPrismicRichText,\n\tPrismicText,\n\tSliceZone,\n} from \"./components\";\nimport { prismicKey } from \"./injectionSymbols\";\n\n/**\n * Creates a `@prismicio/vue` plugin instance that can be used by a Vue app.\n *\n * @param options - {@link PrismicPluginOptions}\n *\n * @returns `@prismicio/vue` plugin instance {@link PrismicPlugin}\n *\n * @see Prismic Official Vue.js documentation: {@link https://prismic.io/docs/technologies/vuejs}\n * @see Plugin repository: {@link https://github.com/prismicio/prismic-vue}\n */\nexport const createPrismic = (options: PrismicPluginOptions): PrismicPlugin => {\n\t// Create plugin client\n\tlet client: Client;\n\tif (options.client) {\n\t\tclient = options.client;\n\t} else {\n\t\tclient = createClient(options.endpoint, {\n\t\t\tfetch: async (endpoint, options) => {\n\t\t\t\tlet fetchFunction: FetchLike;\n\t\t\t\tif (typeof globalThis.fetch === \"function\") {\n\t\t\t\t\tfetchFunction = globalThis.fetch;\n\t\t\t\t} else {\n\t\t\t\t\tfetchFunction = (await import(\"isomorphic-unfetch\")).default;\n\t\t\t\t}\n\n\t\t\t\treturn await fetchFunction(endpoint, options);\n\t\t\t},\n\t\t\t...options.clientConfig,\n\t\t});\n\t}\n\n\tconst prismicClient: PrismicPluginClient = {\n\t\tclient,\n\t\tfilter,\n\t\tcookie,\n\t};\n\n\t// Create plugin helpers\n\tconst prismicHelpers: PrismicPluginHelpers = {\n\t\tasText,\n\t\tasHTML: (richTextField, ...config) => {\n\t\t\tconst [configOrLinkResolver, maybeHTMLSerializer] = config;\n\n\t\t\treturn asHTML(\n\t\t\t\trichTextField,\n\t\t\t\ttypeof configOrLinkResolver === \"function\" ||\n\t\t\t\t\tconfigOrLinkResolver == null\n\t\t\t\t\t? {\n\t\t\t\t\t\t\tlinkResolver: configOrLinkResolver || options.linkResolver,\n\t\t\t\t\t\t\tserializer:\n\t\t\t\t\t\t\t\tmaybeHTMLSerializer ||\n\t\t\t\t\t\t\t\toptions.richTextSerializer ||\n\t\t\t\t\t\t\t\toptions.htmlSerializer,\n\t\t\t\t\t }\n\t\t\t\t\t: {\n\t\t\t\t\t\t\tlinkResolver: options.linkResolver,\n\t\t\t\t\t\t\tserializer: options.richTextSerializer || options.htmlSerializer,\n\t\t\t\t\t\t\t...configOrLinkResolver,\n\t\t\t\t\t },\n\t\t\t);\n\t\t},\n\t\tasLink: (linkField, config) => {\n\t\t\treturn asLink(\n\t\t\t\tlinkField,\n\t\t\t\ttypeof config === \"function\"\n\t\t\t\t\t? { linkResolver: config }\n\t\t\t\t\t: {\n\t\t\t\t\t\t\tlinkResolver: options.linkResolver,\n\t\t\t\t\t\t\t// TODO: For some reasons, TypeScript narrows the type to \"unknown\" where it's supposed to be a union\n\t\t\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\t\t\t\t\t\t\t...(config as any),\n\t\t\t\t\t },\n\t\t\t);\n\t\t},\n\t\tasLinkAttrs: (linkField, config) => {\n\t\t\treturn asLinkAttrs(linkField, {\n\t\t\t\t// TODO: We can't really retrieve the generic type here, this might cause some unexpected type error in some edge-case scenario\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\t\t\t\tlinkResolver: options.linkResolver as LinkResolverFunction<any>,\n\t\t\t\t...config,\n\t\t\t});\n\t\t},\n\t\tasDate,\n\t\tasImageSrc,\n\t\tasImageWidthSrcSet,\n\t\tasImagePixelDensitySrcSet,\n\t\tisFilled,\n\t\tdocumentToLinkField,\n\t};\n\n\t// Create plugin interface\n\tconst prismic: PrismicPlugin = {\n\t\toptions,\n\n\t\t...prismicClient,\n\t\t...prismicHelpers,\n\n\t\tinstall(app: App): void {\n\t\t\tapp.provide(prismicKey, this);\n\t\t\tapp.config.globalProperties.$prismic = this;\n\n\t\t\tif (options.injectComponents !== false) {\n\t\t\t\tapp.component(PrismicLink.name, PrismicLink);\n\t\t\t\tapp.component(PrismicEmbed.name, PrismicEmbed);\n\t\t\t\tapp.component(PrismicImage.name, PrismicImage);\n\t\t\t\tapp.component(PrismicText.name, PrismicText);\n\t\t\t\tapp.component(PrismicRichText.name, PrismicRichText);\n\t\t\t\tapp.component(SliceZone.name, SliceZone);\n\t\t\t}\n\t\t},\n\t};\n\n\treturn prismic;\n};\n"],"names":["options"],"mappings":";;;;;;;;AA+Ca,MAAA,gBAAgB,CAAC,YAAgD;AAEzE,MAAA;AACJ,MAAI,QAAQ,QAAQ;AACnB,aAAS,QAAQ;AAAA,EAAA,OACX;AACG,aAAA,aAAa,QAAQ,UAAU;AAAA,MACvC,OAAO,OAAO,UAAUA,aAAW;AAC9B,YAAA;AACA,YAAA,OAAO,WAAW,UAAU,YAAY;AAC3C,0BAAgB,WAAW;AAAA,QAAA,OACrB;AACW,2BAAA,MAAM,OAAO,oBAAoB,GAAG;AAAA,QACtD;AAEO,eAAA,MAAM,cAAc,UAAUA,QAAO;AAAA,MAC7C;AAAA,MACA,GAAG,QAAQ;AAAA,IAAA,CACX;AAAA,EACF;AAEA,QAAM,gBAAqC;AAAA,IAC1C;AAAA,IACA;AAAA,IACA;AAAA,EAAA;AAID,QAAM,iBAAuC;AAAA,IAC5C;AAAA,IACA,QAAQ,CAAC,kBAAkB,WAAU;AAC9B,YAAA,CAAC,sBAAsB,mBAAmB,IAAI;AAEpD,aAAO,OACN,eACA,OAAO,yBAAyB,cAC/B,wBAAwB,OACtB;AAAA,QACA,cAAc,wBAAwB,QAAQ;AAAA,QAC9C,YACC,uBACA,QAAQ,sBACR,QAAQ;AAAA,MAAA,IAET;AAAA,QACA,cAAc,QAAQ;AAAA,QACtB,YAAY,QAAQ,sBAAsB,QAAQ;AAAA,QAClD,GAAG;AAAA,MAAA,CACF;AAAA,IAEN;AAAA,IACA,QAAQ,CAAC,WAAW,WAAU;AACtB,aAAA,OACN,WACA,OAAO,WAAW,aACf,EAAE,cAAc,WAChB;AAAA,QACA,cAAc,QAAQ;AAAA;AAAA;AAAA,QAGtB,GAAI;AAAA,MAAA,CACH;AAAA,IAEN;AAAA,IACA,aAAa,CAAC,WAAW,WAAU;AAClC,aAAO,YAAY,WAAW;AAAA;AAAA;AAAA,QAG7B,cAAc,QAAQ;AAAA,QACtB,GAAG;AAAA,MAAA,CACH;AAAA,IACF;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EAAA;AAID,QAAM,UAAyB;AAAA,IAC9B;AAAA,IAEA,GAAG;AAAA,IACH,GAAG;AAAA,IAEH,QAAQ,KAAQ;AACX,UAAA,QAAQ,YAAY,IAAI;AACxB,UAAA,OAAO,iBAAiB,WAAW;AAEnC,UAAA,QAAQ,qBAAqB,OAAO;AACnC,YAAA,UAAU,YAAY,MAAM,WAAW;AACvC,YAAA,UAAU,aAAa,MAAM,YAAY;AACzC,YAAA,UAAU,aAAa,MAAM,YAAY;AACzC,YAAA,UAAU,YAAY,MAAM,WAAW;AACvC,YAAA,UAAU,gBAAgB,MAAM,eAAe;AAC/C,YAAA,UAAU,UAAU,MAAM,SAAS;AAAA,MACxC;AAAA,IACD;AAAA,EAAA;AAGM,SAAA;AACR;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"__PRODUCTION__.cjs","sources":["../../../src/lib/__PRODUCTION__.ts"],"sourcesContent":["// We need to polyfill process if it doesn't exist, such as in the browser.\nif (typeof process === \"undefined\") {\n\tglobalThis.process = { env: {} } as typeof process;\n}\n\n/**\n * `true` if in the production environment, `false` otherwise.\n *\n * This boolean can be used to perform actions only in development environments,\n * such as logging.\n */\nexport const __PRODUCTION__ = process.env.NODE_ENV === \"production\";\n"],"names":[],"mappings":";;AACA,IAAI,OAAO,YAAY,aAAa;AACnC,aAAW,UAAU,EAAE,KAAK;
|
|
1
|
+
{"version":3,"file":"__PRODUCTION__.cjs","sources":["../../../src/lib/__PRODUCTION__.ts"],"sourcesContent":["// We need to polyfill process if it doesn't exist, such as in the browser.\nif (typeof process === \"undefined\") {\n\tglobalThis.process = { env: {} } as typeof process;\n}\n\n/**\n * `true` if in the production environment, `false` otherwise.\n *\n * This boolean can be used to perform actions only in development environments,\n * such as logging.\n */\nexport const __PRODUCTION__ = process.env.NODE_ENV === \"production\";\n"],"names":[],"mappings":";;AACA,IAAI,OAAO,YAAY,aAAa;AACnC,aAAW,UAAU,EAAE,KAAK;AAC7B;AAQa,MAAA,iBAAiB,QAAQ,IAAI,aAAa;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"__PRODUCTION__.js","sources":["../../../src/lib/__PRODUCTION__.ts"],"sourcesContent":["// We need to polyfill process if it doesn't exist, such as in the browser.\nif (typeof process === \"undefined\") {\n\tglobalThis.process = { env: {} } as typeof process;\n}\n\n/**\n * `true` if in the production environment, `false` otherwise.\n *\n * This boolean can be used to perform actions only in development environments,\n * such as logging.\n */\nexport const __PRODUCTION__ = process.env.NODE_ENV === \"production\";\n"],"names":[],"mappings":"AACA,IAAI,OAAO,YAAY,aAAa;AACnC,aAAW,UAAU,EAAE,KAAK;
|
|
1
|
+
{"version":3,"file":"__PRODUCTION__.js","sources":["../../../src/lib/__PRODUCTION__.ts"],"sourcesContent":["// We need to polyfill process if it doesn't exist, such as in the browser.\nif (typeof process === \"undefined\") {\n\tglobalThis.process = { env: {} } as typeof process;\n}\n\n/**\n * `true` if in the production environment, `false` otherwise.\n *\n * This boolean can be used to perform actions only in development environments,\n * such as logging.\n */\nexport const __PRODUCTION__ = process.env.NODE_ENV === \"production\";\n"],"names":[],"mappings":"AACA,IAAI,OAAO,YAAY,aAAa;AACnC,aAAW,UAAU,EAAE,KAAK;AAC7B;AAQa,MAAA,iBAAiB,QAAQ,IAAI,aAAa;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getSlots.cjs","sources":["../../../src/lib/getSlots.ts"],"sourcesContent":["import { ConcreteComponent, Slots, VNode } from \"vue\";\n\n/**\n * Get the appropriate `slots` object/array according to the provided parent,\n * fixing `Non-function value encountered for default slot.` warnings.\n *\n * @param parent - The parent inheriting slots\n * @param slots - The `slots` to transform for parent\n * @param defaultParams - The parameters to provide to the default slot\n *\n * @returns The appropriate slots object/array\n *\n * @internal\n */\nexport const getSlots = (\n\tparent: string | ConcreteComponent,\n\tslots: Slots,\n\tdefaultPayload?: unknown,\n): VNode[] | undefined | Slots => {\n\tif (typeof parent === \"string\") {\n\t\treturn slots.default && slots.default(defaultPayload);\n\t} else {\n\t\tif (slots.default) {\n\t\t\tconst content = slots.default(defaultPayload);\n\n\t\t\treturn {\n\t\t\t\t...slots,\n\t\t\t\tdefault: () => content,\n\t\t\t};\n\t\t} else {\n\t\t\treturn slots;\n\t\t}\n\t}\n};\n"],"names":[],"mappings":";;AAcO,MAAM,WAAW,CACvB,QACA,OACA,mBACgC;AAC5B,MAAA,OAAO,WAAW,UAAU;AAC/B,WAAO,MAAM,WAAW,MAAM,QAAQ,cAAc;AAAA,EAAA,OAC9C;AACN,QAAI,MAAM,SAAS;AACZ,YAAA,UAAU,MAAM,QAAQ,cAAc;AAErC,aAAA;AAAA,QACN,GAAG;AAAA,QACH,SAAS,MAAM;AAAA,MAAA;AAAA,WAEV;AACC,aAAA;AAAA,
|
|
1
|
+
{"version":3,"file":"getSlots.cjs","sources":["../../../src/lib/getSlots.ts"],"sourcesContent":["import { ConcreteComponent, Slots, VNode } from \"vue\";\n\n/**\n * Get the appropriate `slots` object/array according to the provided parent,\n * fixing `Non-function value encountered for default slot.` warnings.\n *\n * @param parent - The parent inheriting slots\n * @param slots - The `slots` to transform for parent\n * @param defaultParams - The parameters to provide to the default slot\n *\n * @returns The appropriate slots object/array\n *\n * @internal\n */\nexport const getSlots = (\n\tparent: string | ConcreteComponent,\n\tslots: Slots,\n\tdefaultPayload?: unknown,\n): VNode[] | undefined | Slots => {\n\tif (typeof parent === \"string\") {\n\t\treturn slots.default && slots.default(defaultPayload);\n\t} else {\n\t\tif (slots.default) {\n\t\t\tconst content = slots.default(defaultPayload);\n\n\t\t\treturn {\n\t\t\t\t...slots,\n\t\t\t\tdefault: () => content,\n\t\t\t};\n\t\t} else {\n\t\t\treturn slots;\n\t\t}\n\t}\n};\n"],"names":[],"mappings":";;AAcO,MAAM,WAAW,CACvB,QACA,OACA,mBACgC;AAC5B,MAAA,OAAO,WAAW,UAAU;AAC/B,WAAO,MAAM,WAAW,MAAM,QAAQ,cAAc;AAAA,EAAA,OAC9C;AACN,QAAI,MAAM,SAAS;AACZ,YAAA,UAAU,MAAM,QAAQ,cAAc;AAErC,aAAA;AAAA,QACN,GAAG;AAAA,QACH,SAAS,MAAM;AAAA,MAAA;AAAA,WAEV;AACC,aAAA;AAAA,IACR;AAAA,EACD;AACD;;"}
|
package/dist/lib/getSlots.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getSlots.js","sources":["../../../src/lib/getSlots.ts"],"sourcesContent":["import { ConcreteComponent, Slots, VNode } from \"vue\";\n\n/**\n * Get the appropriate `slots` object/array according to the provided parent,\n * fixing `Non-function value encountered for default slot.` warnings.\n *\n * @param parent - The parent inheriting slots\n * @param slots - The `slots` to transform for parent\n * @param defaultParams - The parameters to provide to the default slot\n *\n * @returns The appropriate slots object/array\n *\n * @internal\n */\nexport const getSlots = (\n\tparent: string | ConcreteComponent,\n\tslots: Slots,\n\tdefaultPayload?: unknown,\n): VNode[] | undefined | Slots => {\n\tif (typeof parent === \"string\") {\n\t\treturn slots.default && slots.default(defaultPayload);\n\t} else {\n\t\tif (slots.default) {\n\t\t\tconst content = slots.default(defaultPayload);\n\n\t\t\treturn {\n\t\t\t\t...slots,\n\t\t\t\tdefault: () => content,\n\t\t\t};\n\t\t} else {\n\t\t\treturn slots;\n\t\t}\n\t}\n};\n"],"names":[],"mappings":"AAcO,MAAM,WAAW,CACvB,QACA,OACA,mBACgC;AAC5B,MAAA,OAAO,WAAW,UAAU;AAC/B,WAAO,MAAM,WAAW,MAAM,QAAQ,cAAc;AAAA,EAAA,OAC9C;AACN,QAAI,MAAM,SAAS;AACZ,YAAA,UAAU,MAAM,QAAQ,cAAc;AAErC,aAAA;AAAA,QACN,GAAG;AAAA,QACH,SAAS,MAAM;AAAA,MAAA;AAAA,WAEV;AACC,aAAA;AAAA,
|
|
1
|
+
{"version":3,"file":"getSlots.js","sources":["../../../src/lib/getSlots.ts"],"sourcesContent":["import { ConcreteComponent, Slots, VNode } from \"vue\";\n\n/**\n * Get the appropriate `slots` object/array according to the provided parent,\n * fixing `Non-function value encountered for default slot.` warnings.\n *\n * @param parent - The parent inheriting slots\n * @param slots - The `slots` to transform for parent\n * @param defaultParams - The parameters to provide to the default slot\n *\n * @returns The appropriate slots object/array\n *\n * @internal\n */\nexport const getSlots = (\n\tparent: string | ConcreteComponent,\n\tslots: Slots,\n\tdefaultPayload?: unknown,\n): VNode[] | undefined | Slots => {\n\tif (typeof parent === \"string\") {\n\t\treturn slots.default && slots.default(defaultPayload);\n\t} else {\n\t\tif (slots.default) {\n\t\t\tconst content = slots.default(defaultPayload);\n\n\t\t\treturn {\n\t\t\t\t...slots,\n\t\t\t\tdefault: () => content,\n\t\t\t};\n\t\t} else {\n\t\t\treturn slots;\n\t\t}\n\t}\n};\n"],"names":[],"mappings":"AAcO,MAAM,WAAW,CACvB,QACA,OACA,mBACgC;AAC5B,MAAA,OAAO,WAAW,UAAU;AAC/B,WAAO,MAAM,WAAW,MAAM,QAAQ,cAAc;AAAA,EAAA,OAC9C;AACN,QAAI,MAAM,SAAS;AACZ,YAAA,UAAU,MAAM,QAAQ,cAAc;AAErC,aAAA;AAAA,QACN,GAAG;AAAA,QACH,SAAS,MAAM;AAAA,MAAA;AAAA,WAEV;AACC,aAAA;AAAA,IACR;AAAA,EACD;AACD;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useStatefulPrismicClientMethod.cjs","sources":["../../src/useStatefulPrismicClientMethod.ts"],"sourcesContent":["import {\n\tClient,\n\tForbiddenError,\n\tParsingError,\n\tPrismicError,\n} from \"@prismicio/client\";\nimport { Ref, isRef, ref, shallowRef, unref, watch } from \"vue\";\n\nimport { PrismicClientComposableState, VueUseParameters } from \"./types\";\n\nimport { usePrismic } from \"./usePrismic\";\n\n// Helpers\ntype UnwrapPromise<T> = T extends Promise<infer U> ? U : T;\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype ClientMethodLike = (...args: any[]) => Promise<any> | any;\ntype ClientMethods = typeof Client.prototype;\ntype ClientError = PrismicError<unknown> | ParsingError | ForbiddenError;\n\n// Interfaces\n\n/**\n * @internal\n */\nexport type ClientMethodParameters<TMethodName extends keyof ClientMethods> =\n\tClientMethods[TMethodName] extends ClientMethodLike\n\t\t? VueUseParameters<Parameters<ClientMethods[TMethodName]>>\n\t\t: never;\n\n/**\n * @internal\n */\nexport type ClientMethodReturnType<TMethodName extends keyof ClientMethods> =\n\tClientMethods[TMethodName] extends ClientMethodLike\n\t\t? ReturnType<ClientMethods[TMethodName]>\n\t\t: never;\n\n/**\n * @internal\n */\nexport type ComposableOnlyParameters = {\n\tclient?: Ref<Client> | Client;\n};\n\n/**\n * The return type of a `@prismicio/client` Vue composable.\n *\n * @typeParam TData - The expected format of the `data` property of the returned\n * object\n */\nexport type ClientComposableReturnType<TData = unknown> = {\n\t/**\n\t * The current state of the composable's client method call.\n\t */\n\tstate: Ref<PrismicClientComposableState>;\n\n\t/**\n\t * Data returned by the client.\n\t */\n\tdata: Ref<TData | null>;\n\n\t/**\n\t * Error returned by the composable's client method call if in an errror\n\t * state.\n\t */\n\terror: Ref<ClientError | Error | null>;\n\n\t/**\n\t * Perform the composable's client method call again.\n\t */\n\trefresh: () => Promise<void>;\n};\n\n/**\n * Determines if a value is a `@prismicio/client` params object.\n *\n * @param value - The value to check\n *\n * @returns `true` if `value` is a `@prismicio/client` params object, `false`\n * otherwise\n */\nconst isParams = (\n\tvalue: unknown,\n): value is ClientMethodParameters<\"get\">[0] & ComposableOnlyParameters => {\n\t// This is a *very* naive check.\n\treturn typeof value === \"object\" && value !== null && !Array.isArray(value);\n};\n\n/**\n * A low level Vue composable that uses provided method name on plugin or\n * provided client with given arguments. The composable has its own internal\n * state manager to report async status, such as pending or error statuses.\n *\n * @typeParam TClientMethodName - A method name from `@prismicio/client`\n * @typeParam TClientMethodArguments - The method expected arguments\n * @typeParam TClientMethodReturnType - The method expected return type\n *\n * @param method - The `@prismicio/client` method name to use\n * @param args - The arguments to use with requested method\n *\n * @returns The composable payload {@link ClientComposableReturnType}\n *\n * @internal\n */\nexport const useStatefulPrismicClientMethod = <\n\tTClientMethodName extends keyof ClientMethods,\n\tTClientMethodArguments extends ClientMethodParameters<TClientMethodName>,\n\tTClientMethodReturnType extends UnwrapPromise<\n\t\tClientMethodReturnType<TClientMethodName>\n\t>,\n>(\n\tmethodName: TClientMethodName,\n\targs: TClientMethodArguments,\n): ClientComposableReturnType<TClientMethodReturnType> => {\n\tconst { client } = usePrismic();\n\n\tconst state = ref<PrismicClientComposableState>(\n\t\tPrismicClientComposableState.Idle,\n\t);\n\tconst data = shallowRef<TClientMethodReturnType | null>(null);\n\tconst error = ref<ClientError | Error | null>(null);\n\tconst refresh = async (): Promise<void> => {\n\t\tconst lastArg = unref(args[args.length - 1]);\n\t\tconst { client: explicitClient, ...params } = isParams(lastArg)\n\t\t\t? (lastArg as ClientMethodParameters<\"get\">[0] & ComposableOnlyParameters)\n\t\t\t: ({} as ComposableOnlyParameters);\n\t\tconst argsWithoutParams = isParams(lastArg) ? args.slice(0, -1) : args;\n\n\t\tstate.value = PrismicClientComposableState.Pending;\n\t\tdata.value = null;\n\t\terror.value = null;\n\t\ttry {\n\t\t\tdata.value = await (\n\t\t\t\t(unref(explicitClient) || client)[methodName] as ClientMethodLike\n\t\t\t)(\n\t\t\t\t...argsWithoutParams.map((arg: Ref<unknown> | unknown) => unref(arg)),\n\t\t\t\tparams,\n\t\t\t);\n\t\t\tstate.value = PrismicClientComposableState.Success;\n\t\t} catch (err) {\n\t\t\tstate.value = PrismicClientComposableState.Error;\n\t\t\terror.value = err as ClientError | Error;\n\t\t}\n\t};\n\n\t// Watch reactive args\n\tconst refArgs = args.filter((arg) => isRef(arg));\n\tif (refArgs.length) {\n\t\twatch(refArgs, refresh, { deep: true });\n\t}\n\n\t// Fetch once\n\trefresh();\n\n\treturn { state, data, error, refresh };\n};\n"],"names":["usePrismic","ref","shallowRef","unref","isRef","watch"],"mappings":";;;;AAiFA,MAAM,WAAW,CAChB,UACyE;AAElE,SAAA,OAAO,UAAU,YAAY,UAAU,QAAQ,CAAC,MAAM,QAAQ,KAAK;AAC3E;AAkBa,MAAA,iCAAiC,CAO7C,YACA,SACwD;AAClD,QAAA,EAAE,WAAWA,WAAAA;AAEnB,QAAM,QAAQC,IAAA;AAAA,IAAG;AAAA;AAAA,EAAA;AAGX,QAAA,OAAOC,eAA2C,IAAI;AACtD,QAAA,QAAQD,QAAgC,IAAI;AAClD,QAAM,UAAU,YAA0B;AACzC,UAAM,UAAUE,IAAAA,MAAM,KAAK,KAAK,SAAS,CAAC,CAAC;AACrC,UAAA,EAAE,QAAQ,gBAAgB,GAAG,OAAA,IAAW,SAAS,OAAO,IAC1D,UACA;AACE,UAAA,oBAAoB,SAAS,OAAO,IAAI,KAAK,MAAM,GAAG,EAAE,IAAI;AAElE,UAAM,QAAK;AACX,SAAK,QAAQ;AACb,UAAM,QAAQ;AACV,QAAA;AACH,WAAK,QAAQ,OACXA,IAAAA,MAAM,cAAc,KAAK,QAAQ,UAAU,EAE5C,GAAG,kBAAkB,IAAI,CAAC,QAAgCA,IAAAA,MAAM,GAAG,CAAC,GACpE,MAAM;AAEP,YAAM,QAAK;AAAA,aACH,KAAK;AACb,YAAM,QAAK;AACX,YAAM,QAAQ;AAAA,
|
|
1
|
+
{"version":3,"file":"useStatefulPrismicClientMethod.cjs","sources":["../../src/useStatefulPrismicClientMethod.ts"],"sourcesContent":["import {\n\tClient,\n\tForbiddenError,\n\tParsingError,\n\tPrismicError,\n} from \"@prismicio/client\";\nimport { Ref, isRef, ref, shallowRef, unref, watch } from \"vue\";\n\nimport { PrismicClientComposableState, VueUseParameters } from \"./types\";\n\nimport { usePrismic } from \"./usePrismic\";\n\n// Helpers\ntype UnwrapPromise<T> = T extends Promise<infer U> ? U : T;\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype ClientMethodLike = (...args: any[]) => Promise<any> | any;\ntype ClientMethods = typeof Client.prototype;\ntype ClientError = PrismicError<unknown> | ParsingError | ForbiddenError;\n\n// Interfaces\n\n/**\n * @internal\n */\nexport type ClientMethodParameters<TMethodName extends keyof ClientMethods> =\n\tClientMethods[TMethodName] extends ClientMethodLike\n\t\t? VueUseParameters<Parameters<ClientMethods[TMethodName]>>\n\t\t: never;\n\n/**\n * @internal\n */\nexport type ClientMethodReturnType<TMethodName extends keyof ClientMethods> =\n\tClientMethods[TMethodName] extends ClientMethodLike\n\t\t? ReturnType<ClientMethods[TMethodName]>\n\t\t: never;\n\n/**\n * @internal\n */\nexport type ComposableOnlyParameters = {\n\tclient?: Ref<Client> | Client;\n};\n\n/**\n * The return type of a `@prismicio/client` Vue composable.\n *\n * @typeParam TData - The expected format of the `data` property of the returned\n * object\n */\nexport type ClientComposableReturnType<TData = unknown> = {\n\t/**\n\t * The current state of the composable's client method call.\n\t */\n\tstate: Ref<PrismicClientComposableState>;\n\n\t/**\n\t * Data returned by the client.\n\t */\n\tdata: Ref<TData | null>;\n\n\t/**\n\t * Error returned by the composable's client method call if in an errror\n\t * state.\n\t */\n\terror: Ref<ClientError | Error | null>;\n\n\t/**\n\t * Perform the composable's client method call again.\n\t */\n\trefresh: () => Promise<void>;\n};\n\n/**\n * Determines if a value is a `@prismicio/client` params object.\n *\n * @param value - The value to check\n *\n * @returns `true` if `value` is a `@prismicio/client` params object, `false`\n * otherwise\n */\nconst isParams = (\n\tvalue: unknown,\n): value is ClientMethodParameters<\"get\">[0] & ComposableOnlyParameters => {\n\t// This is a *very* naive check.\n\treturn typeof value === \"object\" && value !== null && !Array.isArray(value);\n};\n\n/**\n * A low level Vue composable that uses provided method name on plugin or\n * provided client with given arguments. The composable has its own internal\n * state manager to report async status, such as pending or error statuses.\n *\n * @typeParam TClientMethodName - A method name from `@prismicio/client`\n * @typeParam TClientMethodArguments - The method expected arguments\n * @typeParam TClientMethodReturnType - The method expected return type\n *\n * @param method - The `@prismicio/client` method name to use\n * @param args - The arguments to use with requested method\n *\n * @returns The composable payload {@link ClientComposableReturnType}\n *\n * @internal\n */\nexport const useStatefulPrismicClientMethod = <\n\tTClientMethodName extends keyof ClientMethods,\n\tTClientMethodArguments extends ClientMethodParameters<TClientMethodName>,\n\tTClientMethodReturnType extends UnwrapPromise<\n\t\tClientMethodReturnType<TClientMethodName>\n\t>,\n>(\n\tmethodName: TClientMethodName,\n\targs: TClientMethodArguments,\n): ClientComposableReturnType<TClientMethodReturnType> => {\n\tconst { client } = usePrismic();\n\n\tconst state = ref<PrismicClientComposableState>(\n\t\tPrismicClientComposableState.Idle,\n\t);\n\tconst data = shallowRef<TClientMethodReturnType | null>(null);\n\tconst error = ref<ClientError | Error | null>(null);\n\tconst refresh = async (): Promise<void> => {\n\t\tconst lastArg = unref(args[args.length - 1]);\n\t\tconst { client: explicitClient, ...params } = isParams(lastArg)\n\t\t\t? (lastArg as ClientMethodParameters<\"get\">[0] & ComposableOnlyParameters)\n\t\t\t: ({} as ComposableOnlyParameters);\n\t\tconst argsWithoutParams = isParams(lastArg) ? args.slice(0, -1) : args;\n\n\t\tstate.value = PrismicClientComposableState.Pending;\n\t\tdata.value = null;\n\t\terror.value = null;\n\t\ttry {\n\t\t\tdata.value = await (\n\t\t\t\t(unref(explicitClient) || client)[methodName] as ClientMethodLike\n\t\t\t)(\n\t\t\t\t...argsWithoutParams.map((arg: Ref<unknown> | unknown) => unref(arg)),\n\t\t\t\tparams,\n\t\t\t);\n\t\t\tstate.value = PrismicClientComposableState.Success;\n\t\t} catch (err) {\n\t\t\tstate.value = PrismicClientComposableState.Error;\n\t\t\terror.value = err as ClientError | Error;\n\t\t}\n\t};\n\n\t// Watch reactive args\n\tconst refArgs = args.filter((arg) => isRef(arg));\n\tif (refArgs.length) {\n\t\twatch(refArgs, refresh, { deep: true });\n\t}\n\n\t// Fetch once\n\trefresh();\n\n\treturn { state, data, error, refresh };\n};\n"],"names":["usePrismic","ref","shallowRef","unref","isRef","watch"],"mappings":";;;;AAiFA,MAAM,WAAW,CAChB,UACyE;AAElE,SAAA,OAAO,UAAU,YAAY,UAAU,QAAQ,CAAC,MAAM,QAAQ,KAAK;AAC3E;AAkBa,MAAA,iCAAiC,CAO7C,YACA,SACwD;AAClD,QAAA,EAAE,WAAWA,WAAAA;AAEnB,QAAM,QAAQC,IAAA;AAAA,IAAG;AAAA;AAAA,EAAA;AAGX,QAAA,OAAOC,eAA2C,IAAI;AACtD,QAAA,QAAQD,QAAgC,IAAI;AAClD,QAAM,UAAU,YAA0B;AACzC,UAAM,UAAUE,IAAAA,MAAM,KAAK,KAAK,SAAS,CAAC,CAAC;AACrC,UAAA,EAAE,QAAQ,gBAAgB,GAAG,OAAA,IAAW,SAAS,OAAO,IAC1D,UACA;AACE,UAAA,oBAAoB,SAAS,OAAO,IAAI,KAAK,MAAM,GAAG,EAAE,IAAI;AAElE,UAAM,QAAK;AACX,SAAK,QAAQ;AACb,UAAM,QAAQ;AACV,QAAA;AACH,WAAK,QAAQ,OACXA,IAAAA,MAAM,cAAc,KAAK,QAAQ,UAAU,EAE5C,GAAG,kBAAkB,IAAI,CAAC,QAAgCA,IAAAA,MAAM,GAAG,CAAC,GACpE,MAAM;AAEP,YAAM,QAAK;AAAA,aACH,KAAK;AACb,YAAM,QAAK;AACX,YAAM,QAAQ;AAAA,IACf;AAAA,EAAA;AAID,QAAM,UAAU,KAAK,OAAO,CAAC,QAAQC,IAAA,MAAM,GAAG,CAAC;AAC/C,MAAI,QAAQ,QAAQ;AACnBC,QAAA,MAAM,SAAS,SAAS,EAAE,MAAM,KAAM,CAAA;AAAA,EACvC;;AAKA,SAAO,EAAE,OAAO,MAAM,OAAO,QAAO;AACrC;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useStatefulPrismicClientMethod.js","sources":["../../src/useStatefulPrismicClientMethod.ts"],"sourcesContent":["import {\n\tClient,\n\tForbiddenError,\n\tParsingError,\n\tPrismicError,\n} from \"@prismicio/client\";\nimport { Ref, isRef, ref, shallowRef, unref, watch } from \"vue\";\n\nimport { PrismicClientComposableState, VueUseParameters } from \"./types\";\n\nimport { usePrismic } from \"./usePrismic\";\n\n// Helpers\ntype UnwrapPromise<T> = T extends Promise<infer U> ? U : T;\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype ClientMethodLike = (...args: any[]) => Promise<any> | any;\ntype ClientMethods = typeof Client.prototype;\ntype ClientError = PrismicError<unknown> | ParsingError | ForbiddenError;\n\n// Interfaces\n\n/**\n * @internal\n */\nexport type ClientMethodParameters<TMethodName extends keyof ClientMethods> =\n\tClientMethods[TMethodName] extends ClientMethodLike\n\t\t? VueUseParameters<Parameters<ClientMethods[TMethodName]>>\n\t\t: never;\n\n/**\n * @internal\n */\nexport type ClientMethodReturnType<TMethodName extends keyof ClientMethods> =\n\tClientMethods[TMethodName] extends ClientMethodLike\n\t\t? ReturnType<ClientMethods[TMethodName]>\n\t\t: never;\n\n/**\n * @internal\n */\nexport type ComposableOnlyParameters = {\n\tclient?: Ref<Client> | Client;\n};\n\n/**\n * The return type of a `@prismicio/client` Vue composable.\n *\n * @typeParam TData - The expected format of the `data` property of the returned\n * object\n */\nexport type ClientComposableReturnType<TData = unknown> = {\n\t/**\n\t * The current state of the composable's client method call.\n\t */\n\tstate: Ref<PrismicClientComposableState>;\n\n\t/**\n\t * Data returned by the client.\n\t */\n\tdata: Ref<TData | null>;\n\n\t/**\n\t * Error returned by the composable's client method call if in an errror\n\t * state.\n\t */\n\terror: Ref<ClientError | Error | null>;\n\n\t/**\n\t * Perform the composable's client method call again.\n\t */\n\trefresh: () => Promise<void>;\n};\n\n/**\n * Determines if a value is a `@prismicio/client` params object.\n *\n * @param value - The value to check\n *\n * @returns `true` if `value` is a `@prismicio/client` params object, `false`\n * otherwise\n */\nconst isParams = (\n\tvalue: unknown,\n): value is ClientMethodParameters<\"get\">[0] & ComposableOnlyParameters => {\n\t// This is a *very* naive check.\n\treturn typeof value === \"object\" && value !== null && !Array.isArray(value);\n};\n\n/**\n * A low level Vue composable that uses provided method name on plugin or\n * provided client with given arguments. The composable has its own internal\n * state manager to report async status, such as pending or error statuses.\n *\n * @typeParam TClientMethodName - A method name from `@prismicio/client`\n * @typeParam TClientMethodArguments - The method expected arguments\n * @typeParam TClientMethodReturnType - The method expected return type\n *\n * @param method - The `@prismicio/client` method name to use\n * @param args - The arguments to use with requested method\n *\n * @returns The composable payload {@link ClientComposableReturnType}\n *\n * @internal\n */\nexport const useStatefulPrismicClientMethod = <\n\tTClientMethodName extends keyof ClientMethods,\n\tTClientMethodArguments extends ClientMethodParameters<TClientMethodName>,\n\tTClientMethodReturnType extends UnwrapPromise<\n\t\tClientMethodReturnType<TClientMethodName>\n\t>,\n>(\n\tmethodName: TClientMethodName,\n\targs: TClientMethodArguments,\n): ClientComposableReturnType<TClientMethodReturnType> => {\n\tconst { client } = usePrismic();\n\n\tconst state = ref<PrismicClientComposableState>(\n\t\tPrismicClientComposableState.Idle,\n\t);\n\tconst data = shallowRef<TClientMethodReturnType | null>(null);\n\tconst error = ref<ClientError | Error | null>(null);\n\tconst refresh = async (): Promise<void> => {\n\t\tconst lastArg = unref(args[args.length - 1]);\n\t\tconst { client: explicitClient, ...params } = isParams(lastArg)\n\t\t\t? (lastArg as ClientMethodParameters<\"get\">[0] & ComposableOnlyParameters)\n\t\t\t: ({} as ComposableOnlyParameters);\n\t\tconst argsWithoutParams = isParams(lastArg) ? args.slice(0, -1) : args;\n\n\t\tstate.value = PrismicClientComposableState.Pending;\n\t\tdata.value = null;\n\t\terror.value = null;\n\t\ttry {\n\t\t\tdata.value = await (\n\t\t\t\t(unref(explicitClient) || client)[methodName] as ClientMethodLike\n\t\t\t)(\n\t\t\t\t...argsWithoutParams.map((arg: Ref<unknown> | unknown) => unref(arg)),\n\t\t\t\tparams,\n\t\t\t);\n\t\t\tstate.value = PrismicClientComposableState.Success;\n\t\t} catch (err) {\n\t\t\tstate.value = PrismicClientComposableState.Error;\n\t\t\terror.value = err as ClientError | Error;\n\t\t}\n\t};\n\n\t// Watch reactive args\n\tconst refArgs = args.filter((arg) => isRef(arg));\n\tif (refArgs.length) {\n\t\twatch(refArgs, refresh, { deep: true });\n\t}\n\n\t// Fetch once\n\trefresh();\n\n\treturn { state, data, error, refresh };\n};\n"],"names":[],"mappings":";;AAiFA,MAAM,WAAW,CAChB,UACyE;AAElE,SAAA,OAAO,UAAU,YAAY,UAAU,QAAQ,CAAC,MAAM,QAAQ,KAAK;AAC3E;AAkBa,MAAA,iCAAiC,CAO7C,YACA,SACwD;AAClD,QAAA,EAAE,WAAW;AAEnB,QAAM,QAAQ;AAAA,IAAG;AAAA;AAAA,EAAA;AAGX,QAAA,OAAO,WAA2C,IAAI;AACtD,QAAA,QAAQ,IAAgC,IAAI;AAClD,QAAM,UAAU,YAA0B;AACzC,UAAM,UAAU,MAAM,KAAK,KAAK,SAAS,CAAC,CAAC;AACrC,UAAA,EAAE,QAAQ,gBAAgB,GAAG,OAAA,IAAW,SAAS,OAAO,IAC1D,UACA;AACE,UAAA,oBAAoB,SAAS,OAAO,IAAI,KAAK,MAAM,GAAG,EAAE,IAAI;AAElE,UAAM,QAAK;AACX,SAAK,QAAQ;AACb,UAAM,QAAQ;AACV,QAAA;AACH,WAAK,QAAQ,OACX,MAAM,cAAc,KAAK,QAAQ,UAAU,EAE5C,GAAG,kBAAkB,IAAI,CAAC,QAAgC,MAAM,GAAG,CAAC,GACpE,MAAM;AAEP,YAAM,QAAK;AAAA,aACH,KAAK;AACb,YAAM,QAAK;AACX,YAAM,QAAQ;AAAA,
|
|
1
|
+
{"version":3,"file":"useStatefulPrismicClientMethod.js","sources":["../../src/useStatefulPrismicClientMethod.ts"],"sourcesContent":["import {\n\tClient,\n\tForbiddenError,\n\tParsingError,\n\tPrismicError,\n} from \"@prismicio/client\";\nimport { Ref, isRef, ref, shallowRef, unref, watch } from \"vue\";\n\nimport { PrismicClientComposableState, VueUseParameters } from \"./types\";\n\nimport { usePrismic } from \"./usePrismic\";\n\n// Helpers\ntype UnwrapPromise<T> = T extends Promise<infer U> ? U : T;\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype ClientMethodLike = (...args: any[]) => Promise<any> | any;\ntype ClientMethods = typeof Client.prototype;\ntype ClientError = PrismicError<unknown> | ParsingError | ForbiddenError;\n\n// Interfaces\n\n/**\n * @internal\n */\nexport type ClientMethodParameters<TMethodName extends keyof ClientMethods> =\n\tClientMethods[TMethodName] extends ClientMethodLike\n\t\t? VueUseParameters<Parameters<ClientMethods[TMethodName]>>\n\t\t: never;\n\n/**\n * @internal\n */\nexport type ClientMethodReturnType<TMethodName extends keyof ClientMethods> =\n\tClientMethods[TMethodName] extends ClientMethodLike\n\t\t? ReturnType<ClientMethods[TMethodName]>\n\t\t: never;\n\n/**\n * @internal\n */\nexport type ComposableOnlyParameters = {\n\tclient?: Ref<Client> | Client;\n};\n\n/**\n * The return type of a `@prismicio/client` Vue composable.\n *\n * @typeParam TData - The expected format of the `data` property of the returned\n * object\n */\nexport type ClientComposableReturnType<TData = unknown> = {\n\t/**\n\t * The current state of the composable's client method call.\n\t */\n\tstate: Ref<PrismicClientComposableState>;\n\n\t/**\n\t * Data returned by the client.\n\t */\n\tdata: Ref<TData | null>;\n\n\t/**\n\t * Error returned by the composable's client method call if in an errror\n\t * state.\n\t */\n\terror: Ref<ClientError | Error | null>;\n\n\t/**\n\t * Perform the composable's client method call again.\n\t */\n\trefresh: () => Promise<void>;\n};\n\n/**\n * Determines if a value is a `@prismicio/client` params object.\n *\n * @param value - The value to check\n *\n * @returns `true` if `value` is a `@prismicio/client` params object, `false`\n * otherwise\n */\nconst isParams = (\n\tvalue: unknown,\n): value is ClientMethodParameters<\"get\">[0] & ComposableOnlyParameters => {\n\t// This is a *very* naive check.\n\treturn typeof value === \"object\" && value !== null && !Array.isArray(value);\n};\n\n/**\n * A low level Vue composable that uses provided method name on plugin or\n * provided client with given arguments. The composable has its own internal\n * state manager to report async status, such as pending or error statuses.\n *\n * @typeParam TClientMethodName - A method name from `@prismicio/client`\n * @typeParam TClientMethodArguments - The method expected arguments\n * @typeParam TClientMethodReturnType - The method expected return type\n *\n * @param method - The `@prismicio/client` method name to use\n * @param args - The arguments to use with requested method\n *\n * @returns The composable payload {@link ClientComposableReturnType}\n *\n * @internal\n */\nexport const useStatefulPrismicClientMethod = <\n\tTClientMethodName extends keyof ClientMethods,\n\tTClientMethodArguments extends ClientMethodParameters<TClientMethodName>,\n\tTClientMethodReturnType extends UnwrapPromise<\n\t\tClientMethodReturnType<TClientMethodName>\n\t>,\n>(\n\tmethodName: TClientMethodName,\n\targs: TClientMethodArguments,\n): ClientComposableReturnType<TClientMethodReturnType> => {\n\tconst { client } = usePrismic();\n\n\tconst state = ref<PrismicClientComposableState>(\n\t\tPrismicClientComposableState.Idle,\n\t);\n\tconst data = shallowRef<TClientMethodReturnType | null>(null);\n\tconst error = ref<ClientError | Error | null>(null);\n\tconst refresh = async (): Promise<void> => {\n\t\tconst lastArg = unref(args[args.length - 1]);\n\t\tconst { client: explicitClient, ...params } = isParams(lastArg)\n\t\t\t? (lastArg as ClientMethodParameters<\"get\">[0] & ComposableOnlyParameters)\n\t\t\t: ({} as ComposableOnlyParameters);\n\t\tconst argsWithoutParams = isParams(lastArg) ? args.slice(0, -1) : args;\n\n\t\tstate.value = PrismicClientComposableState.Pending;\n\t\tdata.value = null;\n\t\terror.value = null;\n\t\ttry {\n\t\t\tdata.value = await (\n\t\t\t\t(unref(explicitClient) || client)[methodName] as ClientMethodLike\n\t\t\t)(\n\t\t\t\t...argsWithoutParams.map((arg: Ref<unknown> | unknown) => unref(arg)),\n\t\t\t\tparams,\n\t\t\t);\n\t\t\tstate.value = PrismicClientComposableState.Success;\n\t\t} catch (err) {\n\t\t\tstate.value = PrismicClientComposableState.Error;\n\t\t\terror.value = err as ClientError | Error;\n\t\t}\n\t};\n\n\t// Watch reactive args\n\tconst refArgs = args.filter((arg) => isRef(arg));\n\tif (refArgs.length) {\n\t\twatch(refArgs, refresh, { deep: true });\n\t}\n\n\t// Fetch once\n\trefresh();\n\n\treturn { state, data, error, refresh };\n};\n"],"names":[],"mappings":";;AAiFA,MAAM,WAAW,CAChB,UACyE;AAElE,SAAA,OAAO,UAAU,YAAY,UAAU,QAAQ,CAAC,MAAM,QAAQ,KAAK;AAC3E;AAkBa,MAAA,iCAAiC,CAO7C,YACA,SACwD;AAClD,QAAA,EAAE,WAAW;AAEnB,QAAM,QAAQ;AAAA,IAAG;AAAA;AAAA,EAAA;AAGX,QAAA,OAAO,WAA2C,IAAI;AACtD,QAAA,QAAQ,IAAgC,IAAI;AAClD,QAAM,UAAU,YAA0B;AACzC,UAAM,UAAU,MAAM,KAAK,KAAK,SAAS,CAAC,CAAC;AACrC,UAAA,EAAE,QAAQ,gBAAgB,GAAG,OAAA,IAAW,SAAS,OAAO,IAC1D,UACA;AACE,UAAA,oBAAoB,SAAS,OAAO,IAAI,KAAK,MAAM,GAAG,EAAE,IAAI;AAElE,UAAM,QAAK;AACX,SAAK,QAAQ;AACb,UAAM,QAAQ;AACV,QAAA;AACH,WAAK,QAAQ,OACX,MAAM,cAAc,KAAK,QAAQ,UAAU,EAE5C,GAAG,kBAAkB,IAAI,CAAC,QAAgC,MAAM,GAAG,CAAC,GACpE,MAAM;AAEP,YAAM,QAAK;AAAA,aACH,KAAK;AACb,YAAM,QAAK;AACX,YAAM,QAAQ;AAAA,IACf;AAAA,EAAA;AAID,QAAM,UAAU,KAAK,OAAO,CAAC,QAAQ,MAAM,GAAG,CAAC;AAC/C,MAAI,QAAQ,QAAQ;AACnB,UAAM,SAAS,SAAS,EAAE,MAAM,KAAM,CAAA;AAAA,EACvC;;AAKA,SAAO,EAAE,OAAO,MAAM,OAAO,QAAO;AACrC;"}
|