@plasmicapp/loader-react 1.0.326 → 1.0.328

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.
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../src/react-server.ts", "../src/bundles.ts", "../src/utils.tsx", "../src/loader-react-server.ts"],
4
- "sourcesContent": ["import \"server-only\";\n\nimport { PlasmicModulesFetcher, PlasmicTracker } from \"@plasmicapp/loader-core\";\nimport {\n InitOptions,\n ReactServerPlasmicComponentLoader,\n} from \"./loader-react-server\";\n\nexport * from \"./shared-exports\";\nexport { ReactServerPlasmicComponentLoader };\n\nexport function initPlasmicLoader(\n opts: InitOptions\n): ReactServerPlasmicComponentLoader {\n return new ReactServerPlasmicComponentLoader({\n opts,\n fetcher: new PlasmicModulesFetcher(opts),\n tracker: new PlasmicTracker({\n projectIds: opts.projects.map((p) => p.id),\n platform: opts.platform,\n preview: opts.preview,\n }),\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 { 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 LoaderBundleCache,\n PageMeta,\n PlasmicModulesFetcher,\n PlasmicTracker,\n} from \"@plasmicapp/loader-core\";\nimport { ComponentMeta, LoaderBundleOutput } 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/** 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 };\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 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 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 };\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"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO;AAEP,SAAS,uBAAuB,sBAAsB;;;ACFtD;AAAA,EAEE;AAAA,OAEK;AAGP,SAAS,aAAa,eAAgC,cAAwB;AAC5E,QAAM,IAAc,CAAC,GAAG,YAAY;AACpC,QAAM,UAAU,IAAI,IAAY,YAAY;AAC5C,QAAM,oBAAoB,IAAI;AAAA,IAC5B,cAAc,IAAI,CAAC,SAAS,CAAC,KAAK,IAAI,IAAI,CAAC;AAAA,EAC7C;AACA,QAAM,YAA6B,CAAC;AACpC,SAAO,EAAE,SAAS,GAAG;AACnB,UAAM,CAAC,EAAE,IAAI,EAAE,OAAO,GAAG,CAAC;AAC1B,UAAM,OAAO,kBAAkB,IAAI,EAAE;AACrC,QAAI,CAAC,MAAM;AACT;AAAA,IACF;AACA,cAAU,KAAK,IAAI;AACnB,SAAK,eAAe,QAAQ,CAAC,eAAe;AAC1C,UAAI,CAAC,QAAQ,IAAI,UAAU,GAAG;AAC5B,gBAAQ,IAAI,UAAU;AACtB,UAAE,KAAK,UAAU;AAAA,MACnB;AAAA,IACF,CAAC;AAAA,EACH;AACA,SAAO;AACT;AAEO,SAAS,kBACd,QACA,WACA,MAGqB;AACrB,MAAI,UAAU,WAAW,GAAG;AAC1B,WAAO;AAAA,MACL,gBAAgB,OAAO;AAAA,MACvB;AAAA,MACA,gBAAgB,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nimport { PlasmicModulesFetcher, PlasmicTracker } from \"@plasmicapp/loader-core\";\nimport {\n InitOptions,\n ReactServerPlasmicComponentLoader,\n} from \"./loader-react-server\";\n\nexport * from \"./shared-exports\";\nexport { ReactServerPlasmicComponentLoader };\n\nexport function initPlasmicLoader(\n opts: InitOptions\n): ReactServerPlasmicComponentLoader {\n return new ReactServerPlasmicComponentLoader({\n opts,\n fetcher: new PlasmicModulesFetcher(opts),\n tracker: new PlasmicTracker({\n projectIds: opts.projects.map((p) => p.id),\n platform: opts.platform,\n preview: opts.preview,\n }),\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 { 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 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"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO;AAEP,SAAS,uBAAuB,sBAAsB;;;ACFtD;AAAA,EAEE;AAAA,OAEK;AAGP,SAAS,aAAa,eAAgC,cAAwB;AAC5E,QAAM,IAAc,CAAC,GAAG,YAAY;AACpC,QAAM,UAAU,IAAI,IAAY,YAAY;AAC5C,QAAM,oBAAoB,IAAI;AAAA,IAC5B,cAAc,IAAI,CAAC,SAAS,CAAC,KAAK,IAAI,IAAI,CAAC;AAAA,EAC7C;AACA,QAAM,YAA6B,CAAC;AACpC,SAAO,EAAE,SAAS,GAAG;AACnB,UAAM,CAAC,EAAE,IAAI,EAAE,OAAO,GAAG,CAAC;AAC1B,UAAM,OAAO,kBAAkB,IAAI,EAAE;AACrC,QAAI,CAAC,MAAM;AACT;AAAA,IACF;AACA,cAAU,KAAK,IAAI;AACnB,SAAK,eAAe,QAAQ,CAAC,eAAe;AAC1C,UAAI,CAAC,QAAQ,IAAI,UAAU,GAAG;AAC5B,gBAAQ,IAAI,UAAU;AACtB,UAAE,KAAK,UAAU;AAAA,MACnB;AAAA,IACF,CAAC;AAAA,EACH;AACA,SAAO;AACT;AAEO,SAAS,kBACd,QACA,WACA,MAGqB;AACrB,MAAI,UAAU,WAAW,GAAG;AAC1B,WAAO;AAAA,MACL,gBAAgB,OAAO;A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AAI;AAAA,IACvC,SAAS,IAAI,eAAe;AAAA,MAC1B,YAAY,KAAK,SAAS,IAAI,CAAC,MAAM,EAAE,EAAE;AAAA,MACzC,UAAU,KAAK;AAAA,MACf,SAAS,KAAK;AAAA,IAChB,CAAC;AAAA,EACH,CAAC;AACH;",
6
6
  "names": []
7
7
  }
@@ -317,7 +317,8 @@ var ReactServerPlasmicComponentLoader = class {
317
317
  globalGroups: [],
318
318
  external: [],
319
319
  projects: [],
320
- activeSplits: []
320
+ activeSplits: [],
321
+ bundleUrlQuery: null
321
322
  };
322
323
  this.opts = args.opts;
323
324
  this.fetcher = args.fetcher;
@@ -395,6 +396,9 @@ var ReactServerPlasmicComponentLoader = class {
395
396
  getActiveSplits() {
396
397
  return this.bundle.activeSplits;
397
398
  }
399
+ getChunksUrl(bundle, modules) {
400
+ return this.fetcher.getChunksUrl(bundle, modules);
401
+ }
398
402
  fetchMissingData(opts) {
399
403
  return __async(this, null, function* () {
400
404
  this.maybeReportClientSideFetch(
@@ -424,9 +428,10 @@ var ReactServerPlasmicComponentLoader = class {
424
428
  });
425
429
  }
426
430
  mergeBundle(bundle) {
427
- var _a;
431
+ var _a, _b;
428
432
  this.bundle = bundle;
429
- (_a = this.onBundleMerged) == null ? void 0 : _a.call(this);
433
+ this.bundle.bundleUrlQuery = (_a = this.bundle.bundleUrlQuery) != null ? _a : null;
434
+ (_b = this.onBundleMerged) == null ? void 0 : _b.call(this);
430
435
  }
431
436
  getBundle() {
432
437
  return this.bundle;
@@ -441,7 +446,8 @@ var ReactServerPlasmicComponentLoader = class {
441
446
  globalGroups: [],
442
447
  external: [],
443
448
  projects: [],
444
- activeSplits: []
449
+ activeSplits: [],
450
+ bundleUrlQuery: null
445
451
  };
446
452
  }
447
453
  };
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../src/react-server.ts", "../src/bundles.ts", "../src/utils.tsx", "../src/loader-react-server.ts"],
4
- "sourcesContent": ["import \"server-only\";\n\nimport { PlasmicModulesFetcher, PlasmicTracker } from \"@plasmicapp/loader-core\";\nimport {\n InitOptions,\n ReactServerPlasmicComponentLoader,\n} from \"./loader-react-server\";\n\nexport * from \"./shared-exports\";\nexport { ReactServerPlasmicComponentLoader };\n\nexport function initPlasmicLoader(\n opts: InitOptions\n): ReactServerPlasmicComponentLoader {\n return new ReactServerPlasmicComponentLoader({\n opts,\n fetcher: new PlasmicModulesFetcher(opts),\n tracker: new PlasmicTracker({\n projectIds: opts.projects.map((p) => p.id),\n platform: opts.platform,\n preview: opts.preview,\n }),\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 { 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 LoaderBundleCache,\n PageMeta,\n PlasmicModulesFetcher,\n PlasmicTracker,\n} from \"@plasmicapp/loader-core\";\nimport { ComponentMeta, LoaderBundleOutput } 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/** 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 };\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 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 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 };\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"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,yBAAO;AAEP,IAAAA,sBAAsD;;;ACFtD,yBAIO;AAGP,SAAS,aAAa,eAAgC,cAAwB;AAC5E,QAAM,IAAc,CAAC,GAAG,YAAY;AACpC,QAAM,UAAU,IAAI,IAAY,YAAY;AAC5C,QAAM,oBAAoB,IAAI;AAAA,IAC5B,cAAc,IAAI,CAAC,SAAS,CAAC,KAAK,IAAI,IAAI,CAAC;AAAA,EAC7C;AACA,QAAM,YAA6B,CAAC;AACpC,SAAO,EAAE,SAAS,GAAG;AACnB,UAAM,CAAC,EAAE,IAAI,EAAE,OAAO,GAAG,CAAC;AAC1B,UAAM,OAAO,kBAAkB,IAAI,EAAE;AACrC,QAAI,CAAC,MAAM;AACT;AAAA,IACF;AACA,cAAU,KAAK,IAAI;AACnB,SAAK,eAAe,QAAQ,CAAC,eAAe;AAC1C,UAAI,CAAC,QAAQ,IAAI,UAAU,GAAG;AAC5B,gBAAQ,IAAI,UAAU;AACtB,UAAE,KAAK,UAAU;AAAA,MACnB;AAAA,IACF,CAAC;AAAA,EACH;AACA,SAAO;AACT;AAEO,SAAS,kBACd,QACA,WACA,MAGqB;AACrB,MAAI,UAAU,WAAW,GAAG;AAC1B,WAAO;AAAA,MACL,gBAAgB,OAAO;AAAA,MACvB;AAAA,MACA,gBAAgB,CAAC;AAAA,IACnB;AAAA,EACF;AAEA,QAAM,YAAY;AAAA,IAChB,OAAO;AAAA,IACP,UAAU,IAAI,CAAC,aAAa,SAAS,EAAE;AAAA,EACzC;AACA,QAAM,YAAY,UAAU,IAAI,CAAC,aAAa,SAAS,KAAK;AAC5D,QAAM,gBAAY;AAAA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/C,WAAK,QAAQ,WAAW;AACxB,WAAK,YAAY,MAAM;AACvB,iBAAK,oBAAL;AACA,aAAO;AAAA,IACT;AAAA;AAAA,EAEA,YAAY,QAA4B;AArO1C;AAwOI,SAAK,SAAS;AACd,eAAK,mBAAL;AAAA,EACF;AAAA,EAEA,YAAgC;AAC9B,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,aAAa;AACX,SAAK,SAAS;AAAA,MACZ,SAAS;AAAA,QACP,SAAS,CAAC;AAAA,QACV,QAAQ,CAAC;AAAA,MACX;AAAA,MACA,YAAY,CAAC;AAAA,MACb,cAAc,CAAC;AAAA,MACf,UAAU,CAAC;AAAA,MACX,UAAU,CAAC;AAAA,MACX,cAAc,CAAC;AAAA,IACjB;AAAA,EACF;AACF;AA4BA,SAAS,+BAA+B,MAAa;AACnD,MAAI;AACJ,MAAI;AACJ,MAAI,MAAM,QAAQ,KAAK,CAAC,CAAC,GAAG;AAC1B,YAAQ,KAAK,CAAC;AACd,WAAO,KAAK,CAAC;AAAA,EACf,OAAO;AACL,YAAQ;AACR,WAAO;AAAA,EACT;AACA,SAAO,EAAE,OAAO,KAAK;AACvB;;;AHzRO,SAAS,kBACd,MACmC;AACnC,SAAO,IAAI,kCAAkC;AAAA,IAC3C;AAAA,IACA,SAAS,IAAI,0CAAsB,IAAI;AAAA,IACvC,SAAS,IAAI,mCAAe;AAAA,MAC1B,YAAY,KAAK,SAAS,IAAI,CAAC,MAAM,EAAE,EAAE;AAAA,MACzC,UAAU,KAAK;AAAA,MACf,SAAS,KAAK;AAAA,IAChB,CAAC;AAAA,EACH,CAAC;AACH;",
4
+ "sourcesContent": ["import \"server-only\";\n\nimport { PlasmicModulesFetcher, PlasmicTracker } from \"@plasmicapp/loader-core\";\nimport {\n InitOptions,\n ReactServerPlasmicComponentLoader,\n} from \"./loader-react-server\";\n\nexport * from \"./shared-exports\";\nexport { ReactServerPlasmicComponentLoader };\n\nexport function initPlasmicLoader(\n opts: InitOptions\n): ReactServerPlasmicComponentLoader {\n return new ReactServerPlasmicComponentLoader({\n opts,\n fetcher: new PlasmicModulesFetcher(opts),\n tracker: new PlasmicTracker({\n projectIds: opts.projects.map((p) => p.id),\n platform: opts.platform,\n preview: opts.preview,\n }),\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 { 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 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"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,yBAAO;AAEP,IAAAA,sBAAsD;;;ACFtD,yBAIO;AAGP,SAAS,aAAa,eAAgC,cAAwB;AAC5E,QAAM,IAAc,CAAC,GAAG,YAAY;AACpC,QAAM,UAAU,IAAI,IAAY,YAAY;AAC5C,QAAM,oBAAoB,IAAI;AAAA,IAC5B,cAAc,IAAI,CAAC,SAAS,CAAC,KAAK,IAAI,IAAI,CAAC;AAAA,EAC7C;AACA,QAAM,YAA6B,CAAC;AACpC,SAAO,EAAE,SAAS,GAAG;AACnB,UAAM,CAAC,EAAE,IAAI,EAAE,OAAO,GAAG,CAAC;AAC1B,UAAM,OAAO,kBAAkB,IAAI,EAAE;AACrC,QAAI,CAAC,MAAM;AACT;AAAA,IACF;AACA,cAAU,KAAK,IAAI;AACnB,SAAK,eAAe,QAAQ,CAAC,eAAe;AAC1C,UAAI,CAAC,QAAQ,IAAI,UAAU,GAAG;AAC5B,gBAAQ,IAAI,UAAU;AACtB,UAAE,KAAK,UAAU;AAAA,MACnB;AAAA,IACF,CAAC;AAAA,EACH;AACA,SAAO;AACT;AAEO,SAAS,kBACd,QACA,WACA,MAGqB;AACrB,MAAI,UAAU,WAAW,GAAG;AAC1B,WAAO;AAAA,MACL,gBAAgB,OAAO;AAAA,MACvB;AAAA,MACA,gBAAgB,CAAC;AAAA,IACnB;AAAA,EACF;AAEA,QAAM,YAAY;AAAA,IAChB,OAAO;AAAA,IACP,UAAU,IAAI,CAAC,aAAa,SAAS,EAAE;AAA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AA,IAChB,CAAC;AAAA,EACH,CAAC;AACH;",
6
6
  "names": ["import_loader_core", "pascalcase"]
7
7
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plasmicapp/loader-react",
3
- "version": "1.0.326",
3
+ "version": "1.0.328",
4
4
  "types": "./dist/index.d.ts",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.esm.js",
@@ -54,9 +54,9 @@
54
54
  "dependencies": {
55
55
  "@plasmicapp/data-sources-context": "0.1.20",
56
56
  "@plasmicapp/host": "1.0.185",
57
- "@plasmicapp/loader-core": "1.0.121",
58
- "@plasmicapp/loader-fetcher": "1.0.43",
59
- "@plasmicapp/loader-splits": "1.0.51",
57
+ "@plasmicapp/loader-core": "1.0.123",
58
+ "@plasmicapp/loader-fetcher": "1.0.45",
59
+ "@plasmicapp/loader-splits": "1.0.53",
60
60
  "@plasmicapp/prepass": "1.0.13",
61
61
  "@plasmicapp/query": "0.1.77",
62
62
  "pascalcase": "^1.0.0",
@@ -84,5 +84,5 @@
84
84
  "@types/react-is": "^17.0.3"
85
85
  },
86
86
  "license": "MIT",
87
- "gitHead": "9638cc7f1d2af2fbbf9966b4096449e9c82b375b"
87
+ "gitHead": "06322ab98d09d2a4f26e68939555898c57d2d082"
88
88
  }