@plasmicapp/loader-react 1.0.397 → 1.0.399
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/index.d.ts +2 -0
- package/dist/index.esm.js +23 -1
- package/dist/index.esm.js.map +2 -2
- package/dist/index.js +23 -1
- package/dist/index.js.map +2 -2
- package/dist/react-server.d.ts +2 -0
- package/dist/react-server.esm.js +11 -0
- package/dist/react-server.esm.js.map +2 -2
- package/dist/react-server.js +11 -0
- package/dist/react-server.js.map +2 -2
- package/package.json +6 -6
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/react-server.ts", "../src/loader-server.tsx", "../src/loader-shared.ts", "../src/bundles.ts", "../src/utils.tsx", "../src/component-lookup.ts", "../src/variation.ts", "../src/swr-util.ts", "../src/prepass-server.ts"],
|
|
4
|
-
"sourcesContent": ["import \"server-only\";\n\nimport { InternalPrepassPlasmicLoader } from \"./loader-server\";\nimport { InitOptions, PlasmicComponentLoader } from \"./loader-shared\";\n\nexport { extractPlasmicQueryData as __EXPERMIENTAL__extractPlasmicQueryData } from \"./prepass-server\";\nexport * from \"./shared-exports\";\nexport {\n InternalPrepassPlasmicLoader as InternalPlasmicComponentLoader,\n PlasmicComponentLoader,\n};\n\nexport function initPlasmicLoader(opts: InitOptions): PlasmicComponentLoader {\n const internal = new InternalPrepassPlasmicLoader(opts);\n return new PlasmicComponentLoader(internal);\n}\n", "import type { TokenRegistration, TraitMeta } from \"@plasmicapp/host\";\nimport { PlasmicModulesFetcher } from \"@plasmicapp/loader-core\";\nimport type {\n PlasmicPrepassContext,\n useMutablePlasmicQueryData,\n} from \"@plasmicapp/query\";\nimport React from \"react\";\nimport ReactDOM from \"react-dom\";\nimport * as jsxDevRuntime from \"react/jsx-dev-runtime\";\nimport * as jsxRuntime from \"react/jsx-runtime\";\nimport type { PlasmicComponent } from \"./PlasmicComponent\";\nimport type {\n PlasmicRootContextValue,\n PlasmicRootProvider,\n} from \"./PlasmicRootProvider\";\nimport {\n BaseInternalPlasmicComponentLoader,\n CodeComponentMeta,\n CustomFunctionMeta,\n GlobalContextMeta,\n InitOptions,\n REGISTERED_CODE_COMPONENT_HELPERS,\n REGISTERED_CUSTOM_FUNCTIONS,\n SUBSTITUTED_COMPONENTS,\n SUBSTITUTED_GLOBAL_VARIANT_HOOKS,\n ServerProvidedContext,\n ServerProvidedData,\n internalSetRegisteredFunction,\n} from \"./loader-shared\";\nimport { swrSerialize } from \"./swr-util\";\nimport {\n getGlobalVariantsFromSplits,\n mergeGlobalVariantsSpec,\n} from \"./variation\";\n\nconst noop: (...args: any) => void = () => {};\nconst identity = <T,>(x: T): T => x;\nconst unreachable: (...args: any) => never = () => {\n debugger;\n throw new Error(\"Unreachable code\");\n};\n\nconst REACT_PROVIDER_TYPE =\n typeof Symbol === \"function\" && Symbol.for\n ? Symbol.for(\"react.provider\")\n : (0xeacd as any as symbol);\n\nexport const FakeRootProviderContext: React.Context<any> = {\n _currentValue: undefined, // default value\n} as any;\n\nconst FakeDataContext: React.Context<any> = {\n _currentValue: undefined, // default value\n} as any;\n\nconst FakePlasmicComponentContext: React.Context<boolean> = {\n _currentValue: false, // default value\n} as any;\n\nconst FakePlasmicPrepassContext: React.Context<any> = {\n _currentValue: undefined,\n} as any;\n\nconst mkMetaName = (name: string) => `__plasmic_meta_${name}`;\n\nfunction FakeDataCtxReader({ children }: { children: ($ctx: any) => any }) {\n const $ctx = getPrepassContextEnv().readContextValue(FakeDataContext);\n return children($ctx);\n}\n\nfunction FakeDataProvider({\n name,\n data,\n hidden,\n advanced,\n label,\n children,\n}: any) {\n const { readContextValue, setContextValue } = getPrepassContextEnv();\n const existingEnv = readContextValue(FakeDataContext) ?? {};\n if (!name) {\n return <>{children}</>;\n } else {\n setContextValue(FakeDataContext, {\n ...existingEnv,\n [name]: data,\n [mkMetaName(name)]: { hidden, advanced, label },\n });\n return <>{children}</>;\n }\n}\n\nconst fakeApplySelector = (rawData: any, selector: string | undefined) => {\n if (!selector) {\n return undefined;\n }\n let curData = rawData;\n for (const key of selector.split(\".\")) {\n curData = curData?.[key];\n }\n return curData;\n};\n\nfunction fakeUseSelector(selector: string | undefined): any {\n const rawData = getPrepassContextEnv().readContextValue(FakeDataContext);\n return fakeApplySelector(rawData, selector);\n}\n\nfunction fakeUseSelectors(selectors = {}): any {\n const rawData = getPrepassContextEnv().readContextValue(FakeDataContext);\n return Object.fromEntries(\n Object.entries(selectors)\n .filter(([key, selector]) => !!key && !!selector)\n .map(([key, selector]) => [\n key,\n fakeApplySelector(rawData, selector as string),\n ])\n );\n}\n\nfunction fakeUsePlasmicDataConfig() {\n const cache = getPrepassContextEnv().readContextValue(\n FakePlasmicPrepassContext\n );\n return { cache } as any;\n}\n\nconst fakeUseMutablePlasmicQueryData: typeof useMutablePlasmicQueryData = (\n unserializedKey,\n fetcher\n) => {\n const [key, args] = swrSerialize(unserializedKey);\n if (!key) {\n return {\n isValidating: false,\n mutate: (async () => {}) as any,\n data: undefined,\n };\n }\n const cache = fakeUsePlasmicDataConfig().cache as Map<string, any>;\n if (cache.has(key)) {\n return {\n isValidating: false,\n mutate: (async () => {}) as any,\n data: cache.get(key),\n };\n }\n const response = fetcher(...(args as any));\n if (response && typeof (response as Promise<any>).then == \"function\") {\n throw (response as Promise<any>).then((data) => cache.set(key, data));\n } else {\n cache.set(key, response);\n return {\n isValidating: false,\n mutate: (async () => {}) as any,\n data: cache.get(key),\n };\n }\n};\n\n/**\n * Class components cannot be server components, and for that reason React\n * doesn't even allow calling `createElement` on them if they are not client\n * references.\n *\n * For prepass, we replace the actual Component class with this fake one, and\n * use it as an adaptor to creating a function component instead, before calling\n * `createElement`.\n */\nconst FakeReactComponent = class FakeReactComponent {\n context = undefined;\n static contextType: any = undefined;\n props: any = {};\n setState: (v: any) => void = (v) => void (this.state = v);\n forceUpdate = noop;\n initRender(props: any) {\n // Called before render to set the appropriate values for props, state,\n // context... Use hooks to simulate the class component behavior.\n this.props = props;\n const dispatcher = (React as any)\n .__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentDispatcher\n .current;\n const [state, setState] = dispatcher.useState({});\n this.state = state;\n this.setState = setState;\n if ((this.constructor as any).contextType) {\n this.context = dispatcher.useContext(\n (this.constructor as any).contextType\n );\n }\n }\n render = () => null;\n state: any = {};\n refs = {};\n} satisfies typeof React.Component;\n\nconst fakeCreateElement: <F extends (type: any, ...args: any[]) => any>(\n originalFn: F\n) => F = ((originalCreateElement: Function) =>\n (type: any, ...args: any[]) => {\n if (Object.prototype.isPrototypeOf.call(FakeReactComponent, type)) {\n return originalCreateElement((props: any) => {\n const instance: InstanceType<typeof FakeReactComponent> = new type();\n instance.initRender(props);\n return instance.render();\n }, ...args);\n }\n return originalCreateElement(type, ...args);\n }) as any;\n\nexport class InternalPrepassPlasmicLoader extends BaseInternalPlasmicComponentLoader {\n constructor(opts: InitOptions) {\n super({\n opts,\n onBundleMerged: () => {\n this.refreshRegistry();\n },\n fetcher: new PlasmicModulesFetcher(opts),\n builtinModules: {\n react: {\n ...React,\n // We use this flag to indicate our packages fecthed from loader that\n // we are running in RSC environment\n ...({ isRSC: true } as any),\n createContext: <T,>(defaultValue?: T) => {\n const context: React.Context<T> = {\n _currentValue: defaultValue,\n displayName: \"FakeContext\",\n Provider: ({ value, children }: any) => {\n getPrepassContextEnv().setContextValue(context, value);\n return <>{children}</>;\n },\n Consumer: ({ children }: any) =>\n children(getPrepassContextEnv().readContextValue(context)),\n } as any;\n return context;\n },\n ...Object.fromEntries(\n [\n \"useCallback\",\n \"useContext\",\n \"useEffect\",\n \"useImperativeHandle\",\n \"useDebugValue\",\n \"useInsertionEffect\",\n \"useLayoutEffect\",\n \"useMemo\",\n \"useSyncExternalStore\",\n \"useReducer\",\n \"useRef\",\n \"useState\",\n ].map((hook) => [\n hook,\n (...args: any) => {\n const dispatcher = (React as any)\n .__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED\n .ReactCurrentDispatcher.current;\n return dispatcher[hook](...args);\n },\n ])\n ),\n useDeferredValue: (v) => v,\n useTransition: () => [\n false,\n (f) => {\n f();\n },\n ],\n createFactory: (type: any) =>\n React.createElement.bind(null, type) as any,\n Component: FakeReactComponent,\n PureComponent: FakeReactComponent,\n createElement: fakeCreateElement(React.createElement),\n },\n \"react-dom\": ReactDOM,\n \"react/jsx-runtime\": {\n ...jsxRuntime,\n ...((jsxRuntime as any).jsx\n ? { jsx: fakeCreateElement((jsxRuntime as any).jsx) }\n : {}),\n ...((jsxRuntime as any).jsxs\n ? { jsxs: fakeCreateElement((jsxRuntime as any).jsxs) }\n : {}),\n ...((jsxRuntime as any).jsxDEV\n ? { jsxDEV: fakeCreateElement((jsxRuntime as any).jsxDEV) }\n : {}),\n },\n \"react/jsx-dev-runtime\": {\n ...jsxDevRuntime,\n ...((jsxDevRuntime as any).jsx\n ? { jsx: fakeCreateElement((jsxDevRuntime as any).jsx) }\n : {}),\n ...((jsxDevRuntime as any).jsxs\n ? { jsxs: fakeCreateElement((jsxDevRuntime as any).jsxs) }\n : {}),\n ...((jsxDevRuntime as any).jsxDEV\n ? { jsxDEV: fakeCreateElement((jsxDevRuntime as any).jsxDEV) }\n : {}),\n },\n \"@plasmicapp/query\": {\n addLoadingStateListener: () => noop,\n isPlasmicPrepass: () => true,\n PlasmicPrepassContext: {} as any,\n PlasmicQueryDataProvider: ({ children }: any) => <>{children}</>,\n useMutablePlasmicQueryData: fakeUseMutablePlasmicQueryData,\n usePlasmicDataConfig: fakeUsePlasmicDataConfig,\n usePlasmicQueryData: fakeUseMutablePlasmicQueryData,\n useSWRConfig: unreachable,\n wrapLoadingFetcher: identity,\n HeadMetadataContext: {\n _currentValue: {},\n displayName: \"FakeHeadMetadataContext\",\n Provider: ({ children }: any) => <>{children}</>,\n Consumer: ({ children }: any) => children({}),\n } as any as React.Context<any>,\n },\n \"@plasmicapp/data-sources-context\": (() => {\n const FakePlasmicDataSourceContext: React.Context<any> = {\n _currentValue: undefined, // default value\n } as any;\n return {\n PlasmicDataSourceContextProvider: Object.assign(\n ({ children, value }: any) => {\n const { setContextValue } = getPrepassContextEnv();\n setContextValue(FakePlasmicDataSourceContext, value);\n return <>{children}</>;\n },\n {\n $$typeof: REACT_PROVIDER_TYPE,\n _context: FakePlasmicDataSourceContext,\n }\n ),\n useCurrentUser: () => {\n const { readContextValue } = getPrepassContextEnv();\n const ctx = readContextValue(FakePlasmicDataSourceContext);\n return (\n ctx?.user ?? {\n isLoggedIn: false,\n }\n );\n },\n usePlasmicDataSourceContext: () => {\n const { readContextValue } = getPrepassContextEnv();\n return readContextValue(FakePlasmicDataSourceContext);\n },\n };\n })(),\n \"@plasmicapp/host\": (() => {\n return {\n applySelector: fakeApplySelector,\n DataContext: FakeDataContext,\n DataCtxReader: FakeDataCtxReader,\n DataProvider: FakeDataProvider,\n GlobalActionsContext: {\n _currentValue: undefined, // default value\n } as any as React.Context<any>,\n GlobalActionsProvider: ({ children }) => <>{children}</>,\n mkMetaName,\n mkMetaValue: identity,\n PageParamsProvider: ({ children }) => <>{children}</>,\n PlasmicCanvasContext: { _currentValue: false } as any,\n PlasmicCanvasHost: () => null,\n PlasmicLinkProvider: ({ children }) => <>{children}</>,\n registerComponent: noop,\n registerFunction: noop,\n registerGlobalContext: noop,\n registerToken: noop,\n registerTrait: noop,\n repeatedElement: unreachable,\n stateHelpersKeys: [\"initFunc\", \"onChangeArgsToValue\", \"onMutate\"],\n unstable_registerFetcher: noop,\n useDataEnv: () =>\n getPrepassContextEnv().readContextValue(FakeDataContext),\n useGlobalActions: () =>\n new Proxy(\n {},\n {\n get: () => noop,\n }\n ),\n usePlasmicTranslator: () => undefined,\n PlasmicTranslatorContext: { _currentValue: undefined } as any,\n usePlasmicCanvasContext: () => false,\n usePlasmicLink: () => (props) => <a {...props} />,\n usePlasmicLinkMaybe: () => undefined,\n useSelector: fakeUseSelector,\n useSelectors: fakeUseSelectors,\n usePlasmicCanvasComponentInfo: () => null,\n };\n })(),\n \"@plasmicapp/loader-runtime-registry\": {\n components: SUBSTITUTED_COMPONENTS,\n globalVariantHooks: SUBSTITUTED_GLOBAL_VARIANT_HOOKS,\n codeComponentHelpers: REGISTERED_CODE_COMPONENT_HELPERS,\n functions: REGISTERED_CUSTOM_FUNCTIONS,\n },\n },\n });\n }\n\n registerComponent<T extends React.ComponentType<any>>(\n component: T,\n meta: CodeComponentMeta<React.ComponentProps<T>>\n ) {\n // making the component meta consistent between codegen and loader\n const stateHelpers = Object.fromEntries(\n Object.entries(meta.states ?? {})\n .filter(\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n ([_, stateSpec]) =>\n // `initFunc` is the only helper function used in RSC phase\n \"initFunc\" in stateSpec\n )\n .map(([stateName, stateSpec]) => [\n stateName,\n { initFunc: stateSpec.initFunc },\n ])\n );\n const helpers = { states: stateHelpers };\n this.internalSubstituteComponent(\n meta.getServerInfo\n ? (props) => {\n const { readContextValue } = getPrepassContextEnv();\n\n const serverInfo = meta.getServerInfo?.(props, {\n readContext: readContextValue as any,\n readDataEnv: () => readContextValue(FakeDataContext),\n readDataSelector: fakeUseSelector,\n readDataSelectors: fakeUseSelectors,\n fetchData: fakeUseMutablePlasmicQueryData,\n });\n\n if (serverInfo && serverInfo.children) {\n const contents: React.ReactNode[] = [] as React.ReactNode[];\n const children = Array.isArray(serverInfo.children)\n ? serverInfo.children\n : [serverInfo.children];\n children.forEach((childData) => {\n contents.push(\n <ContextAndDataProviderWrapper contextAndData={childData}>\n {childData.node}\n </ContextAndDataProviderWrapper>\n );\n });\n return (\n <ContextAndDataProviderWrapper contextAndData={serverInfo}>\n {contents}\n </ContextAndDataProviderWrapper>\n );\n } else {\n return (\n <ContextAndDataProviderWrapper\n contextAndData={serverInfo ?? {}}\n >\n {Object.values(props)\n .flat(Infinity)\n .filter(\n (v: any): v is React.ReactNode =>\n v &&\n typeof v == \"object\" &&\n v.$$typeof &&\n React.isValidElement(v)\n )}\n </ContextAndDataProviderWrapper>\n );\n }\n }\n : component,\n { name: meta.name, isCode: true },\n Object.keys(stateHelpers).length > 0 ? helpers : undefined\n );\n }\n\n registerFunction<F extends (...args: any[]) => any>(\n fn: F,\n meta: CustomFunctionMeta<F>\n ) {\n internalSetRegisteredFunction(fn, meta);\n }\n\n registerGlobalContext<T extends React.ComponentType<any>>(\n context: T,\n meta: GlobalContextMeta<React.ComponentProps<T>>\n ) {\n this.substituteComponent(context, { name: meta.name, isCode: true });\n }\n\n registerTrait: (trait: string, meta: TraitMeta) => void = noop;\n\n registerToken: (token: TokenRegistration) => void = noop;\n\n refreshRegistry() {\n // We swap global variants' useXXXGlobalVariant() hook with\n // a fake one that just reads from the PlasmicRootContext. Because\n // global variant values are not supplied by the generated global variant\n // context providers, but instead by <PlasmicRootProvider/> and by\n // PlasmicComponentLoader.setGlobalVariants(), we redirect these\n // hooks to read from them instead.\n for (const globalGroup of this.getBundle().globalGroups) {\n if (globalGroup.type !== \"global-screen\") {\n SUBSTITUTED_GLOBAL_VARIANT_HOOKS[globalGroup.id] = () => {\n const rootContext = getPrepassContextEnv().readContextValue(\n FakeRootProviderContext\n );\n const loader = this;\n const { name, projectId } = globalGroup;\n const spec = [\n ...loader.getGlobalVariants(),\n ...(rootContext.globalVariants ?? []),\n ].find(\n (s) =>\n s.name === name && (!s.projectId || s.projectId === projectId)\n );\n return spec ? spec.value : undefined;\n };\n }\n }\n super.refreshRegistry();\n }\n}\nexport function handlePrepassPlasmicRootComponent(\n props: Parameters<typeof PlasmicRootProvider>[0]\n) {\n const {\n globalVariants,\n globalContextsProps,\n variation,\n translator,\n Head,\n Link,\n pageRoute,\n pageParams,\n pageQuery,\n suspenseFallback,\n disableLoadingBoundary,\n user,\n userAuthToken,\n isUserLoading,\n authRedirectUri,\n } = props;\n const loader = (props.loader as any)\n .__internal as InternalPrepassPlasmicLoader;\n\n const splits = loader.getActiveSplits();\n const value = {\n globalVariants: mergeGlobalVariantsSpec(\n globalVariants ?? [],\n getGlobalVariantsFromSplits(splits, variation ?? {})\n ),\n globalContextsProps,\n loader,\n variation,\n translator,\n Head,\n Link,\n user,\n userAuthToken,\n isUserLoading,\n authRedirectUri,\n suspenseFallback,\n disableLoadingBoundary,\n };\n\n const { setContextValue, readContextValue } = getPrepassContextEnv();\n\n setContextValue(FakeRootProviderContext, value);\n\n const existingEnv = readContextValue(FakeDataContext) ?? {};\n\n // We can't re-use these functions from @plasmiapp/host while it's a\n // client component package :/\n const fixCatchallParams = (\n params: Record<string, string | string[] | undefined>\n ) => {\n const newParams: Record<string, string | string[]> = {};\n for (const [key, val] of Object.entries(params)) {\n if (!val) {\n continue;\n }\n if (key.startsWith(\"...\")) {\n newParams[key.slice(3)] =\n typeof val === \"string\"\n ? val.replace(/^\\/|\\/$/g, \"\").split(\"/\")\n : val;\n } else {\n newParams[key] = val;\n }\n }\n return newParams;\n };\n\n const mkPathFromRouteAndParams = (\n route: string,\n params: Record<string, string | string[] | undefined>\n ) => {\n if (!params) {\n return route;\n }\n let path = route;\n for (const [key, val] of Object.entries(params)) {\n if (typeof val === \"string\") {\n path = path.replace(`[${key}]`, val);\n } else if (Array.isArray(val)) {\n if (path.includes(`[[...${key}]]`)) {\n path = path.replace(`[[...${key}]]`, val.join(\"/\"));\n } else if (path.includes(`[...${key}]`)) {\n path = path.replace(`[...${key}]`, val.join(\"/\"));\n }\n }\n }\n return path;\n };\n\n const fixedParams = fixCatchallParams(pageParams ?? {});\n\n setContextValue(FakeDataContext, {\n ...existingEnv,\n [\"pageRoute\"]: pageRoute,\n [mkMetaName(\"pageRoute\")]: { advanced: true, label: \"Page route\" },\n\n [\"pagePath\"]: pageRoute\n ? mkPathFromRouteAndParams(pageRoute, fixedParams)\n : undefined,\n [mkMetaName(\"pagePath\")]: { label: \"Page path\" },\n\n [\"params\"]: { ...existingEnv.params, ...fixedParams },\n [mkMetaName(\"params\")]: { label: \"Page URL path params\" },\n\n [\"query\"]: { ...existingEnv.query, ...pageQuery },\n [mkMetaName(\"query\")]: { label: \"Page URL query params\" },\n });\n}\n\nexport function handlePrepassPlasmicComponent(\n props: Parameters<typeof PlasmicComponent>[0]\n) {\n const { component, projectId, componentProps, forceOriginal } = props;\n const { setContextValue, readContextValue } = getPrepassContextEnv();\n const rootContext: PlasmicRootContextValue = readContextValue(\n FakeRootProviderContext\n );\n const isRootLoader = !readContextValue(FakePlasmicComponentContext);\n if (!rootContext) {\n // no existing PlasmicRootProvider\n throw new Error(\n `You must use <PlasmicRootProvider/> at the root of your app`\n );\n }\n const {\n loader,\n globalContextsProps,\n userAuthToken,\n isUserLoading,\n authRedirectUri,\n translator,\n ...rest\n } = rootContext;\n\n const spec = { name: component, projectId, isCode: false };\n const opts = { forceOriginal };\n\n const lookup = loader.getLookup();\n\n if (!lookup.hasComponent(spec)) {\n return null;\n }\n\n const Component = lookup.getComponent(spec, opts);\n\n let element = <Component {...componentProps} />;\n if (isRootLoader) {\n const ReactWebRootProvider = lookup.getRootProvider();\n const GlobalContextsProvider = lookup.getGlobalContextsProvider({\n name: component,\n projectId,\n });\n setContextValue(FakePlasmicComponentContext, true);\n element = (\n <ReactWebRootProvider\n {...rest}\n userAuthToken={userAuthToken}\n isUserLoading={isUserLoading}\n authRedirectUri={authRedirectUri}\n i18n={{\n translator,\n tagPrefix: loader.opts.i18n?.tagPrefix,\n }}\n >\n {element}\n </ReactWebRootProvider>\n );\n if (GlobalContextsProvider) {\n element = (\n <GlobalContextsProvider {...globalContextsProps}>\n {element}\n </GlobalContextsProvider>\n );\n }\n }\n return element;\n}\n\nexport function handlePlasmicPrepassContext({\n cache,\n}: Parameters<typeof PlasmicPrepassContext>[0]) {\n getPrepassContextEnv().setContextValue(FakePlasmicPrepassContext, cache);\n}\n\nfunction getPrepassContextEnv(): {\n setContextValue: (context: React.Context<any>, value: any) => void;\n readContextValue: (context: React.Context<any>) => any;\n} {\n return (globalThis as any).__ssrPrepassEnv;\n}\n\n// Provides context values to the children, described by\n// `ComponentMeta.getServerInfo`.\nfunction ContextAndDataProviderWrapper({\n children,\n contextAndData,\n}: {\n children: React.ReactNode;\n contextAndData: {\n providedData?: ServerProvidedData | ServerProvidedData[];\n providedContexts?: ServerProvidedContext | ServerProvidedContext[];\n };\n}) {\n const { setContextValue, readContextValue } = getPrepassContextEnv();\n const contexts = contextAndData.providedContexts\n ? Array.isArray(contextAndData.providedContexts)\n ? contextAndData.providedContexts\n : [contextAndData.providedContexts]\n : [];\n const providedData = contextAndData.providedData\n ? Array.isArray(contextAndData.providedData)\n ? contextAndData.providedData\n : [contextAndData.providedData]\n : [];\n contexts.forEach((context) => {\n setContextValue(context.contextKey as any, context.value);\n });\n let $ctx = readContextValue(FakeDataContext) ?? {};\n providedData.forEach(({ name, data }) => {\n $ctx = {\n ...$ctx,\n [name]: data,\n };\n });\n setContextValue(FakeDataContext, $ctx);\n return <>{children}</>;\n}\n", "import type {\n ComponentHelpers,\n ComponentHelpers as InternalCodeComponentHelpers,\n CodeComponentMeta as InternalCodeComponentMeta,\n CustomFunctionMeta as InternalCustomFunctionMeta,\n GlobalContextMeta as InternalGlobalContextMeta,\n StateHelpers,\n StateSpec,\n TokenRegistration,\n TraitMeta,\n useDataEnv,\n useSelector,\n useSelectors,\n} from \"@plasmicapp/host\";\nimport {\n LoaderBundleCache,\n PageMeta,\n PlasmicModulesFetcher,\n Registry,\n TrackRenderOptions,\n} from \"@plasmicapp/loader-core\";\nimport {\n CodeModule,\n ComponentMeta,\n LoaderBundleOutput,\n internal_getCachedBundleInNodeServer,\n} from \"@plasmicapp/loader-fetcher\";\nimport { getActiveVariation, getExternalIds } from \"@plasmicapp/loader-splits\";\nimport type { useMutablePlasmicQueryData } from \"@plasmicapp/query\";\nimport type { GlobalVariantSpec } from \"./PlasmicRootProvider\";\nimport { mergeBundles, prepComponentData } from \"./bundles\";\nimport { ComponentLookup } from \"./component-lookup\";\nimport {\n ComponentLookupSpec,\n getCompMetas,\n getLookupSpecName,\n isBrowser,\n isDynamicPagePath,\n uniq,\n} from \"./utils\";\nimport { getPlasmicCookieValues, updatePlasmicCookieValue } from \"./variation\";\n\nexport interface InitOptions {\n projects: {\n id: string;\n token: string;\n version?: string;\n }[];\n cache?: LoaderBundleCache;\n platform?: \"react\" | \"nextjs\" | \"gatsby\";\n platformOptions?: {\n nextjs?: {\n appDir: boolean;\n };\n };\n preview?: boolean;\n host?: string;\n onClientSideFetch?: \"warn\" | \"error\";\n i18n?: {\n keyScheme: \"content\" | \"hash\" | \"path\";\n tagPrefix?: string;\n };\n /**\n * @deprecated use i18n.keyScheme instead\n */\n i18nKeyScheme?: \"content\" | \"hash\";\n\n /**\n * By default, fetchComponentData() and fetchPages() calls cached in memory\n * with the PlasmicComponentLoader instance. If alwaysFresh is true, then\n * data is always freshly fetched over the network.\n */\n alwaysFresh?: boolean;\n\n /**\n * If true, generated code from the server won't include page metadata tags\n */\n skipHead?: boolean;\n\n /**\n * If true, uses browser / node's native fetch\n */\n nativeFetch?: boolean;\n\n /**\n * If true, will not redirect to the codegen server automatically, and will\n * try to reuse the existing bundle in the cache.\n */\n manualRedirect?: boolean;\n}\n\nexport interface ComponentRenderData {\n entryCompMetas: (ComponentMeta & { params?: Record<string, string> })[];\n bundle: LoaderBundleOutput;\n remoteFontUrls: string[];\n}\n\nexport interface ComponentSubstitutionSpec {\n lookup: ComponentLookupSpec;\n component: React.ComponentType<any>;\n codeComponentHelpers?: InternalCodeComponentHelpers<\n React.ComponentProps<any>\n >;\n}\n\nexport interface PlasmicRootWatcher {\n onDataFetched?: () => void;\n}\n\n/**\n * Helper functions to describe code component behaviors, in order to allow\n * data extraction in RSC / Next.js App routing.\n */\nexport interface ReactServerOps {\n readDataEnv: typeof useDataEnv;\n readDataSelector: typeof useSelector;\n readDataSelectors: typeof useSelectors;\n /**\n * The contexts are passed using a key instead of the context provider\n * Notice it cannot access the default context value if none has been provided,\n * since React server components cannot create contexts.\n */\n readContext: (contextKey: string) => any;\n /**\n * Allows data fetching from the code component and caching the result,\n * which will be stored in the `queryCache` returned by\n * `extractPlasmicQueryData`.\n */\n fetchData: typeof useMutablePlasmicQueryData;\n}\n\n/**\n * Represents data provided by a code component via `DataProvider`\n */\nexport interface ServerProvidedData {\n name: string;\n data: any;\n}\n\n/**\n * Provides a new value for a given context key, similar to Context.Provider.\n * The context itself is not available (RSC doesn't allow calling\n * `createContext`) so each context will need to be represented as a unique\n * \"context key\". Also it means the default context value is not available\n * in case no value is passed (and reading that context will return `undefined`)\n */\nexport interface ServerProvidedContext {\n /**\n * Identifier to the context, required to read it later via\n * `ReactServerOps.readContext()`.\n */\n contextKey: string;\n /**\n * Context value being provided (similar to `Context.Provider`).\n */\n value: any;\n}\n\n/**\n * Each child of a code component might receive separate `DataProvider` and\n * Context values.\n */\nexport interface ServerChildData {\n providedData?: ServerProvidedData | ServerProvidedData[];\n providedContexts?: ServerProvidedContext | ServerProvidedContext[];\n node: React.ReactNode;\n}\n\nexport interface ServerInfo {\n /**\n * Optional: Indicates the React Nodes created by the component and the\n * respective contexts provided to them. If not specified, it will render the\n * children passed to the component as props.\n */\n children?: ServerChildData | ServerChildData[];\n providedData?: ServerProvidedData | ServerProvidedData[];\n providedContexts?: ServerProvidedContext | ServerProvidedContext[];\n}\n\nexport type CodeComponentMeta<P> = Omit<\n InternalCodeComponentMeta<P>,\n \"importPath\" | \"componentHelpers\" | \"states\"\n> & {\n /**\n * The path to be used when importing the component in the generated code.\n * It can be the name of the package that contains the component, or the path\n * to the file in the project (relative to the root directory).\n * Optional: not used by Plasmic headless API, only by codegen.\n */\n importPath?: string;\n /**\n * The states helpers are registered together with the states for the Plasmic headless API\n */\n states?: Record<string, StateSpec<P> & StateHelpers<P, any>>;\n\n /**\n * Helper function to enable data extraction when running Plasmic from\n * Next.js App Router.\n */\n getServerInfo?: (props: P, ops: ReactServerOps) => ServerInfo;\n};\n\nexport type GlobalContextMeta<P> = Omit<\n InternalGlobalContextMeta<P>,\n \"importPath\"\n> & {\n /**\n * The path to be used when importing the component in the generated code.\n * It can be the name of the package that contains the component, or the path\n * to the file in the project (relative to the root directory).\n * Optional: not used by Plasmic headless API, only by codegen.\n */\n importPath?: string;\n};\n\nexport type CustomFunctionMeta<F extends (...args: any[]) => any> = Omit<\n InternalCustomFunctionMeta<F>,\n \"importPath\"\n> & {\n /**\n * The path to be used when importing the function in the generated code.\n * It can be the name of the package that contains the function, or the path\n * to the file in the project (relative to the root directory).\n * Optional: not used by Plasmic headless API, only by codegen.\n */\n importPath?: string;\n};\n\nexport type FetchPagesOpts = {\n /**\n * Whether to include dynamic pages in fetchPages() output. A page is\n * considered dynamic if its path contains some param between brackets,\n * e.g. \"[slug]\".\n */\n includeDynamicPages?: boolean;\n};\n\nexport const SUBSTITUTED_COMPONENTS: Record<\n string,\n React.ComponentType<any>\n> = {};\nexport const REGISTERED_CODE_COMPONENT_HELPERS: Record<\n string,\n InternalCodeComponentHelpers<React.ComponentProps<any>>\n> = {};\nexport const SUBSTITUTED_GLOBAL_VARIANT_HOOKS: Record<string, () => any> = {};\nexport const REGISTERED_CUSTOM_FUNCTIONS: Record<\n string,\n (...args: any[]) => any\n> = {};\n\nexport function customFunctionImportAlias<F extends (...args: any[]) => any>(\n meta: CustomFunctionMeta<F>\n) {\n const customFunctionPrefix = `__fn_`;\n return meta.namespace\n ? `${customFunctionPrefix}${meta.namespace}__${meta.name}`\n : `${customFunctionPrefix}${meta.name}`;\n}\n\nexport function internalSetRegisteredFunction<\n F extends (...args: any[]) => any\n>(fn: F, meta: CustomFunctionMeta<F>) {\n REGISTERED_CUSTOM_FUNCTIONS[customFunctionImportAlias(meta)] = fn;\n}\n\ninterface BuiltinRegisteredModules {\n react: typeof import(\"react\");\n \"react-dom\": typeof import(\"react-dom\");\n \"react/jsx-runtime\": typeof import(\"react/jsx-runtime\");\n \"react/jsx-dev-runtime\": typeof import(\"react/jsx-dev-runtime\");\n \"@plasmicapp/query\": typeof import(\"@plasmicapp/query\");\n \"@plasmicapp/data-sources-context\": typeof import(\"@plasmicapp/data-sources-context\");\n \"@plasmicapp/host\": typeof import(\"@plasmicapp/host\");\n \"@plasmicapp/loader-runtime-registry\": {\n components: Record<string, React.ComponentType<any>>;\n globalVariantHooks: Record<string, () => any>;\n codeComponentHelpers: Record<string, ComponentHelpers<any>>;\n functions: Record<string, (...args: any[]) => any>;\n };\n}\n\nexport interface FetchComponentDataOpts {\n /**\n * Will fetch either code targeting SSR or browser hydration in the\n * returned bundle.\n *\n * By default, the target is browser. That's okay, because even when\n * doing SSR, as long as you are using the same instance of PlasmicLoader\n * that was used to fetch component data, it will still know how to get at\n * the server code.\n *\n * But, if you are building your own SSR solution, where fetching and rendering\n * are using different instances of PlasmicLoader, then you'll want to make\n * sure that when you fetch, you are fetching the right one to be used in the\n * right environment for either SSR or browser hydration.\n */\n target?: \"server\" | \"browser\";\n}\n\nfunction parseFetchComponentDataArgs(\n specs: ComponentLookupSpec[],\n opts?: FetchComponentDataOpts\n): { specs: ComponentLookupSpec[]; opts?: FetchComponentDataOpts };\nfunction parseFetchComponentDataArgs(...specs: ComponentLookupSpec[]): {\n specs: ComponentLookupSpec[];\n opts?: FetchComponentDataOpts;\n};\nfunction parseFetchComponentDataArgs(...args: any[]) {\n let specs: ComponentLookupSpec[];\n let opts: FetchComponentDataOpts | undefined;\n if (Array.isArray(args[0])) {\n specs = args[0];\n opts = args[1];\n } else {\n specs = args;\n opts = undefined;\n }\n return { specs, opts };\n}\n\n/** Subset of loader functionality that works on Client and React Server Components. */\nexport abstract class BaseInternalPlasmicComponentLoader {\n public readonly opts: InitOptions;\n private readonly registry = new Registry();\n private readonly fetcher: PlasmicModulesFetcher;\n private readonly onBundleMerged?: () => void;\n private readonly onBundleFetched?: () => void;\n private globalVariants: GlobalVariantSpec[] = [];\n private subs: ComponentSubstitutionSpec[] = [];\n\n private bundle: LoaderBundleOutput = {\n modules: {\n browser: [],\n server: [],\n },\n components: [],\n globalGroups: [],\n projects: [],\n activeSplits: [],\n bundleKey: null,\n deferChunksByDefault: false,\n disableRootLoadingBoundaryByDefault: false,\n filteredIds: {},\n };\n\n constructor(args: {\n opts: InitOptions;\n fetcher: PlasmicModulesFetcher;\n /** Called after `mergeBundle` (including `fetch` calls). */\n onBundleMerged?: () => void;\n /** Called after any `fetch` calls. */\n onBundleFetched?: () => void;\n builtinModules: BuiltinRegisteredModules;\n }) {\n this.opts = args.opts;\n this.fetcher = args.fetcher;\n this.onBundleMerged = args.onBundleMerged;\n this.onBundleFetched = args.onBundleFetched;\n this.registerModules(args.builtinModules);\n }\n\n private maybeGetCompMetas(...specs: ComponentLookupSpec[]) {\n const found = new Set<ComponentMeta>();\n const missing: ComponentLookupSpec[] = [];\n for (const spec of specs) {\n const filteredMetas = getCompMetas(this.bundle.components, spec);\n if (filteredMetas.length > 0) {\n filteredMetas.forEach((meta) => found.add(meta));\n } else {\n missing.push(spec);\n }\n }\n return { found: Array.from(found.keys()), missing };\n }\n\n async maybeFetchComponentData(\n specs: ComponentLookupSpec[],\n opts?: FetchComponentDataOpts\n ): Promise<ComponentRenderData | null>;\n async maybeFetchComponentData(\n ...specs: ComponentLookupSpec[]\n ): Promise<ComponentRenderData | null>;\n async maybeFetchComponentData(\n ...args: any[]\n ): Promise<ComponentRenderData | null> {\n const { specs, opts } = parseFetchComponentDataArgs(...args);\n const returnWithSpecsToFetch = async (\n specsToFetch: ComponentLookupSpec[]\n ) => {\n await this.fetchMissingData({ missingSpecs: specsToFetch });\n const { found: existingMetas2, missing: missingSpecs2 } =\n this.maybeGetCompMetas(...specs);\n if (missingSpecs2.length > 0) {\n return null;\n }\n\n return prepComponentData(this.bundle, existingMetas2, opts);\n };\n\n if (this.opts.alwaysFresh) {\n // If alwaysFresh, then we treat all specs as missing\n return await returnWithSpecsToFetch(specs);\n }\n\n // Else we only fetch actually missing specs\n const { found: existingMetas, missing: missingSpecs } =\n this.maybeGetCompMetas(...specs);\n if (missingSpecs.length === 0) {\n return prepComponentData(this.bundle, existingMetas, opts);\n }\n\n return await returnWithSpecsToFetch(missingSpecs);\n }\n\n async fetchComponentData(\n specs: ComponentLookupSpec[],\n opts?: FetchComponentDataOpts\n ): Promise<ComponentRenderData>;\n async fetchComponentData(\n ...specs: ComponentLookupSpec[]\n ): Promise<ComponentRenderData>;\n async fetchComponentData(...args: any[]): Promise<ComponentRenderData> {\n const { specs, opts } = parseFetchComponentDataArgs(...args);\n const data = await this.maybeFetchComponentData(specs, opts);\n\n if (!data) {\n const { missing: missingSpecs } = this.maybeGetCompMetas(...specs);\n throw new Error(\n `Unable to find components ${missingSpecs\n .map(getLookupSpecName)\n .join(\", \")}`\n );\n }\n\n return data;\n }\n\n async fetchPages(opts?: FetchPagesOpts) {\n this.maybeReportClientSideFetch(\n () => `Plasmic: fetching all page metadata in the browser`\n );\n const data = await this.fetchAllData();\n return data.components.filter(\n (comp) =>\n comp.isPage &&\n comp.path &&\n (opts?.includeDynamicPages || !isDynamicPagePath(comp.path))\n ) as PageMeta[];\n }\n\n async fetchComponents() {\n this.maybeReportClientSideFetch(\n () => `Plasmic: fetching all component metadata in the browser`\n );\n const data = await this.fetchAllData();\n return data.components;\n }\n\n getActiveSplits() {\n return this.bundle.activeSplits;\n }\n\n getChunksUrl(bundle: LoaderBundleOutput, modules: CodeModule[]) {\n return this.fetcher.getChunksUrl(bundle, modules);\n }\n\n private async fetchMissingData(opts: {\n missingSpecs: ComponentLookupSpec[];\n }) {\n // TODO: do better than just fetching everything\n this.maybeReportClientSideFetch(\n () =>\n `Plasmic: fetching missing components in the browser: ${opts.missingSpecs\n .map((spec) => getLookupSpecName(spec))\n .join(\", \")}`\n );\n return this.fetchAllData();\n }\n\n private maybeReportClientSideFetch(mkMsg: () => string) {\n if (isBrowser && this.opts.onClientSideFetch) {\n const msg = mkMsg();\n if (this.opts.onClientSideFetch === \"warn\") {\n console.warn(msg);\n } else {\n throw new Error(msg);\n }\n }\n }\n\n private async fetchAllData() {\n const bundle = await this.fetcher.fetchAllData();\n this.mergeBundle(bundle);\n this.onBundleFetched?.();\n return bundle;\n }\n\n mergeBundle(newBundle: LoaderBundleOutput) {\n newBundle.bundleKey = newBundle.bundleKey ?? null;\n if (\n newBundle.bundleKey &&\n this.bundle.bundleKey &&\n newBundle.bundleKey !== this.bundle.bundleKey\n ) {\n console.warn(\n `Plasmic Error: Different code export hashes. This can happen if your app is using different loaders with different project IDs or project versions.\nConflicting values:\n${newBundle.bundleKey}\n${this.bundle.bundleKey}`\n );\n }\n // Merge the old bundle into the new bundle, this way\n // the new bundle will enforce the latest data from the server\n // allowing elements to be deleted by newer bundles\n this.bundle = mergeBundles(newBundle, this.bundle);\n\n this.onBundleMerged?.();\n }\n\n getBundle(): LoaderBundleOutput {\n return this.bundle;\n }\n\n clearCache() {\n this.bundle = {\n modules: {\n browser: [],\n server: [],\n },\n components: [],\n globalGroups: [],\n projects: [],\n activeSplits: [],\n bundleKey: null,\n deferChunksByDefault: false,\n disableRootLoadingBoundaryByDefault: false,\n filteredIds: {},\n };\n this.registry.clear();\n }\n\n registerModules(modules: Record<string, any>) {\n if (\n Object.keys(modules).some(\n (name) => this.registry.getRegisteredModule(name) !== modules[name]\n )\n ) {\n if (!this.registry.isEmpty()) {\n console.warn(\n \"Calling PlasmicComponentLoader.registerModules() after Plasmic component has rendered; starting over.\"\n );\n this.registry.clear();\n }\n for (const key of Object.keys(modules)) {\n this.registry.register(key, modules[key]);\n }\n }\n }\n\n substituteComponent<P>(\n component: React.ComponentType<P>,\n name: ComponentLookupSpec\n ) {\n this.internalSubstituteComponent(component, name, undefined);\n }\n\n protected internalSubstituteComponent<P>(\n component: React.ComponentType<P>,\n name: ComponentLookupSpec,\n codeComponentHelpers:\n | InternalCodeComponentHelpers<\n React.ComponentProps<React.ComponentType<P>>\n >\n | undefined\n ) {\n if (!this.isRegistryEmpty()) {\n console.warn(\n \"Calling PlasmicComponentLoader.registerSubstitution() after Plasmic component has rendered; starting over.\"\n );\n this.clearRegistry();\n }\n this.subs.push({ lookup: name, component, codeComponentHelpers });\n }\n\n abstract registerComponent<T extends React.ComponentType<any>>(\n component: T,\n meta: CodeComponentMeta<React.ComponentProps<T>>\n ): void;\n abstract registerFunction<F extends (...args: any[]) => any>(\n fn: F,\n meta: CustomFunctionMeta<F>\n ): void;\n abstract registerGlobalContext<T extends React.ComponentType<any>>(\n context: T,\n meta: GlobalContextMeta<React.ComponentProps<T>>\n ): void;\n abstract registerTrait(trait: string, meta: TraitMeta): void;\n abstract registerToken(token: TokenRegistration): void;\n\n protected refreshRegistry() {\n // Once we have received data, we register components to\n // substitute. We had to wait for data to do this so\n // that we can look up the right module name to substitute\n // in component meta.\n for (const sub of this.subs) {\n const metas = getCompMetas(this.getBundle().components, sub.lookup);\n metas.forEach((meta) => {\n SUBSTITUTED_COMPONENTS[meta.id] = sub.component;\n if (sub.codeComponentHelpers) {\n REGISTERED_CODE_COMPONENT_HELPERS[meta.id] = sub.codeComponentHelpers;\n }\n });\n }\n\n this.registry.updateModules(this.getBundle());\n }\n\n isRegistryEmpty() {\n return this.registry.isEmpty();\n }\n\n clearRegistry() {\n this.registry.clear();\n }\n\n setGlobalVariants(globalVariants: GlobalVariantSpec[]) {\n this.globalVariants = globalVariants;\n }\n\n getGlobalVariants() {\n return this.globalVariants;\n }\n\n registerPrefetchedBundle(bundle: LoaderBundleOutput) {\n // For React Server Components (Next.js 13+),\n // we need to pass server modules in LoaderBundleOutput from Server Components to Client Components.\n // We don't want to pass them via normal page props because that will be serialized to the browser.\n // Instead, we pass the bundle (including the server modules) via the Node `global` variable.\n //\n // This is the code that reads the stored bundle and merges it back into the loader.\n if (!isBrowser) {\n // Check if we have a cached bundle on this Node server.\n const cachedBundle = internal_getCachedBundleInNodeServer(this.opts);\n if (cachedBundle) {\n // If it's there, merge the cached bundle first.\n this.mergeBundle(cachedBundle);\n }\n }\n this.mergeBundle(bundle);\n }\n\n getLookup() {\n return new ComponentLookup(this.getBundle(), this.registry);\n }\n\n trackConversion(_value = 0) {\n // no-op: tracking removed from loader packages\n }\n\n public async getActiveVariation(\n opts: Omit<Parameters<typeof getActiveVariation>[0], \"splits\">\n ) {\n await this.fetchComponents();\n return getActiveVariation({\n ...opts,\n splits: this.getBundle().activeSplits,\n });\n }\n\n public getTeamIds(): string[] {\n return uniq(\n this.getBundle()\n .projects.map((p) =>\n p.teamId ? `${p.teamId}${p.indirect ? \"@indirect\" : \"\"}` : null\n )\n .filter((x): x is string => !!x)\n );\n }\n\n public getProjectIds(): string[] {\n return uniq(\n this.getBundle().projects.map(\n (p) => `${p.id}${p.indirect ? \"@indirect\" : \"\"}`\n )\n );\n }\n\n public trackRender(_opts?: TrackRenderOptions) {\n // no-op: tracking removed from loader packages\n }\n\n public loadServerQueriesModule(fileName: string) {\n return this.registry.load(fileName);\n }\n}\n\n/**\n * Library for fetching component data, and registering\n * custom components.\n */\nexport class PlasmicComponentLoader {\n private __internal: BaseInternalPlasmicComponentLoader;\n\n constructor(internal: BaseInternalPlasmicComponentLoader) {\n this.__internal = internal;\n }\n\n /**\n * Sets global variants to be used for all components. Note that\n * this is not reactive, and will not re-render all components\n * already mounted; instead, it should be used to activate global\n * variants that should always be activated for the lifetime of this\n * app. If you'd like to reactively change the global variants,\n * you should specify them via <PlasmicRootProvider />\n */\n setGlobalVariants(globalVariants: GlobalVariantSpec[]) {\n this.__internal.setGlobalVariants(globalVariants);\n }\n\n registerModules(modules: Record<string, any>) {\n this.__internal.registerModules(modules);\n }\n\n /**\n * Register custom components that should be swapped in for\n * components defined in your project. You can use this to\n * swap in / substitute a Plasmic component with a \"real\" component.\n */\n substituteComponent<P>(\n component: React.ComponentType<P>,\n name: ComponentLookupSpec\n ) {\n this.__internal.substituteComponent(component, name);\n }\n\n /**\n * Register code components to be used on Plasmic Editor.\n */\n registerComponent<T extends React.ComponentType<any>>(\n component: T,\n meta: CodeComponentMeta<React.ComponentProps<T>>\n ): void;\n\n /**\n * [[deprecated]] Please use `substituteComponent` instead for component\n * substitution, or the other `registerComponent` overload to register\n * code components to be used on Plasmic Editor.\n *\n * @see `substituteComponent`\n */\n registerComponent<T extends React.ComponentType<any>>(\n component: T,\n name: ComponentLookupSpec\n ): void;\n\n registerComponent<T extends React.ComponentType<any>>(\n component: T,\n metaOrName: ComponentLookupSpec | CodeComponentMeta<React.ComponentProps<T>>\n ) {\n // 'props' is a required field in CodeComponentMeta\n if (metaOrName && typeof metaOrName === \"object\" && \"props\" in metaOrName) {\n this.__internal.registerComponent(component, metaOrName);\n } else {\n // Deprecated call\n if (\n process.env.NODE_ENV === \"development\" &&\n !this.warnedRegisterComponent\n ) {\n console.warn(\n `PlasmicLoader: Using deprecated method \\`registerComponent\\` for component substitution. ` +\n `Please consider using \\`substituteComponent\\` instead.`\n );\n this.warnedRegisterComponent = true;\n }\n this.substituteComponent(component, metaOrName);\n }\n }\n private warnedRegisterComponent = false;\n\n registerFunction<F extends (...args: any[]) => any>(\n fn: F,\n meta: CustomFunctionMeta<F>\n ) {\n this.__internal.registerFunction(fn, meta);\n }\n\n registerGlobalContext<T extends React.ComponentType<any>>(\n context: T,\n meta: GlobalContextMeta<React.ComponentProps<T>>\n ) {\n this.__internal.registerGlobalContext(context, meta);\n }\n\n registerTrait(trait: string, meta: TraitMeta) {\n this.__internal.registerTrait(trait, meta);\n }\n\n registerToken(token: TokenRegistration) {\n this.__internal.registerToken(token);\n }\n\n /**\n * Pre-fetches component data needed to for PlasmicLoader to render\n * these components. Should be passed into PlasmicRootProvider as\n * the prefetchedData prop.\n *\n * You can look up a component either by:\n * - the name of the component\n * - the path for a page component\n * - an array of strings that make up parts of the path\n * - object { name: \"name_or_path\", projectId: ...}, to specify which project\n * to use, if multiple projects have the same component name\n *\n * Throws an Error if a specified component to fetch does not exist in\n * the Plasmic project.\n */\n fetchComponentData(\n ...specs: ComponentLookupSpec[]\n ): Promise<ComponentRenderData>;\n fetchComponentData(\n specs: ComponentLookupSpec[],\n opts?: FetchComponentDataOpts\n ): Promise<ComponentRenderData>;\n fetchComponentData(...args: any[]): Promise<ComponentRenderData> {\n return this.__internal.fetchComponentData(...args);\n }\n\n /**\n * Like fetchComponentData(), but returns null instead of throwing an Error\n * when a component is not found. Useful when you are implementing a catch-all\n * page and want to check if a specific path had been defined for Plasmic.\n */\n async maybeFetchComponentData(\n ...specs: ComponentLookupSpec[]\n ): Promise<ComponentRenderData | null>;\n async maybeFetchComponentData(\n specs: ComponentLookupSpec[],\n opts?: FetchComponentDataOpts\n ): Promise<ComponentRenderData | null>;\n async maybeFetchComponentData(\n ...args: any[]\n ): Promise<ComponentRenderData | null> {\n return this.__internal.maybeFetchComponentData(...args);\n }\n\n /**\n * Returns all the page component metadata for these projects.\n */\n async fetchPages(opts?: FetchPagesOpts) {\n return this.__internal.fetchPages(opts);\n }\n\n /**\n * Returns all components metadata for these projects.\n */\n async fetchComponents() {\n return this.__internal.fetchComponents();\n }\n\n protected async _getActiveVariation(\n opts: Parameters<typeof this.__internal.getActiveVariation>[0]\n ) {\n return this.__internal.getActiveVariation(opts);\n }\n\n async getActiveVariation(opts: {\n known?: Record<string, string>;\n traits: Record<string, string | number | boolean>;\n }) {\n return this._getActiveVariation({\n traits: opts.traits,\n getKnownValue: (key: string) => {\n if (opts.known) {\n return opts.known[key];\n } else {\n const cookies = getPlasmicCookieValues();\n return cookies[key];\n }\n },\n updateKnownValue: (key: string, value: string) => {\n if (!opts.known) {\n updatePlasmicCookieValue(key, value);\n }\n },\n });\n }\n\n getChunksUrl(bundle: LoaderBundleOutput, modules: CodeModule[]) {\n return this.__internal.getChunksUrl(bundle, modules);\n }\n\n getExternalVariation(\n variation: Record<string, string>,\n filters?: Parameters<typeof getExternalIds>[2]\n ) {\n return getExternalIds(this.getActiveSplits(), variation, filters);\n }\n\n getActiveSplits() {\n return this.__internal.getActiveSplits();\n }\n\n trackConversion(value = 0) {\n this.__internal.trackConversion(value);\n }\n\n clearCache() {\n return this.__internal.clearCache();\n }\n\n async unstable__getServerQueriesData(\n renderData: ComponentRenderData,\n $ctx: Record<string, any>\n ) {\n if (renderData.entryCompMetas.length === 0) {\n return {};\n }\n\n const fileName = renderData.entryCompMetas[0].serverQueriesExecFuncFileName;\n\n if (!fileName) {\n return {};\n }\n\n const module = this.__internal.loadServerQueriesModule(fileName);\n const { executeServerQueries } = module;\n\n try {\n const $serverQueries = await executeServerQueries($ctx);\n return $serverQueries;\n } catch (err) {\n console.error(\"Error executing server queries function\", err);\n return {};\n }\n }\n}\n", "import {\n ComponentMeta,\n getBundleSubset,\n LoaderBundleOutput,\n} from \"@plasmicapp/loader-core\";\nimport type { ComponentRenderData } from \"./loader-shared\";\nimport { intersect } from \"./utils\";\n\nfunction getUsedComps(allComponents: ComponentMeta[], entryCompIds: string[]) {\n const q: string[] = [...entryCompIds];\n const seenIds = new Set<string>(entryCompIds);\n const componentMetaById = new Map<string, ComponentMeta>(\n allComponents.map((meta) => [meta.id, meta])\n );\n const usedComps: ComponentMeta[] = [];\n while (q.length > 0) {\n const [id] = q.splice(0, 1);\n const meta = componentMetaById.get(id);\n if (!meta) {\n continue;\n }\n usedComps.push(meta);\n meta.usedComponents.forEach((usedCompId) => {\n if (!seenIds.has(usedCompId)) {\n seenIds.add(usedCompId);\n q.push(usedCompId);\n }\n });\n }\n return usedComps;\n}\n\nexport function prepComponentData(\n bundle: LoaderBundleOutput,\n compMetas: ComponentMeta[],\n opts?: {\n target?: \"browser\" | \"server\";\n }\n): ComponentRenderData {\n if (compMetas.length === 0) {\n return {\n entryCompMetas: bundle.components,\n bundle: bundle,\n remoteFontUrls: [],\n };\n }\n\n const usedComps = getUsedComps(\n bundle.components,\n compMetas.map((compMeta) => compMeta.id)\n );\n const compPaths = usedComps.map((compMeta) => compMeta.entry);\n const subBundle = getBundleSubset(\n bundle,\n [\n \"entrypoint.css\",\n ...compPaths,\n \"root-provider.js\",\n ...bundle.projects\n .map((x) => x.globalContextsProviderFileName)\n .filter((x) => !!x),\n // We need to explicitly include global context provider components\n // to make sure they are kept in bundle.components. That's because\n // for esbuild, just the globalContextsProviderFileName is not enough,\n // because it will import a chunk that includes the global context\n // component, instead of importing that global context component's\n // entry file. And because nothing depends on the global context component's\n // entry file, we end up excluding the global context component from\n // bundle.components, which then makes its substitution not work.\n // Instead, we forcibly include it here (we'll definitely need it anyway!).\n ...bundle.components\n .filter((c) => c.isGlobalContextProvider)\n .map((c) => c.entry),\n ...bundle.globalGroups.map((g) => g.contextFile),\n ],\n opts\n );\n\n const remoteFontUrls: string[] = [];\n subBundle.projects.forEach((p) =>\n remoteFontUrls.push(...p.remoteFonts.map((f) => f.url))\n );\n\n return {\n entryCompMetas: compMetas,\n bundle: subBundle,\n remoteFontUrls,\n };\n}\n\n// It's important to deep clone any attributes that are going to be changed in the\n// target bundle, since the build of pages can be done in multiple stages/processes\n// we don't want to mutate the original bundle, which can impact other pages.\nexport function mergeBundles(\n target: LoaderBundleOutput,\n from: LoaderBundleOutput\n) {\n const existingProjects = new Set(target.projects.map((p) => p.id));\n const newProjects = from.projects.filter((p) => !existingProjects.has(p.id));\n if (newProjects.length > 0) {\n target = {\n ...target,\n projects: [...target.projects, ...newProjects],\n };\n }\n\n const existingCompIds = new Set(target.components.map((c) => c.id));\n\n function shouldIncludeComponentInBundle(c: ComponentMeta) {\n // If the component is already present in the target bundle, don't include it\n if (existingCompIds.has(c.id)) {\n return false;\n }\n // If the component belongs to a project that is not present in the target bundle,\n // include it\n if (!existingProjects.has(c.projectId)) {\n return true;\n }\n // If the component is present in the filteredIds of the project it belongs to,\n // in the target bundle, we consider that the component was not deleted in the target\n // bundle, so we can include it\n const targetBundleFilteredIds = target.filteredIds[c.projectId] ?? [];\n return targetBundleFilteredIds.includes(c.id);\n }\n\n const newCompMetas = from.components.filter((m) =>\n shouldIncludeComponentInBundle(m)\n );\n if (newCompMetas.length > 0) {\n target = {\n ...target,\n components: [...target.components, ...newCompMetas],\n };\n\n // Deep clone the filteredIds object to avoid mutating the original bundle\n target.filteredIds = Object.fromEntries(\n Object.entries(target.filteredIds).map(([k, v]) => [k, [...v]])\n );\n\n from.projects.forEach((fromProject) => {\n const projectId = fromProject.id;\n const fromBundleFilteredIds = from.filteredIds[projectId] ?? [];\n if (!existingProjects.has(projectId)) {\n target.filteredIds[projectId] = [...fromBundleFilteredIds];\n } else {\n target.filteredIds[projectId] = intersect(\n target.filteredIds[projectId] ?? [],\n fromBundleFilteredIds\n );\n }\n });\n }\n\n const existingModules = {\n browser: new Set(target.modules.browser.map((m) => m.fileName)),\n server: new Set(target.modules.server.map((m) => m.fileName)),\n };\n const newModules = {\n browser: from.modules.browser.filter(\n (m) => !existingModules.browser.has(m.fileName)\n ),\n server: from.modules.server.filter(\n (m) => !existingModules.server.has(m.fileName)\n ),\n };\n if (newModules.browser.length > 0 || newModules.server.length > 0) {\n target = {\n ...target,\n modules: {\n browser: [...target.modules.browser, ...newModules.browser],\n server: [...target.modules.server, ...newModules.server],\n },\n };\n }\n\n const existingGlobalIds = new Set(target.globalGroups.map((g) => g.id));\n const newGlobals = from.globalGroups.filter(\n (g) => !existingGlobalIds.has(g.id)\n );\n if (newGlobals.length > 0) {\n target = {\n ...target,\n globalGroups: [...target.globalGroups, ...newGlobals],\n };\n }\n\n const existingSplitIds = new Set(target.activeSplits.map((s) => s.id));\n const newSplits =\n from.activeSplits.filter(\n // Don't include splits belonging to projects already present\n // in the target bundle\n (s) => !existingSplitIds.has(s.id) && !existingProjects.has(s.projectId)\n ) ?? [];\n if (newSplits.length > 0) {\n target = {\n ...target,\n activeSplits: [...target.activeSplits, ...newSplits],\n };\n }\n\n // Avoid `undefined` as it cannot be serialized as JSON\n target.bundleKey = target.bundleKey ?? from.bundleKey ?? null;\n target.deferChunksByDefault =\n target.deferChunksByDefault ?? from.deferChunksByDefault ?? false;\n\n target.disableRootLoadingBoundaryByDefault =\n target.disableRootLoadingBoundaryByDefault ??\n from.disableRootLoadingBoundaryByDefault ??\n false;\n\n return target;\n}\n\nexport const convertBundlesToComponentRenderData = (\n bundles: LoaderBundleOutput[],\n compMetas: ComponentMeta[]\n): ComponentRenderData | null => {\n if (bundles.length === 0) {\n return null;\n }\n\n const mergedBundles = bundles.reduce((prev, cur) => mergeBundles(prev, cur));\n return prepComponentData(mergedBundles, compMetas);\n};\n", "import { ComponentMeta } from \"@plasmicapp/loader-core\";\nimport pascalcase from \"pascalcase\";\nimport * as React from \"react\";\n\nexport const isBrowser = typeof window !== \"undefined\";\n\nexport type ComponentLookupSpec =\n | string\n | { name: string; projectId?: string; isCode?: boolean };\n\ninterface FullNameLookupSpec {\n name: string;\n rawName?: string;\n projectId?: string;\n isCode?: boolean;\n}\n\ninterface FullPathLookupSpec {\n path: string;\n projectId?: string;\n}\n\ntype FullLookupSpec = FullNameLookupSpec | FullPathLookupSpec;\n\nexport function useForceUpdate() {\n const [, setTick] = React.useState(0);\n const update = React.useCallback(() => {\n setTick((tick) => tick + 1);\n }, []);\n return update;\n}\n\nexport function useStableLookupSpec(spec: ComponentLookupSpec) {\n return useStableLookupSpecs(spec)[0];\n}\n\nexport function useStableLookupSpecs(...specs: ComponentLookupSpec[]) {\n const [stableSpecs, setStableSpecs] = React.useState(specs);\n\n React.useEffect(() => {\n if (\n specs.length !== stableSpecs.length ||\n specs.some((s, i) => !areLookupSpecsEqual(s, stableSpecs[i]))\n ) {\n setStableSpecs(specs);\n }\n }, [specs, stableSpecs]);\n return stableSpecs;\n}\n\nfunction areLookupSpecsEqual(\n spec1: ComponentLookupSpec,\n spec2: ComponentLookupSpec\n) {\n if (spec1 === spec2) {\n return true;\n }\n if (typeof spec1 !== typeof spec2) {\n return false;\n }\n\n const fullSpec1 = toFullLookup(spec1);\n const fullSpec2 = toFullLookup(spec2);\n return (\n ((isNameSpec(fullSpec1) &&\n isNameSpec(fullSpec2) &&\n fullSpec1.name === fullSpec2.name &&\n fullSpec1.isCode === fullSpec2.isCode) ||\n (isPathSpec(fullSpec1) &&\n isPathSpec(fullSpec2) &&\n fullSpec1.path === fullSpec2.path)) &&\n fullSpec1.projectId === fullSpec2.projectId\n );\n}\n\nfunction isNameSpec(lookup: FullLookupSpec): lookup is FullNameLookupSpec {\n return \"name\" in lookup;\n}\n\nfunction isPathSpec(lookup: FullLookupSpec): lookup is FullPathLookupSpec {\n return \"path\" in lookup;\n}\n\nfunction toFullLookup(lookup: ComponentLookupSpec): FullLookupSpec {\n const namePart = typeof lookup === \"string\" ? lookup : lookup.name;\n const projectId = typeof lookup === \"string\" ? undefined : lookup.projectId;\n const codeComponent = typeof lookup === \"string\" ? undefined : lookup.isCode;\n\n if (codeComponent !== true && namePart.startsWith(\"/\")) {\n return { path: normalizePath(namePart), projectId };\n } else {\n return {\n name: codeComponent ? namePart : normalizeName(namePart),\n rawName: namePart.trim(),\n projectId,\n isCode: codeComponent,\n };\n }\n}\n\nfunction normalizePath(path: string) {\n return path.trim();\n}\n\nfunction normalizeName(name: string) {\n // Not a full normalization, but should be good enough\n return pascalcase(name).trim();\n}\n\nexport function useIsMounted(): () => boolean {\n const ref = React.useRef<boolean>(false);\n const isMounted = React.useCallback(() => ref.current, []);\n\n React.useEffect(() => {\n ref.current = true;\n return () => {\n ref.current = false;\n };\n }, []);\n\n return isMounted;\n}\n\n/**\n * Check if `lookup` resolves to `pagePath`. If it's a match, return an object\n * containing path params; otherwise, return false.\n *\n * For example,\n * - `matchesPagePath(\"/hello/[name]\", \"/hello/world\")` -> `{params: {name:\n * \"world\"}}`\n * - `matchesPagePath(\"/hello/[name]\", \"/\")` -> `false`\n * - `matchesPagePath(\"/hello/[...catchall]\", \"/hello/a/b/c\")` -> `{params: {catchall: [\"a\", \"b\", \"c\"]}}`\n * - `matchesPagePath(\"/hello/[[...catchall]]\", \"/hello/\")` -> `{params: {catchall: []}}`\n * - `matchesPagePath(\"/\", \"\")` -> `{params: {}}`\n */\nexport function matchesPagePath(pattern: string, path: string) {\n // (generated by ChatGPT 4 from the test cases)\n\n // Normalize the path and pattern by ensuring they both start and end without slashes\n const normalizedPattern = \"/\" + pattern.replace(/^\\/|\\/$/g, \"\");\n const normalizedPath = \"/\" + path.replace(/^\\/|\\/$/g, \"\");\n\n // Modify the regex to match optional leading slashes\n const regexString = normalizedPattern\n .replace(/\\/\\[\\[\\.\\.\\.([^\\]^]+)]]/g, \"(?:/([^]*))?\") // Optional catch-all\n .replace(/\\/\\[\\.\\.\\.([^\\]^]+)]/g, \"/([^]*)\") // Catch-all\n .replace(/\\[([^\\]^]+)]/g, \"([^/]+)\") // Normal slug\n .replace(/\\//g, \"\\\\/\"); // Escape forward slashes\n\n const regex = new RegExp(`^/?${regexString}$`); // Allow optional leading slash\n const match = normalizedPath.match(regex);\n\n if (!match) return false;\n\n // Extract slug names from pattern\n const slugNames = [...pattern.matchAll(/\\[\\.?\\.?\\.?([^[\\]]+)]/g)].map(\n (m) => m[1]\n );\n\n // Construct params object\n const params: Record<string, string | string[]> = {};\n for (let i = 0; i < slugNames.length; i++) {\n const slugName = slugNames[i];\n const value = match[i + 1];\n\n if (pattern.includes(`[[...${slugName}]]`)) {\n // Handle optional catchall slugs\n params[slugName] = value ? value.split(\"/\").filter(Boolean) : [];\n } else if (pattern.includes(`[...${slugName}]`)) {\n // Handle mandatory catchall slugs\n params[slugName] = value.split(\"/\").filter(Boolean);\n } else if (value !== undefined) {\n // Handle normal slugs\n params[slugName] = value;\n }\n }\n\n return { params };\n}\n\nexport function isDynamicPagePath(path: string): boolean {\n return !!path.match(/\\[[^/]*\\]/);\n}\n\nfunction matchesCompMeta(lookup: FullLookupSpec, meta: ComponentMeta) {\n if (lookup.projectId && meta.projectId !== lookup.projectId) {\n return false;\n }\n\n return isNameSpec(lookup)\n ? (lookup.name === meta.name ||\n lookup.rawName === meta.name ||\n lookup.rawName === meta.displayName) &&\n (lookup.isCode == null || lookup.isCode === meta.isCode)\n : !!(meta.path && matchesPagePath(meta.path, lookup.path));\n}\n\nexport function getCompMetas(\n metas: ComponentMeta[],\n lookup: ComponentLookupSpec\n) {\n const full = toFullLookup(lookup);\n return metas\n .filter((meta) => matchesCompMeta(full, meta))\n .map<ComponentMeta & { params?: Record<string, string | string[]> }>(\n (meta) => {\n if (isNameSpec(full) || !meta.path) {\n return meta;\n }\n\n const match = matchesPagePath(meta.path, full.path);\n if (!match) {\n return meta;\n }\n\n return { ...meta, params: match.params };\n }\n )\n .sort(\n (meta1, meta2) =>\n // We sort the matched component metas by the number of path params, so\n // if there are two pages `/products/foo` and `/products/[slug]`,\n // the first one will have higher precedence.\n Array.from(Object.keys(meta1.params || {})).length -\n Array.from(Object.keys(meta2.params || {})).length\n );\n}\n\nexport function getLookupSpecName(lookup: ComponentLookupSpec) {\n if (typeof lookup === \"string\") {\n return lookup;\n } else if (lookup.projectId) {\n return `${lookup.name} (project ${lookup.projectId})`;\n } else {\n return lookup.name;\n }\n}\n\nexport function MaybeWrap(props: {\n children: React.ReactNode;\n cond: boolean;\n wrapper: (children: React.ReactNode) => React.ReactElement;\n}) {\n return (\n props.cond ? props.wrapper(props.children) : props.children\n ) as React.ReactElement;\n}\n\nexport function uniq<T>(elements: T[]): T[] {\n return Array.from(new Set(elements));\n}\n\nexport function uniqBy<T, K>(elements: T[], iterator: (elt: T) => K): T[] {\n const vis = new Set<K>();\n const filtered: T[] = [];\n for (const elt of elements) {\n const key = iterator(elt);\n if (!vis.has(key)) {\n vis.add(key);\n filtered.push(elt);\n }\n }\n return filtered;\n}\n\nexport function intersect<T>(a: T[], b: T[]): T[] {\n const setB = new Set(b);\n return a.filter((elt) => setB.has(elt));\n}\n", "import {\n AssetModule,\n ComponentMeta,\n FontMeta,\n GlobalGroupMeta,\n LoaderBundleOutput,\n Registry,\n} from '@plasmicapp/loader-core';\nimport * as React from 'react';\nimport { ComponentLookupSpec, getCompMetas } from './utils';\n\nfunction getFirstCompMeta(metas: ComponentMeta[], lookup: ComponentLookupSpec) {\n const filtered = getCompMetas(metas, lookup);\n return filtered.length === 0 ? undefined : filtered[0];\n}\n\nexport class ComponentLookup {\n constructor(private bundle: LoaderBundleOutput, private registry: Registry) {}\n\n getComponentMeta(spec: ComponentLookupSpec): ComponentMeta | undefined {\n const compMeta = getFirstCompMeta(this.bundle.components, spec);\n return compMeta;\n }\n\n getComponent<P extends React.ComponentType = any>(\n spec: ComponentLookupSpec,\n opts: { forceOriginal?: boolean } = {}\n ) {\n const compMeta = getFirstCompMeta(this.bundle.components, spec);\n if (!compMeta) {\n throw new Error(`Component not found: ${spec}`);\n }\n const moduleName = compMeta.entry;\n if (!this.registry.hasModule(moduleName, opts)) {\n throw new Error(`Component not yet fetched: ${compMeta.name}`);\n }\n const entry = this.registry.load(moduleName, {\n forceOriginal: opts.forceOriginal,\n });\n return !opts.forceOriginal &&\n typeof entry?.getPlasmicComponent === 'function'\n ? entry.getPlasmicComponent()\n : (entry.default as P);\n }\n\n hasComponent(spec: ComponentLookupSpec) {\n const compMeta = getFirstCompMeta(this.bundle.components, spec);\n if (compMeta) {\n return this.registry.hasModule(compMeta.entry);\n }\n return false;\n }\n\n getGlobalContexts(): { meta: GlobalGroupMeta; context: any }[] {\n const customGlobalMetas = this.bundle.globalGroups.filter(\n (m) => m.type === 'global-user-defined'\n );\n return customGlobalMetas.map((meta) => ({\n meta,\n context: this.registry.load(meta.contextFile).default,\n }));\n }\n\n getGlobalContextsProvider(spec: ComponentLookupSpec) {\n const compMeta = getFirstCompMeta(this.bundle.components, spec);\n const projectMeta = compMeta\n ? this.bundle.projects.find((x) => x.id === compMeta.projectId)\n : undefined;\n\n if (\n !projectMeta ||\n !projectMeta.globalContextsProviderFileName ||\n !this.registry.hasModule(projectMeta.globalContextsProviderFileName)\n ) {\n return undefined;\n }\n const entry = this.registry.load(\n projectMeta.globalContextsProviderFileName\n );\n\n return typeof entry?.getPlasmicComponent === 'function'\n ? entry.getPlasmicComponent()\n : entry.default;\n }\n\n getRootProvider() {\n const entry = this.registry.load('root-provider.js');\n return entry.default;\n }\n\n getCss(): AssetModule[] {\n // We can probably always get the modules from the browser build\n return this.bundle.modules.browser.filter(\n (mod) => mod.type === 'asset' && mod.fileName.endsWith('css')\n ) as AssetModule[];\n }\n\n getRemoteFonts(): FontMeta[] {\n return this.bundle.projects.flatMap((p) => p.remoteFonts);\n }\n}\n", "import type {\n ExperimentSlice,\n SegmentSlice,\n Split,\n} from \"@plasmicapp/loader-core\";\nimport type { GlobalVariantSpec } from \"./PlasmicRootProvider\";\n\nexport function getPlasmicCookieValues() {\n return Object.fromEntries(\n document.cookie\n .split(\"; \")\n .filter((cookie) => cookie.includes(\"plasmic:\"))\n .map((cookie) => cookie.split(\"=\"))\n .map(([key, value]) => [key.split(\":\")[1], value])\n );\n}\n\nexport function updatePlasmicCookieValue(key: string, value: string) {\n document.cookie = `plasmic:${key}=${value}`;\n}\n\nexport const getGlobalVariantsFromSplits = (\n splits: Split[],\n variation: Record<string, string>\n) => {\n const globalVariants: GlobalVariantSpec[] = [];\n\n Object.keys(variation).map((variationKey: string) => {\n const [_type, splitId] = variationKey.split(\".\");\n const sliceId = variation[variationKey];\n const split = splits.find(\n (s) => s.id === splitId || s.externalId === splitId\n );\n if (split) {\n const slice: ExperimentSlice | SegmentSlice | undefined = (\n split.slices as Array<ExperimentSlice | SegmentSlice>\n ).find((s: any) => s.id === sliceId || s.externalId === sliceId);\n if (slice) {\n slice.contents.map((x) => {\n globalVariants.push({\n name: x.group,\n value: x.variant,\n projectId: x.projectId,\n });\n });\n }\n }\n });\n\n return globalVariants;\n};\n\nexport const mergeGlobalVariantsSpec = (\n target: GlobalVariantSpec[],\n from: GlobalVariantSpec[]\n) => {\n let result = [...target];\n const existingGlobalVariants = new Set(\n target.map((t) => `${t.name}-${t.projectId ?? \"\"}`)\n );\n const newGlobals = from.filter(\n (t) => !existingGlobalVariants.has(`${t.name}-${t.projectId ?? \"\"}`)\n );\n\n if (newGlobals.length > 0) {\n result = [...result, ...newGlobals];\n }\n\n return result;\n};\n", "import type { useMutablePlasmicQueryData } from \"@plasmicapp/query\";\n\n/**\n * It's not possible to `import { serialize } from \"swr\"` from RSC, as it\n * triggers \"`createContext` is not a function\" error :/\n *\n * So here we replicate the key serialization in order to generate the\n * appropriate cache key within data extraction.\n */\nexport function swrSerialize(\n key: Parameters<typeof useMutablePlasmicQueryData>[0]\n): [string | null | undefined | false, any[]] {\n if (typeof key === \"function\") {\n try {\n key = key();\n } catch (err) {\n // dependencies not ready\n key = \"\";\n }\n }\n const args = [].concat(key as any);\n // If key is not falsy, or not an empty array, hash it.\n key =\n typeof key == \"string\"\n ? key\n : (Array.isArray(key) ? key.length : key)\n ? stableHash(key)\n : \"\";\n return [key as any, args];\n}\n\nconst table = new WeakMap();\nlet counter = 0;\n\nfunction stableHash(arg: any) {\n const type = typeof arg;\n const constructor = arg && arg.constructor;\n const isDate = constructor == Date;\n let result: any;\n let index;\n if (Object(arg) === arg && !isDate && constructor != RegExp) {\n // Object/function, not null/date/regexp. Use WeakMap to store the id first.\n // If it's already hashed, directly return the result.\n result = table.get(arg);\n if (result) return result;\n // Store the hash first for circular reference detection before entering the\n // recursive `stableHash` calls.\n // For other objects like set and map, we use this id directly as the hash.\n result = ++counter + \"~\";\n table.set(arg, result);\n if (constructor == Array) {\n // Array.\n result = \"@\";\n for (index = 0; index < arg.length; index++) {\n result += stableHash(arg[index]) + \",\";\n }\n table.set(arg, result);\n }\n if (constructor == Object) {\n // Object, sort keys.\n result = \"#\";\n const keys = Object.keys(arg).sort();\n while ((index = keys.pop()) !== undefined) {\n if (arg[index] !== undefined) {\n result += index + \":\" + stableHash(arg[index]) + \",\";\n }\n }\n table.set(arg, result);\n }\n } else {\n result = isDate\n ? arg.toJSON()\n : type == \"symbol\"\n ? arg.toString()\n : type == \"string\"\n ? JSON.stringify(arg)\n : \"\" + arg;\n }\n return result;\n}\n", "import { extractPlasmicQueryData as internalExtractQueryData } from \"@plasmicapp/prepass\";\nimport {\n handlePlasmicPrepassContext,\n handlePrepassPlasmicComponent,\n handlePrepassPlasmicRootComponent,\n} from \"./loader-server\";\nimport type { PlasmicComponentLoader } from \"./loader-shared\";\nimport type { PlasmicRootProvider } from \"./PlasmicRootProvider\";\n\n/**\n * Performs a prepass over Plasmic content, kicking off the necessary\n * data fetches, and populating the fetched data into a cache. This\n * cache can be passed as prefetchedQueryData into PlasmicRootProvider.\n *\n * To limit rendering errors that can occur when you do this, we recommend\n * that you pass in _only_ the PlasmicComponents that you are planning to use\n * as the argument. For example:\n *\n * const cache = await extractPlasmicQueryData(\n * <ClientPlasmicRootProvider prefetchedData={plasmicData}>\n * <PlasmicComponent component=\"Home\" componentProps={{\n * // Specify the component prop overrides you are planning to use\n * // to render the page, as they may change what data is fetched.\n * ...\n * }} />\n * <PlasmicComponent component=\"NavBar\" componentProps={{\n * ...\n * }} />\n * ...\n * </ClientPlasmicRootProvider>,\n * PLASMIC\n * );\n *\n * If your PlasmicComponent will be wrapping components that require special\n * context set up, you should also wrap the element above with those context\n * providers. Avoid, however, wrapping the root provider, because we inspect\n * the props passed to the root element.\n *\n * You should avoid passing in elements that are not related to Plasmic, as any\n * rendering errors from those elements during the prepass may result in data\n * not being populated in the cache.\n *\n * @param element a React element containing instances of PlasmicComponent.\n * Will attempt to satisfy all data needs from usePlasmicDataQuery()\n * in this element tree.\n * @returns an object mapping query key to fetched data\n */\nexport async function extractPlasmicQueryData(\n element: React.ReactElement,\n loader: PlasmicComponentLoader\n): Promise<Record<string, any>> {\n return await internalExtractQueryData(element, (elt) =>\n handleClientComponentRef(elt, loader, element)\n );\n}\n\nfunction handleClientComponentRef(\n elt: React.ReactElement,\n loader: PlasmicComponentLoader,\n rootElement: React.ReactElement\n) {\n try {\n const refId: string = (elt.type as any).$$id;\n // We try to detect the root provider by name, as well as by comparing to\n // the root element.\n if (refId.includes(\"PlasmicRootProvider\") || elt === rootElement) {\n const props: Parameters<typeof PlasmicRootProvider>[0] = elt.props as any;\n if (props.prefetchedData) {\n handlePrepassPlasmicRootComponent({ ...props, loader });\n }\n return;\n } else if (\n refId.includes(\"PlasmicComponent\") &&\n elt.props?.component != null\n ) {\n return handlePrepassPlasmicComponent(elt.props);\n } else if (\n refId.includes(\"PlasmicPrepassContext\") &&\n elt.props?.cache != null\n ) {\n return handlePlasmicPrepassContext(elt.props);\n }\n } catch (err) {\n console.warn(\"Error processing client reference: \", err);\n }\n return;\n}\n"],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,KAAa;AAGxC,QAAI,MAAM,SAAS,qBAAqB,KAAK,QAAQ,aAAa;AAChE,YAAM,QAAmD,IAAI;AAC7D,UAAI,MAAM,gBAAgB;AACxB,0CAAkC,iCAAK,QAAL,EAAY,OAAO,EAAC;AAAA,MACxD;AACA;AAAA,IACF,WACE,MAAM,SAAS,kBAAkB,OACjCA,MAAA,IAAI,UAAJ,gBAAAA,IAAW,cAAa,MACxB;AACA,aAAO,8BAA8B,IAAI,KAAK;AAAA,IAChD,WACE,MAAM,SAAS,uBAAuB,OACtC,SAAI,UAAJ,mBAAW,UAAS,MACpB;AACA,aAAO,4BAA4B,IAAI,KAAK;AAAA,IAC9C;AAAA,EACF,SAAS,KAAP;AACA,YAAQ,KAAK,uCAAuC,GAAG;AAAA,EACzD;AACA;AACF;;;AR1EO,SAAS,kBAAkB,MAA2C;AAC3E,QAAM,WAAW,IAAI,6BAA6B,IAAI;AACtD,SAAO,IAAI,uBAAuB,QAAQ;AAC5C;",
|
|
4
|
+
"sourcesContent": ["import \"server-only\";\n\nimport { InternalPrepassPlasmicLoader } from \"./loader-server\";\nimport { InitOptions, PlasmicComponentLoader } from \"./loader-shared\";\n\nexport { extractPlasmicQueryData as __EXPERMIENTAL__extractPlasmicQueryData } from \"./prepass-server\";\nexport * from \"./shared-exports\";\nexport {\n InternalPrepassPlasmicLoader as InternalPlasmicComponentLoader,\n PlasmicComponentLoader,\n};\n\nexport function initPlasmicLoader(opts: InitOptions): PlasmicComponentLoader {\n const internal = new InternalPrepassPlasmicLoader(opts);\n return new PlasmicComponentLoader(internal);\n}\n", "import type { TokenRegistration, TraitMeta } from \"@plasmicapp/host\";\nimport { PlasmicModulesFetcher } from \"@plasmicapp/loader-core\";\nimport type {\n PlasmicPrepassContext,\n useMutablePlasmicQueryData,\n} from \"@plasmicapp/query\";\nimport React from \"react\";\nimport ReactDOM from \"react-dom\";\nimport * as jsxDevRuntime from \"react/jsx-dev-runtime\";\nimport * as jsxRuntime from \"react/jsx-runtime\";\nimport type { PlasmicComponent } from \"./PlasmicComponent\";\nimport type {\n PlasmicRootContextValue,\n PlasmicRootProvider,\n} from \"./PlasmicRootProvider\";\nimport {\n BaseInternalPlasmicComponentLoader,\n CodeComponentMeta,\n CustomFunctionMeta,\n GlobalContextMeta,\n InitOptions,\n REGISTERED_CODE_COMPONENT_HELPERS,\n REGISTERED_CUSTOM_FUNCTIONS,\n SUBSTITUTED_COMPONENTS,\n SUBSTITUTED_GLOBAL_VARIANT_HOOKS,\n ServerProvidedContext,\n ServerProvidedData,\n internalSetRegisteredFunction,\n} from \"./loader-shared\";\nimport { swrSerialize } from \"./swr-util\";\nimport {\n getGlobalVariantsFromSplits,\n mergeGlobalVariantsSpec,\n} from \"./variation\";\n\nconst noop: (...args: any) => void = () => {};\nconst identity = <T,>(x: T): T => x;\nconst unreachable: (...args: any) => never = () => {\n debugger;\n throw new Error(\"Unreachable code\");\n};\n\nconst REACT_PROVIDER_TYPE =\n typeof Symbol === \"function\" && Symbol.for\n ? Symbol.for(\"react.provider\")\n : (0xeacd as any as symbol);\n\nexport const FakeRootProviderContext: React.Context<any> = {\n _currentValue: undefined, // default value\n} as any;\n\nconst FakeDataContext: React.Context<any> = {\n _currentValue: undefined, // default value\n} as any;\n\nconst FakePlasmicComponentContext: React.Context<boolean> = {\n _currentValue: false, // default value\n} as any;\n\nconst FakePlasmicPrepassContext: React.Context<any> = {\n _currentValue: undefined,\n} as any;\n\nconst mkMetaName = (name: string) => `__plasmic_meta_${name}`;\n\nfunction FakeDataCtxReader({ children }: { children: ($ctx: any) => any }) {\n const $ctx = getPrepassContextEnv().readContextValue(FakeDataContext);\n return children($ctx);\n}\n\nfunction FakeDataProvider({\n name,\n data,\n hidden,\n advanced,\n label,\n children,\n}: any) {\n const { readContextValue, setContextValue } = getPrepassContextEnv();\n const existingEnv = readContextValue(FakeDataContext) ?? {};\n if (!name) {\n return <>{children}</>;\n } else {\n setContextValue(FakeDataContext, {\n ...existingEnv,\n [name]: data,\n [mkMetaName(name)]: { hidden, advanced, label },\n });\n return <>{children}</>;\n }\n}\n\nconst fakeApplySelector = (rawData: any, selector: string | undefined) => {\n if (!selector) {\n return undefined;\n }\n let curData = rawData;\n for (const key of selector.split(\".\")) {\n curData = curData?.[key];\n }\n return curData;\n};\n\nfunction fakeUseSelector(selector: string | undefined): any {\n const rawData = getPrepassContextEnv().readContextValue(FakeDataContext);\n return fakeApplySelector(rawData, selector);\n}\n\nfunction fakeUseSelectors(selectors = {}): any {\n const rawData = getPrepassContextEnv().readContextValue(FakeDataContext);\n return Object.fromEntries(\n Object.entries(selectors)\n .filter(([key, selector]) => !!key && !!selector)\n .map(([key, selector]) => [\n key,\n fakeApplySelector(rawData, selector as string),\n ])\n );\n}\n\nfunction fakeUsePlasmicDataConfig() {\n const cache = getPrepassContextEnv().readContextValue(\n FakePlasmicPrepassContext\n );\n return { cache } as any;\n}\n\nconst fakeUseMutablePlasmicQueryData: typeof useMutablePlasmicQueryData = (\n unserializedKey,\n fetcher\n) => {\n const [key, args] = swrSerialize(unserializedKey);\n if (!key) {\n return {\n isValidating: false,\n mutate: (async () => {}) as any,\n data: undefined,\n };\n }\n const cache = fakeUsePlasmicDataConfig().cache as Map<string, any>;\n if (cache.has(key)) {\n return {\n isValidating: false,\n mutate: (async () => {}) as any,\n data: cache.get(key),\n };\n }\n const response = fetcher(...(args as any));\n if (response && typeof (response as Promise<any>).then == \"function\") {\n throw (response as Promise<any>).then((data) => cache.set(key, data));\n } else {\n cache.set(key, response);\n return {\n isValidating: false,\n mutate: (async () => {}) as any,\n data: cache.get(key),\n };\n }\n};\n\n/**\n * Class components cannot be server components, and for that reason React\n * doesn't even allow calling `createElement` on them if they are not client\n * references.\n *\n * For prepass, we replace the actual Component class with this fake one, and\n * use it as an adaptor to creating a function component instead, before calling\n * `createElement`.\n */\nconst FakeReactComponent = class FakeReactComponent {\n context = undefined;\n static contextType: any = undefined;\n props: any = {};\n setState: (v: any) => void = (v) => void (this.state = v);\n forceUpdate = noop;\n initRender(props: any) {\n // Called before render to set the appropriate values for props, state,\n // context... Use hooks to simulate the class component behavior.\n this.props = props;\n const dispatcher = (React as any)\n .__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentDispatcher\n .current;\n const [state, setState] = dispatcher.useState({});\n this.state = state;\n this.setState = setState;\n if ((this.constructor as any).contextType) {\n this.context = dispatcher.useContext(\n (this.constructor as any).contextType\n );\n }\n }\n render = () => null;\n state: any = {};\n refs = {};\n} satisfies typeof React.Component;\n\nconst fakeCreateElement: <F extends (type: any, ...args: any[]) => any>(\n originalFn: F\n) => F = ((originalCreateElement: Function) =>\n (type: any, ...args: any[]) => {\n if (Object.prototype.isPrototypeOf.call(FakeReactComponent, type)) {\n return originalCreateElement((props: any) => {\n const instance: InstanceType<typeof FakeReactComponent> = new type();\n instance.initRender(props);\n return instance.render();\n }, ...args);\n }\n return originalCreateElement(type, ...args);\n }) as any;\n\nexport class InternalPrepassPlasmicLoader extends BaseInternalPlasmicComponentLoader {\n constructor(opts: InitOptions) {\n super({\n opts,\n onBundleMerged: () => {\n this.refreshRegistry();\n },\n fetcher: new PlasmicModulesFetcher(opts),\n builtinModules: {\n react: {\n ...React,\n // We use this flag to indicate our packages fecthed from loader that\n // we are running in RSC environment\n ...({ isRSC: true } as any),\n createContext: <T,>(defaultValue?: T) => {\n const context: React.Context<T> = {\n _currentValue: defaultValue,\n displayName: \"FakeContext\",\n Provider: ({ value, children }: any) => {\n getPrepassContextEnv().setContextValue(context, value);\n return <>{children}</>;\n },\n Consumer: ({ children }: any) =>\n children(getPrepassContextEnv().readContextValue(context)),\n } as any;\n return context;\n },\n ...Object.fromEntries(\n [\n \"useCallback\",\n \"useContext\",\n \"useEffect\",\n \"useImperativeHandle\",\n \"useDebugValue\",\n \"useInsertionEffect\",\n \"useLayoutEffect\",\n \"useMemo\",\n \"useSyncExternalStore\",\n \"useReducer\",\n \"useRef\",\n \"useState\",\n ].map((hook) => [\n hook,\n (...args: any) => {\n const dispatcher = (React as any)\n .__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED\n .ReactCurrentDispatcher.current;\n return dispatcher[hook](...args);\n },\n ])\n ),\n useDeferredValue: (v) => v,\n useTransition: () => [\n false,\n (f) => {\n f();\n },\n ],\n createFactory: (type: any) =>\n React.createElement.bind(null, type) as any,\n Component: FakeReactComponent,\n PureComponent: FakeReactComponent,\n createElement: fakeCreateElement(React.createElement),\n },\n \"react-dom\": ReactDOM,\n \"react/jsx-runtime\": {\n ...jsxRuntime,\n ...((jsxRuntime as any).jsx\n ? { jsx: fakeCreateElement((jsxRuntime as any).jsx) }\n : {}),\n ...((jsxRuntime as any).jsxs\n ? { jsxs: fakeCreateElement((jsxRuntime as any).jsxs) }\n : {}),\n ...((jsxRuntime as any).jsxDEV\n ? { jsxDEV: fakeCreateElement((jsxRuntime as any).jsxDEV) }\n : {}),\n },\n \"react/jsx-dev-runtime\": {\n ...jsxDevRuntime,\n ...((jsxDevRuntime as any).jsx\n ? { jsx: fakeCreateElement((jsxDevRuntime as any).jsx) }\n : {}),\n ...((jsxDevRuntime as any).jsxs\n ? { jsxs: fakeCreateElement((jsxDevRuntime as any).jsxs) }\n : {}),\n ...((jsxDevRuntime as any).jsxDEV\n ? { jsxDEV: fakeCreateElement((jsxDevRuntime as any).jsxDEV) }\n : {}),\n },\n \"@plasmicapp/query\": {\n addLoadingStateListener: () => noop,\n isPlasmicPrepass: () => true,\n PlasmicPrepassContext: {} as any,\n PlasmicQueryDataProvider: ({ children }: any) => <>{children}</>,\n useMutablePlasmicQueryData: fakeUseMutablePlasmicQueryData,\n usePlasmicDataConfig: fakeUsePlasmicDataConfig,\n usePlasmicQueryData: fakeUseMutablePlasmicQueryData,\n useSWRConfig: unreachable,\n wrapLoadingFetcher: identity,\n HeadMetadataContext: {\n _currentValue: {},\n displayName: \"FakeHeadMetadataContext\",\n Provider: ({ children }: any) => <>{children}</>,\n Consumer: ({ children }: any) => children({}),\n } as any as React.Context<any>,\n },\n \"@plasmicapp/data-sources-context\": (() => {\n const FakePlasmicDataSourceContext: React.Context<any> = {\n _currentValue: undefined, // default value\n } as any;\n return {\n PlasmicDataSourceContextProvider: Object.assign(\n ({ children, value }: any) => {\n const { setContextValue } = getPrepassContextEnv();\n setContextValue(FakePlasmicDataSourceContext, value);\n return <>{children}</>;\n },\n {\n $$typeof: REACT_PROVIDER_TYPE,\n _context: FakePlasmicDataSourceContext,\n }\n ),\n useCurrentUser: () => {\n const { readContextValue } = getPrepassContextEnv();\n const ctx = readContextValue(FakePlasmicDataSourceContext);\n return (\n ctx?.user ?? {\n isLoggedIn: false,\n }\n );\n },\n usePlasmicDataSourceContext: () => {\n const { readContextValue } = getPrepassContextEnv();\n return readContextValue(FakePlasmicDataSourceContext);\n },\n };\n })(),\n \"@plasmicapp/host\": (() => {\n return {\n applySelector: fakeApplySelector,\n DataContext: FakeDataContext,\n DataCtxReader: FakeDataCtxReader,\n DataProvider: FakeDataProvider,\n GlobalActionsContext: {\n _currentValue: undefined, // default value\n } as any as React.Context<any>,\n GlobalActionsProvider: ({ children }) => <>{children}</>,\n mkMetaName,\n mkMetaValue: identity,\n PageParamsProvider: ({ children }) => <>{children}</>,\n PlasmicCanvasContext: { _currentValue: false } as any,\n PlasmicCanvasHost: () => null,\n PlasmicLinkProvider: ({ children }) => <>{children}</>,\n registerComponent: noop,\n registerFunction: noop,\n registerGlobalContext: noop,\n registerToken: noop,\n registerTrait: noop,\n repeatedElement: unreachable,\n stateHelpersKeys: [\"initFunc\", \"onChangeArgsToValue\", \"onMutate\"],\n unstable_registerFetcher: noop,\n useDataEnv: () =>\n getPrepassContextEnv().readContextValue(FakeDataContext),\n useGlobalActions: () =>\n new Proxy(\n {},\n {\n get: () => noop,\n }\n ),\n usePlasmicTranslator: () => undefined,\n PlasmicTranslatorContext: { _currentValue: undefined } as any,\n usePlasmicCanvasContext: () => false,\n usePlasmicLink: () => (props) => <a {...props} />,\n usePlasmicLinkMaybe: () => undefined,\n useSelector: fakeUseSelector,\n useSelectors: fakeUseSelectors,\n usePlasmicCanvasComponentInfo: () => null,\n };\n })(),\n \"@plasmicapp/loader-runtime-registry\": {\n components: SUBSTITUTED_COMPONENTS,\n globalVariantHooks: SUBSTITUTED_GLOBAL_VARIANT_HOOKS,\n codeComponentHelpers: REGISTERED_CODE_COMPONENT_HELPERS,\n functions: REGISTERED_CUSTOM_FUNCTIONS,\n },\n },\n });\n }\n\n registerComponent<T extends React.ComponentType<any>>(\n component: T,\n meta: CodeComponentMeta<React.ComponentProps<T>>\n ) {\n // making the component meta consistent between codegen and loader\n const stateHelpers = Object.fromEntries(\n Object.entries(meta.states ?? {})\n .filter(\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n ([_, stateSpec]) =>\n // `initFunc` is the only helper function used in RSC phase\n \"initFunc\" in stateSpec\n )\n .map(([stateName, stateSpec]) => [\n stateName,\n { initFunc: stateSpec.initFunc },\n ])\n );\n const helpers = { states: stateHelpers };\n this.internalSubstituteComponent(\n meta.getServerInfo\n ? (props) => {\n const { readContextValue } = getPrepassContextEnv();\n\n const serverInfo = meta.getServerInfo?.(props, {\n readContext: readContextValue as any,\n readDataEnv: () => readContextValue(FakeDataContext),\n readDataSelector: fakeUseSelector,\n readDataSelectors: fakeUseSelectors,\n fetchData: fakeUseMutablePlasmicQueryData,\n });\n\n if (serverInfo && serverInfo.children) {\n const contents: React.ReactNode[] = [] as React.ReactNode[];\n const children = Array.isArray(serverInfo.children)\n ? serverInfo.children\n : [serverInfo.children];\n children.forEach((childData) => {\n contents.push(\n <ContextAndDataProviderWrapper contextAndData={childData}>\n {childData.node}\n </ContextAndDataProviderWrapper>\n );\n });\n return (\n <ContextAndDataProviderWrapper contextAndData={serverInfo}>\n {contents}\n </ContextAndDataProviderWrapper>\n );\n } else {\n return (\n <ContextAndDataProviderWrapper\n contextAndData={serverInfo ?? {}}\n >\n {Object.values(props)\n .flat(Infinity)\n .filter(\n (v: any): v is React.ReactNode =>\n v &&\n typeof v == \"object\" &&\n v.$$typeof &&\n React.isValidElement(v)\n )}\n </ContextAndDataProviderWrapper>\n );\n }\n }\n : component,\n { name: meta.name, isCode: true },\n Object.keys(stateHelpers).length > 0 ? helpers : undefined\n );\n }\n\n registerFunction<F extends (...args: any[]) => any>(\n fn: F,\n meta: CustomFunctionMeta<F>\n ) {\n internalSetRegisteredFunction(fn, meta);\n }\n\n registerGlobalContext<T extends React.ComponentType<any>>(\n context: T,\n meta: GlobalContextMeta<React.ComponentProps<T>>\n ) {\n this.substituteComponent(context, { name: meta.name, isCode: true });\n }\n\n registerTrait: (trait: string, meta: TraitMeta) => void = noop;\n\n registerToken: (token: TokenRegistration) => void = noop;\n\n refreshRegistry() {\n // We swap global variants' useXXXGlobalVariant() hook with\n // a fake one that just reads from the PlasmicRootContext. Because\n // global variant values are not supplied by the generated global variant\n // context providers, but instead by <PlasmicRootProvider/> and by\n // PlasmicComponentLoader.setGlobalVariants(), we redirect these\n // hooks to read from them instead.\n for (const globalGroup of this.getBundle().globalGroups) {\n if (globalGroup.type !== \"global-screen\") {\n SUBSTITUTED_GLOBAL_VARIANT_HOOKS[globalGroup.id] = () => {\n const rootContext = getPrepassContextEnv().readContextValue(\n FakeRootProviderContext\n );\n const loader = this;\n const { name, projectId } = globalGroup;\n const spec = [\n ...loader.getGlobalVariants(),\n ...(rootContext.globalVariants ?? []),\n ].find(\n (s) =>\n s.name === name && (!s.projectId || s.projectId === projectId)\n );\n return spec ? spec.value : undefined;\n };\n }\n }\n super.refreshRegistry();\n }\n}\nexport function handlePrepassPlasmicRootComponent(\n props: Parameters<typeof PlasmicRootProvider>[0]\n) {\n const {\n globalVariants,\n globalContextsProps,\n variation,\n translator,\n Head,\n Link,\n pageRoute,\n pageParams,\n pageQuery,\n suspenseFallback,\n disableLoadingBoundary,\n user,\n userAuthToken,\n isUserLoading,\n authRedirectUri,\n } = props;\n const loader = (props.loader as any)\n .__internal as InternalPrepassPlasmicLoader;\n\n const splits = loader.getActiveSplits();\n const value = {\n globalVariants: mergeGlobalVariantsSpec(\n globalVariants ?? [],\n getGlobalVariantsFromSplits(splits, variation ?? {})\n ),\n globalContextsProps,\n loader,\n variation,\n translator,\n Head,\n Link,\n user,\n userAuthToken,\n isUserLoading,\n authRedirectUri,\n suspenseFallback,\n disableLoadingBoundary,\n };\n\n const { setContextValue, readContextValue } = getPrepassContextEnv();\n\n setContextValue(FakeRootProviderContext, value);\n\n const existingEnv = readContextValue(FakeDataContext) ?? {};\n\n // We can't re-use these functions from @plasmiapp/host while it's a\n // client component package :/\n const fixCatchallParams = (\n params: Record<string, string | string[] | undefined>\n ) => {\n const newParams: Record<string, string | string[]> = {};\n for (const [key, val] of Object.entries(params)) {\n if (!val) {\n continue;\n }\n if (key.startsWith(\"...\")) {\n newParams[key.slice(3)] =\n typeof val === \"string\"\n ? val.replace(/^\\/|\\/$/g, \"\").split(\"/\")\n : val;\n } else {\n newParams[key] = val;\n }\n }\n return newParams;\n };\n\n const mkPathFromRouteAndParams = (\n route: string,\n params: Record<string, string | string[] | undefined>\n ) => {\n if (!params) {\n return route;\n }\n let path = route;\n for (const [key, val] of Object.entries(params)) {\n if (typeof val === \"string\") {\n path = path.replace(`[${key}]`, val);\n } else if (Array.isArray(val)) {\n if (path.includes(`[[...${key}]]`)) {\n path = path.replace(`[[...${key}]]`, val.join(\"/\"));\n } else if (path.includes(`[...${key}]`)) {\n path = path.replace(`[...${key}]`, val.join(\"/\"));\n }\n }\n }\n return path;\n };\n\n const fixedParams = fixCatchallParams(pageParams ?? {});\n\n setContextValue(FakeDataContext, {\n ...existingEnv,\n [\"pageRoute\"]: pageRoute,\n [mkMetaName(\"pageRoute\")]: { advanced: true, label: \"Page route\" },\n\n [\"pagePath\"]: pageRoute\n ? mkPathFromRouteAndParams(pageRoute, fixedParams)\n : undefined,\n [mkMetaName(\"pagePath\")]: { label: \"Page path\" },\n\n [\"params\"]: { ...existingEnv.params, ...fixedParams },\n [mkMetaName(\"params\")]: { label: \"Page URL path params\" },\n\n [\"query\"]: { ...existingEnv.query, ...pageQuery },\n [mkMetaName(\"query\")]: { label: \"Page URL query params\" },\n });\n}\n\nexport function handlePrepassPlasmicComponent(\n props: Parameters<typeof PlasmicComponent>[0]\n) {\n const { component, projectId, componentProps, forceOriginal } = props;\n const { setContextValue, readContextValue } = getPrepassContextEnv();\n const rootContext: PlasmicRootContextValue = readContextValue(\n FakeRootProviderContext\n );\n const isRootLoader = !readContextValue(FakePlasmicComponentContext);\n if (!rootContext) {\n // no existing PlasmicRootProvider\n throw new Error(\n `You must use <PlasmicRootProvider/> at the root of your app`\n );\n }\n const {\n loader,\n globalContextsProps,\n userAuthToken,\n isUserLoading,\n authRedirectUri,\n translator,\n ...rest\n } = rootContext;\n\n const spec = { name: component, projectId, isCode: false };\n const opts = { forceOriginal };\n\n const lookup = loader.getLookup();\n\n if (!lookup.hasComponent(spec)) {\n return null;\n }\n\n const Component = lookup.getComponent(spec, opts);\n\n let element = <Component {...componentProps} />;\n if (isRootLoader) {\n const ReactWebRootProvider = lookup.getRootProvider();\n const GlobalContextsProvider = lookup.getGlobalContextsProvider({\n name: component,\n projectId,\n });\n setContextValue(FakePlasmicComponentContext, true);\n element = (\n <ReactWebRootProvider\n {...rest}\n userAuthToken={userAuthToken}\n isUserLoading={isUserLoading}\n authRedirectUri={authRedirectUri}\n i18n={{\n translator,\n tagPrefix: loader.opts.i18n?.tagPrefix,\n }}\n >\n {element}\n </ReactWebRootProvider>\n );\n if (GlobalContextsProvider) {\n element = (\n <GlobalContextsProvider {...globalContextsProps}>\n {element}\n </GlobalContextsProvider>\n );\n }\n }\n return element;\n}\n\nexport function handlePlasmicPrepassContext({\n cache,\n}: Parameters<typeof PlasmicPrepassContext>[0]) {\n getPrepassContextEnv().setContextValue(FakePlasmicPrepassContext, cache);\n}\n\nfunction getPrepassContextEnv(): {\n setContextValue: (context: React.Context<any>, value: any) => void;\n readContextValue: (context: React.Context<any>) => any;\n} {\n return (globalThis as any).__ssrPrepassEnv;\n}\n\n// Provides context values to the children, described by\n// `ComponentMeta.getServerInfo`.\nfunction ContextAndDataProviderWrapper({\n children,\n contextAndData,\n}: {\n children: React.ReactNode;\n contextAndData: {\n providedData?: ServerProvidedData | ServerProvidedData[];\n providedContexts?: ServerProvidedContext | ServerProvidedContext[];\n };\n}) {\n const { setContextValue, readContextValue } = getPrepassContextEnv();\n const contexts = contextAndData.providedContexts\n ? Array.isArray(contextAndData.providedContexts)\n ? contextAndData.providedContexts\n : [contextAndData.providedContexts]\n : [];\n const providedData = contextAndData.providedData\n ? Array.isArray(contextAndData.providedData)\n ? contextAndData.providedData\n : [contextAndData.providedData]\n : [];\n contexts.forEach((context) => {\n setContextValue(context.contextKey as any, context.value);\n });\n let $ctx = readContextValue(FakeDataContext) ?? {};\n providedData.forEach(({ name, data }) => {\n $ctx = {\n ...$ctx,\n [name]: data,\n };\n });\n setContextValue(FakeDataContext, $ctx);\n return <>{children}</>;\n}\n", "import type {\n ComponentHelpers,\n ComponentHelpers as InternalCodeComponentHelpers,\n CodeComponentMeta as InternalCodeComponentMeta,\n CustomFunctionMeta as InternalCustomFunctionMeta,\n GlobalContextMeta as InternalGlobalContextMeta,\n StateHelpers,\n StateSpec,\n TokenRegistration,\n TraitMeta,\n useDataEnv,\n useSelector,\n useSelectors,\n} from \"@plasmicapp/host\";\nimport {\n LoaderBundleCache,\n PageMeta,\n PlasmicModulesFetcher,\n Registry,\n TrackRenderOptions,\n} from \"@plasmicapp/loader-core\";\nimport {\n CodeModule,\n ComponentMeta,\n LoaderBundleOutput,\n internal_getCachedBundleInNodeServer,\n} from \"@plasmicapp/loader-fetcher\";\nimport { getActiveVariation, getExternalIds } from \"@plasmicapp/loader-splits\";\nimport type { useMutablePlasmicQueryData } from \"@plasmicapp/query\";\nimport type { GlobalVariantSpec } from \"./PlasmicRootProvider\";\nimport { mergeBundles, prepComponentData } from \"./bundles\";\nimport { ComponentLookup } from \"./component-lookup\";\nimport {\n ComponentLookupSpec,\n getCompMetas,\n getLookupSpecName,\n isBrowser,\n isDynamicPagePath,\n uniq,\n} from \"./utils\";\nimport { getPlasmicCookieValues, updatePlasmicCookieValue } from \"./variation\";\n\nexport interface InitOptions {\n projects: {\n id: string;\n token: string;\n version?: string;\n }[];\n cache?: LoaderBundleCache;\n platform?: \"react\" | \"nextjs\" | \"gatsby\";\n platformOptions?: {\n nextjs?: {\n appDir: boolean;\n };\n };\n preview?: boolean;\n host?: string;\n onClientSideFetch?: \"warn\" | \"error\";\n i18n?: {\n keyScheme: \"content\" | \"hash\" | \"path\";\n tagPrefix?: string;\n };\n /**\n * @deprecated use i18n.keyScheme instead\n */\n i18nKeyScheme?: \"content\" | \"hash\";\n\n /**\n * By default, fetchComponentData() and fetchPages() calls cached in memory\n * with the PlasmicComponentLoader instance. If alwaysFresh is true, then\n * data is always freshly fetched over the network.\n */\n alwaysFresh?: boolean;\n\n /**\n * If true, generated code from the server won't include page metadata tags\n */\n skipHead?: boolean;\n\n /**\n * If true, uses browser / node's native fetch\n */\n nativeFetch?: boolean;\n\n /**\n * If true, will not redirect to the codegen server automatically, and will\n * try to reuse the existing bundle in the cache.\n */\n manualRedirect?: boolean;\n}\n\nexport interface ComponentRenderData {\n entryCompMetas: (ComponentMeta & { params?: Record<string, string> })[];\n bundle: LoaderBundleOutput;\n remoteFontUrls: string[];\n}\n\nexport interface ComponentSubstitutionSpec {\n lookup: ComponentLookupSpec;\n component: React.ComponentType<any>;\n codeComponentHelpers?: InternalCodeComponentHelpers<\n React.ComponentProps<any>\n >;\n}\n\nexport interface PlasmicRootWatcher {\n onDataFetched?: () => void;\n}\n\n/**\n * Helper functions to describe code component behaviors, in order to allow\n * data extraction in RSC / Next.js App routing.\n */\nexport interface ReactServerOps {\n readDataEnv: typeof useDataEnv;\n readDataSelector: typeof useSelector;\n readDataSelectors: typeof useSelectors;\n /**\n * The contexts are passed using a key instead of the context provider\n * Notice it cannot access the default context value if none has been provided,\n * since React server components cannot create contexts.\n */\n readContext: (contextKey: string) => any;\n /**\n * Allows data fetching from the code component and caching the result,\n * which will be stored in the `queryCache` returned by\n * `extractPlasmicQueryData`.\n */\n fetchData: typeof useMutablePlasmicQueryData;\n}\n\n/**\n * Represents data provided by a code component via `DataProvider`\n */\nexport interface ServerProvidedData {\n name: string;\n data: any;\n}\n\n/**\n * Provides a new value for a given context key, similar to Context.Provider.\n * The context itself is not available (RSC doesn't allow calling\n * `createContext`) so each context will need to be represented as a unique\n * \"context key\". Also it means the default context value is not available\n * in case no value is passed (and reading that context will return `undefined`)\n */\nexport interface ServerProvidedContext {\n /**\n * Identifier to the context, required to read it later via\n * `ReactServerOps.readContext()`.\n */\n contextKey: string;\n /**\n * Context value being provided (similar to `Context.Provider`).\n */\n value: any;\n}\n\n/**\n * Each child of a code component might receive separate `DataProvider` and\n * Context values.\n */\nexport interface ServerChildData {\n providedData?: ServerProvidedData | ServerProvidedData[];\n providedContexts?: ServerProvidedContext | ServerProvidedContext[];\n node: React.ReactNode;\n}\n\nexport interface ServerInfo {\n /**\n * Optional: Indicates the React Nodes created by the component and the\n * respective contexts provided to them. If not specified, it will render the\n * children passed to the component as props.\n */\n children?: ServerChildData | ServerChildData[];\n providedData?: ServerProvidedData | ServerProvidedData[];\n providedContexts?: ServerProvidedContext | ServerProvidedContext[];\n}\n\nexport type CodeComponentMeta<P> = Omit<\n InternalCodeComponentMeta<P>,\n \"importPath\" | \"componentHelpers\" | \"states\"\n> & {\n /**\n * The path to be used when importing the component in the generated code.\n * It can be the name of the package that contains the component, or the path\n * to the file in the project (relative to the root directory).\n * Optional: not used by Plasmic headless API, only by codegen.\n */\n importPath?: string;\n /**\n * The states helpers are registered together with the states for the Plasmic headless API\n */\n states?: Record<string, StateSpec<P> & StateHelpers<P, any>>;\n\n /**\n * Helper function to enable data extraction when running Plasmic from\n * Next.js App Router.\n */\n getServerInfo?: (props: P, ops: ReactServerOps) => ServerInfo;\n};\n\nexport type GlobalContextMeta<P> = Omit<\n InternalGlobalContextMeta<P>,\n \"importPath\"\n> & {\n /**\n * The path to be used when importing the component in the generated code.\n * It can be the name of the package that contains the component, or the path\n * to the file in the project (relative to the root directory).\n * Optional: not used by Plasmic headless API, only by codegen.\n */\n importPath?: string;\n};\n\nexport type CustomFunctionMeta<F extends (...args: any[]) => any> = Omit<\n InternalCustomFunctionMeta<F>,\n \"importPath\"\n> & {\n /**\n * The path to be used when importing the function in the generated code.\n * It can be the name of the package that contains the function, or the path\n * to the file in the project (relative to the root directory).\n * Optional: not used by Plasmic headless API, only by codegen.\n */\n importPath?: string;\n};\n\nexport type FetchPagesOpts = {\n /**\n * Whether to include dynamic pages in fetchPages() output. A page is\n * considered dynamic if its path contains some param between brackets,\n * e.g. \"[slug]\".\n */\n includeDynamicPages?: boolean;\n};\n\nexport const SUBSTITUTED_COMPONENTS: Record<\n string,\n React.ComponentType<any>\n> = {};\nexport const REGISTERED_CODE_COMPONENT_HELPERS: Record<\n string,\n InternalCodeComponentHelpers<React.ComponentProps<any>>\n> = {};\nexport const SUBSTITUTED_GLOBAL_VARIANT_HOOKS: Record<string, () => any> = {};\nexport const REGISTERED_CUSTOM_FUNCTIONS: Record<\n string,\n (...args: any[]) => any\n> = {};\n\nexport function customFunctionImportAlias<F extends (...args: any[]) => any>(\n meta: CustomFunctionMeta<F>\n) {\n const customFunctionPrefix = `__fn_`;\n return meta.namespace\n ? `${customFunctionPrefix}${meta.namespace}__${meta.name}`\n : `${customFunctionPrefix}${meta.name}`;\n}\n\nexport function internalSetRegisteredFunction<\n F extends (...args: any[]) => any\n>(fn: F, meta: CustomFunctionMeta<F>) {\n REGISTERED_CUSTOM_FUNCTIONS[customFunctionImportAlias(meta)] = fn;\n}\n\ninterface BuiltinRegisteredModules {\n react: typeof import(\"react\");\n \"react-dom\": typeof import(\"react-dom\");\n \"react/jsx-runtime\": typeof import(\"react/jsx-runtime\");\n \"react/jsx-dev-runtime\": typeof import(\"react/jsx-dev-runtime\");\n \"@plasmicapp/query\": typeof import(\"@plasmicapp/query\");\n \"@plasmicapp/data-sources-context\": typeof import(\"@plasmicapp/data-sources-context\");\n \"@plasmicapp/host\": typeof import(\"@plasmicapp/host\");\n \"@plasmicapp/loader-runtime-registry\": {\n components: Record<string, React.ComponentType<any>>;\n globalVariantHooks: Record<string, () => any>;\n codeComponentHelpers: Record<string, ComponentHelpers<any>>;\n functions: Record<string, (...args: any[]) => any>;\n };\n}\n\nexport interface FetchComponentDataOpts {\n /**\n * Will fetch either code targeting SSR or browser hydration in the\n * returned bundle.\n *\n * By default, the target is browser. That's okay, because even when\n * doing SSR, as long as you are using the same instance of PlasmicLoader\n * that was used to fetch component data, it will still know how to get at\n * the server code.\n *\n * But, if you are building your own SSR solution, where fetching and rendering\n * are using different instances of PlasmicLoader, then you'll want to make\n * sure that when you fetch, you are fetching the right one to be used in the\n * right environment for either SSR or browser hydration.\n */\n target?: \"server\" | \"browser\";\n}\n\nfunction parseFetchComponentDataArgs(\n specs: ComponentLookupSpec[],\n opts?: FetchComponentDataOpts\n): { specs: ComponentLookupSpec[]; opts?: FetchComponentDataOpts };\nfunction parseFetchComponentDataArgs(...specs: ComponentLookupSpec[]): {\n specs: ComponentLookupSpec[];\n opts?: FetchComponentDataOpts;\n};\nfunction parseFetchComponentDataArgs(...args: any[]) {\n let specs: ComponentLookupSpec[];\n let opts: FetchComponentDataOpts | undefined;\n if (Array.isArray(args[0])) {\n specs = args[0];\n opts = args[1];\n } else {\n specs = args;\n opts = undefined;\n }\n return { specs, opts };\n}\n\n/** Subset of loader functionality that works on Client and React Server Components. */\nexport abstract class BaseInternalPlasmicComponentLoader {\n public readonly opts: InitOptions;\n private readonly registry = new Registry();\n private readonly fetcher: PlasmicModulesFetcher;\n private readonly onBundleMerged?: () => void;\n private readonly onBundleFetched?: () => void;\n private globalVariants: GlobalVariantSpec[] = [];\n private subs: ComponentSubstitutionSpec[] = [];\n\n private bundle: LoaderBundleOutput = {\n modules: {\n browser: [],\n server: [],\n },\n components: [],\n globalGroups: [],\n projects: [],\n activeSplits: [],\n bundleKey: null,\n deferChunksByDefault: false,\n disableRootLoadingBoundaryByDefault: false,\n filteredIds: {},\n };\n\n constructor(args: {\n opts: InitOptions;\n fetcher: PlasmicModulesFetcher;\n /** Called after `mergeBundle` (including `fetch` calls). */\n onBundleMerged?: () => void;\n /** Called after any `fetch` calls. */\n onBundleFetched?: () => void;\n builtinModules: BuiltinRegisteredModules;\n }) {\n this.opts = args.opts;\n this.fetcher = args.fetcher;\n this.onBundleMerged = args.onBundleMerged;\n this.onBundleFetched = args.onBundleFetched;\n this.registerModules(args.builtinModules);\n }\n\n private maybeGetCompMetas(...specs: ComponentLookupSpec[]) {\n const found = new Set<ComponentMeta>();\n const missing: ComponentLookupSpec[] = [];\n for (const spec of specs) {\n const filteredMetas = getCompMetas(this.bundle.components, spec);\n if (filteredMetas.length > 0) {\n filteredMetas.forEach((meta) => found.add(meta));\n } else {\n missing.push(spec);\n }\n }\n return { found: Array.from(found.keys()), missing };\n }\n\n async maybeFetchComponentData(\n specs: ComponentLookupSpec[],\n opts?: FetchComponentDataOpts\n ): Promise<ComponentRenderData | null>;\n async maybeFetchComponentData(\n ...specs: ComponentLookupSpec[]\n ): Promise<ComponentRenderData | null>;\n async maybeFetchComponentData(\n ...args: any[]\n ): Promise<ComponentRenderData | null> {\n const { specs, opts } = parseFetchComponentDataArgs(...args);\n const returnWithSpecsToFetch = async (\n specsToFetch: ComponentLookupSpec[]\n ) => {\n await this.fetchMissingData({ missingSpecs: specsToFetch });\n const { found: existingMetas2, missing: missingSpecs2 } =\n this.maybeGetCompMetas(...specs);\n if (missingSpecs2.length > 0) {\n return null;\n }\n\n return prepComponentData(this.bundle, existingMetas2, opts);\n };\n\n if (this.opts.alwaysFresh) {\n // If alwaysFresh, then we treat all specs as missing\n return await returnWithSpecsToFetch(specs);\n }\n\n // Else we only fetch actually missing specs\n const { found: existingMetas, missing: missingSpecs } =\n this.maybeGetCompMetas(...specs);\n if (missingSpecs.length === 0) {\n return prepComponentData(this.bundle, existingMetas, opts);\n }\n\n return await returnWithSpecsToFetch(missingSpecs);\n }\n\n async fetchComponentData(\n specs: ComponentLookupSpec[],\n opts?: FetchComponentDataOpts\n ): Promise<ComponentRenderData>;\n async fetchComponentData(\n ...specs: ComponentLookupSpec[]\n ): Promise<ComponentRenderData>;\n async fetchComponentData(...args: any[]): Promise<ComponentRenderData> {\n const { specs, opts } = parseFetchComponentDataArgs(...args);\n const data = await this.maybeFetchComponentData(specs, opts);\n\n if (!data) {\n const { missing: missingSpecs } = this.maybeGetCompMetas(...specs);\n throw new Error(\n `Unable to find components ${missingSpecs\n .map(getLookupSpecName)\n .join(\", \")}`\n );\n }\n\n return data;\n }\n\n async fetchPages(opts?: FetchPagesOpts) {\n this.maybeReportClientSideFetch(\n () => `Plasmic: fetching all page metadata in the browser`\n );\n const data = await this.fetchAllData();\n return data.components.filter(\n (comp) =>\n comp.isPage &&\n comp.path &&\n (opts?.includeDynamicPages || !isDynamicPagePath(comp.path))\n ) as PageMeta[];\n }\n\n async fetchComponents() {\n this.maybeReportClientSideFetch(\n () => `Plasmic: fetching all component metadata in the browser`\n );\n const data = await this.fetchAllData();\n return data.components;\n }\n\n getActiveSplits() {\n return this.bundle.activeSplits;\n }\n\n getChunksUrl(bundle: LoaderBundleOutput, modules: CodeModule[]) {\n return this.fetcher.getChunksUrl(bundle, modules);\n }\n\n private async fetchMissingData(opts: {\n missingSpecs: ComponentLookupSpec[];\n }) {\n // TODO: do better than just fetching everything\n this.maybeReportClientSideFetch(\n () =>\n `Plasmic: fetching missing components in the browser: ${opts.missingSpecs\n .map((spec) => getLookupSpecName(spec))\n .join(\", \")}`\n );\n return this.fetchAllData();\n }\n\n private maybeReportClientSideFetch(mkMsg: () => string) {\n if (isBrowser && this.opts.onClientSideFetch) {\n const msg = mkMsg();\n if (this.opts.onClientSideFetch === \"warn\") {\n console.warn(msg);\n } else {\n throw new Error(msg);\n }\n }\n }\n\n private async fetchAllData() {\n const bundle = await this.fetcher.fetchAllData();\n this.mergeBundle(bundle);\n this.onBundleFetched?.();\n return bundle;\n }\n\n mergeBundle(newBundle: LoaderBundleOutput) {\n newBundle.bundleKey = newBundle.bundleKey ?? null;\n if (\n newBundle.bundleKey &&\n this.bundle.bundleKey &&\n newBundle.bundleKey !== this.bundle.bundleKey\n ) {\n console.warn(\n `Plasmic Error: Different code export hashes. This can happen if your app is using different loaders with different project IDs or project versions.\nConflicting values:\n${newBundle.bundleKey}\n${this.bundle.bundleKey}`\n );\n }\n // Merge the old bundle into the new bundle, this way\n // the new bundle will enforce the latest data from the server\n // allowing elements to be deleted by newer bundles\n this.bundle = mergeBundles(newBundle, this.bundle);\n\n this.onBundleMerged?.();\n }\n\n getBundle(): LoaderBundleOutput {\n return this.bundle;\n }\n\n clearCache() {\n this.bundle = {\n modules: {\n browser: [],\n server: [],\n },\n components: [],\n globalGroups: [],\n projects: [],\n activeSplits: [],\n bundleKey: null,\n deferChunksByDefault: false,\n disableRootLoadingBoundaryByDefault: false,\n filteredIds: {},\n };\n this.registry.clear();\n }\n\n registerModules(modules: Record<string, any>) {\n if (\n Object.keys(modules).some(\n (name) => this.registry.getRegisteredModule(name) !== modules[name]\n )\n ) {\n if (!this.registry.isEmpty()) {\n console.warn(\n \"Calling PlasmicComponentLoader.registerModules() after Plasmic component has rendered; starting over.\"\n );\n this.registry.clear();\n }\n for (const key of Object.keys(modules)) {\n this.registry.register(key, modules[key]);\n }\n }\n }\n\n substituteComponent<P>(\n component: React.ComponentType<P>,\n name: ComponentLookupSpec\n ) {\n this.internalSubstituteComponent(component, name, undefined);\n }\n\n protected internalSubstituteComponent<P>(\n component: React.ComponentType<P>,\n name: ComponentLookupSpec,\n codeComponentHelpers:\n | InternalCodeComponentHelpers<\n React.ComponentProps<React.ComponentType<P>>\n >\n | undefined\n ) {\n if (!this.isRegistryEmpty()) {\n console.warn(\n \"Calling PlasmicComponentLoader.registerSubstitution() after Plasmic component has rendered; starting over.\"\n );\n this.clearRegistry();\n }\n this.subs.push({ lookup: name, component, codeComponentHelpers });\n }\n\n abstract registerComponent<T extends React.ComponentType<any>>(\n component: T,\n meta: CodeComponentMeta<React.ComponentProps<T>>\n ): void;\n abstract registerFunction<F extends (...args: any[]) => any>(\n fn: F,\n meta: CustomFunctionMeta<F>\n ): void;\n abstract registerGlobalContext<T extends React.ComponentType<any>>(\n context: T,\n meta: GlobalContextMeta<React.ComponentProps<T>>\n ): void;\n abstract registerTrait(trait: string, meta: TraitMeta): void;\n abstract registerToken(token: TokenRegistration): void;\n\n protected refreshRegistry() {\n // Once we have received data, we register components to\n // substitute. We had to wait for data to do this so\n // that we can look up the right module name to substitute\n // in component meta.\n for (const sub of this.subs) {\n const metas = getCompMetas(this.getBundle().components, sub.lookup);\n metas.forEach((meta) => {\n SUBSTITUTED_COMPONENTS[meta.id] = sub.component;\n if (sub.codeComponentHelpers) {\n REGISTERED_CODE_COMPONENT_HELPERS[meta.id] = sub.codeComponentHelpers;\n }\n });\n }\n\n this.registry.updateModules(this.getBundle());\n }\n\n isRegistryEmpty() {\n return this.registry.isEmpty();\n }\n\n clearRegistry() {\n this.registry.clear();\n }\n\n setGlobalVariants(globalVariants: GlobalVariantSpec[]) {\n this.globalVariants = globalVariants;\n }\n\n getGlobalVariants() {\n return this.globalVariants;\n }\n\n registerPrefetchedBundle(bundle: LoaderBundleOutput) {\n // For React Server Components (Next.js 13+),\n // we need to pass server modules in LoaderBundleOutput from Server Components to Client Components.\n // We don't want to pass them via normal page props because that will be serialized to the browser.\n // Instead, we pass the bundle (including the server modules) via the Node `global` variable.\n //\n // This is the code that reads the stored bundle and merges it back into the loader.\n if (!isBrowser) {\n // Check if we have a cached bundle on this Node server.\n const cachedBundle = internal_getCachedBundleInNodeServer(this.opts);\n if (cachedBundle) {\n // If it's there, merge the cached bundle first.\n this.mergeBundle(cachedBundle);\n }\n }\n this.mergeBundle(bundle);\n }\n\n getLookup() {\n return new ComponentLookup(this.getBundle(), this.registry);\n }\n\n trackConversion(_value = 0) {\n // no-op: tracking removed from loader packages\n }\n\n public async getActiveVariation(\n opts: Omit<Parameters<typeof getActiveVariation>[0], \"splits\">\n ) {\n await this.fetchComponents();\n return getActiveVariation({\n ...opts,\n splits: this.getBundle().activeSplits,\n });\n }\n\n public getTeamIds(): string[] {\n return uniq(\n this.getBundle()\n .projects.map((p) =>\n p.teamId ? `${p.teamId}${p.indirect ? \"@indirect\" : \"\"}` : null\n )\n .filter((x): x is string => !!x)\n );\n }\n\n public getProjectIds(): string[] {\n return uniq(\n this.getBundle().projects.map(\n (p) => `${p.id}${p.indirect ? \"@indirect\" : \"\"}`\n )\n );\n }\n\n public trackRender(_opts?: TrackRenderOptions) {\n // no-op: tracking removed from loader packages\n }\n\n public loadServerQueriesModule(fileName: string) {\n return this.registry.load(fileName);\n }\n}\n\n/**\n * Library for fetching component data, and registering\n * custom components.\n */\nexport class PlasmicComponentLoader {\n private __internal: BaseInternalPlasmicComponentLoader;\n\n constructor(internal: BaseInternalPlasmicComponentLoader) {\n this.__internal = internal;\n }\n\n /**\n * Sets global variants to be used for all components. Note that\n * this is not reactive, and will not re-render all components\n * already mounted; instead, it should be used to activate global\n * variants that should always be activated for the lifetime of this\n * app. If you'd like to reactively change the global variants,\n * you should specify them via <PlasmicRootProvider />\n */\n setGlobalVariants(globalVariants: GlobalVariantSpec[]) {\n this.__internal.setGlobalVariants(globalVariants);\n }\n\n registerModules(modules: Record<string, any>) {\n this.__internal.registerModules(modules);\n }\n\n /**\n * Register custom components that should be swapped in for\n * components defined in your project. You can use this to\n * swap in / substitute a Plasmic component with a \"real\" component.\n */\n substituteComponent<P>(\n component: React.ComponentType<P>,\n name: ComponentLookupSpec\n ) {\n this.__internal.substituteComponent(component, name);\n }\n\n /**\n * Register code components to be used on Plasmic Editor.\n */\n registerComponent<T extends React.ComponentType<any>>(\n component: T,\n meta: CodeComponentMeta<React.ComponentProps<T>>\n ): void;\n\n /**\n * [[deprecated]] Please use `substituteComponent` instead for component\n * substitution, or the other `registerComponent` overload to register\n * code components to be used on Plasmic Editor.\n *\n * @see `substituteComponent`\n */\n registerComponent<T extends React.ComponentType<any>>(\n component: T,\n name: ComponentLookupSpec\n ): void;\n\n registerComponent<T extends React.ComponentType<any>>(\n component: T,\n metaOrName: ComponentLookupSpec | CodeComponentMeta<React.ComponentProps<T>>\n ) {\n // 'props' is a required field in CodeComponentMeta\n if (metaOrName && typeof metaOrName === \"object\" && \"props\" in metaOrName) {\n this.__internal.registerComponent(component, metaOrName);\n } else {\n // Deprecated call\n if (\n process.env.NODE_ENV === \"development\" &&\n !this.warnedRegisterComponent\n ) {\n console.warn(\n `PlasmicLoader: Using deprecated method \\`registerComponent\\` for component substitution. ` +\n `Please consider using \\`substituteComponent\\` instead.`\n );\n this.warnedRegisterComponent = true;\n }\n this.substituteComponent(component, metaOrName);\n }\n }\n private warnedRegisterComponent = false;\n\n registerFunction<F extends (...args: any[]) => any>(\n fn: F,\n meta: CustomFunctionMeta<F>\n ) {\n this.__internal.registerFunction(fn, meta);\n }\n\n registerGlobalContext<T extends React.ComponentType<any>>(\n context: T,\n meta: GlobalContextMeta<React.ComponentProps<T>>\n ) {\n this.__internal.registerGlobalContext(context, meta);\n }\n\n registerTrait(trait: string, meta: TraitMeta) {\n this.__internal.registerTrait(trait, meta);\n }\n\n registerToken(token: TokenRegistration) {\n this.__internal.registerToken(token);\n }\n\n /**\n * Pre-fetches component data needed to for PlasmicLoader to render\n * these components. Should be passed into PlasmicRootProvider as\n * the prefetchedData prop.\n *\n * You can look up a component either by:\n * - the name of the component\n * - the path for a page component\n * - an array of strings that make up parts of the path\n * - object { name: \"name_or_path\", projectId: ...}, to specify which project\n * to use, if multiple projects have the same component name\n *\n * Throws an Error if a specified component to fetch does not exist in\n * the Plasmic project.\n */\n fetchComponentData(\n ...specs: ComponentLookupSpec[]\n ): Promise<ComponentRenderData>;\n fetchComponentData(\n specs: ComponentLookupSpec[],\n opts?: FetchComponentDataOpts\n ): Promise<ComponentRenderData>;\n fetchComponentData(...args: any[]): Promise<ComponentRenderData> {\n return this.__internal.fetchComponentData(...args);\n }\n\n /**\n * Like fetchComponentData(), but returns null instead of throwing an Error\n * when a component is not found. Useful when you are implementing a catch-all\n * page and want to check if a specific path had been defined for Plasmic.\n */\n async maybeFetchComponentData(\n ...specs: ComponentLookupSpec[]\n ): Promise<ComponentRenderData | null>;\n async maybeFetchComponentData(\n specs: ComponentLookupSpec[],\n opts?: FetchComponentDataOpts\n ): Promise<ComponentRenderData | null>;\n async maybeFetchComponentData(\n ...args: any[]\n ): Promise<ComponentRenderData | null> {\n return this.__internal.maybeFetchComponentData(...args);\n }\n\n /**\n * Returns all the page component metadata for these projects.\n */\n async fetchPages(opts?: FetchPagesOpts) {\n return this.__internal.fetchPages(opts);\n }\n\n /**\n * Returns all components metadata for these projects.\n */\n async fetchComponents() {\n return this.__internal.fetchComponents();\n }\n\n protected async _getActiveVariation(\n opts: Parameters<typeof this.__internal.getActiveVariation>[0]\n ) {\n return this.__internal.getActiveVariation(opts);\n }\n\n async getActiveVariation(opts: {\n known?: Record<string, string>;\n traits: Record<string, string | number | boolean>;\n }) {\n return this._getActiveVariation({\n traits: opts.traits,\n getKnownValue: (key: string) => {\n if (opts.known) {\n return opts.known[key];\n } else {\n const cookies = getPlasmicCookieValues();\n return cookies[key];\n }\n },\n updateKnownValue: (key: string, value: string) => {\n if (!opts.known) {\n updatePlasmicCookieValue(key, value);\n }\n },\n });\n }\n\n getChunksUrl(bundle: LoaderBundleOutput, modules: CodeModule[]) {\n return this.__internal.getChunksUrl(bundle, modules);\n }\n\n getExternalVariation(\n variation: Record<string, string>,\n filters?: Parameters<typeof getExternalIds>[2]\n ) {\n return getExternalIds(this.getActiveSplits(), variation, filters);\n }\n\n getActiveSplits() {\n return this.__internal.getActiveSplits();\n }\n\n trackConversion(value = 0) {\n this.__internal.trackConversion(value);\n }\n\n clearCache() {\n return this.__internal.clearCache();\n }\n\n async unstable__getServerQueriesData(\n renderData: ComponentRenderData,\n $ctx: Record<string, any>\n ) {\n if (renderData.entryCompMetas.length === 0) {\n return {};\n }\n\n const fileName = renderData.entryCompMetas[0].serverQueriesExecFuncFileName;\n\n if (!fileName) {\n return {};\n }\n\n const module = this.__internal.loadServerQueriesModule(fileName);\n const { executeServerQueries } = module;\n\n try {\n const $serverQueries = await executeServerQueries($ctx);\n return $serverQueries;\n } catch (err) {\n console.error(\"Error executing server queries function\", err);\n return {};\n }\n }\n}\n", "import {\n ComponentMeta,\n getBundleSubset,\n LoaderBundleOutput,\n} from \"@plasmicapp/loader-core\";\nimport type { ComponentRenderData } from \"./loader-shared\";\nimport { intersect } from \"./utils\";\n\nfunction getUsedComps(allComponents: ComponentMeta[], entryCompIds: string[]) {\n const q: string[] = [...entryCompIds];\n const seenIds = new Set<string>(entryCompIds);\n const componentMetaById = new Map<string, ComponentMeta>(\n allComponents.map((meta) => [meta.id, meta])\n );\n const usedComps: ComponentMeta[] = [];\n while (q.length > 0) {\n const [id] = q.splice(0, 1);\n const meta = componentMetaById.get(id);\n if (!meta) {\n continue;\n }\n usedComps.push(meta);\n meta.usedComponents.forEach((usedCompId) => {\n if (!seenIds.has(usedCompId)) {\n seenIds.add(usedCompId);\n q.push(usedCompId);\n }\n });\n }\n return usedComps;\n}\n\nexport function prepComponentData(\n bundle: LoaderBundleOutput,\n compMetas: ComponentMeta[],\n opts?: {\n target?: \"browser\" | \"server\";\n }\n): ComponentRenderData {\n if (compMetas.length === 0) {\n return {\n entryCompMetas: bundle.components,\n bundle: bundle,\n remoteFontUrls: [],\n };\n }\n\n const usedComps = getUsedComps(\n bundle.components,\n compMetas.map((compMeta) => compMeta.id)\n );\n const compPaths = usedComps.map((compMeta) => compMeta.entry);\n const subBundle = getBundleSubset(\n bundle,\n [\n \"entrypoint.css\",\n ...compPaths,\n \"root-provider.js\",\n ...bundle.projects\n .map((x) => x.styleTokensProviderFileName)\n .filter((x) => !!x),\n ...bundle.projects\n .map((x) => x.globalContextsProviderFileName)\n .filter((x) => !!x),\n // We need to explicitly include global context provider components\n // to make sure they are kept in bundle.components. That's because\n // for esbuild, just the globalContextsProviderFileName is not enough,\n // because it will import a chunk that includes the global context\n // component, instead of importing that global context component's\n // entry file. And because nothing depends on the global context component's\n // entry file, we end up excluding the global context component from\n // bundle.components, which then makes its substitution not work.\n // Instead, we forcibly include it here (we'll definitely need it anyway!).\n ...bundle.components\n .filter((c) => c.isGlobalContextProvider)\n .map((c) => c.entry),\n ...bundle.globalGroups.map((g) => g.contextFile),\n ],\n opts\n );\n\n const remoteFontUrls: string[] = [];\n subBundle.projects.forEach((p) =>\n remoteFontUrls.push(...p.remoteFonts.map((f) => f.url))\n );\n\n return {\n entryCompMetas: compMetas,\n bundle: subBundle,\n remoteFontUrls,\n };\n}\n\n// It's important to deep clone any attributes that are going to be changed in the\n// target bundle, since the build of pages can be done in multiple stages/processes\n// we don't want to mutate the original bundle, which can impact other pages.\nexport function mergeBundles(\n target: LoaderBundleOutput,\n from: LoaderBundleOutput\n) {\n const existingProjects = new Set(target.projects.map((p) => p.id));\n const newProjects = from.projects.filter((p) => !existingProjects.has(p.id));\n if (newProjects.length > 0) {\n target = {\n ...target,\n projects: [...target.projects, ...newProjects],\n };\n }\n\n const existingCompIds = new Set(target.components.map((c) => c.id));\n\n function shouldIncludeComponentInBundle(c: ComponentMeta) {\n // If the component is already present in the target bundle, don't include it\n if (existingCompIds.has(c.id)) {\n return false;\n }\n // If the component belongs to a project that is not present in the target bundle,\n // include it\n if (!existingProjects.has(c.projectId)) {\n return true;\n }\n // If the component is present in the filteredIds of the project it belongs to,\n // in the target bundle, we consider that the component was not deleted in the target\n // bundle, so we can include it\n const targetBundleFilteredIds = target.filteredIds[c.projectId] ?? [];\n return targetBundleFilteredIds.includes(c.id);\n }\n\n const newCompMetas = from.components.filter((m) =>\n shouldIncludeComponentInBundle(m)\n );\n if (newCompMetas.length > 0) {\n target = {\n ...target,\n components: [...target.components, ...newCompMetas],\n };\n\n // Deep clone the filteredIds object to avoid mutating the original bundle\n target.filteredIds = Object.fromEntries(\n Object.entries(target.filteredIds).map(([k, v]) => [k, [...v]])\n );\n\n from.projects.forEach((fromProject) => {\n const projectId = fromProject.id;\n const fromBundleFilteredIds = from.filteredIds[projectId] ?? [];\n if (!existingProjects.has(projectId)) {\n target.filteredIds[projectId] = [...fromBundleFilteredIds];\n } else {\n target.filteredIds[projectId] = intersect(\n target.filteredIds[projectId] ?? [],\n fromBundleFilteredIds\n );\n }\n });\n }\n\n const existingModules = {\n browser: new Set(target.modules.browser.map((m) => m.fileName)),\n server: new Set(target.modules.server.map((m) => m.fileName)),\n };\n const newModules = {\n browser: from.modules.browser.filter(\n (m) => !existingModules.browser.has(m.fileName)\n ),\n server: from.modules.server.filter(\n (m) => !existingModules.server.has(m.fileName)\n ),\n };\n if (newModules.browser.length > 0 || newModules.server.length > 0) {\n target = {\n ...target,\n modules: {\n browser: [...target.modules.browser, ...newModules.browser],\n server: [...target.modules.server, ...newModules.server],\n },\n };\n }\n\n const existingGlobalIds = new Set(target.globalGroups.map((g) => g.id));\n const newGlobals = from.globalGroups.filter(\n (g) => !existingGlobalIds.has(g.id)\n );\n if (newGlobals.length > 0) {\n target = {\n ...target,\n globalGroups: [...target.globalGroups, ...newGlobals],\n };\n }\n\n const existingSplitIds = new Set(target.activeSplits.map((s) => s.id));\n const newSplits =\n from.activeSplits.filter(\n // Don't include splits belonging to projects already present\n // in the target bundle\n (s) => !existingSplitIds.has(s.id) && !existingProjects.has(s.projectId)\n ) ?? [];\n if (newSplits.length > 0) {\n target = {\n ...target,\n activeSplits: [...target.activeSplits, ...newSplits],\n };\n }\n\n // Avoid `undefined` as it cannot be serialized as JSON\n target.bundleKey = target.bundleKey ?? from.bundleKey ?? null;\n target.deferChunksByDefault =\n target.deferChunksByDefault ?? from.deferChunksByDefault ?? false;\n\n target.disableRootLoadingBoundaryByDefault =\n target.disableRootLoadingBoundaryByDefault ??\n from.disableRootLoadingBoundaryByDefault ??\n false;\n\n return target;\n}\n\nexport const convertBundlesToComponentRenderData = (\n bundles: LoaderBundleOutput[],\n compMetas: ComponentMeta[]\n): ComponentRenderData | null => {\n if (bundles.length === 0) {\n return null;\n }\n\n const mergedBundles = bundles.reduce((prev, cur) => mergeBundles(prev, cur));\n return prepComponentData(mergedBundles, compMetas);\n};\n", "import { ComponentMeta } from \"@plasmicapp/loader-core\";\nimport pascalcase from \"pascalcase\";\nimport * as React from \"react\";\n\nexport const isBrowser = typeof window !== \"undefined\";\n\nexport type ComponentLookupSpec =\n | string\n | { name: string; projectId?: string; isCode?: boolean };\n\ninterface FullNameLookupSpec {\n name: string;\n rawName?: string;\n projectId?: string;\n isCode?: boolean;\n}\n\ninterface FullPathLookupSpec {\n path: string;\n projectId?: string;\n}\n\ntype FullLookupSpec = FullNameLookupSpec | FullPathLookupSpec;\n\nexport function useForceUpdate() {\n const [, setTick] = React.useState(0);\n const update = React.useCallback(() => {\n setTick((tick) => tick + 1);\n }, []);\n return update;\n}\n\nexport function useStableLookupSpec(spec: ComponentLookupSpec) {\n return useStableLookupSpecs(spec)[0];\n}\n\nexport function useStableLookupSpecs(...specs: ComponentLookupSpec[]) {\n const [stableSpecs, setStableSpecs] = React.useState(specs);\n\n React.useEffect(() => {\n if (\n specs.length !== stableSpecs.length ||\n specs.some((s, i) => !areLookupSpecsEqual(s, stableSpecs[i]))\n ) {\n setStableSpecs(specs);\n }\n }, [specs, stableSpecs]);\n return stableSpecs;\n}\n\nfunction areLookupSpecsEqual(\n spec1: ComponentLookupSpec,\n spec2: ComponentLookupSpec\n) {\n if (spec1 === spec2) {\n return true;\n }\n if (typeof spec1 !== typeof spec2) {\n return false;\n }\n\n const fullSpec1 = toFullLookup(spec1);\n const fullSpec2 = toFullLookup(spec2);\n return (\n ((isNameSpec(fullSpec1) &&\n isNameSpec(fullSpec2) &&\n fullSpec1.name === fullSpec2.name &&\n fullSpec1.isCode === fullSpec2.isCode) ||\n (isPathSpec(fullSpec1) &&\n isPathSpec(fullSpec2) &&\n fullSpec1.path === fullSpec2.path)) &&\n fullSpec1.projectId === fullSpec2.projectId\n );\n}\n\nfunction isNameSpec(lookup: FullLookupSpec): lookup is FullNameLookupSpec {\n return \"name\" in lookup;\n}\n\nfunction isPathSpec(lookup: FullLookupSpec): lookup is FullPathLookupSpec {\n return \"path\" in lookup;\n}\n\nfunction toFullLookup(lookup: ComponentLookupSpec): FullLookupSpec {\n const namePart = typeof lookup === \"string\" ? lookup : lookup.name;\n const projectId = typeof lookup === \"string\" ? undefined : lookup.projectId;\n const codeComponent = typeof lookup === \"string\" ? undefined : lookup.isCode;\n\n if (codeComponent !== true && namePart.startsWith(\"/\")) {\n return { path: normalizePath(namePart), projectId };\n } else {\n return {\n name: codeComponent ? namePart : normalizeName(namePart),\n rawName: namePart.trim(),\n projectId,\n isCode: codeComponent,\n };\n }\n}\n\nfunction normalizePath(path: string) {\n return path.trim();\n}\n\nfunction normalizeName(name: string) {\n // Not a full normalization, but should be good enough\n return pascalcase(name).trim();\n}\n\nexport function useIsMounted(): () => boolean {\n const ref = React.useRef<boolean>(false);\n const isMounted = React.useCallback(() => ref.current, []);\n\n React.useEffect(() => {\n ref.current = true;\n return () => {\n ref.current = false;\n };\n }, []);\n\n return isMounted;\n}\n\n/**\n * Check if `lookup` resolves to `pagePath`. If it's a match, return an object\n * containing path params; otherwise, return false.\n *\n * For example,\n * - `matchesPagePath(\"/hello/[name]\", \"/hello/world\")` -> `{params: {name:\n * \"world\"}}`\n * - `matchesPagePath(\"/hello/[name]\", \"/\")` -> `false`\n * - `matchesPagePath(\"/hello/[...catchall]\", \"/hello/a/b/c\")` -> `{params: {catchall: [\"a\", \"b\", \"c\"]}}`\n * - `matchesPagePath(\"/hello/[[...catchall]]\", \"/hello/\")` -> `{params: {catchall: []}}`\n * - `matchesPagePath(\"/\", \"\")` -> `{params: {}}`\n */\nexport function matchesPagePath(pattern: string, path: string) {\n // (generated by ChatGPT 4 from the test cases)\n\n // Normalize the path and pattern by ensuring they both start and end without slashes\n const normalizedPattern = \"/\" + pattern.replace(/^\\/|\\/$/g, \"\");\n const normalizedPath = \"/\" + path.replace(/^\\/|\\/$/g, \"\");\n\n // Modify the regex to match optional leading slashes\n const regexString = normalizedPattern\n .replace(/\\/\\[\\[\\.\\.\\.([^\\]^]+)]]/g, \"(?:/([^]*))?\") // Optional catch-all\n .replace(/\\/\\[\\.\\.\\.([^\\]^]+)]/g, \"/([^]*)\") // Catch-all\n .replace(/\\[([^\\]^]+)]/g, \"([^/]+)\") // Normal slug\n .replace(/\\//g, \"\\\\/\"); // Escape forward slashes\n\n const regex = new RegExp(`^/?${regexString}$`); // Allow optional leading slash\n const match = normalizedPath.match(regex);\n\n if (!match) return false;\n\n // Extract slug names from pattern\n const slugNames = [...pattern.matchAll(/\\[\\.?\\.?\\.?([^[\\]]+)]/g)].map(\n (m) => m[1]\n );\n\n // Construct params object\n const params: Record<string, string | string[]> = {};\n for (let i = 0; i < slugNames.length; i++) {\n const slugName = slugNames[i];\n const value = match[i + 1];\n\n if (pattern.includes(`[[...${slugName}]]`)) {\n // Handle optional catchall slugs\n params[slugName] = value ? value.split(\"/\").filter(Boolean) : [];\n } else if (pattern.includes(`[...${slugName}]`)) {\n // Handle mandatory catchall slugs\n params[slugName] = value.split(\"/\").filter(Boolean);\n } else if (value !== undefined) {\n // Handle normal slugs\n params[slugName] = value;\n }\n }\n\n return { params };\n}\n\nexport function isDynamicPagePath(path: string): boolean {\n return !!path.match(/\\[[^/]*\\]/);\n}\n\nfunction matchesCompMeta(lookup: FullLookupSpec, meta: ComponentMeta) {\n if (lookup.projectId && meta.projectId !== lookup.projectId) {\n return false;\n }\n\n return isNameSpec(lookup)\n ? (lookup.name === meta.name ||\n lookup.rawName === meta.name ||\n lookup.rawName === meta.displayName) &&\n (lookup.isCode == null || lookup.isCode === meta.isCode)\n : !!(meta.path && matchesPagePath(meta.path, lookup.path));\n}\n\nexport function getCompMetas(\n metas: ComponentMeta[],\n lookup: ComponentLookupSpec\n) {\n const full = toFullLookup(lookup);\n return metas\n .filter((meta) => matchesCompMeta(full, meta))\n .map<ComponentMeta & { params?: Record<string, string | string[]> }>(\n (meta) => {\n if (isNameSpec(full) || !meta.path) {\n return meta;\n }\n\n const match = matchesPagePath(meta.path, full.path);\n if (!match) {\n return meta;\n }\n\n return { ...meta, params: match.params };\n }\n )\n .sort(\n (meta1, meta2) =>\n // We sort the matched component metas by the number of path params, so\n // if there are two pages `/products/foo` and `/products/[slug]`,\n // the first one will have higher precedence.\n Array.from(Object.keys(meta1.params || {})).length -\n Array.from(Object.keys(meta2.params || {})).length\n );\n}\n\nexport function getLookupSpecName(lookup: ComponentLookupSpec) {\n if (typeof lookup === \"string\") {\n return lookup;\n } else if (lookup.projectId) {\n return `${lookup.name} (project ${lookup.projectId})`;\n } else {\n return lookup.name;\n }\n}\n\nexport function MaybeWrap(props: {\n children: React.ReactNode;\n cond: boolean;\n wrapper: (children: React.ReactNode) => React.ReactElement;\n}) {\n return (\n props.cond ? props.wrapper(props.children) : props.children\n ) as React.ReactElement;\n}\n\nexport function uniq<T>(elements: T[]): T[] {\n return Array.from(new Set(elements));\n}\n\nexport function uniqBy<T, K>(elements: T[], iterator: (elt: T) => K): T[] {\n const vis = new Set<K>();\n const filtered: T[] = [];\n for (const elt of elements) {\n const key = iterator(elt);\n if (!vis.has(key)) {\n vis.add(key);\n filtered.push(elt);\n }\n }\n return filtered;\n}\n\nexport function intersect<T>(a: T[], b: T[]): T[] {\n const setB = new Set(b);\n return a.filter((elt) => setB.has(elt));\n}\n", "import {\n AssetModule,\n ComponentMeta,\n FontMeta,\n GlobalGroupMeta,\n LoaderBundleOutput,\n Registry,\n} from \"@plasmicapp/loader-core\";\nimport * as React from \"react\";\nimport { ComponentLookupSpec, getCompMetas } from \"./utils\";\n\nfunction getFirstCompMeta(metas: ComponentMeta[], lookup: ComponentLookupSpec) {\n const filtered = getCompMetas(metas, lookup);\n return filtered.length === 0 ? undefined : filtered[0];\n}\n\nexport class ComponentLookup {\n constructor(private bundle: LoaderBundleOutput, private registry: Registry) {}\n\n getComponentMeta(spec: ComponentLookupSpec): ComponentMeta | undefined {\n const compMeta = getFirstCompMeta(this.bundle.components, spec);\n return compMeta;\n }\n\n getComponent<P extends React.ComponentType = any>(\n spec: ComponentLookupSpec,\n opts: { forceOriginal?: boolean } = {}\n ) {\n const compMeta = getFirstCompMeta(this.bundle.components, spec);\n if (!compMeta) {\n throw new Error(`Component not found: ${spec}`);\n }\n const moduleName = compMeta.entry;\n if (!this.registry.hasModule(moduleName, opts)) {\n throw new Error(`Component not yet fetched: ${compMeta.name}`);\n }\n const entry = this.registry.load(moduleName, {\n forceOriginal: opts.forceOriginal,\n });\n return !opts.forceOriginal &&\n typeof entry?.getPlasmicComponent === \"function\"\n ? entry.getPlasmicComponent()\n : (entry.default as P);\n }\n\n hasComponent(spec: ComponentLookupSpec) {\n const compMeta = getFirstCompMeta(this.bundle.components, spec);\n if (compMeta) {\n return this.registry.hasModule(compMeta.entry);\n }\n return false;\n }\n\n getGlobalContexts(): { meta: GlobalGroupMeta; context: any }[] {\n const customGlobalMetas = this.bundle.globalGroups.filter(\n (m) => m.type === \"global-user-defined\"\n );\n return customGlobalMetas.map((meta) => ({\n meta,\n context: this.registry.load(meta.contextFile).default,\n }));\n }\n\n /** Returns StyleTokensProvider if the project has style token overrides. */\n maybeGetStyleTokensProvider(spec: ComponentLookupSpec) {\n const compMeta = getFirstCompMeta(this.bundle.components, spec);\n const projectMeta = compMeta\n ? this.bundle.projects.find((x) => x.id === compMeta.projectId)\n : undefined;\n\n if (\n !projectMeta ||\n !projectMeta.styleTokensProviderFileName ||\n !this.registry.hasModule(projectMeta.styleTokensProviderFileName) ||\n !projectMeta.hasStyleTokenOverrides\n ) {\n return undefined;\n }\n const entry = this.registry.load(projectMeta.styleTokensProviderFileName);\n return entry.StyleTokensProvider;\n }\n\n getGlobalContextsProvider(spec: ComponentLookupSpec) {\n const compMeta = getFirstCompMeta(this.bundle.components, spec);\n const projectMeta = compMeta\n ? this.bundle.projects.find((x) => x.id === compMeta.projectId)\n : undefined;\n\n if (\n !projectMeta ||\n !projectMeta.globalContextsProviderFileName ||\n !this.registry.hasModule(projectMeta.globalContextsProviderFileName)\n ) {\n return undefined;\n }\n const entry = this.registry.load(\n projectMeta.globalContextsProviderFileName\n );\n\n return typeof entry?.getPlasmicComponent === \"function\"\n ? entry.getPlasmicComponent()\n : entry.default;\n }\n\n getRootProvider() {\n const entry = this.registry.load(\"root-provider.js\");\n return entry.default;\n }\n\n getCss(): AssetModule[] {\n // We can probably always get the modules from the browser build\n return this.bundle.modules.browser.filter(\n (mod) => mod.type === \"asset\" && mod.fileName.endsWith(\"css\")\n ) as AssetModule[];\n }\n\n getRemoteFonts(): FontMeta[] {\n return this.bundle.projects.flatMap((p) => p.remoteFonts);\n }\n}\n", "import type {\n ExperimentSlice,\n SegmentSlice,\n Split,\n} from \"@plasmicapp/loader-core\";\nimport type { GlobalVariantSpec } from \"./PlasmicRootProvider\";\n\nexport function getPlasmicCookieValues() {\n return Object.fromEntries(\n document.cookie\n .split(\"; \")\n .filter((cookie) => cookie.includes(\"plasmic:\"))\n .map((cookie) => cookie.split(\"=\"))\n .map(([key, value]) => [key.split(\":\")[1], value])\n );\n}\n\nexport function updatePlasmicCookieValue(key: string, value: string) {\n document.cookie = `plasmic:${key}=${value}`;\n}\n\nexport const getGlobalVariantsFromSplits = (\n splits: Split[],\n variation: Record<string, string>\n) => {\n const globalVariants: GlobalVariantSpec[] = [];\n\n Object.keys(variation).map((variationKey: string) => {\n const [_type, splitId] = variationKey.split(\".\");\n const sliceId = variation[variationKey];\n const split = splits.find(\n (s) => s.id === splitId || s.externalId === splitId\n );\n if (split) {\n const slice: ExperimentSlice | SegmentSlice | undefined = (\n split.slices as Array<ExperimentSlice | SegmentSlice>\n ).find((s: any) => s.id === sliceId || s.externalId === sliceId);\n if (slice) {\n slice.contents.map((x) => {\n globalVariants.push({\n name: x.group,\n value: x.variant,\n projectId: x.projectId,\n });\n });\n }\n }\n });\n\n return globalVariants;\n};\n\nexport const mergeGlobalVariantsSpec = (\n target: GlobalVariantSpec[],\n from: GlobalVariantSpec[]\n) => {\n let result = [...target];\n const existingGlobalVariants = new Set(\n target.map((t) => `${t.name}-${t.projectId ?? \"\"}`)\n );\n const newGlobals = from.filter(\n (t) => !existingGlobalVariants.has(`${t.name}-${t.projectId ?? \"\"}`)\n );\n\n if (newGlobals.length > 0) {\n result = [...result, ...newGlobals];\n }\n\n return result;\n};\n", "import type { useMutablePlasmicQueryData } from \"@plasmicapp/query\";\n\n/**\n * It's not possible to `import { serialize } from \"swr\"` from RSC, as it\n * triggers \"`createContext` is not a function\" error :/\n *\n * So here we replicate the key serialization in order to generate the\n * appropriate cache key within data extraction.\n */\nexport function swrSerialize(\n key: Parameters<typeof useMutablePlasmicQueryData>[0]\n): [string | null | undefined | false, any[]] {\n if (typeof key === \"function\") {\n try {\n key = key();\n } catch (err) {\n // dependencies not ready\n key = \"\";\n }\n }\n const args = [].concat(key as any);\n // If key is not falsy, or not an empty array, hash it.\n key =\n typeof key == \"string\"\n ? key\n : (Array.isArray(key) ? key.length : key)\n ? stableHash(key)\n : \"\";\n return [key as any, args];\n}\n\nconst table = new WeakMap();\nlet counter = 0;\n\nfunction stableHash(arg: any) {\n const type = typeof arg;\n const constructor = arg && arg.constructor;\n const isDate = constructor == Date;\n let result: any;\n let index;\n if (Object(arg) === arg && !isDate && constructor != RegExp) {\n // Object/function, not null/date/regexp. Use WeakMap to store the id first.\n // If it's already hashed, directly return the result.\n result = table.get(arg);\n if (result) return result;\n // Store the hash first for circular reference detection before entering the\n // recursive `stableHash` calls.\n // For other objects like set and map, we use this id directly as the hash.\n result = ++counter + \"~\";\n table.set(arg, result);\n if (constructor == Array) {\n // Array.\n result = \"@\";\n for (index = 0; index < arg.length; index++) {\n result += stableHash(arg[index]) + \",\";\n }\n table.set(arg, result);\n }\n if (constructor == Object) {\n // Object, sort keys.\n result = \"#\";\n const keys = Object.keys(arg).sort();\n while ((index = keys.pop()) !== undefined) {\n if (arg[index] !== undefined) {\n result += index + \":\" + stableHash(arg[index]) + \",\";\n }\n }\n table.set(arg, result);\n }\n } else {\n result = isDate\n ? arg.toJSON()\n : type == \"symbol\"\n ? arg.toString()\n : type == \"string\"\n ? JSON.stringify(arg)\n : \"\" + arg;\n }\n return result;\n}\n", "import { extractPlasmicQueryData as internalExtractQueryData } from \"@plasmicapp/prepass\";\nimport {\n handlePlasmicPrepassContext,\n handlePrepassPlasmicComponent,\n handlePrepassPlasmicRootComponent,\n} from \"./loader-server\";\nimport type { PlasmicComponentLoader } from \"./loader-shared\";\nimport type { PlasmicRootProvider } from \"./PlasmicRootProvider\";\n\n/**\n * Performs a prepass over Plasmic content, kicking off the necessary\n * data fetches, and populating the fetched data into a cache. This\n * cache can be passed as prefetchedQueryData into PlasmicRootProvider.\n *\n * To limit rendering errors that can occur when you do this, we recommend\n * that you pass in _only_ the PlasmicComponents that you are planning to use\n * as the argument. For example:\n *\n * const cache = await extractPlasmicQueryData(\n * <ClientPlasmicRootProvider prefetchedData={plasmicData}>\n * <PlasmicComponent component=\"Home\" componentProps={{\n * // Specify the component prop overrides you are planning to use\n * // to render the page, as they may change what data is fetched.\n * ...\n * }} />\n * <PlasmicComponent component=\"NavBar\" componentProps={{\n * ...\n * }} />\n * ...\n * </ClientPlasmicRootProvider>,\n * PLASMIC\n * );\n *\n * If your PlasmicComponent will be wrapping components that require special\n * context set up, you should also wrap the element above with those context\n * providers. Avoid, however, wrapping the root provider, because we inspect\n * the props passed to the root element.\n *\n * You should avoid passing in elements that are not related to Plasmic, as any\n * rendering errors from those elements during the prepass may result in data\n * not being populated in the cache.\n *\n * @param element a React element containing instances of PlasmicComponent.\n * Will attempt to satisfy all data needs from usePlasmicDataQuery()\n * in this element tree.\n * @returns an object mapping query key to fetched data\n */\nexport async function extractPlasmicQueryData(\n element: React.ReactElement,\n loader: PlasmicComponentLoader\n): Promise<Record<string, any>> {\n return await internalExtractQueryData(element, (elt) =>\n handleClientComponentRef(elt, loader, element)\n );\n}\n\nfunction handleClientComponentRef(\n elt: React.ReactElement,\n loader: PlasmicComponentLoader,\n rootElement: React.ReactElement\n) {\n try {\n const refId: string = (elt.type as any).$$id;\n // We try to detect the root provider by name, as well as by comparing to\n // the root element.\n if (refId.includes(\"PlasmicRootProvider\") || elt === rootElement) {\n const props: Parameters<typeof PlasmicRootProvider>[0] = elt.props as any;\n if (props.prefetchedData) {\n handlePrepassPlasmicRootComponent({ ...props, loader });\n }\n return;\n } else if (\n refId.includes(\"PlasmicComponent\") &&\n elt.props?.component != null\n ) {\n return handlePrepassPlasmicComponent(elt.props);\n } else if (\n refId.includes(\"PlasmicPrepassContext\") &&\n elt.props?.cache != null\n ) {\n return handlePlasmicPrepassContext(elt.props);\n }\n } catch (err) {\n console.warn(\"Error processing client reference: \", err);\n }\n return;\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO;;;ACCP,SAAS,yBAAAA,8BAA6B;AAKtC,OAAOC,YAAW;AAClB,OAAO,cAAc;AACrB,YAAY,mBAAmB;AAC/B,YAAY,gBAAgB;;;ACK5B;AAAA,EAIE;AAAA,OAEK;AACP;AAAA,EAIE;AAAA,OACK;AACP,SAAS,oBAAoB,sBAAsB;;;AC3BnD;AAAA,EAEE;AAAA,OAEK;;;ACHP,OAAO,gBAAgB;AACvB,YAAY,WAAW;AAEhB,IAAM,YAAY,OAAO,WAAW;AAuE3C,SAAS,WAAW,QAAsD;AACxE,SAAO,UAAU;AACnB;AAMA,SAAS,aAAa,QAA6C;AACjE,QAAM,WAAW,OAAO,WAAW,WAAW,SAAS,OAAO;AAC9D,QAAM,YAAY,OAAO,WAAW,WAAW,SAAY,OAAO;AAClE,QAAM,gBAAgB,OAAO,WAAW,WAAW,SAAY,OAAO;AAEtE,MAAI,kBAAkB,QAAQ,SAAS,WAAW,GAAG,GAAG;AACtD,WAAO,EAAE,MAAM,cAAc,QAAQ,GAAG,UAAU;AAAA,EACpD,OAAO;AACL,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AAO,8BAA8B,IAAI,KAAK;AAAA,IAChD,WACE,MAAM,SAAS,uBAAuB,OACtC,SAAI,UAAJ,mBAAW,UAAS,MACpB;AACA,aAAO,4BAA4B,IAAI,KAAK;AAAA,IAC9C;AAAA,EACF,SAAS,KAAP;AACA,YAAQ,KAAK,uCAAuC,GAAG;AAAA,EACzD;AACA;AACF;;;AR1EO,SAAS,kBAAkB,MAA2C;AAC3E,QAAM,WAAW,IAAI,6BAA6B,IAAI;AACtD,SAAO,IAAI,uBAAuB,QAAQ;AAC5C;",
|
|
6
6
|
"names": ["PlasmicModulesFetcher", "React", "_a", "_b", "_a", "_a", "_a", "React", "PlasmicModulesFetcher", "_a"]
|
|
7
7
|
}
|
package/dist/react-server.js
CHANGED
|
@@ -248,6 +248,7 @@ function prepComponentData(bundle, compMetas, opts) {
|
|
|
248
248
|
"entrypoint.css",
|
|
249
249
|
...compPaths,
|
|
250
250
|
"root-provider.js",
|
|
251
|
+
...bundle.projects.map((x) => x.styleTokensProviderFileName).filter((x) => !!x),
|
|
251
252
|
...bundle.projects.map((x) => x.globalContextsProviderFileName).filter((x) => !!x),
|
|
252
253
|
// We need to explicitly include global context provider components
|
|
253
254
|
// to make sure they are kept in bundle.components. That's because
|
|
@@ -415,6 +416,16 @@ var ComponentLookup = class {
|
|
|
415
416
|
context: this.registry.load(meta.contextFile).default
|
|
416
417
|
}));
|
|
417
418
|
}
|
|
419
|
+
/** Returns StyleTokensProvider if the project has style token overrides. */
|
|
420
|
+
maybeGetStyleTokensProvider(spec) {
|
|
421
|
+
const compMeta = getFirstCompMeta(this.bundle.components, spec);
|
|
422
|
+
const projectMeta = compMeta ? this.bundle.projects.find((x) => x.id === compMeta.projectId) : void 0;
|
|
423
|
+
if (!projectMeta || !projectMeta.styleTokensProviderFileName || !this.registry.hasModule(projectMeta.styleTokensProviderFileName) || !projectMeta.hasStyleTokenOverrides) {
|
|
424
|
+
return void 0;
|
|
425
|
+
}
|
|
426
|
+
const entry = this.registry.load(projectMeta.styleTokensProviderFileName);
|
|
427
|
+
return entry.StyleTokensProvider;
|
|
428
|
+
}
|
|
418
429
|
getGlobalContextsProvider(spec) {
|
|
419
430
|
const compMeta = getFirstCompMeta(this.bundle.components, spec);
|
|
420
431
|
const projectMeta = compMeta ? this.bundle.projects.find((x) => x.id === compMeta.projectId) : void 0;
|