@plasmicapp/loader-react 1.0.328 → 1.0.330
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 +7 -4
- package/dist/index.esm.js +24 -47
- package/dist/index.esm.js.map +3 -3
- package/dist/index.js +24 -47
- package/dist/index.js.map +3 -3
- package/dist/react-server.d.ts +3 -2
- package/dist/react-server.esm.js +19 -18
- package/dist/react-server.esm.js.map +2 -2
- package/dist/react-server.js +19 -18
- package/dist/react-server.js.map +2 -2
- package/package.json +3 -3
package/dist/index.esm.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/loader.ts", "../src/utils.tsx", "../src/component-lookup.ts", "../src/PlasmicRootProvider.tsx", "../src/variation.ts", "../src/global-variants.ts", "../src/bundles.ts", "../src/loader-react-server.ts", "../src/index.ts", "../src/PlasmicComponent.tsx", "../src/usePlasmicComponent.tsx", "../src/render.tsx"],
|
|
4
|
-
"sourcesContent": ["import * as PlasmicDataSourcesContext from \"@plasmicapp/data-sources-context\";\n// eslint-disable-next-line no-restricted-imports\nimport * as PlasmicHost from \"@plasmicapp/host\";\nimport {\n CodeComponentMeta as InternalCodeComponentMeta,\n ComponentHelpers as InternalCodeComponentHelpers,\n CustomFunctionMeta as InternalCustomFunctionMeta,\n GlobalContextMeta as InternalGlobalContextMeta,\n // eslint-disable-next-line no-restricted-imports\n registerComponent,\n registerFunction,\n registerGlobalContext,\n registerToken,\n registerTrait,\n StateHelpers,\n stateHelpersKeys,\n StateSpec,\n TokenRegistration,\n TraitMeta,\n} from \"@plasmicapp/host\";\nimport {\n ComponentMeta,\n LoaderBundleOutput,\n PlasmicModulesFetcher,\n PlasmicTracker,\n Registry,\n TrackRenderOptions,\n} from \"@plasmicapp/loader-core\";\nimport {\n CodeModule,\n internal_getCachedBundleInNodeServer,\n} from \"@plasmicapp/loader-fetcher\";\nimport { getActiveVariation, getExternalIds } from \"@plasmicapp/loader-splits\";\nimport * as PlasmicQuery 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 { ComponentLookup } from \"./component-lookup\";\nimport { createUseGlobalVariant } from \"./global-variants\";\nimport {\n FetchComponentDataOpts,\n InitOptions,\n ReactServerPlasmicComponentLoader,\n} from \"./loader-react-server\";\nimport type { GlobalVariantSpec } from \"./PlasmicRootProvider\";\nimport { ComponentLookupSpec, getCompMetas, isBrowser, uniq } from \"./utils\";\nimport { getPlasmicCookieValues, updatePlasmicCookieValue } from \"./variation\";\n\nexport interface ComponentRenderData {\n entryCompMetas: (ComponentMeta & { params?: Record<string, string> })[];\n bundle: LoaderBundleOutput;\n remoteFontUrls: string[];\n}\n\ninterface ComponentSubstitutionSpec {\n lookup: ComponentLookupSpec;\n component: React.ComponentType<any>;\n codeComponentHelpers?: InternalCodeComponentHelpers<\n React.ComponentProps<any>\n >;\n}\n\ninterface PlasmicRootWatcher {\n onDataFetched?: () => void;\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\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\nconst SUBSTITUTED_COMPONENTS: Record<string, React.ComponentType<any>> = {};\nconst REGISTERED_CODE_COMPONENT_HELPERS: Record<\n string,\n InternalCodeComponentHelpers<React.ComponentProps<any>>\n> = {};\nconst SUBSTITUTED_GLOBAL_VARIANT_HOOKS: Record<string, () => any> = {};\nconst REGISTERED_CUSTOM_FUNCTIONS: Record<string, (...args: any[]) => any> = {};\n\nfunction 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 class InternalPlasmicComponentLoader {\n private readonly reactServerLoader: ReactServerPlasmicComponentLoader;\n private readonly registry = new Registry();\n private subs: ComponentSubstitutionSpec[] = [];\n private roots: PlasmicRootWatcher[] = [];\n private globalVariants: GlobalVariantSpec[] = [];\n private tracker: PlasmicTracker;\n\n constructor(public opts: InitOptions) {\n this.tracker = new PlasmicTracker({\n projectIds: opts.projects.map((p) => p.id),\n platform: opts.platform,\n preview: opts.preview,\n nativeFetch: opts.nativeFetch,\n });\n this.reactServerLoader = new ReactServerPlasmicComponentLoader({\n opts,\n fetcher: new PlasmicModulesFetcher(opts),\n tracker: this.tracker,\n onBundleMerged: () => {\n this.refreshRegistry();\n },\n onBundleFetched: () => {\n this.roots.forEach((watcher) => watcher.onDataFetched?.());\n },\n });\n\n this.registerModules({\n react: React,\n \"react-dom\": ReactDOM,\n \"react/jsx-runtime\": jsxRuntime,\n \"react/jsx-dev-runtime\": jsxDevRuntime,\n\n // Also inject @plasmicapp/query and @plasmicapp/host to use the\n // same contexts here and in loader-downloaded code.\n \"@plasmicapp/query\": PlasmicQuery,\n \"@plasmicapp/data-sources-context\": PlasmicDataSourcesContext,\n \"@plasmicapp/host\": PlasmicHost,\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 getBundle() {\n return this.reactServerLoader.getBundle();\n }\n\n setGlobalVariants(globalVariants: GlobalVariantSpec[]) {\n this.globalVariants = globalVariants;\n }\n\n getGlobalVariants() {\n return this.globalVariants;\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 private 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.registry.isEmpty()) {\n console.warn(\n \"Calling PlasmicComponentLoader.registerSubstitution() after Plasmic component has rendered; starting over.\"\n );\n this.registry.clear();\n }\n this.subs.push({ lookup: name, component, codeComponentHelpers });\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(([_, stateSpec]) =>\n Object.keys(stateSpec).some((key) => stateHelpersKeys.includes(key))\n )\n .map(([stateName, stateSpec]) => [\n stateName,\n Object.fromEntries(\n stateHelpersKeys\n .filter((key) => key in stateSpec)\n .map((key) => [key, stateSpec[key]])\n ),\n ])\n );\n const helpers = { states: stateHelpers };\n this.internalSubstituteComponent(\n component,\n { name: meta.name, isCode: true },\n Object.keys(stateHelpers).length > 0 ? helpers : undefined\n );\n registerComponent(component, {\n ...meta,\n // Import path is not used as we will use component substitution\n importPath: meta.importPath ?? \"\",\n ...(Object.keys(stateHelpers).length > 0\n ? {\n componentHelpers: {\n helpers,\n importPath: \"\",\n importName: \"\",\n },\n }\n : {}),\n });\n }\n\n registerFunction<F extends (...args: any[]) => any>(\n fn: F,\n meta: CustomFunctionMeta<F>\n ) {\n registerFunction(fn, {\n ...meta,\n importPath: meta.importPath ?? \"\",\n });\n REGISTERED_CUSTOM_FUNCTIONS[customFunctionImportAlias(meta)] = fn;\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 // Import path is not used as we will use component substitution\n registerGlobalContext(context, {\n ...meta,\n importPath: meta.importPath ?? \"\",\n });\n }\n\n registerTrait(trait: string, meta: TraitMeta) {\n registerTrait(trait, meta);\n }\n\n registerToken(token: TokenRegistration) {\n registerToken(token);\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.reactServerLoader.mergeBundle(cachedBundle);\n }\n }\n this.reactServerLoader.mergeBundle(bundle);\n }\n\n subscribePlasmicRoot(watcher: PlasmicRootWatcher) {\n this.roots.push(watcher);\n }\n\n unsubscribePlasmicRoot(watcher: PlasmicRootWatcher) {\n const index = this.roots.indexOf(watcher);\n if (index >= 0) {\n this.roots.splice(index, 1);\n }\n }\n\n clearCache() {\n this.reactServerLoader.clearCache();\n this.registry.clear();\n }\n\n getLookup() {\n return new ComponentLookup(this.getBundle(), this.registry);\n }\n\n // ReactServerLoader methods\n\n maybeFetchComponentData(\n specs: ComponentLookupSpec[],\n opts?: FetchComponentDataOpts\n ): Promise<ComponentRenderData | null>;\n maybeFetchComponentData(\n ...specs: ComponentLookupSpec[]\n ): Promise<ComponentRenderData | null>;\n maybeFetchComponentData(...args: any[]): Promise<ComponentRenderData | null> {\n return this.reactServerLoader.maybeFetchComponentData(...args);\n }\n\n fetchComponentData(\n specs: ComponentLookupSpec[],\n opts?: FetchComponentDataOpts\n ): Promise<ComponentRenderData>;\n fetchComponentData(\n ...specs: ComponentLookupSpec[]\n ): Promise<ComponentRenderData>;\n fetchComponentData(...args: any[]): Promise<ComponentRenderData> {\n return this.reactServerLoader.fetchComponentData(...args);\n }\n\n fetchPages(opts?: FetchPagesOpts) {\n return this.reactServerLoader.fetchPages(opts);\n }\n\n fetchComponents() {\n return this.reactServerLoader.fetchComponents();\n }\n\n getActiveSplits() {\n return this.reactServerLoader.getActiveSplits();\n }\n\n getChunksUrl(bundle: LoaderBundleOutput, modules: CodeModule[]) {\n return this.reactServerLoader.getChunksUrl(bundle, modules);\n }\n\n trackConversion(value = 0) {\n this.tracker.trackConversion(value);\n }\n\n public async getActiveVariation(opts: {\n traits: Record<string, string | number | boolean>;\n getKnownValue: (key: string) => string | undefined;\n updateKnownValue: (key: string, value: string) => void;\n }) {\n await this.reactServerLoader.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 this.tracker.trackRender(opts);\n }\n\n private 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 // We also 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 createUseGlobalVariant(globalGroup.name, globalGroup.projectId);\n }\n }\n this.registry.updateModules(this.getBundle());\n }\n}\n\n/**\n * Library for fetching component data, and registering\n * custom components.\n */\nexport class PlasmicComponentLoader {\n private __internal: InternalPlasmicComponentLoader;\n constructor(internal: InternalPlasmicComponentLoader) {\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 async fetchComponentData(\n ...specs: ComponentLookupSpec[]\n ): Promise<ComponentRenderData> {\n return this.__internal.fetchComponentData(...specs);\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 return this.__internal.maybeFetchComponentData(...specs);\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(opts: {\n traits: Record<string, string | number | boolean>;\n getKnownValue: (key: string) => string | undefined;\n updateKnownValue: (key: string, value: string) => void;\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", "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(\"/\", \"\")` -> `{params: {}}`\n */\nexport function matchesPagePath(\n pagePath: string,\n lookup: string\n): { params: Record<string, string | string[]> } | false {\n // Remove trailing slashes from both `pagePath` and `lookup`.\n pagePath = pagePath.replace(/^\\/*/, \"\").replace(/\\/*$/, \"\");\n lookup = lookup.replace(/^\\/*/, \"\").replace(/\\/*$/, \"\");\n\n // paramNames will contain a list of parameter names; e.g. if pagePath\n // is \"/products/[slug]/[...catchall]\" it will contain [\"slug\", \"...catchall\"].\n const paramNames = (pagePath.match(/\\[([^\\]]*)\\]/g) || []).map((group) =>\n group.slice(1, -1)\n );\n\n const pagePathRegExp = new RegExp(\n \"^/?\" +\n pagePath\n .replace(/\\[\\.\\.\\.[^\\]]*\\]/g, \"(.+)\")\n .replace(/\\[[^\\]]*\\]/g, \"([^/]+)\") +\n \"$\"\n );\n const maybeVals = lookup.replace(/[?].*/, \"\").match(pagePathRegExp)?.slice(1);\n if (!maybeVals) {\n return false;\n }\n\n const params: Record<string, string | string[]> = {};\n for (let i = 0; i < paramNames.length; i++) {\n if (paramNames[i].startsWith(\"...\")) {\n params[paramNames[i].slice(3)] = maybeVals[i].split(\"/\");\n } else {\n params[paramNames[i]] = maybeVals[i];\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 uniq<T>(elements: T[]): T[] {\n return Array.from(new Set(elements));\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 { PlasmicDataSourceContextValue } from \"@plasmicapp/data-sources-context\";\nimport { PageParamsProvider } from \"@plasmicapp/host\";\nimport { AssetModule, ComponentMeta, Split } from \"@plasmicapp/loader-core\";\nimport { PlasmicQueryDataProvider } from \"@plasmicapp/query\";\nimport * as React from \"react\";\nimport {\n ComponentRenderData,\n InternalPlasmicComponentLoader,\n PlasmicComponentLoader,\n} from \"./loader\";\nimport { useForceUpdate } from \"./utils\";\nimport {\n ensureVariationCookies,\n getGlobalVariantsFromSplits,\n mergeGlobalVariantsSpec,\n} from \"./variation\";\n\ninterface PlasmicRootContextValue extends PlasmicDataSourceContextValue {\n globalVariants?: GlobalVariantSpec[];\n globalContextsProps?: Record<string, any>;\n loader: InternalPlasmicComponentLoader;\n variation?: Record<string, string>;\n translator?: PlasmicTranslator;\n Head?: React.ComponentType<any>;\n Link?: React.ComponentType<any>;\n disableLoadingBoundary?: boolean;\n suspenseFallback?: React.ReactNode;\n}\n\nconst PlasmicRootContext = React.createContext<\n PlasmicRootContextValue | undefined\n>(undefined);\n\nexport interface GlobalVariantSpec {\n name: string;\n projectId?: string;\n value: any;\n}\n\nexport type PlasmicTranslator = (\n str: string,\n opts?: {\n components?: {\n [key: string]: React.ReactElement | React.ReactFragment;\n };\n }\n) => React.ReactNode;\n\n/**\n * PlasmicRootProvider should be used at the root of your page\n * or application.\n */\nexport function PlasmicRootProvider(\n props: {\n /**\n * The global PlasmicComponentLoader instance you created via\n * initPlasmicLoader().\n */\n loader: PlasmicComponentLoader;\n\n /**\n * Global variants to activate for Plasmic components\n */\n globalVariants?: GlobalVariantSpec[];\n\n children?: React.ReactNode;\n\n /**\n * If true, will skip rendering css\n */\n skipCss?: boolean;\n\n /**\n * If true, will skip installing fonts\n */\n skipFonts?: boolean;\n\n /**\n * If you have pre-fetched component data via PlasmicComponentLoader,\n * you can pass them in here; PlasmicComponent will avoid fetching\n * component data that have already been pre-fetched.\n */\n prefetchedData?: ComponentRenderData;\n\n /**\n * If you have pre-fetched data that are needed by usePlasmicQueryData(),\n * then pass in the pre-fetched cache here, mapping query key to fetched data.\n */\n prefetchedQueryData?: Record<string, any>;\n\n /**\n * Specifies whether usePlasmicQueryData() should be operating in suspense mode\n * (throwing promises).\n */\n suspenseForQueryData?: boolean;\n\n /**\n * Override your Global Contexts Provider props. This is a map from\n * globalContextComponentNameProps to object of props to use for that\n * component.\n */\n globalContextsProps?: Record<string, any>;\n\n /**\n * Specifies a mapping of split id to slice id that should be activated\n */\n variation?: Record<string, string>;\n\n /**\n * Translator function to be used for text blocks\n */\n translator?: PlasmicTranslator;\n\n /**\n * Head component to use in PlasmicHead component (e.g. Head from next/head\n * or Helmet from react-helmet).\n */\n Head?: React.ComponentType<any>;\n\n /**\n * Link component to use. Can be any component that takes in props passed\n * to an <a/> tag.\n */\n Link?: React.ComponentType<any>;\n\n /**\n * Page route without params substitution (e.g. /products/[slug]).\n */\n pageRoute?: string;\n\n /**\n * Page path parameters (e.g. {slug: \"foo\"} if page path is\n * /products/[slug] and URI is /products/foo).\n */\n pageParams?: Record<string, string | string[] | undefined>;\n\n /**\n * Page query parameters (e.g. {q: \"foo\"} if page path is\n * /some/path?q=foo).\n */\n pageQuery?: Record<string, string | string[] | undefined>;\n /**\n * Whether the React.Suspense boundaries should be removed\n */\n disableLoadingBoundary?: boolean;\n /**\n * Fallback value for the root-level React.Suspense\n */\n suspenseFallback?: React.ReactNode;\n } & PlasmicDataSourceContextValue\n) {\n const {\n globalVariants,\n prefetchedData,\n children,\n skipCss,\n skipFonts,\n prefetchedQueryData,\n suspenseForQueryData,\n globalContextsProps,\n variation,\n translator,\n Head,\n Link,\n pageRoute,\n pageParams,\n pageQuery,\n suspenseFallback,\n disableLoadingBoundary,\n } = props;\n const loader = (props.loader as any)\n .__internal as InternalPlasmicComponentLoader;\n\n if (prefetchedData) {\n loader.registerPrefetchedBundle(prefetchedData?.bundle);\n }\n\n const [splits, setSplits] = React.useState<Split[]>(loader.getActiveSplits());\n const forceUpdate = useForceUpdate();\n const watcher = React.useMemo(\n () => ({\n onDataFetched: () => {\n setSplits(loader.getActiveSplits());\n forceUpdate();\n },\n }),\n [loader, forceUpdate]\n );\n\n React.useEffect(() => {\n loader.subscribePlasmicRoot(watcher);\n return () => loader.unsubscribePlasmicRoot(watcher);\n }, [watcher, loader]);\n\n React.useEffect(() => {\n ensureVariationCookies(variation);\n loader.trackRender({\n renderCtx: {\n // We track the provider as a single entity\n rootComponentId: \"provider\",\n teamIds: loader.getTeamIds(),\n projectIds: loader.getProjectIds(),\n },\n variation,\n });\n }, [loader, variation]);\n\n const { user, userAuthToken, isUserLoading, authRedirectUri } = props;\n\n const value = React.useMemo<PlasmicRootContextValue>(\n () => ({\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 globalVariants,\n variation,\n globalContextsProps,\n loader,\n splits,\n translator,\n Head,\n Link,\n user,\n userAuthToken,\n isUserLoading,\n authRedirectUri,\n suspenseFallback,\n disableLoadingBoundary,\n ]\n );\n\n return (\n <PlasmicQueryDataProvider\n prefetchedCache={prefetchedQueryData}\n suspense={suspenseForQueryData}\n >\n <PlasmicRootContext.Provider value={value}>\n {!skipCss && (\n <PlasmicCss\n loader={loader}\n prefetchedData={prefetchedData}\n skipFonts={skipFonts}\n />\n )}\n <PageParamsProvider\n route={pageRoute}\n params={pageParams}\n query={pageQuery}\n >\n {children}\n </PageParamsProvider>\n </PlasmicRootContext.Provider>\n </PlasmicQueryDataProvider>\n );\n}\n\n/**\n * Inject all css modules as <style/> tags. We can't use the usual styleInjector postcss\n * uses because that doesn't work on the server side for SSR.\n */\nconst PlasmicCss = React.memo(function PlasmicCss(props: {\n loader: InternalPlasmicComponentLoader;\n prefetchedData?: ComponentRenderData;\n skipFonts?: boolean;\n}) {\n const { loader, prefetchedData, skipFonts } = props;\n const [useScopedCss, setUseScopedCss] = React.useState(!!prefetchedData);\n const builtCss = buildCss(loader, {\n scopedCompMetas:\n useScopedCss && prefetchedData\n ? prefetchedData.bundle.components\n : undefined,\n skipFonts,\n });\n const forceUpdate = useForceUpdate();\n const watcher = React.useMemo(\n () => ({\n onDataFetched: () => {\n // If new data has been fetched, then use all the fetched css\n setUseScopedCss(false);\n forceUpdate();\n },\n }),\n [loader, forceUpdate]\n );\n\n React.useEffect(() => {\n loader.subscribePlasmicRoot(watcher);\n return () => loader.unsubscribePlasmicRoot(watcher);\n }, [watcher, loader]);\n\n return <style dangerouslySetInnerHTML={{ __html: builtCss }} />;\n});\n\nfunction buildCss(\n loader: InternalPlasmicComponentLoader,\n opts: {\n scopedCompMetas?: ComponentMeta[];\n skipFonts?: boolean;\n }\n) {\n const { scopedCompMetas, skipFonts } = opts;\n const cssFiles =\n scopedCompMetas &&\n new Set<string>([\n \"entrypoint.css\",\n ...scopedCompMetas.map((c) => c.cssFile),\n ]);\n const cssModules = loader\n .getLookup()\n .getCss()\n .filter((f) => !cssFiles || cssFiles.has(f.fileName));\n\n const getPri = (fileName: string) => (fileName === \"entrypoint.css\" ? 0 : 1);\n const compareModules = (a: AssetModule, b: AssetModule) =>\n getPri(a.fileName) !== getPri(b.fileName)\n ? getPri(a.fileName) - getPri(b.fileName)\n : a.fileName.localeCompare(b.fileName);\n cssModules.sort(compareModules);\n\n const remoteFonts = loader.getLookup().getRemoteFonts();\n\n // Make sure the @import statements come at the front of css\n return `\n ${\n skipFonts\n ? \"\"\n : remoteFonts.map((f) => `@import url('${f.url}');`).join(\"\\n\")\n }\n ${cssModules.map((mod) => mod.source).join(\"\\n\")}\n `;\n}\n\nexport function usePlasmicRootContext() {\n return React.useContext(PlasmicRootContext);\n}\n", "import { ExperimentSlice, SegmentSlice, Split } 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 function ensureVariationCookies(variation: Record<string, string> = {}) {\n Object.keys(variation).map((variationKey) => {\n const sliceId = variation[variationKey];\n updatePlasmicCookieValue(variationKey, sliceId);\n });\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", "/**\n * We don't actually make use of the global variant React contexts generated\n * in the bundle. That's because we would have to wait until the data is\n * loaded before we can set up the context providers, but setting up context\n * providers will mutate the React tree and invalidate all the children. That means\n * once data comes in, we'll re-render the React tree from the providers down\n * in a way that will lose all existing React state. Therefore, instead,\n * we always have a single context provided -- the PlasmicRootContext -- and we\n * create these fake useGlobalVariant() hooks that just read from that\n * PlasmicRootContext. This allows us to have a stable React tree before and\n * after the data load.\n */\n\nimport { InternalPlasmicComponentLoader } from './loader';\nimport { usePlasmicRootContext } from './PlasmicRootProvider';\n\nexport function createUseGlobalVariant(name: string, projectId: string) {\n return () => {\n const rootContext = usePlasmicRootContext();\n if (!rootContext) {\n return undefined;\n }\n\n const loader = rootContext.loader as InternalPlasmicComponentLoader;\n const spec = [\n ...loader.getGlobalVariants(),\n ...(rootContext.globalVariants ?? []),\n ].find(\n (spec) =>\n spec.name === name && (!spec.projectId || spec.projectId === projectId)\n );\n return spec ? spec.value : undefined;\n };\n}\n", "import {\n ComponentMeta,\n getBundleSubset,\n LoaderBundleOutput,\n} from '@plasmicapp/loader-core';\nimport type { ComponentRenderData } from './loader';\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\nexport function mergeBundles(\n target: LoaderBundleOutput,\n from: LoaderBundleOutput\n) {\n const existingCompIds = new Set(target.components.map((c) => c.id));\n\n const newCompMetas = from.components.filter(\n (m) => !existingCompIds.has(m.id)\n );\n if (newCompMetas.length > 0) {\n target = { ...target, components: [...target.components, ...newCompMetas] };\n }\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 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 existingExternals = new Set(target.external);\n const newExternals = target.external.filter((x) => !existingExternals.has(x));\n if (newExternals.length > 0) {\n target = { ...target, external: [...target.external, ...newExternals] };\n }\n\n const existingSplitIds = new Set(target.activeSplits.map((s) => s.id));\n const newSplits =\n from.activeSplits.filter((s) => !existingSplitIds.has(s.id)) ?? [];\n if (newSplits.length > 0) {\n target = {\n ...target,\n activeSplits: [...target.activeSplits, ...newSplits],\n };\n }\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 {\n LoaderBundleCache,\n PageMeta,\n PlasmicModulesFetcher,\n PlasmicTracker,\n} from \"@plasmicapp/loader-core\";\nimport {\n CodeModule,\n ComponentMeta,\n LoaderBundleOutput,\n} from \"@plasmicapp/loader-fetcher\";\nimport { prepComponentData } from \"./bundles\";\nimport { ComponentRenderData, FetchPagesOpts } from \"./loader\";\nimport {\n ComponentLookupSpec,\n getCompMetas,\n getLookupSpecName,\n isBrowser,\n isDynamicPagePath,\n} from \"./utils\";\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\n/** Subset of loader functionality that works on React Server Components. */\nexport class ReactServerPlasmicComponentLoader {\n private readonly opts: InitOptions;\n private readonly fetcher: PlasmicModulesFetcher;\n private readonly tracker: PlasmicTracker;\n private readonly onBundleMerged?: () => void;\n private readonly onBundleFetched?: () => void;\n\n private bundle: LoaderBundleOutput = {\n modules: {\n browser: [],\n server: [],\n },\n components: [],\n globalGroups: [],\n external: [],\n projects: [],\n activeSplits: [],\n bundleUrlQuery: null,\n };\n\n constructor(args: {\n opts: InitOptions;\n fetcher: PlasmicModulesFetcher;\n tracker: PlasmicTracker;\n /** Called after `mergeBundle` (including `fetch` calls). */\n onBundleMerged?: () => void;\n /** Called after any `fetch` calls. */\n onBundleFetched?: () => void;\n }) {\n this.opts = args.opts;\n this.fetcher = args.fetcher;\n this.tracker = args.tracker;\n this.onBundleMerged = args.onBundleMerged;\n this.onBundleFetched = args.onBundleFetched;\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.tracker.trackFetch();\n this.mergeBundle(bundle);\n this.onBundleFetched?.();\n return bundle;\n }\n\n mergeBundle(bundle: LoaderBundleOutput) {\n // TODO: this is only possible as the bundle is the full bundle,\n // not a partial bundle. Figure it out how to merge partial bundles.\n this.bundle = bundle;\n // Avoid `undefined` as it cannot be serialized as JSON\n this.bundle.bundleUrlQuery = this.bundle.bundleUrlQuery ?? null;\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 external: [],\n projects: [],\n activeSplits: [],\n bundleUrlQuery: null,\n };\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", "import {\n CodeComponentMeta,\n InternalPlasmicComponentLoader,\n PlasmicComponentLoader,\n} from \"./loader\";\nimport type { InitOptions } from \"./loader-react-server\";\n\nexport type { PropType, TokenRegistration } from \"@plasmicapp/host\";\nexport {\n DataCtxReader,\n DataProvider,\n PageParamsProvider,\n PlasmicCanvasContext,\n PlasmicCanvasHost,\n repeatedElement,\n useDataEnv,\n usePlasmicCanvasContext,\n useSelector,\n useSelectors,\n} from \"@plasmicapp/host\";\nexport { usePlasmicQueryData } from \"@plasmicapp/query\";\nexport * from \"./shared-exports\";\nexport { PlasmicComponent } from \"./PlasmicComponent\";\nexport type {\n GlobalVariantSpec,\n PlasmicTranslator,\n} from \"./PlasmicRootProvider\";\nexport { PlasmicRootProvider } from \"./PlasmicRootProvider\";\nexport { extractPlasmicQueryData, plasmicPrepass } from \"@plasmicapp/prepass\";\nexport {\n extractPlasmicQueryDataFromElement,\n hydrateFromElement,\n renderToElement,\n renderToString,\n} from \"./render\";\nexport { usePlasmicComponent } from \"./usePlasmicComponent\";\nexport type { CodeComponentMeta };\nexport { InternalPlasmicComponentLoader, PlasmicComponentLoader };\n\nexport function initPlasmicLoader(opts: InitOptions): PlasmicComponentLoader {\n const internal = new InternalPlasmicComponentLoader(opts);\n return new PlasmicComponentLoader(internal);\n}\n", "import * as React from \"react\";\nimport { usePlasmicRootContext } from \"./PlasmicRootProvider\";\nimport { usePlasmicComponent } from \"./usePlasmicComponent\";\n\nconst PlasmicComponentContext = React.createContext(false);\n\nexport function PlasmicComponent(props: {\n /**\n * Name of the component to render, or the path of the page component\n */\n component: string;\n /**\n * Optionally specify a projectId if there are multiple components\n * of the same name from different projects\n */\n projectId?: string;\n /**\n * If you used registerComponent(), then if the name matches a registered\n * component, that component is used. If you want the Plasmic-generated\n * component instead, specify forceOriginal.\n */\n forceOriginal?: boolean;\n componentProps?: any;\n}): React.ReactElement | null {\n const { component, projectId, componentProps, forceOriginal } = props;\n\n const rootContext = usePlasmicRootContext();\n const isRootLoader = !React.useContext(PlasmicComponentContext);\n\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\n const {\n loader,\n globalContextsProps,\n variation,\n userAuthToken,\n isUserLoading,\n authRedirectUri,\n translator,\n ...rest\n } = rootContext;\n\n const Component = usePlasmicComponent(\n { name: component, projectId, isCode: false },\n { forceOriginal }\n );\n\n React.useEffect(() => {\n if (isRootLoader) {\n const meta = loader\n .getLookup()\n .getComponentMeta({ name: component, projectId });\n\n if (meta) {\n loader.trackRender({\n renderCtx: {\n rootProjectId: meta.projectId,\n rootComponentId: meta.id,\n rootComponentName: component,\n teamIds: loader.getTeamIds(),\n projectIds: loader.getProjectIds(),\n },\n variation,\n });\n }\n }\n }, [component, projectId, loader, variation]);\n\n const element = React.useMemo(() => {\n if (!Component) {\n return null;\n }\n\n let element = <Component {...componentProps} />;\n\n if (isRootLoader) {\n // If this is the root PlasmicComponent, then wrap the content with the\n // react-web's PlasmicRootProvider. We are doing this here, instead of\n // say PlasmicRootProvider, because we don't have access to this context\n // provider until data has been loaded. If we insert this provider into\n // the tree at the root after data is loaded, then we'll invalidate the\n // React tree and tree state, which is bad. Instead, we do it at the\n // \"root-most PlasmicComponent\"; we won't risk invalidating the sub-tree\n // here because there were no children before the data came in.\n const lookup = loader.getLookup();\n const ReactWebRootProvider = lookup.getRootProvider();\n const GlobalContextsProvider = lookup.getGlobalContextsProvider({\n name: component,\n projectId,\n });\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 <MaybeWrap\n cond={!!GlobalContextsProvider}\n wrapper={(children) => (\n <GlobalContextsProvider {...globalContextsProps}>\n {children}\n </GlobalContextsProvider>\n )}\n >\n <PlasmicComponentContext.Provider value={true}>\n {element}\n </PlasmicComponentContext.Provider>\n </MaybeWrap>\n </ReactWebRootProvider>\n );\n }\n return element;\n }, [\n Component,\n componentProps,\n loader,\n isRootLoader,\n component,\n projectId,\n globalContextsProps,\n userAuthToken, // Just use the token to memo, `user` should be derived from it\n isUserLoading,\n authRedirectUri,\n ]);\n return element;\n}\n\nfunction 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", "import * as React from 'react';\nimport { usePlasmicRootContext } from './PlasmicRootProvider';\nimport {\n ComponentLookupSpec,\n useForceUpdate,\n useIsMounted,\n useStableLookupSpec,\n} from './utils';\n\n/**\n * Hook that fetches and returns a React component for rendering the argument\n * Plasmic component. Returns undefined if the component data is still\n * being fetched.\n *\n * @param opts.forceOriginal if you used PlasmicComponentLoader.registerComponent,\n * then normally usePlasmicComponent will return the registered component.\n * You can set forceOriginal to true if you want to return the Plasmic-generated\n * component instead.\n */\nexport function usePlasmicComponent<P extends React.ComponentType = any>(\n spec: ComponentLookupSpec,\n opts: { forceOriginal?: boolean } = {}\n) {\n const rootContext = usePlasmicRootContext();\n if (!rootContext) {\n throw new Error(\n `You can only use usePlasmicComponent if wrapped in <PlasmicRootProvider />`\n );\n }\n\n const loader = rootContext.loader;\n const lookup = loader.getLookup();\n\n const component = lookup.hasComponent(spec)\n ? lookup.getComponent(spec, opts)\n : undefined;\n\n const stableSpec = useStableLookupSpec(spec);\n const isMounted = useIsMounted();\n const forceUpdate = useForceUpdate();\n\n React.useEffect(() => {\n if (!component) {\n (async () => {\n await loader.fetchComponentData(stableSpec);\n if (isMounted()) {\n forceUpdate();\n }\n })();\n }\n }, [component, stableSpec]);\n\n return component as P;\n}\n", "import React from \"react\";\nimport ReactDOM from \"react-dom\";\nimport { renderToString as reactRenderToString } from \"react-dom/server\";\nimport { ComponentRenderData, PlasmicComponentLoader } from \"./loader\";\nimport { PlasmicComponent } from \"./PlasmicComponent\";\nimport { GlobalVariantSpec, PlasmicRootProvider } from \"./PlasmicRootProvider\";\nimport { extractPlasmicQueryData } from \"@plasmicapp/prepass\";\nimport { ComponentLookupSpec } from \"./utils\";\n\nexport async function renderToElement(\n loader: PlasmicComponentLoader,\n target: HTMLElement,\n lookup: ComponentLookupSpec,\n opts: {\n prefetchedData?: ComponentRenderData;\n componentProps?: any;\n globalVariants?: GlobalVariantSpec[];\n prefetchedQueryData?: Record<string, any>;\n pageParams?: Record<string, any>;\n pageQuery?: Record<string, any>;\n } = {}\n) {\n return new Promise<void>((resolve) => {\n const element = makeElement(loader, lookup, opts);\n ReactDOM.render(element, target, () => resolve());\n });\n}\n\nexport function renderToString(\n loader: PlasmicComponentLoader,\n lookup: ComponentLookupSpec,\n opts: {\n prefetchedData?: ComponentRenderData;\n componentProps?: any;\n globalVariants?: GlobalVariantSpec[];\n prefetchedQueryData?: Record<string, any>;\n } = {}\n) {\n const element = makeElement(loader, lookup, opts);\n return reactRenderToString(element);\n}\n\nexport async function extractPlasmicQueryDataFromElement(\n loader: PlasmicComponentLoader,\n lookup: ComponentLookupSpec,\n opts: {\n prefetchedData?: ComponentRenderData;\n componentProps?: any;\n globalVariants?: GlobalVariantSpec[];\n prefetchedQueryData?: Record<string, any>;\n } = {}\n) {\n const element = makeElement(loader, lookup, opts);\n return extractPlasmicQueryData(element);\n}\n\nexport async function hydrateFromElement(\n loader: PlasmicComponentLoader,\n target: HTMLElement,\n lookup: ComponentLookupSpec,\n opts: {\n prefetchedData?: ComponentRenderData;\n componentProps?: any;\n globalVariants?: GlobalVariantSpec[];\n prefetchedQueryData?: Record<string, any>;\n } = {}\n) {\n return new Promise<void>((resolve) => {\n const element = makeElement(loader, lookup, opts);\n ReactDOM.hydrate(element, target, () => resolve());\n });\n}\n\nfunction makeElement(\n loader: PlasmicComponentLoader,\n lookup: ComponentLookupSpec,\n opts: {\n prefetchedData?: ComponentRenderData;\n componentProps?: any;\n globalVariants?: GlobalVariantSpec[];\n prefetchedQueryData?: Record<string, any>;\n pageParams?: Record<string, any>;\n pageQuery?: Record<string, any>;\n } = {}\n) {\n return (\n <PlasmicRootProvider\n loader={loader}\n prefetchedData={opts.prefetchedData}\n globalVariants={opts.globalVariants}\n prefetchedQueryData={opts.prefetchedQueryData}\n pageParams={opts.pageParams}\n pageQuery={opts.pageQuery}\n >\n <PlasmicComponent\n component={typeof lookup === \"string\" ? lookup : lookup.name}\n projectId={typeof lookup === \"string\" ? undefined : lookup.projectId}\n componentProps={opts.componentProps}\n />\n </PlasmicRootProvider>\n );\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,YAAY,+BAA+B;AAE3C,YAAY,iBAAiB;AAC7B;AAAA,EAME;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAEA;AAAA,OAIK;AACP;AAAA,EAGE;AAAA,EACA;AAAA,EACA;AAAA,OAEK;AACP;AAAA,EAEE;AAAA,OACK;AACP,SAAS,oBAAoB,sBAAsB;AACnD,YAAY,kBAAkB;AAC9B,OAAOA,YAAW;AAClB,OAAO,cAAc;AACrB,YAAY,mBAAmB;AAC/B,YAAY,gBAAgB;;;ACpC5B,OAAO,gBAAgB;AACvB,YAAY,WAAW;AAEhB,IAAM,YAAY,OAAO,WAAW;AAoBpC,SAAS,iBAAiB;AAC/B,QAAM,CAAC,EAAE,OAAO,IAAU,eAAS,CAAC;AACpC,QAAM,SAAe,kBAAY,MAAM;AACrC,YAAQ,CAAC,SAAS,OAAO,CAAC;AAAA,EAC5B,GAAG,CAAC,CAAC;AACL,SAAO;AACT;AAEO,SAAS,oBAAoB,MAA2B;AAC7D,SAAO,qBAAqB,IAAI,EAAE,CAAC;AACrC;AAEO,SAAS,wBAAwB,OAA8B;AACpE,QAAM,CAAC,aAAa,cAAc,IAAU,eAAS,KAAK;AAE1D,EAAM,gBAAU,MAAM;AACpB,QACE,MAAM,WAAW,YAAY,UAC7B,MAAM,KAAK,CAAC,GAAG,MAAM,CAAC,oBAAoB,GAAG,YAAY,CAAC,CAAC,CAAC,GAC5D;AACA,qBAAe,KAAK;AAAA,IACtB;AAAA,EACF,GAAG,CAAC,OAAO,WAAW,CAAC;AACvB,SAAO;AACT;AAEA,SAAS,oBACP,OACA,OACA;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Y,OAAO;AAAA,QAC3D,gBAAgB,KAAK;AAAA;AAAA,IACvB;AAAA,EACF;AAEJ;;;AH9DO,SAAS,kBAAkB,MAA2C;AAC3E,QAAM,WAAW,IAAI,+BAA+B,IAAI;AACxD,SAAO,IAAI,uBAAuB,QAAQ;AAC5C;",
|
|
6
|
-
"names": ["React", "React", "PlasmicCss", "spec", "React", "PageParamsProvider", "
|
|
4
|
+
"sourcesContent": ["import * as PlasmicDataSourcesContext from \"@plasmicapp/data-sources-context\";\n// eslint-disable-next-line no-restricted-imports\nimport * as PlasmicHost from \"@plasmicapp/host\";\nimport {\n CodeComponentMeta as InternalCodeComponentMeta,\n ComponentHelpers as InternalCodeComponentHelpers,\n CustomFunctionMeta as InternalCustomFunctionMeta,\n GlobalContextMeta as InternalGlobalContextMeta,\n // eslint-disable-next-line no-restricted-imports\n registerComponent,\n registerFunction,\n registerGlobalContext,\n registerToken,\n registerTrait,\n StateHelpers,\n stateHelpersKeys,\n StateSpec,\n TokenRegistration,\n TraitMeta,\n} from \"@plasmicapp/host\";\nimport {\n ComponentMeta,\n LoaderBundleOutput,\n PlasmicModulesFetcher,\n PlasmicTracker,\n Registry,\n TrackRenderOptions,\n} from \"@plasmicapp/loader-core\";\nimport {\n CodeModule,\n internal_getCachedBundleInNodeServer,\n} from \"@plasmicapp/loader-fetcher\";\nimport { getActiveVariation, getExternalIds } from \"@plasmicapp/loader-splits\";\nimport * as PlasmicQuery 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 { ComponentLookup } from \"./component-lookup\";\nimport { createUseGlobalVariant } from \"./global-variants\";\nimport {\n FetchComponentDataOpts,\n InitOptions,\n ReactServerPlasmicComponentLoader,\n} from \"./loader-react-server\";\nimport type { GlobalVariantSpec } from \"./PlasmicRootProvider\";\nimport { ComponentLookupSpec, getCompMetas, isBrowser, uniq } from \"./utils\";\nimport { getPlasmicCookieValues, updatePlasmicCookieValue } from \"./variation\";\n\nexport interface ComponentRenderData {\n entryCompMetas: (ComponentMeta & { params?: Record<string, string> })[];\n bundle: LoaderBundleOutput;\n remoteFontUrls: string[];\n}\n\ninterface ComponentSubstitutionSpec {\n lookup: ComponentLookupSpec;\n component: React.ComponentType<any>;\n codeComponentHelpers?: InternalCodeComponentHelpers<\n React.ComponentProps<any>\n >;\n}\n\ninterface PlasmicRootWatcher {\n onDataFetched?: () => void;\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\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\nconst SUBSTITUTED_COMPONENTS: Record<string, React.ComponentType<any>> = {};\nconst REGISTERED_CODE_COMPONENT_HELPERS: Record<\n string,\n InternalCodeComponentHelpers<React.ComponentProps<any>>\n> = {};\nconst SUBSTITUTED_GLOBAL_VARIANT_HOOKS: Record<string, () => any> = {};\nconst REGISTERED_CUSTOM_FUNCTIONS: Record<string, (...args: any[]) => any> = {};\n\nfunction 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 class InternalPlasmicComponentLoader {\n private readonly reactServerLoader: ReactServerPlasmicComponentLoader;\n private readonly registry = new Registry();\n private subs: ComponentSubstitutionSpec[] = [];\n private roots: PlasmicRootWatcher[] = [];\n private globalVariants: GlobalVariantSpec[] = [];\n private tracker: PlasmicTracker;\n\n constructor(public opts: InitOptions) {\n this.tracker = new PlasmicTracker({\n projectIds: opts.projects.map((p) => p.id),\n platform: opts.platform,\n preview: opts.preview,\n nativeFetch: opts.nativeFetch,\n });\n this.reactServerLoader = new ReactServerPlasmicComponentLoader({\n opts,\n fetcher: new PlasmicModulesFetcher(opts),\n tracker: this.tracker,\n onBundleMerged: () => {\n this.refreshRegistry();\n },\n onBundleFetched: () => {\n this.roots.forEach((watcher) => watcher.onDataFetched?.());\n },\n });\n\n this.registerModules({\n react: React,\n \"react-dom\": ReactDOM,\n \"react/jsx-runtime\": jsxRuntime,\n \"react/jsx-dev-runtime\": jsxDevRuntime,\n\n // Also inject @plasmicapp/query and @plasmicapp/host to use the\n // same contexts here and in loader-downloaded code.\n \"@plasmicapp/query\": PlasmicQuery,\n \"@plasmicapp/data-sources-context\": PlasmicDataSourcesContext,\n \"@plasmicapp/host\": PlasmicHost,\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 getBundle() {\n return this.reactServerLoader.getBundle();\n }\n\n setGlobalVariants(globalVariants: GlobalVariantSpec[]) {\n this.globalVariants = globalVariants;\n }\n\n getGlobalVariants() {\n return this.globalVariants;\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 private 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.registry.isEmpty()) {\n console.warn(\n \"Calling PlasmicComponentLoader.registerSubstitution() after Plasmic component has rendered; starting over.\"\n );\n this.registry.clear();\n }\n this.subs.push({ lookup: name, component, codeComponentHelpers });\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(([_, stateSpec]) =>\n Object.keys(stateSpec).some((key) => stateHelpersKeys.includes(key))\n )\n .map(([stateName, stateSpec]) => [\n stateName,\n Object.fromEntries(\n stateHelpersKeys\n .filter((key) => key in stateSpec)\n .map((key) => [key, stateSpec[key]])\n ),\n ])\n );\n const helpers = { states: stateHelpers };\n this.internalSubstituteComponent(\n component,\n { name: meta.name, isCode: true },\n Object.keys(stateHelpers).length > 0 ? helpers : undefined\n );\n registerComponent(component, {\n ...meta,\n // Import path is not used as we will use component substitution\n importPath: meta.importPath ?? \"\",\n ...(Object.keys(stateHelpers).length > 0\n ? {\n componentHelpers: {\n helpers,\n importPath: \"\",\n importName: \"\",\n },\n }\n : {}),\n });\n }\n\n registerFunction<F extends (...args: any[]) => any>(\n fn: F,\n meta: CustomFunctionMeta<F>\n ) {\n registerFunction(fn, {\n ...meta,\n importPath: meta.importPath ?? \"\",\n });\n REGISTERED_CUSTOM_FUNCTIONS[customFunctionImportAlias(meta)] = fn;\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 // Import path is not used as we will use component substitution\n registerGlobalContext(context, {\n ...meta,\n importPath: meta.importPath ?? \"\",\n });\n }\n\n registerTrait(trait: string, meta: TraitMeta) {\n registerTrait(trait, meta);\n }\n\n registerToken(token: TokenRegistration) {\n registerToken(token);\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.reactServerLoader.mergeBundle(cachedBundle);\n }\n }\n this.reactServerLoader.mergeBundle(bundle);\n }\n\n subscribePlasmicRoot(watcher: PlasmicRootWatcher) {\n this.roots.push(watcher);\n }\n\n unsubscribePlasmicRoot(watcher: PlasmicRootWatcher) {\n const index = this.roots.indexOf(watcher);\n if (index >= 0) {\n this.roots.splice(index, 1);\n }\n }\n\n clearCache() {\n this.reactServerLoader.clearCache();\n this.registry.clear();\n }\n\n getLookup() {\n return new ComponentLookup(this.getBundle(), this.registry);\n }\n\n // ReactServerLoader methods\n\n maybeFetchComponentData(\n specs: ComponentLookupSpec[],\n opts?: FetchComponentDataOpts\n ): Promise<ComponentRenderData | null>;\n maybeFetchComponentData(\n ...specs: ComponentLookupSpec[]\n ): Promise<ComponentRenderData | null>;\n maybeFetchComponentData(...args: any[]): Promise<ComponentRenderData | null> {\n return this.reactServerLoader.maybeFetchComponentData(...args);\n }\n\n fetchComponentData(\n specs: ComponentLookupSpec[],\n opts?: FetchComponentDataOpts\n ): Promise<ComponentRenderData>;\n fetchComponentData(\n ...specs: ComponentLookupSpec[]\n ): Promise<ComponentRenderData>;\n fetchComponentData(...args: any[]): Promise<ComponentRenderData> {\n return this.reactServerLoader.fetchComponentData(...args);\n }\n\n fetchPages(opts?: FetchPagesOpts) {\n return this.reactServerLoader.fetchPages(opts);\n }\n\n fetchComponents() {\n return this.reactServerLoader.fetchComponents();\n }\n\n getActiveSplits() {\n return this.reactServerLoader.getActiveSplits();\n }\n\n getChunksUrl(bundle: LoaderBundleOutput, modules: CodeModule[]) {\n return this.reactServerLoader.getChunksUrl(bundle, modules);\n }\n\n trackConversion(value = 0) {\n this.tracker.trackConversion(value);\n }\n\n public async getActiveVariation(opts: {\n traits: Record<string, string | number | boolean>;\n getKnownValue: (key: string) => string | undefined;\n updateKnownValue: (key: string, value: string) => void;\n }) {\n await this.reactServerLoader.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 this.tracker.trackRender(opts);\n }\n\n private 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 // We also 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 createUseGlobalVariant(globalGroup.name, globalGroup.projectId);\n }\n }\n this.registry.updateModules(this.getBundle());\n }\n}\n\n/**\n * Library for fetching component data, and registering\n * custom components.\n */\nexport class PlasmicComponentLoader {\n private __internal: InternalPlasmicComponentLoader;\n constructor(internal: InternalPlasmicComponentLoader) {\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(opts: {\n traits: Record<string, string | number | boolean>;\n getKnownValue: (key: string) => string | undefined;\n updateKnownValue: (key: string, value: string) => void;\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", "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(/\\/\\[\\[\\.\\.\\.(\\w+)]]/g, \"(?:/([^]*))?\") // Optional catch-all\n .replace(/\\/\\[\\.\\.\\.(\\w+)]/g, \"/([^]*)\") // Catch-all\n .replace(/\\[(\\w+)]/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(/\\[\\.?\\.?\\.?(\\w+)]/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 uniq<T>(elements: T[]): T[] {\n return Array.from(new Set(elements));\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 { PlasmicDataSourceContextValue } from \"@plasmicapp/data-sources-context\";\nimport { PageParamsProvider } from \"@plasmicapp/host\";\nimport { AssetModule, ComponentMeta, Split } from \"@plasmicapp/loader-core\";\nimport { PlasmicQueryDataProvider } from \"@plasmicapp/query\";\nimport * as React from \"react\";\nimport {\n ComponentRenderData,\n InternalPlasmicComponentLoader,\n PlasmicComponentLoader,\n} from \"./loader\";\nimport { useForceUpdate } from \"./utils\";\nimport {\n ensureVariationCookies,\n getGlobalVariantsFromSplits,\n mergeGlobalVariantsSpec,\n} from \"./variation\";\n\ninterface PlasmicRootContextValue extends PlasmicDataSourceContextValue {\n globalVariants?: GlobalVariantSpec[];\n globalContextsProps?: Record<string, any>;\n loader: InternalPlasmicComponentLoader;\n variation?: Record<string, string>;\n translator?: PlasmicTranslator;\n Head?: React.ComponentType<any>;\n Link?: React.ComponentType<any>;\n disableLoadingBoundary?: boolean;\n suspenseFallback?: React.ReactNode;\n}\n\nconst PlasmicRootContext = React.createContext<\n PlasmicRootContextValue | undefined\n>(undefined);\n\nexport interface GlobalVariantSpec {\n name: string;\n projectId?: string;\n value: any;\n}\n\nexport type PlasmicTranslator = (\n str: string,\n opts?: {\n components?: {\n [key: string]: React.ReactElement | React.ReactFragment;\n };\n }\n) => React.ReactNode;\n\n/**\n * PlasmicRootProvider should be used at the root of your page\n * or application.\n */\nexport function PlasmicRootProvider(\n props: {\n /**\n * The global PlasmicComponentLoader instance you created via\n * initPlasmicLoader().\n */\n loader: PlasmicComponentLoader;\n\n /**\n * Global variants to activate for Plasmic components\n */\n globalVariants?: GlobalVariantSpec[];\n\n children?: React.ReactNode;\n\n /**\n * If true, will skip rendering css\n */\n skipCss?: boolean;\n\n /**\n * If true, will skip installing fonts\n */\n skipFonts?: boolean;\n\n /**\n * If you have pre-fetched component data via PlasmicComponentLoader,\n * you can pass them in here; PlasmicComponent will avoid fetching\n * component data that have already been pre-fetched.\n */\n prefetchedData?: ComponentRenderData;\n\n /**\n * If you have pre-fetched data that are needed by usePlasmicQueryData(),\n * then pass in the pre-fetched cache here, mapping query key to fetched data.\n */\n prefetchedQueryData?: Record<string, any>;\n\n /**\n * Specifies whether usePlasmicQueryData() should be operating in suspense mode\n * (throwing promises).\n */\n suspenseForQueryData?: boolean;\n\n /**\n * Override your Global Contexts Provider props. This is a map from\n * globalContextComponentNameProps to object of props to use for that\n * component.\n */\n globalContextsProps?: Record<string, any>;\n\n /**\n * Specifies a mapping of split id to slice id that should be activated\n */\n variation?: Record<string, string>;\n\n /**\n * Translator function to be used for text blocks\n */\n translator?: PlasmicTranslator;\n\n /**\n * Head component to use in PlasmicHead component (e.g. Head from next/head\n * or Helmet from react-helmet).\n */\n Head?: React.ComponentType<any>;\n\n /**\n * Link component to use. Can be any component that takes in props passed\n * to an <a/> tag.\n */\n Link?: React.ComponentType<any>;\n\n /**\n * Page route without params substitution (e.g. /products/[slug]).\n */\n pageRoute?: string;\n\n /**\n * Page path parameters (e.g. {slug: \"foo\"} if page path is\n * /products/[slug] and URI is /products/foo).\n */\n pageParams?: Record<string, string | string[] | undefined>;\n\n /**\n * Page query parameters (e.g. {q: \"foo\"} if page path is\n * /some/path?q=foo).\n */\n pageQuery?: Record<string, string | string[] | undefined>;\n /**\n * Whether the React.Suspense boundaries should be removed\n */\n disableLoadingBoundary?: boolean;\n /**\n * Fallback value for the root-level React.Suspense\n */\n suspenseFallback?: React.ReactNode;\n } & PlasmicDataSourceContextValue\n) {\n const {\n globalVariants,\n prefetchedData,\n children,\n skipCss,\n skipFonts,\n prefetchedQueryData,\n suspenseForQueryData,\n globalContextsProps,\n variation,\n translator,\n Head,\n Link,\n pageRoute,\n pageParams,\n pageQuery,\n suspenseFallback,\n disableLoadingBoundary,\n } = props;\n const loader = (props.loader as any)\n .__internal as InternalPlasmicComponentLoader;\n\n if (prefetchedData) {\n loader.registerPrefetchedBundle(prefetchedData?.bundle);\n }\n\n const [splits, setSplits] = React.useState<Split[]>(loader.getActiveSplits());\n const forceUpdate = useForceUpdate();\n const watcher = React.useMemo(\n () => ({\n onDataFetched: () => {\n setSplits(loader.getActiveSplits());\n forceUpdate();\n },\n }),\n [loader, forceUpdate]\n );\n\n React.useEffect(() => {\n loader.subscribePlasmicRoot(watcher);\n return () => loader.unsubscribePlasmicRoot(watcher);\n }, [watcher, loader]);\n\n React.useEffect(() => {\n ensureVariationCookies(variation);\n loader.trackRender({\n renderCtx: {\n // We track the provider as a single entity\n rootComponentId: \"provider\",\n teamIds: loader.getTeamIds(),\n projectIds: loader.getProjectIds(),\n },\n variation,\n });\n }, [loader, variation]);\n\n const { user, userAuthToken, isUserLoading, authRedirectUri } = props;\n\n const value = React.useMemo<PlasmicRootContextValue>(\n () => ({\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 globalVariants,\n variation,\n globalContextsProps,\n loader,\n splits,\n translator,\n Head,\n Link,\n user,\n userAuthToken,\n isUserLoading,\n authRedirectUri,\n suspenseFallback,\n disableLoadingBoundary,\n ]\n );\n\n return (\n <PlasmicQueryDataProvider\n prefetchedCache={prefetchedQueryData}\n suspense={suspenseForQueryData}\n >\n <PlasmicRootContext.Provider value={value}>\n {!skipCss && (\n <PlasmicCss\n loader={loader}\n prefetchedData={prefetchedData}\n skipFonts={skipFonts}\n />\n )}\n <PageParamsProvider\n route={pageRoute}\n params={pageParams}\n query={pageQuery}\n >\n {children}\n </PageParamsProvider>\n </PlasmicRootContext.Provider>\n </PlasmicQueryDataProvider>\n );\n}\n\n/**\n * Inject all css modules as <style/> tags. We can't use the usual styleInjector postcss\n * uses because that doesn't work on the server side for SSR.\n */\nconst PlasmicCss = React.memo(function PlasmicCss(props: {\n loader: InternalPlasmicComponentLoader;\n prefetchedData?: ComponentRenderData;\n skipFonts?: boolean;\n}) {\n const { loader, prefetchedData, skipFonts } = props;\n const [useScopedCss, setUseScopedCss] = React.useState(!!prefetchedData);\n const builtCss = buildCss(loader, {\n scopedCompMetas:\n useScopedCss && prefetchedData\n ? prefetchedData.bundle.components\n : undefined,\n skipFonts,\n });\n const forceUpdate = useForceUpdate();\n const watcher = React.useMemo(\n () => ({\n onDataFetched: () => {\n // If new data has been fetched, then use all the fetched css\n setUseScopedCss(false);\n forceUpdate();\n },\n }),\n [loader, forceUpdate]\n );\n\n React.useEffect(() => {\n loader.subscribePlasmicRoot(watcher);\n return () => loader.unsubscribePlasmicRoot(watcher);\n }, [watcher, loader]);\n\n return <style dangerouslySetInnerHTML={{ __html: builtCss }} />;\n});\n\nfunction buildCss(\n loader: InternalPlasmicComponentLoader,\n opts: {\n scopedCompMetas?: ComponentMeta[];\n skipFonts?: boolean;\n }\n) {\n const { scopedCompMetas, skipFonts } = opts;\n const cssFiles =\n scopedCompMetas &&\n new Set<string>([\n \"entrypoint.css\",\n ...scopedCompMetas.map((c) => c.cssFile),\n ]);\n const cssModules = loader\n .getLookup()\n .getCss()\n .filter((f) => !cssFiles || cssFiles.has(f.fileName));\n\n const getPri = (fileName: string) => (fileName === \"entrypoint.css\" ? 0 : 1);\n const compareModules = (a: AssetModule, b: AssetModule) =>\n getPri(a.fileName) !== getPri(b.fileName)\n ? getPri(a.fileName) - getPri(b.fileName)\n : a.fileName.localeCompare(b.fileName);\n cssModules.sort(compareModules);\n\n const remoteFonts = loader.getLookup().getRemoteFonts();\n\n // Make sure the @import statements come at the front of css\n return `\n ${\n skipFonts\n ? \"\"\n : remoteFonts.map((f) => `@import url('${f.url}');`).join(\"\\n\")\n }\n ${cssModules.map((mod) => mod.source).join(\"\\n\")}\n `;\n}\n\nexport function usePlasmicRootContext() {\n return React.useContext(PlasmicRootContext);\n}\n", "import { ExperimentSlice, SegmentSlice, Split } 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 function ensureVariationCookies(variation: Record<string, string> = {}) {\n Object.keys(variation).map((variationKey) => {\n const sliceId = variation[variationKey];\n updatePlasmicCookieValue(variationKey, sliceId);\n });\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", "/**\n * We don't actually make use of the global variant React contexts generated\n * in the bundle. That's because we would have to wait until the data is\n * loaded before we can set up the context providers, but setting up context\n * providers will mutate the React tree and invalidate all the children. That means\n * once data comes in, we'll re-render the React tree from the providers down\n * in a way that will lose all existing React state. Therefore, instead,\n * we always have a single context provided -- the PlasmicRootContext -- and we\n * create these fake useGlobalVariant() hooks that just read from that\n * PlasmicRootContext. This allows us to have a stable React tree before and\n * after the data load.\n */\n\nimport { InternalPlasmicComponentLoader } from './loader';\nimport { usePlasmicRootContext } from './PlasmicRootProvider';\n\nexport function createUseGlobalVariant(name: string, projectId: string) {\n return () => {\n const rootContext = usePlasmicRootContext();\n if (!rootContext) {\n return undefined;\n }\n\n const loader = rootContext.loader as InternalPlasmicComponentLoader;\n const spec = [\n ...loader.getGlobalVariants(),\n ...(rootContext.globalVariants ?? []),\n ].find(\n (spec) =>\n spec.name === name && (!spec.projectId || spec.projectId === projectId)\n );\n return spec ? spec.value : undefined;\n };\n}\n", "import {\n ComponentMeta,\n getBundleSubset,\n LoaderBundleOutput,\n} from '@plasmicapp/loader-core';\nimport type { ComponentRenderData } from './loader';\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\nexport function mergeBundles(\n target: LoaderBundleOutput,\n from: LoaderBundleOutput\n) {\n const existingCompIds = new Set(target.components.map((c) => c.id));\n\n const newCompMetas = from.components.filter(\n (m) => !existingCompIds.has(m.id)\n );\n if (newCompMetas.length > 0) {\n target = { ...target, components: [...target.components, ...newCompMetas] };\n }\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 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 existingExternals = new Set(target.external);\n const newExternals = target.external.filter((x) => !existingExternals.has(x));\n if (newExternals.length > 0) {\n target = { ...target, external: [...target.external, ...newExternals] };\n }\n\n const existingSplitIds = new Set(target.activeSplits.map((s) => s.id));\n const newSplits =\n from.activeSplits.filter((s) => !existingSplitIds.has(s.id)) ?? [];\n if (newSplits.length > 0) {\n target = {\n ...target,\n activeSplits: [...target.activeSplits, ...newSplits],\n };\n }\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 {\n LoaderBundleCache,\n PageMeta,\n PlasmicModulesFetcher,\n PlasmicTracker,\n} from \"@plasmicapp/loader-core\";\nimport {\n CodeModule,\n ComponentMeta,\n LoaderBundleOutput,\n} from \"@plasmicapp/loader-fetcher\";\nimport { prepComponentData } from \"./bundles\";\nimport { ComponentRenderData, FetchPagesOpts } from \"./loader\";\nimport {\n ComponentLookupSpec,\n getCompMetas,\n getLookupSpecName,\n isBrowser,\n isDynamicPagePath,\n} from \"./utils\";\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\n/** Subset of loader functionality that works on React Server Components. */\nexport class ReactServerPlasmicComponentLoader {\n private readonly opts: InitOptions;\n private readonly fetcher: PlasmicModulesFetcher;\n private readonly tracker: PlasmicTracker;\n private readonly onBundleMerged?: () => void;\n private readonly onBundleFetched?: () => void;\n\n private bundle: LoaderBundleOutput = {\n modules: {\n browser: [],\n server: [],\n },\n components: [],\n globalGroups: [],\n external: [],\n projects: [],\n activeSplits: [],\n bundleUrlQuery: null,\n };\n\n constructor(args: {\n opts: InitOptions;\n fetcher: PlasmicModulesFetcher;\n tracker: PlasmicTracker;\n /** Called after `mergeBundle` (including `fetch` calls). */\n onBundleMerged?: () => void;\n /** Called after any `fetch` calls. */\n onBundleFetched?: () => void;\n }) {\n this.opts = args.opts;\n this.fetcher = args.fetcher;\n this.tracker = args.tracker;\n this.onBundleMerged = args.onBundleMerged;\n this.onBundleFetched = args.onBundleFetched;\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.tracker.trackFetch();\n this.mergeBundle(bundle);\n this.onBundleFetched?.();\n return bundle;\n }\n\n mergeBundle(bundle: LoaderBundleOutput) {\n // TODO: this is only possible as the bundle is the full bundle,\n // not a partial bundle. Figure it out how to merge partial bundles.\n this.bundle = bundle;\n // Avoid `undefined` as it cannot be serialized as JSON\n this.bundle.bundleUrlQuery = this.bundle.bundleUrlQuery ?? null;\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 external: [],\n projects: [],\n activeSplits: [],\n bundleUrlQuery: null,\n };\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", "import {\n CodeComponentMeta,\n InternalPlasmicComponentLoader,\n PlasmicComponentLoader,\n} from \"./loader\";\nimport type {\n FetchComponentDataOpts,\n InitOptions,\n} from \"./loader-react-server\";\n\nexport {\n DataCtxReader,\n DataProvider,\n PageParamsProvider,\n PlasmicCanvasContext,\n PlasmicCanvasHost,\n repeatedElement,\n useDataEnv,\n usePlasmicCanvasContext,\n useSelector,\n useSelectors,\n} from \"@plasmicapp/host\";\nexport type { PropType, TokenRegistration } from \"@plasmicapp/host\";\nexport { extractPlasmicQueryData, plasmicPrepass } from \"@plasmicapp/prepass\";\nexport { usePlasmicQueryData } from \"@plasmicapp/query\";\nexport { PlasmicComponent } from \"./PlasmicComponent\";\nexport { PlasmicRootProvider } from \"./PlasmicRootProvider\";\nexport type {\n GlobalVariantSpec,\n PlasmicTranslator,\n} from \"./PlasmicRootProvider\";\nexport {\n extractPlasmicQueryDataFromElement,\n hydrateFromElement,\n renderToElement,\n renderToString,\n} from \"./render\";\nexport * from \"./shared-exports\";\nexport { usePlasmicComponent } from \"./usePlasmicComponent\";\nexport type { ComponentLookupSpec } from \"./utils\";\nexport type { CodeComponentMeta };\nexport { FetchComponentDataOpts };\nexport { InternalPlasmicComponentLoader, PlasmicComponentLoader };\n\nexport function initPlasmicLoader(opts: InitOptions): PlasmicComponentLoader {\n const internal = new InternalPlasmicComponentLoader(opts);\n return new PlasmicComponentLoader(internal);\n}\n", "import * as React from \"react\";\nimport { usePlasmicRootContext } from \"./PlasmicRootProvider\";\nimport { usePlasmicComponent } from \"./usePlasmicComponent\";\n\nconst PlasmicComponentContext = React.createContext(false);\n\nexport function PlasmicComponent(props: {\n /**\n * Name of the component to render, or the path of the page component\n */\n component: string;\n /**\n * Optionally specify a projectId if there are multiple components\n * of the same name from different projects\n */\n projectId?: string;\n /**\n * If you used registerComponent(), then if the name matches a registered\n * component, that component is used. If you want the Plasmic-generated\n * component instead, specify forceOriginal.\n */\n forceOriginal?: boolean;\n componentProps?: any;\n}): React.ReactElement | null {\n const { component, projectId, componentProps, forceOriginal } = props;\n\n const rootContext = usePlasmicRootContext();\n const isRootLoader = !React.useContext(PlasmicComponentContext);\n\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\n const {\n loader,\n globalContextsProps,\n variation,\n userAuthToken,\n isUserLoading,\n authRedirectUri,\n translator,\n ...rest\n } = rootContext;\n\n const Component = usePlasmicComponent(\n { name: component, projectId, isCode: false },\n { forceOriginal }\n );\n\n React.useEffect(() => {\n if (isRootLoader) {\n const meta = loader\n .getLookup()\n .getComponentMeta({ name: component, projectId });\n\n if (meta) {\n loader.trackRender({\n renderCtx: {\n rootProjectId: meta.projectId,\n rootComponentId: meta.id,\n rootComponentName: component,\n teamIds: loader.getTeamIds(),\n projectIds: loader.getProjectIds(),\n },\n variation,\n });\n }\n }\n }, [component, projectId, loader, variation]);\n\n const element = React.useMemo(() => {\n if (!Component) {\n return null;\n }\n\n let element = <Component {...componentProps} />;\n\n if (isRootLoader) {\n // If this is the root PlasmicComponent, then wrap the content with the\n // react-web's PlasmicRootProvider. We are doing this here, instead of\n // say PlasmicRootProvider, because we don't have access to this context\n // provider until data has been loaded. If we insert this provider into\n // the tree at the root after data is loaded, then we'll invalidate the\n // React tree and tree state, which is bad. Instead, we do it at the\n // \"root-most PlasmicComponent\"; we won't risk invalidating the sub-tree\n // here because there were no children before the data came in.\n const lookup = loader.getLookup();\n const ReactWebRootProvider = lookup.getRootProvider();\n const GlobalContextsProvider = lookup.getGlobalContextsProvider({\n name: component,\n projectId,\n });\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 <MaybeWrap\n cond={!!GlobalContextsProvider}\n wrapper={(children) => (\n <GlobalContextsProvider {...globalContextsProps}>\n {children}\n </GlobalContextsProvider>\n )}\n >\n <PlasmicComponentContext.Provider value={true}>\n {element}\n </PlasmicComponentContext.Provider>\n </MaybeWrap>\n </ReactWebRootProvider>\n );\n }\n return element;\n }, [\n Component,\n componentProps,\n loader,\n isRootLoader,\n component,\n projectId,\n globalContextsProps,\n userAuthToken, // Just use the token to memo, `user` should be derived from it\n isUserLoading,\n authRedirectUri,\n ]);\n return element;\n}\n\nfunction 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", "import * as React from 'react';\nimport { usePlasmicRootContext } from './PlasmicRootProvider';\nimport {\n ComponentLookupSpec,\n useForceUpdate,\n useIsMounted,\n useStableLookupSpec,\n} from './utils';\n\n/**\n * Hook that fetches and returns a React component for rendering the argument\n * Plasmic component. Returns undefined if the component data is still\n * being fetched.\n *\n * @param opts.forceOriginal if you used PlasmicComponentLoader.registerComponent,\n * then normally usePlasmicComponent will return the registered component.\n * You can set forceOriginal to true if you want to return the Plasmic-generated\n * component instead.\n */\nexport function usePlasmicComponent<P extends React.ComponentType = any>(\n spec: ComponentLookupSpec,\n opts: { forceOriginal?: boolean } = {}\n) {\n const rootContext = usePlasmicRootContext();\n if (!rootContext) {\n throw new Error(\n `You can only use usePlasmicComponent if wrapped in <PlasmicRootProvider />`\n );\n }\n\n const loader = rootContext.loader;\n const lookup = loader.getLookup();\n\n const component = lookup.hasComponent(spec)\n ? lookup.getComponent(spec, opts)\n : undefined;\n\n const stableSpec = useStableLookupSpec(spec);\n const isMounted = useIsMounted();\n const forceUpdate = useForceUpdate();\n\n React.useEffect(() => {\n if (!component) {\n (async () => {\n await loader.fetchComponentData(stableSpec);\n if (isMounted()) {\n forceUpdate();\n }\n })();\n }\n }, [component, stableSpec]);\n\n return component as P;\n}\n", "import React from \"react\";\nimport ReactDOM from \"react-dom\";\nimport { renderToString as reactRenderToString } from \"react-dom/server\";\nimport { ComponentRenderData, PlasmicComponentLoader } from \"./loader\";\nimport { PlasmicComponent } from \"./PlasmicComponent\";\nimport { GlobalVariantSpec, PlasmicRootProvider } from \"./PlasmicRootProvider\";\nimport { extractPlasmicQueryData } from \"@plasmicapp/prepass\";\nimport { ComponentLookupSpec } from \"./utils\";\n\nexport async function renderToElement(\n loader: PlasmicComponentLoader,\n target: HTMLElement,\n lookup: ComponentLookupSpec,\n opts: {\n prefetchedData?: ComponentRenderData;\n componentProps?: any;\n globalVariants?: GlobalVariantSpec[];\n prefetchedQueryData?: Record<string, any>;\n pageParams?: Record<string, any>;\n pageQuery?: Record<string, any>;\n } = {}\n) {\n return new Promise<void>((resolve) => {\n const element = makeElement(loader, lookup, opts);\n ReactDOM.render(element, target, () => resolve());\n });\n}\n\nexport function renderToString(\n loader: PlasmicComponentLoader,\n lookup: ComponentLookupSpec,\n opts: {\n prefetchedData?: ComponentRenderData;\n componentProps?: any;\n globalVariants?: GlobalVariantSpec[];\n prefetchedQueryData?: Record<string, any>;\n } = {}\n) {\n const element = makeElement(loader, lookup, opts);\n return reactRenderToString(element);\n}\n\nexport async function extractPlasmicQueryDataFromElement(\n loader: PlasmicComponentLoader,\n lookup: ComponentLookupSpec,\n opts: {\n prefetchedData?: ComponentRenderData;\n componentProps?: any;\n globalVariants?: GlobalVariantSpec[];\n prefetchedQueryData?: Record<string, any>;\n } = {}\n) {\n const element = makeElement(loader, lookup, opts);\n return extractPlasmicQueryData(element);\n}\n\nexport async function hydrateFromElement(\n loader: PlasmicComponentLoader,\n target: HTMLElement,\n lookup: ComponentLookupSpec,\n opts: {\n prefetchedData?: ComponentRenderData;\n componentProps?: any;\n globalVariants?: GlobalVariantSpec[];\n prefetchedQueryData?: Record<string, any>;\n } = {}\n) {\n return new Promise<void>((resolve) => {\n const element = makeElement(loader, lookup, opts);\n ReactDOM.hydrate(element, target, () => resolve());\n });\n}\n\nfunction makeElement(\n loader: PlasmicComponentLoader,\n lookup: ComponentLookupSpec,\n opts: {\n prefetchedData?: ComponentRenderData;\n componentProps?: any;\n globalVariants?: GlobalVariantSpec[];\n prefetchedQueryData?: Record<string, any>;\n pageParams?: Record<string, any>;\n pageQuery?: Record<string, any>;\n } = {}\n) {\n return (\n <PlasmicRootProvider\n loader={loader}\n prefetchedData={opts.prefetchedData}\n globalVariants={opts.globalVariants}\n prefetchedQueryData={opts.prefetchedQueryData}\n pageParams={opts.pageParams}\n pageQuery={opts.pageQuery}\n >\n <PlasmicComponent\n component={typeof lookup === \"string\" ? lookup : lookup.name}\n projectId={typeof lookup === \"string\" ? undefined : lookup.projectId}\n componentProps={opts.componentProps}\n />\n </PlasmicRootProvider>\n );\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,YAAY,+BAA+B;AAE3C,YAAY,iBAAiB;AAC7B;AAAA,EAME;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAEA;AAAA,OAIK;AACP;AAAA,EAGE;AAAA,EACA;AAAA,EACA;AAAA,OAEK;AACP;AAAA,EAEE;AAAA,OACK;AACP,SAAS,oBAAoB,sBAAsB;AACnD,YAAY,kBAAkB;AAC9B,OAAOA,YAAW;AAClB,OAAO,cAAc;AACrB,YAAY,mBAAmB;AAC/B,YAAY,gBAAgB;;;ACpC5B,OAAO,gBAAgB;AACvB,YAAY,WAAW;AAEhB,IAAM,YAAY,OAAO,WAAW;AAoBpC,SAAS,iBAAiB;AAC/B,QAAM,CAAC,EAAE,OAAO,IAAU,eAAS,CAAC;AACpC,QAAM,SAAe,kBAAY,MAAM;AACrC,YAAQ,CAAC,SAAS,OAAO,CAAC;AAAA,EAC5B,GAAG,CAAC,CAAC;AACL,SAAO;AACT;AAEO,SAAS,oBAAoB,MAA2B;AAC7D,SAAO,qBAAqB,IAAI,EAAE,CAAC;AACrC;AAEO,SAAS,wBAAwB,OAA8B;AACpE,QAAM,CAAC,aAAa,cAAc,IAAU,eAAS,KAAK;AAE1D,EAAM,gBAAU,MAAM;AACpB,QACE,MAAM,WAAW,YAAY,UAC7B,MAAM,KAAK,CAAC,GAAG,M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AAY,KAAK;AAAA,MACjB,WAAW,KAAK;AAAA;AAAA,IAEhB,gBAAAA,OAAA;AAAA,MAAC;AAAA;AAAA,QACC,WAAW,OAAO,WAAW,WAAW,SAAS,OAAO;AAAA,QACxD,WAAW,OAAO,WAAW,WAAW,SAAY,OAAO;AAAA,QAC3D,gBAAgB,KAAK;AAAA;AAAA,IACvB;AAAA,EACF;AAEJ;;;AHzDO,SAAS,kBAAkB,MAA2C;AAC3E,QAAM,WAAW,IAAI,+BAA+B,IAAI;AACxD,SAAO,IAAI,uBAAuB,QAAQ;AAC5C;",
|
|
6
|
+
"names": ["React", "React", "PlasmicCss", "spec", "React", "PageParamsProvider", "extractPlasmicQueryData", "React", "React", "_a", "element", "React", "ReactDOM", "ReactDOM", "React"]
|
|
7
7
|
}
|
package/dist/index.js
CHANGED
|
@@ -193,26 +193,27 @@ function useIsMounted() {
|
|
|
193
193
|
}, []);
|
|
194
194
|
return isMounted;
|
|
195
195
|
}
|
|
196
|
-
function matchesPagePath(
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
const
|
|
201
|
-
|
|
202
|
-
)
|
|
203
|
-
const pagePathRegExp = new RegExp(
|
|
204
|
-
"^/?" + pagePath.replace(/\[\.\.\.[^\]]*\]/g, "(.+)").replace(/\[[^\]]*\]/g, "([^/]+)") + "$"
|
|
205
|
-
);
|
|
206
|
-
const maybeVals = (_a = lookup.replace(/[?].*/, "").match(pagePathRegExp)) == null ? void 0 : _a.slice(1);
|
|
207
|
-
if (!maybeVals) {
|
|
196
|
+
function matchesPagePath(pattern, path) {
|
|
197
|
+
const normalizedPattern = "/" + pattern.replace(/^\/|\/$/g, "");
|
|
198
|
+
const normalizedPath = "/" + path.replace(/^\/|\/$/g, "");
|
|
199
|
+
const regexString = normalizedPattern.replace(/\/\[\[\.\.\.(\w+)]]/g, "(?:/([^]*))?").replace(/\/\[\.\.\.(\w+)]/g, "/([^]*)").replace(/\[(\w+)]/g, "([^/]+)").replace(/\//g, "\\/");
|
|
200
|
+
const regex = new RegExp(`^/?${regexString}$`);
|
|
201
|
+
const match = normalizedPath.match(regex);
|
|
202
|
+
if (!match)
|
|
208
203
|
return false;
|
|
209
|
-
|
|
204
|
+
const slugNames = [...pattern.matchAll(/\[\.?\.?\.?(\w+)]/g)].map(
|
|
205
|
+
(m) => m[1]
|
|
206
|
+
);
|
|
210
207
|
const params = {};
|
|
211
|
-
for (let i = 0; i <
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
}
|
|
215
|
-
params[
|
|
208
|
+
for (let i = 0; i < slugNames.length; i++) {
|
|
209
|
+
const slugName = slugNames[i];
|
|
210
|
+
const value = match[i + 1];
|
|
211
|
+
if (pattern.includes(`[[...${slugName}]]`)) {
|
|
212
|
+
params[slugName] = value ? value.split("/").filter(Boolean) : [];
|
|
213
|
+
} else if (pattern.includes(`[...${slugName}]`)) {
|
|
214
|
+
params[slugName] = value.split("/").filter(Boolean);
|
|
215
|
+
} else if (value !== void 0) {
|
|
216
|
+
params[slugName] = value;
|
|
216
217
|
}
|
|
217
218
|
}
|
|
218
219
|
return { params };
|
|
@@ -1144,34 +1145,12 @@ var PlasmicComponentLoader = class {
|
|
|
1144
1145
|
registerToken(token) {
|
|
1145
1146
|
this.__internal.registerToken(token);
|
|
1146
1147
|
}
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
* these components. Should be passed into PlasmicRootProvider as
|
|
1150
|
-
* the prefetchedData prop.
|
|
1151
|
-
*
|
|
1152
|
-
* You can look up a component either by:
|
|
1153
|
-
* - the name of the component
|
|
1154
|
-
* - the path for a page component
|
|
1155
|
-
* - an array of strings that make up parts of the path
|
|
1156
|
-
* - object { name: "name_or_path", projectId: ...}, to specify which project
|
|
1157
|
-
* to use, if multiple projects have the same component name
|
|
1158
|
-
*
|
|
1159
|
-
* Throws an Error if a specified component to fetch does not exist in
|
|
1160
|
-
* the Plasmic project.
|
|
1161
|
-
*/
|
|
1162
|
-
fetchComponentData(...specs) {
|
|
1163
|
-
return __async(this, null, function* () {
|
|
1164
|
-
return this.__internal.fetchComponentData(...specs);
|
|
1165
|
-
});
|
|
1148
|
+
fetchComponentData(...args) {
|
|
1149
|
+
return this.__internal.fetchComponentData(...args);
|
|
1166
1150
|
}
|
|
1167
|
-
|
|
1168
|
-
* Like fetchComponentData(), but returns null instead of throwing an Error
|
|
1169
|
-
* when a component is not found. Useful when you are implementing a catch-all
|
|
1170
|
-
* page and want to check if a specific path had been defined for Plasmic.
|
|
1171
|
-
*/
|
|
1172
|
-
maybeFetchComponentData(...specs) {
|
|
1151
|
+
maybeFetchComponentData(...args) {
|
|
1173
1152
|
return __async(this, null, function* () {
|
|
1174
|
-
return this.__internal.maybeFetchComponentData(...
|
|
1153
|
+
return this.__internal.maybeFetchComponentData(...args);
|
|
1175
1154
|
});
|
|
1176
1155
|
}
|
|
1177
1156
|
/**
|
|
@@ -1234,6 +1213,7 @@ var PlasmicComponentLoader = class {
|
|
|
1234
1213
|
|
|
1235
1214
|
// src/index.ts
|
|
1236
1215
|
var import_host3 = require("@plasmicapp/host");
|
|
1216
|
+
var import_prepass2 = require("@plasmicapp/prepass");
|
|
1237
1217
|
var import_query2 = require("@plasmicapp/query");
|
|
1238
1218
|
|
|
1239
1219
|
// src/PlasmicComponent.tsx
|
|
@@ -1370,9 +1350,6 @@ function MaybeWrap(props) {
|
|
|
1370
1350
|
return props.cond ? props.wrapper(props.children) : props.children;
|
|
1371
1351
|
}
|
|
1372
1352
|
|
|
1373
|
-
// src/index.ts
|
|
1374
|
-
var import_prepass2 = require("@plasmicapp/prepass");
|
|
1375
|
-
|
|
1376
1353
|
// src/render.tsx
|
|
1377
1354
|
var import_react2 = __toESM(require("react"));
|
|
1378
1355
|
var import_react_dom2 = __toESM(require("react-dom"));
|