@plasmicapp/loader-fetcher 1.0.9 → 1.0.11
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/loader-fetcher.cjs.development.js +1 -1
- package/dist/loader-fetcher.cjs.development.js.map +1 -1
- package/dist/loader-fetcher.cjs.production.min.js +1 -1
- package/dist/loader-fetcher.cjs.production.min.js.map +1 -1
- package/dist/loader-fetcher.esm.js +1 -1
- package/dist/loader-fetcher.esm.js.map +1 -1
- package/package.json +2 -2
|
@@ -6,7 +6,7 @@ function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'defau
|
|
|
6
6
|
|
|
7
7
|
var fetch = _interopDefault(require('isomorphic-unfetch'));
|
|
8
8
|
|
|
9
|
-
const VERSION = '
|
|
9
|
+
const VERSION = '9';
|
|
10
10
|
const isBrowser = typeof window !== 'undefined' && window != null && typeof window.document !== 'undefined';
|
|
11
11
|
class Api {
|
|
12
12
|
constructor(opts) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loader-fetcher.cjs.development.js","sources":["../src/api.ts","../src/fetcher.ts"],"sourcesContent":["import fetch from 'isomorphic-unfetch';\n\nexport interface ComponentMeta {\n id: string;\n usedComponents: string[];\n projectId: string;\n name: string;\n displayName: string;\n cssFile: string;\n path: string | undefined;\n isPage: boolean;\n plumeType?: string;\n entry: string;\n isCode: boolean;\n isGlobalContextProvider: boolean;\n pageMetadata?: PageMetadata;\n metadata?: Record<string, string>;\n}\n\nexport interface PageMeta extends ComponentMeta {\n isPage: true;\n path: string;\n plumeType: never;\n pageMetadata: PageMetadata;\n}\n\nexport interface PageMetadata {\n path: string;\n title?: string | null;\n description?: string | null;\n openGraphImageUrl?: string | null;\n}\n\nexport interface GlobalGroupMeta {\n id: string;\n projectId: string;\n name: string;\n type: string;\n contextFile: string;\n useName: string;\n}\n\nexport interface ProjectMeta {\n id: string;\n teamId?: string;\n indirect?: boolean;\n name: string;\n version: string;\n remoteFonts: FontMeta[];\n globalContextsProviderFileName: string;\n}\n\nexport interface FontMeta {\n url: string;\n}\n\ninterface GlobalVariantSplitContent {\n type: 'global-variant';\n projectId: string;\n group: string;\n variant: string;\n}\n\ninterface Slice {\n id: string;\n contents: GlobalVariantSplitContent[];\n externalId?: string;\n}\n\nexport interface ExperimentSlice extends Slice {\n prob: number;\n}\n\nexport interface SegmentSlice extends Slice {\n cond: any;\n}\n\nexport interface ExperimentSplit {\n id: string;\n externalId?: string;\n type: 'experiment';\n slices: ExperimentSlice[];\n}\n\nexport interface SegmentSplit {\n id: string;\n externalId?: string;\n type: 'segment';\n slices: SegmentSlice[];\n}\n\nexport type Split = ExperimentSplit | SegmentSplit;\n\nexport interface LoaderBundleOutput {\n modules: {\n browser: (CodeModule | AssetModule)[];\n server: (CodeModule | AssetModule)[];\n };\n external: string[];\n components: ComponentMeta[];\n globalGroups: GlobalGroupMeta[];\n projects: ProjectMeta[];\n activeSplits: Split[];\n}\n\nexport interface LoaderHtmlOutput {\n html: string;\n}\n\nexport interface CodeModule {\n fileName: string;\n code: string;\n imports: string[];\n type: 'code';\n}\n\nexport interface AssetModule {\n fileName: string;\n source: string;\n type: 'asset';\n}\n\nconst VERSION = '7';\n\nexport const isBrowser =\n typeof window !== 'undefined' &&\n window != null &&\n typeof window.document !== 'undefined';\n\nexport class Api {\n private host: string;\n constructor(\n private opts: {\n projects: { id: string; token: string }[];\n host?: string;\n }\n ) {\n this.host = opts.host ?? 'https://codegen.plasmic.app';\n }\n\n async fetchLoaderData(\n projectIds: string[],\n opts: {\n platform?: 'react' | 'nextjs' | 'gatsby';\n preview?: boolean;\n browserOnly?: boolean;\n }\n ) {\n const { platform, preview } = opts;\n const query = new URLSearchParams([\n ['platform', platform ?? 'react'],\n ...projectIds.map((projectId) => ['projectId', projectId]),\n ...(opts.browserOnly ? [['browserOnly', 'true']] : []),\n ]).toString();\n\n const url = `${this.host}/api/v1/loader/code/${\n preview ? 'preview' : 'published'\n }?${query}`;\n const resp = await fetch(url, {\n method: 'GET',\n headers: this.makeGetHeaders(),\n });\n if (resp.status >= 400) {\n const error = await resp.json();\n throw new Error(error?.error?.message ?? resp.statusText);\n }\n const json = await resp.json();\n return json as LoaderBundleOutput;\n }\n\n async fetchHtmlData(opts: {\n projectId: string;\n component: string;\n hydrate?: boolean;\n embedHydrate?: boolean;\n }) {\n const { projectId, component, embedHydrate, hydrate } = opts;\n const query = new URLSearchParams([\n ['projectId', projectId],\n ['component', component],\n ['embedHydrate', embedHydrate ? '1' : '0'],\n ['hydrate', hydrate ? '1' : '0'],\n ]).toString();\n const resp = await fetch(`${this.host}/api/v1/loader/html?${query}`, {\n method: 'GET',\n headers: this.makeGetHeaders(),\n });\n const json = await resp.json();\n return json as LoaderHtmlOutput;\n }\n\n private makeGetHeaders() {\n return {\n 'x-plasmic-loader-version': VERSION,\n ...this.makeAuthHeaders(),\n };\n }\n\n // @ts-ignore\n private makePostHeaders() {\n return {\n 'x-plasmic-loader-version': VERSION,\n 'Content-Type': 'application/json',\n ...this.makeAuthHeaders(),\n };\n }\n\n private makeAuthHeaders() {\n const tokens = this.opts.projects\n .map((p) => `${p.id}:${p.token}`)\n .join(',');\n return {\n 'x-plasmic-api-project-tokens': tokens,\n };\n }\n}\n","import { Api, isBrowser, LoaderBundleOutput } from './api';\n\nexport interface FetcherOptions {\n projects: {\n id: string;\n version?: string;\n token: string;\n }[];\n cache?: LoaderBundleCache;\n platform?: 'react' | 'nextjs' | 'gatsby';\n preview?: boolean;\n host?: string;\n}\n\nexport interface LoaderBundleCache {\n set: (data: LoaderBundleOutput) => Promise<void>;\n get: () => Promise<LoaderBundleOutput>;\n}\n\nexport class PlasmicModulesFetcher {\n private api: Api;\n private curFetch: Promise<LoaderBundleOutput> | undefined = undefined;\n constructor(private opts: FetcherOptions) {\n this.api = new Api({\n projects: opts.projects,\n host: opts.host,\n });\n }\n\n async fetchAllData() {\n if (this.opts.cache) {\n const cachedData = await this.opts.cache.get();\n if (cachedData) {\n return cachedData;\n }\n }\n if (this.curFetch) {\n return await this.curFetch;\n }\n console.debug('Plasmic: doing a fresh fetch...');\n this.curFetch = this.doFetch();\n const data = await this.curFetch;\n this.curFetch = undefined;\n return data;\n }\n\n private async doFetch() {\n const data = await this.api.fetchLoaderData(\n this.opts.projects.map((p) =>\n p.version && !this.opts.preview ? `${p.id}@${p.version}` : p.id\n ),\n {\n platform: this.opts.platform,\n preview: this.opts.preview,\n browserOnly: isBrowser,\n }\n );\n if (this.opts.cache) {\n await this.opts.cache.set(data);\n }\n console.debug(\n `Plasmic: fetched designs for ${data.projects\n .map((p) => `\"${p.name}\" (${p.id}@${p.version})`)\n .join(', ')}`\n );\n return data;\n }\n}\n"],"names":["VERSION","isBrowser","window","document","Api","constructor","opts","host","fetchLoaderData","projectIds","platform","preview","query","URLSearchParams","map","projectId","browserOnly","toString","url","resp","fetch","method","headers","makeGetHeaders","status","error","json","Error","message","statusText","fetchHtmlData","component","embedHydrate","hydrate","makeAuthHeaders","makePostHeaders","tokens","projects","p","id","token","join","PlasmicModulesFetcher","undefined","api","fetchAllData","cache","cachedData","get","curFetch","console","debug","doFetch","data","version","set","name"],"mappings":";;;;;;;;AA0HA,MAAMA,OAAO,GAAG,GAAhB;AAEO,MAAMC,SAAS,GACpB,OAAOC,MAAP,KAAkB,WAAlB,IACAA,MAAM,IAAI,IADV,IAEA,OAAOA,MAAM,CAACC,QAAd,KAA2B,WAHtB;MAKMC;AAEXC,EAAAA,YACUC;;;AAAA,aAAA,GAAAA,IAAA;AAKR,SAAKC,IAAL,iBAAYD,IAAI,CAACC,IAAjB,yBAAyB,6BAAzB;AACD;;AAEoB,QAAfC,eAAe,CACnBC,UADmB,EAEnBH,IAFmB;AAQnB,UAAM;AAAEI,MAAAA,QAAF;AAAYC,MAAAA;AAAZ,QAAwBL,IAA9B;AACA,UAAMM,KAAK,GAAG,IAAIC,eAAJ,CAAoB,CAChC,CAAC,UAAD,EAAaH,QAAb,WAAaA,QAAb,GAAyB,OAAzB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,CAACC,KAAR,CAAc,iCAAd;AACA,SAAKF,QAAL,GAAgB,KAAKG,OAAL,EAAhB;AACA,UAAMC,IAAI,GAAG,MAAM,KAAKJ,QAAxB;AACA,SAAKA,QAAL,GAAgBN,SAAhB;AACA,WAAOU,IAAP;AACD;;AAEoB,QAAPD,OAAO;AACnB,UAAMC,IAAI,GAAG,MAAM,KAAKT,GAAL,CAASpC,eAAT,CACjB,KAAKF,IAAL,CAAU+B,QAAV,CAAmBvB,GAAnB,CAAwBwB,CAAD,IACrBA,CAAC,CAACgB,OAAF,IAAa,CAAC,KAAKhD,IAAL,CAAUK,OAAxB,MAAqC2B,CAAC,CAACC,MAAMD,CAAC,CAACgB,SAA/C,GAA2DhB,CAAC,CAACC,EAD/D,CADiB,EAIjB;AACE7B,MAAAA,QAAQ,EAAE,KAAKJ,IAAL,CAAUI,QADtB;AAEEC,MAAAA,OAAO,EAAE,KAAKL,IAAL,CAAUK,OAFrB;AAGEK,MAAAA,WAAW,EAAEf;AAHf,KAJiB,CAAnB;;AAUA,QAAI,KAAKK,IAAL,CAAUwC,KAAd,EAAqB;AACnB,YAAM,KAAKxC,IAAL,CAAUwC,KAAV,CAAgBS,GAAhB,CAAoBF,IAApB,CAAN;AACD;;AACDH,IAAAA,OAAO,CAACC,KAAR,iCACkCE,IAAI,CAAChB,QAAL,CAC7BvB,GAD6B,CACxBwB,CAAD,QAAWA,CAAC,CAACkB,UAAUlB,CAAC,CAACC,MAAMD,CAAC,CAACgB,UADR,EAE7Bb,IAF6B,CAExB,IAFwB,GADlC;AAKA,WAAOY,IAAP;AACD;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"loader-fetcher.cjs.development.js","sources":["../src/api.ts","../src/fetcher.ts"],"sourcesContent":["import fetch from 'isomorphic-unfetch';\n\nexport interface ComponentMeta {\n id: string;\n usedComponents: string[];\n projectId: string;\n name: string;\n displayName: string;\n cssFile: string;\n path: string | undefined;\n isPage: boolean;\n plumeType?: string;\n entry: string;\n isCode: boolean;\n isGlobalContextProvider: boolean;\n pageMetadata?: PageMetadata;\n metadata?: Record<string, string>;\n}\n\nexport interface PageMeta extends ComponentMeta {\n isPage: true;\n path: string;\n plumeType: never;\n pageMetadata: PageMetadata;\n}\n\nexport interface PageMetadata {\n path: string;\n title?: string | null;\n description?: string | null;\n openGraphImageUrl?: string | null;\n}\n\nexport interface GlobalGroupMeta {\n id: string;\n projectId: string;\n name: string;\n type: string;\n contextFile: string;\n useName: string;\n}\n\nexport interface ProjectMeta {\n id: string;\n teamId?: string;\n indirect?: boolean;\n name: string;\n version: string;\n remoteFonts: FontMeta[];\n globalContextsProviderFileName: string;\n}\n\nexport interface FontMeta {\n url: string;\n}\n\ninterface GlobalVariantSplitContent {\n type: 'global-variant';\n projectId: string;\n group: string;\n variant: string;\n}\n\ninterface Slice {\n id: string;\n contents: GlobalVariantSplitContent[];\n externalId?: string;\n}\n\nexport interface ExperimentSlice extends Slice {\n prob: number;\n}\n\nexport interface SegmentSlice extends Slice {\n cond: any;\n}\n\nexport interface ExperimentSplit {\n id: string;\n externalId?: string;\n type: 'experiment';\n slices: ExperimentSlice[];\n}\n\nexport interface SegmentSplit {\n id: string;\n externalId?: string;\n type: 'segment';\n slices: SegmentSlice[];\n}\n\nexport type Split = ExperimentSplit | SegmentSplit;\n\nexport interface LoaderBundleOutput {\n modules: {\n browser: (CodeModule | AssetModule)[];\n server: (CodeModule | AssetModule)[];\n };\n external: string[];\n components: ComponentMeta[];\n globalGroups: GlobalGroupMeta[];\n projects: ProjectMeta[];\n activeSplits: Split[];\n}\n\nexport interface LoaderHtmlOutput {\n html: string;\n}\n\nexport interface CodeModule {\n fileName: string;\n code: string;\n imports: string[];\n type: 'code';\n}\n\nexport interface AssetModule {\n fileName: string;\n source: string;\n type: 'asset';\n}\n\nconst VERSION = '9';\n\nexport const isBrowser =\n typeof window !== 'undefined' &&\n window != null &&\n typeof window.document !== 'undefined';\n\nexport class Api {\n private host: string;\n constructor(\n private opts: {\n projects: { id: string; token: string }[];\n host?: string;\n }\n ) {\n this.host = opts.host ?? 'https://codegen.plasmic.app';\n }\n\n async fetchLoaderData(\n projectIds: string[],\n opts: {\n platform?: 'react' | 'nextjs' | 'gatsby';\n preview?: boolean;\n browserOnly?: boolean;\n }\n ) {\n const { platform, preview } = opts;\n const query = new URLSearchParams([\n ['platform', platform ?? 'react'],\n ...projectIds.map((projectId) => ['projectId', projectId]),\n ...(opts.browserOnly ? [['browserOnly', 'true']] : []),\n ]).toString();\n\n const url = `${this.host}/api/v1/loader/code/${\n preview ? 'preview' : 'published'\n }?${query}`;\n const resp = await fetch(url, {\n method: 'GET',\n headers: this.makeGetHeaders(),\n });\n if (resp.status >= 400) {\n const error = await resp.json();\n throw new Error(error?.error?.message ?? resp.statusText);\n }\n const json = await resp.json();\n return json as LoaderBundleOutput;\n }\n\n async fetchHtmlData(opts: {\n projectId: string;\n component: string;\n hydrate?: boolean;\n embedHydrate?: boolean;\n }) {\n const { projectId, component, embedHydrate, hydrate } = opts;\n const query = new URLSearchParams([\n ['projectId', projectId],\n ['component', component],\n ['embedHydrate', embedHydrate ? '1' : '0'],\n ['hydrate', hydrate ? '1' : '0'],\n ]).toString();\n const resp = await fetch(`${this.host}/api/v1/loader/html?${query}`, {\n method: 'GET',\n headers: this.makeGetHeaders(),\n });\n const json = await resp.json();\n return json as LoaderHtmlOutput;\n }\n\n private makeGetHeaders() {\n return {\n 'x-plasmic-loader-version': VERSION,\n ...this.makeAuthHeaders(),\n };\n }\n\n // @ts-ignore\n private makePostHeaders() {\n return {\n 'x-plasmic-loader-version': VERSION,\n 'Content-Type': 'application/json',\n ...this.makeAuthHeaders(),\n };\n }\n\n private makeAuthHeaders() {\n const tokens = this.opts.projects\n .map((p) => `${p.id}:${p.token}`)\n .join(',');\n return {\n 'x-plasmic-api-project-tokens': tokens,\n };\n }\n}\n","import { Api, isBrowser, LoaderBundleOutput } from './api';\n\nexport interface FetcherOptions {\n projects: {\n id: string;\n version?: string;\n token: string;\n }[];\n cache?: LoaderBundleCache;\n platform?: 'react' | 'nextjs' | 'gatsby';\n preview?: boolean;\n host?: string;\n}\n\nexport interface LoaderBundleCache {\n set: (data: LoaderBundleOutput) => Promise<void>;\n get: () => Promise<LoaderBundleOutput>;\n}\n\nexport class PlasmicModulesFetcher {\n private api: Api;\n private curFetch: Promise<LoaderBundleOutput> | undefined = undefined;\n constructor(private opts: FetcherOptions) {\n this.api = new Api({\n projects: opts.projects,\n host: opts.host,\n });\n }\n\n async fetchAllData() {\n if (this.opts.cache) {\n const cachedData = await this.opts.cache.get();\n if (cachedData) {\n return cachedData;\n }\n }\n if (this.curFetch) {\n return await this.curFetch;\n }\n console.debug('Plasmic: doing a fresh fetch...');\n this.curFetch = this.doFetch();\n const data = await this.curFetch;\n this.curFetch = undefined;\n return data;\n }\n\n private async doFetch() {\n const data = await this.api.fetchLoaderData(\n this.opts.projects.map((p) =>\n p.version && !this.opts.preview ? `${p.id}@${p.version}` : p.id\n ),\n {\n platform: this.opts.platform,\n preview: this.opts.preview,\n browserOnly: isBrowser,\n }\n );\n if (this.opts.cache) {\n await this.opts.cache.set(data);\n }\n console.debug(\n `Plasmic: fetched designs for ${data.projects\n .map((p) => `\"${p.name}\" (${p.id}@${p.version})`)\n .join(', ')}`\n );\n return data;\n }\n}\n"],"names":["VERSION","isBrowser","window","document","Api","constructor","opts","host","fetchLoaderData","projectIds","platform","preview","query","URLSearchParams","map","projectId","browserOnly","toString","url","resp","fetch","method","headers","makeGetHeaders","status","error","json","Error","message","statusText","fetchHtmlData","component","embedHydrate","hydrate","makeAuthHeaders","makePostHeaders","tokens","projects","p","id","token","join","PlasmicModulesFetcher","undefined","api","fetchAllData","cache","cachedData","get","curFetch","console","debug","doFetch","data","version","set","name"],"mappings":";;;;;;;;AA0HA,MAAMA,OAAO,GAAG,GAAhB;AAEO,MAAMC,SAAS,GACpB,OAAOC,MAAP,KAAkB,WAAlB,IACAA,MAAM,IAAI,IADV,IAEA,OAAOA,MAAM,CAACC,QAAd,KA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CAACkB,UAAUlB,CAAC,CAACC,MAAMD,CAAC,CAACgB,UADR,EAE7Bb,IAF6B,CAExB,IAFwB,GADlC;AAKA,WAAOY,IAAP;AACD;;;;;;;"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t,e=(t=require("isomorphic-unfetch"))&&"object"==typeof t&&"default"in t?t.default:t;const s="undefined"!=typeof window&&null!=window&&void 0!==window.document;class o{constructor(t){var e;this.opts=t,this.host=null!=(e=t.host)?e:"https://codegen.plasmic.app"}async fetchLoaderData(t,s){const{platform:o,preview:r}=s,a=new URLSearchParams([["platform",null!=o?o:"react"],...t.map(t=>["projectId",t]),...s.browserOnly?[["browserOnly","true"]]:[]]).toString(),i=`${this.host}/api/v1/loader/code/${r?"preview":"published"}?${a}`,c=await e(i,{method:"GET",headers:this.makeGetHeaders()});if(c.status>=400){var n,h;const t=await c.json();throw new Error(null!=(n=null==t||null==(h=t.error)?void 0:h.message)?n:c.statusText)}return await c.json()}async fetchHtmlData(t){const{projectId:s,component:o,embedHydrate:r,hydrate:a}=t,i=new URLSearchParams([["projectId",s],["component",o],["embedHydrate",r?"1":"0"],["hydrate",a?"1":"0"]]).toString(),c=await e(`${this.host}/api/v1/loader/html?${i}`,{method:"GET",headers:this.makeGetHeaders()});return await c.json()}makeGetHeaders(){return{"x-plasmic-loader-version":"
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t,e=(t=require("isomorphic-unfetch"))&&"object"==typeof t&&"default"in t?t.default:t;const s="undefined"!=typeof window&&null!=window&&void 0!==window.document;class o{constructor(t){var e;this.opts=t,this.host=null!=(e=t.host)?e:"https://codegen.plasmic.app"}async fetchLoaderData(t,s){const{platform:o,preview:r}=s,a=new URLSearchParams([["platform",null!=o?o:"react"],...t.map(t=>["projectId",t]),...s.browserOnly?[["browserOnly","true"]]:[]]).toString(),i=`${this.host}/api/v1/loader/code/${r?"preview":"published"}?${a}`,c=await e(i,{method:"GET",headers:this.makeGetHeaders()});if(c.status>=400){var n,h;const t=await c.json();throw new Error(null!=(n=null==t||null==(h=t.error)?void 0:h.message)?n:c.statusText)}return await c.json()}async fetchHtmlData(t){const{projectId:s,component:o,embedHydrate:r,hydrate:a}=t,i=new URLSearchParams([["projectId",s],["component",o],["embedHydrate",r?"1":"0"],["hydrate",a?"1":"0"]]).toString(),c=await e(`${this.host}/api/v1/loader/html?${i}`,{method:"GET",headers:this.makeGetHeaders()});return await c.json()}makeGetHeaders(){return{"x-plasmic-loader-version":"9",...this.makeAuthHeaders()}}makePostHeaders(){return{"x-plasmic-loader-version":"9","Content-Type":"application/json",...this.makeAuthHeaders()}}makeAuthHeaders(){return{"x-plasmic-api-project-tokens":this.opts.projects.map(t=>`${t.id}:${t.token}`).join(",")}}}exports.Api=o,exports.PlasmicModulesFetcher=class{constructor(t){this.opts=t,this.curFetch=void 0,this.api=new o({projects:t.projects,host:t.host})}async fetchAllData(){if(this.opts.cache){const t=await this.opts.cache.get();if(t)return t}if(this.curFetch)return await this.curFetch;console.debug("Plasmic: doing a fresh fetch..."),this.curFetch=this.doFetch();const t=await this.curFetch;return this.curFetch=void 0,t}async doFetch(){const t=await this.api.fetchLoaderData(this.opts.projects.map(t=>t.version&&!this.opts.preview?`${t.id}@${t.version}`:t.id),{platform:this.opts.platform,preview:this.opts.preview,browserOnly:s});return this.opts.cache&&await this.opts.cache.set(t),console.debug("Plasmic: fetched designs for "+t.projects.map(t=>`"${t.name}" (${t.id}@${t.version})`).join(", ")),t}};
|
|
2
2
|
//# sourceMappingURL=loader-fetcher.cjs.production.min.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loader-fetcher.cjs.production.min.js","sources":["../src/api.ts","../src/fetcher.ts"],"sourcesContent":["import fetch from 'isomorphic-unfetch';\n\nexport interface ComponentMeta {\n id: string;\n usedComponents: string[];\n projectId: string;\n name: string;\n displayName: string;\n cssFile: string;\n path: string | undefined;\n isPage: boolean;\n plumeType?: string;\n entry: string;\n isCode: boolean;\n isGlobalContextProvider: boolean;\n pageMetadata?: PageMetadata;\n metadata?: Record<string, string>;\n}\n\nexport interface PageMeta extends ComponentMeta {\n isPage: true;\n path: string;\n plumeType: never;\n pageMetadata: PageMetadata;\n}\n\nexport interface PageMetadata {\n path: string;\n title?: string | null;\n description?: string | null;\n openGraphImageUrl?: string | null;\n}\n\nexport interface GlobalGroupMeta {\n id: string;\n projectId: string;\n name: string;\n type: string;\n contextFile: string;\n useName: string;\n}\n\nexport interface ProjectMeta {\n id: string;\n teamId?: string;\n indirect?: boolean;\n name: string;\n version: string;\n remoteFonts: FontMeta[];\n globalContextsProviderFileName: string;\n}\n\nexport interface FontMeta {\n url: string;\n}\n\ninterface GlobalVariantSplitContent {\n type: 'global-variant';\n projectId: string;\n group: string;\n variant: string;\n}\n\ninterface Slice {\n id: string;\n contents: GlobalVariantSplitContent[];\n externalId?: string;\n}\n\nexport interface ExperimentSlice extends Slice {\n prob: number;\n}\n\nexport interface SegmentSlice extends Slice {\n cond: any;\n}\n\nexport interface ExperimentSplit {\n id: string;\n externalId?: string;\n type: 'experiment';\n slices: ExperimentSlice[];\n}\n\nexport interface SegmentSplit {\n id: string;\n externalId?: string;\n type: 'segment';\n slices: SegmentSlice[];\n}\n\nexport type Split = ExperimentSplit | SegmentSplit;\n\nexport interface LoaderBundleOutput {\n modules: {\n browser: (CodeModule | AssetModule)[];\n server: (CodeModule | AssetModule)[];\n };\n external: string[];\n components: ComponentMeta[];\n globalGroups: GlobalGroupMeta[];\n projects: ProjectMeta[];\n activeSplits: Split[];\n}\n\nexport interface LoaderHtmlOutput {\n html: string;\n}\n\nexport interface CodeModule {\n fileName: string;\n code: string;\n imports: string[];\n type: 'code';\n}\n\nexport interface AssetModule {\n fileName: string;\n source: string;\n type: 'asset';\n}\n\nconst VERSION = '
|
|
1
|
+
{"version":3,"file":"loader-fetcher.cjs.production.min.js","sources":["../src/api.ts","../src/fetcher.ts"],"sourcesContent":["import fetch from 'isomorphic-unfetch';\n\nexport interface ComponentMeta {\n id: string;\n usedComponents: string[];\n projectId: string;\n name: string;\n displayName: string;\n cssFile: string;\n path: string | undefined;\n isPage: boolean;\n plumeType?: string;\n entry: string;\n isCode: boolean;\n isGlobalContextProvider: boolean;\n pageMetadata?: PageMetadata;\n metadata?: Record<string, string>;\n}\n\nexport interface PageMeta extends ComponentMeta {\n isPage: true;\n path: string;\n plumeType: never;\n pageMetadata: PageMetadata;\n}\n\nexport interface PageMetadata {\n path: string;\n title?: string | null;\n description?: string | null;\n openGraphImageUrl?: string | null;\n}\n\nexport interface GlobalGroupMeta {\n id: string;\n projectId: string;\n name: string;\n type: string;\n contextFile: string;\n useName: string;\n}\n\nexport interface ProjectMeta {\n id: string;\n teamId?: string;\n indirect?: boolean;\n name: string;\n version: string;\n remoteFonts: FontMeta[];\n globalContextsProviderFileName: string;\n}\n\nexport interface FontMeta {\n url: string;\n}\n\ninterface GlobalVariantSplitContent {\n type: 'global-variant';\n projectId: string;\n group: string;\n variant: string;\n}\n\ninterface Slice {\n id: string;\n contents: GlobalVariantSplitContent[];\n externalId?: string;\n}\n\nexport interface ExperimentSlice extends Slice {\n prob: number;\n}\n\nexport interface SegmentSlice extends Slice {\n cond: any;\n}\n\nexport interface ExperimentSplit {\n id: string;\n externalId?: string;\n type: 'experiment';\n slices: ExperimentSlice[];\n}\n\nexport interface SegmentSplit {\n id: string;\n externalId?: string;\n type: 'segment';\n slices: SegmentSlice[];\n}\n\nexport type Split = ExperimentSplit | SegmentSplit;\n\nexport interface LoaderBundleOutput {\n modules: {\n browser: (CodeModule | AssetModule)[];\n server: (CodeModule | AssetModule)[];\n };\n external: string[];\n components: ComponentMeta[];\n globalGroups: GlobalGroupMeta[];\n projects: ProjectMeta[];\n activeSplits: Split[];\n}\n\nexport interface LoaderHtmlOutput {\n html: string;\n}\n\nexport interface CodeModule {\n fileName: string;\n code: string;\n imports: string[];\n type: 'code';\n}\n\nexport interface AssetModule {\n fileName: string;\n source: string;\n type: 'asset';\n}\n\nconst VERSION = '9';\n\nexport const isBrowser =\n typeof window !== 'undefined' &&\n window != null &&\n typeof window.document !== 'undefined';\n\nexport class Api {\n private host: string;\n constructor(\n private opts: {\n projects: { id: string; token: string }[];\n host?: string;\n }\n ) {\n this.host = opts.host ?? 'https://codegen.plasmic.app';\n }\n\n async fetchLoaderData(\n projectIds: string[],\n opts: {\n platform?: 'react' | 'nextjs' | 'gatsby';\n preview?: boolean;\n browserOnly?: boolean;\n }\n ) {\n const { platform, preview } = opts;\n const query = new URLSearchParams([\n ['platform', platform ?? 'react'],\n ...projectIds.map((projectId) => ['projectId', projectId]),\n ...(opts.browserOnly ? [['browserOnly', 'true']] : []),\n ]).toString();\n\n const url = `${this.host}/api/v1/loader/code/${\n preview ? 'preview' : 'published'\n }?${query}`;\n const resp = await fetch(url, {\n method: 'GET',\n headers: this.makeGetHeaders(),\n });\n if (resp.status >= 400) {\n const error = await resp.json();\n throw new Error(error?.error?.message ?? resp.statusText);\n }\n const json = await resp.json();\n return json as LoaderBundleOutput;\n }\n\n async fetchHtmlData(opts: {\n projectId: string;\n component: string;\n hydrate?: boolean;\n embedHydrate?: boolean;\n }) {\n const { projectId, component, embedHydrate, hydrate } = opts;\n const query = new URLSearchParams([\n ['projectId', projectId],\n ['component', component],\n ['embedHydrate', embedHydrate ? '1' : '0'],\n ['hydrate', hydrate ? '1' : '0'],\n ]).toString();\n const resp = await fetch(`${this.host}/api/v1/loader/html?${query}`, {\n method: 'GET',\n headers: this.makeGetHeaders(),\n });\n const json = await resp.json();\n return json as LoaderHtmlOutput;\n }\n\n private makeGetHeaders() {\n return {\n 'x-plasmic-loader-version': VERSION,\n ...this.makeAuthHeaders(),\n };\n }\n\n // @ts-ignore\n private makePostHeaders() {\n return {\n 'x-plasmic-loader-version': VERSION,\n 'Content-Type': 'application/json',\n ...this.makeAuthHeaders(),\n };\n }\n\n private makeAuthHeaders() {\n const tokens = this.opts.projects\n .map((p) => `${p.id}:${p.token}`)\n .join(',');\n return {\n 'x-plasmic-api-project-tokens': tokens,\n };\n }\n}\n","import { Api, isBrowser, LoaderBundleOutput } from './api';\n\nexport interface FetcherOptions {\n projects: {\n id: string;\n version?: string;\n token: string;\n }[];\n cache?: LoaderBundleCache;\n platform?: 'react' | 'nextjs' | 'gatsby';\n preview?: boolean;\n host?: string;\n}\n\nexport interface LoaderBundleCache {\n set: (data: LoaderBundleOutput) => Promise<void>;\n get: () => Promise<LoaderBundleOutput>;\n}\n\nexport class PlasmicModulesFetcher {\n private api: Api;\n private curFetch: Promise<LoaderBundleOutput> | undefined = undefined;\n constructor(private opts: FetcherOptions) {\n this.api = new Api({\n projects: opts.projects,\n host: opts.host,\n });\n }\n\n async fetchAllData() {\n if (this.opts.cache) {\n const cachedData = await this.opts.cache.get();\n if (cachedData) {\n return cachedData;\n }\n }\n if (this.curFetch) {\n return await this.curFetch;\n }\n console.debug('Plasmic: doing a fresh fetch...');\n this.curFetch = this.doFetch();\n const data = await this.curFetch;\n this.curFetch = undefined;\n return data;\n }\n\n private async doFetch() {\n const data = await this.api.fetchLoaderData(\n this.opts.projects.map((p) =>\n p.version && !this.opts.preview ? `${p.id}@${p.version}` : p.id\n ),\n {\n platform: this.opts.platform,\n preview: this.opts.preview,\n browserOnly: isBrowser,\n }\n );\n if (this.opts.cache) {\n await this.opts.cache.set(data);\n }\n console.debug(\n `Plasmic: fetched designs for ${data.projects\n .map((p) => `\"${p.name}\" (${p.id}@${p.version})`)\n .join(', ')}`\n );\n return data;\n }\n}\n"],"names":["isBrowser","window","document","Api","constructor","opts","host","projectIds","platform","preview","query","URLSearchParams","map","projectId","browserOnly","toString","url","this","resp","fetch","method","headers","makeGetHeaders","status","error","json","Error","_error$error","message","statusText","component","embedHydrate","hydrate","makeAuthHeaders","makePostHeaders","projects","p","id","token","join","undefined","api","cache","cachedData","get","curFetch","console","debug","doFetch","data","fetchLoaderData","version","set","name"],"mappings":"6JA0HA,MAEaA,EACO,oBAAXC,QACG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SACKA,KAGP1B,KAAK4B,sBACM5B,KAAK4B,SAEpBC,QAAQC,MAAM,wCACTF,SAAW5B,KAAK+B,gBACfC,QAAahC,KAAK4B,qBACnBA,cAAWL,EACTS,wBAIDA,QAAahC,KAAKwB,IAAIS,gBAC1BjC,KAAKZ,KAAK8B,SAASvB,IAAKwB,GACtBA,EAAEe,UAAYlC,KAAKZ,KAAKI,WAAa2B,EAAEC,MAAMD,EAAEe,UAAYf,EAAEC,IAE/D,CACE7B,SAAUS,KAAKZ,KAAKG,SACpBC,QAASQ,KAAKZ,KAAKI,QACnBK,YAAad,WAGbiB,KAAKZ,KAAKqC,aACNzB,KAAKZ,KAAKqC,MAAMU,IAAIH,GAE5BH,QAAQC,sCAC0BE,EAAKd,SAClCvB,IAAKwB,OAAUA,EAAEiB,UAAUjB,EAAEC,MAAMD,EAAEe,YACrCZ,KAAK,OAEHU"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loader-fetcher.esm.js","sources":["../src/api.ts","../src/fetcher.ts"],"sourcesContent":["import fetch from 'isomorphic-unfetch';\n\nexport interface ComponentMeta {\n id: string;\n usedComponents: string[];\n projectId: string;\n name: string;\n displayName: string;\n cssFile: string;\n path: string | undefined;\n isPage: boolean;\n plumeType?: string;\n entry: string;\n isCode: boolean;\n isGlobalContextProvider: boolean;\n pageMetadata?: PageMetadata;\n metadata?: Record<string, string>;\n}\n\nexport interface PageMeta extends ComponentMeta {\n isPage: true;\n path: string;\n plumeType: never;\n pageMetadata: PageMetadata;\n}\n\nexport interface PageMetadata {\n path: string;\n title?: string | null;\n description?: string | null;\n openGraphImageUrl?: string | null;\n}\n\nexport interface GlobalGroupMeta {\n id: string;\n projectId: string;\n name: string;\n type: string;\n contextFile: string;\n useName: string;\n}\n\nexport interface ProjectMeta {\n id: string;\n teamId?: string;\n indirect?: boolean;\n name: string;\n version: string;\n remoteFonts: FontMeta[];\n globalContextsProviderFileName: string;\n}\n\nexport interface FontMeta {\n url: string;\n}\n\ninterface GlobalVariantSplitContent {\n type: 'global-variant';\n projectId: string;\n group: string;\n variant: string;\n}\n\ninterface Slice {\n id: string;\n contents: GlobalVariantSplitContent[];\n externalId?: string;\n}\n\nexport interface ExperimentSlice extends Slice {\n prob: number;\n}\n\nexport interface SegmentSlice extends Slice {\n cond: any;\n}\n\nexport interface ExperimentSplit {\n id: string;\n externalId?: string;\n type: 'experiment';\n slices: ExperimentSlice[];\n}\n\nexport interface SegmentSplit {\n id: string;\n externalId?: string;\n type: 'segment';\n slices: SegmentSlice[];\n}\n\nexport type Split = ExperimentSplit | SegmentSplit;\n\nexport interface LoaderBundleOutput {\n modules: {\n browser: (CodeModule | AssetModule)[];\n server: (CodeModule | AssetModule)[];\n };\n external: string[];\n components: ComponentMeta[];\n globalGroups: GlobalGroupMeta[];\n projects: ProjectMeta[];\n activeSplits: Split[];\n}\n\nexport interface LoaderHtmlOutput {\n html: string;\n}\n\nexport interface CodeModule {\n fileName: string;\n code: string;\n imports: string[];\n type: 'code';\n}\n\nexport interface AssetModule {\n fileName: string;\n source: string;\n type: 'asset';\n}\n\nconst VERSION = '7';\n\nexport const isBrowser =\n typeof window !== 'undefined' &&\n window != null &&\n typeof window.document !== 'undefined';\n\nexport class Api {\n private host: string;\n constructor(\n private opts: {\n projects: { id: string; token: string }[];\n host?: string;\n }\n ) {\n this.host = opts.host ?? 'https://codegen.plasmic.app';\n }\n\n async fetchLoaderData(\n projectIds: string[],\n opts: {\n platform?: 'react' | 'nextjs' | 'gatsby';\n preview?: boolean;\n browserOnly?: boolean;\n }\n ) {\n const { platform, preview } = opts;\n const query = new URLSearchParams([\n ['platform', platform ?? 'react'],\n ...projectIds.map((projectId) => ['projectId', projectId]),\n ...(opts.browserOnly ? [['browserOnly', 'true']] : []),\n ]).toString();\n\n const url = `${this.host}/api/v1/loader/code/${\n preview ? 'preview' : 'published'\n }?${query}`;\n const resp = await fetch(url, {\n method: 'GET',\n headers: this.makeGetHeaders(),\n });\n if (resp.status >= 400) {\n const error = await resp.json();\n throw new Error(error?.error?.message ?? resp.statusText);\n }\n const json = await resp.json();\n return json as LoaderBundleOutput;\n }\n\n async fetchHtmlData(opts: {\n projectId: string;\n component: string;\n hydrate?: boolean;\n embedHydrate?: boolean;\n }) {\n const { projectId, component, embedHydrate, hydrate } = opts;\n const query = new URLSearchParams([\n ['projectId', projectId],\n ['component', component],\n ['embedHydrate', embedHydrate ? '1' : '0'],\n ['hydrate', hydrate ? '1' : '0'],\n ]).toString();\n const resp = await fetch(`${this.host}/api/v1/loader/html?${query}`, {\n method: 'GET',\n headers: this.makeGetHeaders(),\n });\n const json = await resp.json();\n return json as LoaderHtmlOutput;\n }\n\n private makeGetHeaders() {\n return {\n 'x-plasmic-loader-version': VERSION,\n ...this.makeAuthHeaders(),\n };\n }\n\n // @ts-ignore\n private makePostHeaders() {\n return {\n 'x-plasmic-loader-version': VERSION,\n 'Content-Type': 'application/json',\n ...this.makeAuthHeaders(),\n };\n }\n\n private makeAuthHeaders() {\n const tokens = this.opts.projects\n .map((p) => `${p.id}:${p.token}`)\n .join(',');\n return {\n 'x-plasmic-api-project-tokens': tokens,\n };\n }\n}\n","import { Api, isBrowser, LoaderBundleOutput } from './api';\n\nexport interface FetcherOptions {\n projects: {\n id: string;\n version?: string;\n token: string;\n }[];\n cache?: LoaderBundleCache;\n platform?: 'react' | 'nextjs' | 'gatsby';\n preview?: boolean;\n host?: string;\n}\n\nexport interface LoaderBundleCache {\n set: (data: LoaderBundleOutput) => Promise<void>;\n get: () => Promise<LoaderBundleOutput>;\n}\n\nexport class PlasmicModulesFetcher {\n private api: Api;\n private curFetch: Promise<LoaderBundleOutput> | undefined = undefined;\n constructor(private opts: FetcherOptions) {\n this.api = new Api({\n projects: opts.projects,\n host: opts.host,\n });\n }\n\n async fetchAllData() {\n if (this.opts.cache) {\n const cachedData = await this.opts.cache.get();\n if (cachedData) {\n return cachedData;\n }\n }\n if (this.curFetch) {\n return await this.curFetch;\n }\n console.debug('Plasmic: doing a fresh fetch...');\n this.curFetch = this.doFetch();\n const data = await this.curFetch;\n this.curFetch = undefined;\n return data;\n }\n\n private async doFetch() {\n const data = await this.api.fetchLoaderData(\n this.opts.projects.map((p) =>\n p.version && !this.opts.preview ? `${p.id}@${p.version}` : p.id\n ),\n {\n platform: this.opts.platform,\n preview: this.opts.preview,\n browserOnly: isBrowser,\n }\n );\n if (this.opts.cache) {\n await this.opts.cache.set(data);\n }\n console.debug(\n `Plasmic: fetched designs for ${data.projects\n .map((p) => `\"${p.name}\" (${p.id}@${p.version})`)\n .join(', ')}`\n );\n return data;\n }\n}\n"],"names":["VERSION","isBrowser","window","document","Api","constructor","opts","host","fetchLoaderData","projectIds","platform","preview","query","URLSearchParams","map","projectId","browserOnly","toString","url","resp","fetch","method","headers","makeGetHeaders","status","error","json","Error","message","statusText","fetchHtmlData","component","embedHydrate","hydrate","makeAuthHeaders","makePostHeaders","tokens","projects","p","id","token","join","PlasmicModulesFetcher","undefined","api","fetchAllData","cache","cachedData","get","curFetch","console","debug","doFetch","data","version","set","name"],"mappings":";;AA0HA,MAAMA,OAAO,GAAG,GAAhB;AAEO,MAAMC,SAAS,GACpB,OAAOC,MAAP,KAAkB,WAAlB,IACAA,MAAM,IAAI,IADV,IAEA,OAAOA,MAAM,CAACC,QAAd,KAA2B,WAHtB;MAKMC;AAEXC,EAAAA,YACUC;;;AAAA,aAAA,GAAAA,IAAA;AAKR,SAAKC,IAAL,iBAAYD,IAAI,CAACC,IAAjB,yBAAyB,6BAAzB;AACD;;AAEoB,QAAfC,eAAe,CACnBC,UADmB,EAEnBH,IAFmB;AAQnB,UAAM;AAAEI,MAAAA,QAAF;AAAYC,MAAAA;AAAZ,QAAwBL,IAA9B;AACA,UAAMM,KAAK,GAAG,IAAIC,eAAJ,CAAoB,CAChC,CAAC,UAAD,EAAaH,QAAb,WAAaA,QAAb,GAAyB,OAAzB,CADgC,EAEhC,GAAGD,UAAU,CAACK,GAAX,CAAgBC,SAAD,IAAe,CAAC,WAAD,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AACA,UAAMC,IAAI,GAAG,MAAM,KAAKJ,QAAxB;AACA,SAAKA,QAAL,GAAgBN,SAAhB;AACA,WAAOU,IAAP;AACD;;AAEoB,QAAPD,OAAO;AACnB,UAAMC,IAAI,GAAG,MAAM,KAAKT,GAAL,CAASpC,eAAT,CACjB,KAAKF,IAAL,CAAU+B,QAAV,CAAmBvB,GAAnB,CAAwBwB,CAAD,IACrBA,CAAC,CAACgB,OAAF,IAAa,CAAC,KAAKhD,IAAL,CAAUK,OAAxB,MAAqC2B,CAAC,CAACC,MAAMD,CAAC,CAACgB,SAA/C,GAA2DhB,CAAC,CAACC,EAD/D,CADiB,EAIjB;AACE7B,MAAAA,QAAQ,EAAE,KAAKJ,IAAL,CAAUI,QADtB;AAEEC,MAAAA,OAAO,EAAE,KAAKL,IAAL,CAAUK,OAFrB;AAGEK,MAAAA,WAAW,EAAEf;AAHf,KAJiB,CAAnB;;AAUA,QAAI,KAAKK,IAAL,CAAUwC,KAAd,EAAqB;AACnB,YAAM,KAAKxC,IAAL,CAAUwC,KAAV,CAAgBS,GAAhB,CAAoBF,IAApB,CAAN;AACD;;AACDH,IAAAA,OAAO,CAACC,KAAR,iCACkCE,IAAI,CAAChB,QAAL,CAC7BvB,GAD6B,CACxBwB,CAAD,QAAWA,CAAC,CAACkB,UAAUlB,CAAC,CAACC,MAAMD,CAAC,CAACgB,UADR,EAE7Bb,IAF6B,CAExB,IAFwB,GADlC;AAKA,WAAOY,IAAP;AACD;;;;;;"}
|
|
1
|
+
{"version":3,"file":"loader-fetcher.esm.js","sources":["../src/api.ts","../src/fetcher.ts"],"sourcesContent":["import fetch from 'isomorphic-unfetch';\n\nexport interface ComponentMeta {\n id: string;\n usedComponents: string[];\n projectId: string;\n name: string;\n displayName: string;\n cssFile: string;\n path: string | undefined;\n isPage: boolean;\n plumeType?: string;\n entry: string;\n isCode: boolean;\n isGlobalContextProvider: boolean;\n pageMetadata?: PageMetadata;\n metadata?: Record<string, string>;\n}\n\nexport interface PageMeta extends ComponentMeta {\n isPage: true;\n path: string;\n plumeType: never;\n pageMetadata: PageMetadata;\n}\n\nexport interface PageMetadata {\n path: string;\n title?: string | null;\n description?: string | null;\n openGraphImageUrl?: string | null;\n}\n\nexport interface GlobalGroupMeta {\n id: string;\n projectId: string;\n name: string;\n type: string;\n contextFile: string;\n useName: string;\n}\n\nexport interface ProjectMeta {\n id: string;\n teamId?: string;\n indirect?: boolean;\n name: string;\n version: string;\n remoteFonts: FontMeta[];\n globalContextsProviderFileName: string;\n}\n\nexport interface FontMeta {\n url: string;\n}\n\ninterface GlobalVariantSplitContent {\n type: 'global-variant';\n projectId: string;\n group: string;\n variant: string;\n}\n\ninterface Slice {\n id: string;\n contents: GlobalVariantSplitContent[];\n externalId?: string;\n}\n\nexport interface ExperimentSlice extends Slice {\n prob: number;\n}\n\nexport interface SegmentSlice extends Slice {\n cond: any;\n}\n\nexport interface ExperimentSplit {\n id: string;\n externalId?: string;\n type: 'experiment';\n slices: ExperimentSlice[];\n}\n\nexport interface SegmentSplit {\n id: string;\n externalId?: string;\n type: 'segment';\n slices: SegmentSlice[];\n}\n\nexport type Split = ExperimentSplit | SegmentSplit;\n\nexport interface LoaderBundleOutput {\n modules: {\n browser: (CodeModule | AssetModule)[];\n server: (CodeModule | AssetModule)[];\n };\n external: string[];\n components: ComponentMeta[];\n globalGroups: GlobalGroupMeta[];\n projects: ProjectMeta[];\n activeSplits: Split[];\n}\n\nexport interface LoaderHtmlOutput {\n html: string;\n}\n\nexport interface CodeModule {\n fileName: string;\n code: string;\n imports: string[];\n type: 'code';\n}\n\nexport interface AssetModule {\n fileName: string;\n source: string;\n type: 'asset';\n}\n\nconst VERSION = '9';\n\nexport const isBrowser =\n typeof window !== 'undefined' &&\n window != null &&\n typeof window.document !== 'undefined';\n\nexport class Api {\n private host: string;\n constructor(\n private opts: {\n projects: { id: string; token: string }[];\n host?: string;\n }\n ) {\n this.host = opts.host ?? 'https://codegen.plasmic.app';\n }\n\n async fetchLoaderData(\n projectIds: string[],\n opts: {\n platform?: 'react' | 'nextjs' | 'gatsby';\n preview?: boolean;\n browserOnly?: boolean;\n }\n ) {\n const { platform, preview } = opts;\n const query = new URLSearchParams([\n ['platform', platform ?? 'react'],\n ...projectIds.map((projectId) => ['projectId', projectId]),\n ...(opts.browserOnly ? [['browserOnly', 'true']] : []),\n ]).toString();\n\n const url = `${this.host}/api/v1/loader/code/${\n preview ? 'preview' : 'published'\n }?${query}`;\n const resp = await fetch(url, {\n method: 'GET',\n headers: this.makeGetHeaders(),\n });\n if (resp.status >= 400) {\n const error = await resp.json();\n throw new Error(error?.error?.message ?? resp.statusText);\n }\n const json = await resp.json();\n return json as LoaderBundleOutput;\n }\n\n async fetchHtmlData(opts: {\n projectId: string;\n component: string;\n hydrate?: boolean;\n embedHydrate?: boolean;\n }) {\n const { projectId, component, embedHydrate, hydrate } = opts;\n const query = new URLSearchParams([\n ['projectId', projectId],\n ['component', component],\n ['embedHydrate', embedHydrate ? '1' : '0'],\n ['hydrate', hydrate ? '1' : '0'],\n ]).toString();\n const resp = await fetch(`${this.host}/api/v1/loader/html?${query}`, {\n method: 'GET',\n headers: this.makeGetHeaders(),\n });\n const json = await resp.json();\n return json as LoaderHtmlOutput;\n }\n\n private makeGetHeaders() {\n return {\n 'x-plasmic-loader-version': VERSION,\n ...this.makeAuthHeaders(),\n };\n }\n\n // @ts-ignore\n private makePostHeaders() {\n return {\n 'x-plasmic-loader-version': VERSION,\n 'Content-Type': 'application/json',\n ...this.makeAuthHeaders(),\n };\n }\n\n private makeAuthHeaders() {\n const tokens = this.opts.projects\n .map((p) => `${p.id}:${p.token}`)\n .join(',');\n return {\n 'x-plasmic-api-project-tokens': tokens,\n };\n }\n}\n","import { Api, isBrowser, LoaderBundleOutput } from './api';\n\nexport interface FetcherOptions {\n projects: {\n id: string;\n version?: string;\n token: string;\n }[];\n cache?: LoaderBundleCache;\n platform?: 'react' | 'nextjs' | 'gatsby';\n preview?: boolean;\n host?: string;\n}\n\nexport interface LoaderBundleCache {\n set: (data: LoaderBundleOutput) => Promise<void>;\n get: () => Promise<LoaderBundleOutput>;\n}\n\nexport class PlasmicModulesFetcher {\n private api: Api;\n private curFetch: Promise<LoaderBundleOutput> | undefined = undefined;\n constructor(private opts: FetcherOptions) {\n this.api = new Api({\n projects: opts.projects,\n host: opts.host,\n });\n }\n\n async fetchAllData() {\n if (this.opts.cache) {\n const cachedData = await this.opts.cache.get();\n if (cachedData) {\n return cachedData;\n }\n }\n if (this.curFetch) {\n return await this.curFetch;\n }\n console.debug('Plasmic: doing a fresh fetch...');\n this.curFetch = this.doFetch();\n const data = await this.curFetch;\n this.curFetch = undefined;\n return data;\n }\n\n private async doFetch() {\n const data = await this.api.fetchLoaderData(\n this.opts.projects.map((p) =>\n p.version && !this.opts.preview ? `${p.id}@${p.version}` : p.id\n ),\n {\n platform: this.opts.platform,\n preview: this.opts.preview,\n browserOnly: isBrowser,\n }\n );\n if (this.opts.cache) {\n await this.opts.cache.set(data);\n }\n console.debug(\n `Plasmic: fetched designs for ${data.projects\n .map((p) => `\"${p.name}\" (${p.id}@${p.version})`)\n .join(', ')}`\n );\n return data;\n }\n}\n"],"names":["VERSION","isBrowser","window","document","Api","constructor","opts","host","fetchLoaderData","projectIds","platform","preview","query","URLSearchParams","map","projectId","browserOnly","toString","url","resp","fetch","method","headers","makeGetHeaders","status","error","json","Error","message","statusText","fetchHtmlData","component","embedHydrate","hydrate","makeAuthHeaders","makePostHeaders","tokens","projects","p","id","token","join","PlasmicModulesFetcher","undefined","api","fetchAllData","cache","cachedData","get","curFetch","console","debug","doFetch","data","version","set","name"],"mappings":";;AA0HA,MAAMA,OAAO,GAAG,GAAhB;AAEO,MAAMC,SAAS,GACpB,OAAOC,MAAP,KAAkB,WAAlB,IACAA,MAAM,IAAI,IADV,IAEA,OAAOA,MAAM,CAACC,QAAd,KAA2B,WAHtB;MAKMC;AAEXC,EAAAA,YACUC;;;AAAA,aAAA,GAAAA,IAAA;AAKR,SAAKC,IAA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ADlC;AAKA,WAAOY,IAAP;AACD;;;;;;"}
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "1.0.
|
|
2
|
+
"version": "1.0.11",
|
|
3
3
|
"license": "MIT",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"typings": "dist/index.d.ts",
|
|
@@ -58,5 +58,5 @@
|
|
|
58
58
|
"publishConfig": {
|
|
59
59
|
"access": "public"
|
|
60
60
|
},
|
|
61
|
-
"gitHead": "
|
|
61
|
+
"gitHead": "903ce16d38bad4f23bd6b8e90bb58cf1c9bc27fb"
|
|
62
62
|
}
|