@plasmicapp/loader-react 1.0.302 → 1.0.303
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.esm.js +1400 -0
- package/dist/index.esm.js.map +7 -0
- package/dist/index.js.map +2 -2
- package/dist/loader-react-server.d.ts +5 -0
- package/dist/react-server.esm.js +441 -0
- package/dist/react-server.esm.js.map +7 -0
- package/dist/react-server.js.map +2 -2
- package/package.json +17 -12
|
@@ -0,0 +1,441 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defProps = Object.defineProperties;
|
|
3
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
+
var __spreadValues = (a, b) => {
|
|
9
|
+
for (var prop in b || (b = {}))
|
|
10
|
+
if (__hasOwnProp.call(b, prop))
|
|
11
|
+
__defNormalProp(a, prop, b[prop]);
|
|
12
|
+
if (__getOwnPropSymbols)
|
|
13
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
+
if (__propIsEnum.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
}
|
|
17
|
+
return a;
|
|
18
|
+
};
|
|
19
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
+
var __async = (__this, __arguments, generator) => {
|
|
21
|
+
return new Promise((resolve, reject) => {
|
|
22
|
+
var fulfilled = (value) => {
|
|
23
|
+
try {
|
|
24
|
+
step(generator.next(value));
|
|
25
|
+
} catch (e) {
|
|
26
|
+
reject(e);
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
var rejected = (value) => {
|
|
30
|
+
try {
|
|
31
|
+
step(generator.throw(value));
|
|
32
|
+
} catch (e) {
|
|
33
|
+
reject(e);
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
37
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
38
|
+
});
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
// src/react-server.ts
|
|
42
|
+
import "server-only";
|
|
43
|
+
import { PlasmicModulesFetcher, PlasmicTracker } from "@plasmicapp/loader-core";
|
|
44
|
+
|
|
45
|
+
// src/bundles.ts
|
|
46
|
+
import {
|
|
47
|
+
getBundleSubset
|
|
48
|
+
} from "@plasmicapp/loader-core";
|
|
49
|
+
function getUsedComps(allComponents, entryCompIds) {
|
|
50
|
+
const q = [...entryCompIds];
|
|
51
|
+
const seenIds = new Set(entryCompIds);
|
|
52
|
+
const componentMetaById = new Map(
|
|
53
|
+
allComponents.map((meta) => [meta.id, meta])
|
|
54
|
+
);
|
|
55
|
+
const usedComps = [];
|
|
56
|
+
while (q.length > 0) {
|
|
57
|
+
const [id] = q.splice(0, 1);
|
|
58
|
+
const meta = componentMetaById.get(id);
|
|
59
|
+
if (!meta) {
|
|
60
|
+
continue;
|
|
61
|
+
}
|
|
62
|
+
usedComps.push(meta);
|
|
63
|
+
meta.usedComponents.forEach((usedCompId) => {
|
|
64
|
+
if (!seenIds.has(usedCompId)) {
|
|
65
|
+
seenIds.add(usedCompId);
|
|
66
|
+
q.push(usedCompId);
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
return usedComps;
|
|
71
|
+
}
|
|
72
|
+
function prepComponentData(bundle, compMetas, opts) {
|
|
73
|
+
if (compMetas.length === 0) {
|
|
74
|
+
return {
|
|
75
|
+
entryCompMetas: bundle.components,
|
|
76
|
+
bundle,
|
|
77
|
+
remoteFontUrls: []
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
const usedComps = getUsedComps(
|
|
81
|
+
bundle.components,
|
|
82
|
+
compMetas.map((compMeta) => compMeta.id)
|
|
83
|
+
);
|
|
84
|
+
const compPaths = usedComps.map((compMeta) => compMeta.entry);
|
|
85
|
+
const subBundle = getBundleSubset(
|
|
86
|
+
bundle,
|
|
87
|
+
[
|
|
88
|
+
"entrypoint.css",
|
|
89
|
+
...compPaths,
|
|
90
|
+
"root-provider.js",
|
|
91
|
+
...bundle.projects.map((x) => x.globalContextsProviderFileName).filter((x) => !!x),
|
|
92
|
+
// We need to explicitly include global context provider components
|
|
93
|
+
// to make sure they are kept in bundle.components. That's because
|
|
94
|
+
// for esbuild, just the globalContextsProviderFileName is not enough,
|
|
95
|
+
// because it will import a chunk that includes the global context
|
|
96
|
+
// component, instead of importing that global context component's
|
|
97
|
+
// entry file. And because nothing depends on the global context component's
|
|
98
|
+
// entry file, we end up excluding the global context component from
|
|
99
|
+
// bundle.components, which then makes its substitution not work.
|
|
100
|
+
// Instead, we forcibly include it here (we'll definitely need it anyway!).
|
|
101
|
+
...bundle.components.filter((c) => c.isGlobalContextProvider).map((c) => c.entry),
|
|
102
|
+
...bundle.globalGroups.map((g) => g.contextFile)
|
|
103
|
+
],
|
|
104
|
+
opts
|
|
105
|
+
);
|
|
106
|
+
const remoteFontUrls = [];
|
|
107
|
+
subBundle.projects.forEach(
|
|
108
|
+
(p) => remoteFontUrls.push(...p.remoteFonts.map((f) => f.url))
|
|
109
|
+
);
|
|
110
|
+
return {
|
|
111
|
+
entryCompMetas: compMetas,
|
|
112
|
+
bundle: subBundle,
|
|
113
|
+
remoteFontUrls
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
function mergeBundles(target, from) {
|
|
117
|
+
var _a;
|
|
118
|
+
const existingCompIds = new Set(target.components.map((c) => c.id));
|
|
119
|
+
const newCompMetas = from.components.filter(
|
|
120
|
+
(m) => !existingCompIds.has(m.id)
|
|
121
|
+
);
|
|
122
|
+
if (newCompMetas.length > 0) {
|
|
123
|
+
target = __spreadProps(__spreadValues({}, target), { components: [...target.components, ...newCompMetas] });
|
|
124
|
+
}
|
|
125
|
+
const existingProjects = new Set(target.projects.map((p) => p.id));
|
|
126
|
+
const newProjects = from.projects.filter((p) => !existingProjects.has(p.id));
|
|
127
|
+
if (newProjects.length > 0) {
|
|
128
|
+
target = __spreadProps(__spreadValues({}, target), {
|
|
129
|
+
projects: [...target.projects, ...newProjects]
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
const existingModules = {
|
|
133
|
+
browser: new Set(target.modules.browser.map((m) => m.fileName)),
|
|
134
|
+
server: new Set(target.modules.server.map((m) => m.fileName))
|
|
135
|
+
};
|
|
136
|
+
const newModules = {
|
|
137
|
+
browser: from.modules.browser.filter(
|
|
138
|
+
(m) => !existingModules.browser.has(m.fileName)
|
|
139
|
+
),
|
|
140
|
+
server: from.modules.server.filter(
|
|
141
|
+
(m) => !existingModules.server.has(m.fileName)
|
|
142
|
+
)
|
|
143
|
+
};
|
|
144
|
+
if (newModules.browser.length > 0 || newModules.server.length > 0) {
|
|
145
|
+
target = __spreadProps(__spreadValues({}, target), {
|
|
146
|
+
modules: {
|
|
147
|
+
browser: [...target.modules.browser, ...newModules.browser],
|
|
148
|
+
server: [...target.modules.server, ...newModules.server]
|
|
149
|
+
}
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
const existingGlobalIds = new Set(target.globalGroups.map((g) => g.id));
|
|
153
|
+
const newGlobals = from.globalGroups.filter(
|
|
154
|
+
(g) => !existingGlobalIds.has(g.id)
|
|
155
|
+
);
|
|
156
|
+
if (newGlobals.length > 0) {
|
|
157
|
+
target = __spreadProps(__spreadValues({}, target), {
|
|
158
|
+
globalGroups: [...target.globalGroups, ...newGlobals]
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
const existingExternals = new Set(target.external);
|
|
162
|
+
const newExternals = target.external.filter((x) => !existingExternals.has(x));
|
|
163
|
+
if (newExternals.length > 0) {
|
|
164
|
+
target = __spreadProps(__spreadValues({}, target), { external: [...target.external, ...newExternals] });
|
|
165
|
+
}
|
|
166
|
+
const existingSplitIds = new Set(target.activeSplits.map((s) => s.id));
|
|
167
|
+
const newSplits = (_a = from.activeSplits.filter((s) => !existingSplitIds.has(s.id))) != null ? _a : [];
|
|
168
|
+
if (newSplits.length > 0) {
|
|
169
|
+
target = __spreadProps(__spreadValues({}, target), {
|
|
170
|
+
activeSplits: [...target.activeSplits, ...newSplits]
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
return target;
|
|
174
|
+
}
|
|
175
|
+
var convertBundlesToComponentRenderData = (bundles, compMetas) => {
|
|
176
|
+
if (bundles.length === 0) {
|
|
177
|
+
return null;
|
|
178
|
+
}
|
|
179
|
+
const mergedBundles = bundles.reduce((prev, cur) => mergeBundles(prev, cur));
|
|
180
|
+
return prepComponentData(mergedBundles, compMetas);
|
|
181
|
+
};
|
|
182
|
+
|
|
183
|
+
// src/utils.tsx
|
|
184
|
+
import pascalcase from "pascalcase";
|
|
185
|
+
import * as React from "react";
|
|
186
|
+
var isBrowser = typeof window !== "undefined";
|
|
187
|
+
function isNameSpec(lookup) {
|
|
188
|
+
return "name" in lookup;
|
|
189
|
+
}
|
|
190
|
+
function toFullLookup(lookup) {
|
|
191
|
+
const namePart = typeof lookup === "string" ? lookup : lookup.name;
|
|
192
|
+
const projectId = typeof lookup === "string" ? void 0 : lookup.projectId;
|
|
193
|
+
const codeComponent = typeof lookup === "string" ? void 0 : lookup.isCode;
|
|
194
|
+
if (codeComponent !== true && namePart.startsWith("/")) {
|
|
195
|
+
return { path: normalizePath(namePart), projectId };
|
|
196
|
+
} else {
|
|
197
|
+
return {
|
|
198
|
+
name: codeComponent ? namePart : normalizeName(namePart),
|
|
199
|
+
rawName: namePart.trim(),
|
|
200
|
+
projectId,
|
|
201
|
+
isCode: codeComponent
|
|
202
|
+
};
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
function normalizePath(path) {
|
|
206
|
+
return path.trim();
|
|
207
|
+
}
|
|
208
|
+
function normalizeName(name) {
|
|
209
|
+
return pascalcase(name).trim();
|
|
210
|
+
}
|
|
211
|
+
function matchesPagePath(pagePath, lookup) {
|
|
212
|
+
var _a;
|
|
213
|
+
pagePath = pagePath.replace(/^\/*/, "").replace(/\/*$/, "");
|
|
214
|
+
lookup = lookup.replace(/^\/*/, "").replace(/\/*$/, "");
|
|
215
|
+
const paramNames = (pagePath.match(/\[([^\]]*)\]/g) || []).map(
|
|
216
|
+
(group) => group.slice(1, -1)
|
|
217
|
+
);
|
|
218
|
+
const pagePathRegExp = new RegExp(
|
|
219
|
+
"^" + pagePath.replace(/\[[^\]]*\]/g, "([^/]+)") + "$"
|
|
220
|
+
);
|
|
221
|
+
const maybeVals = (_a = lookup.match(pagePathRegExp)) == null ? void 0 : _a.slice(1);
|
|
222
|
+
if (!maybeVals) {
|
|
223
|
+
return false;
|
|
224
|
+
}
|
|
225
|
+
const params = {};
|
|
226
|
+
for (let i = 0; i < paramNames.length; i++) {
|
|
227
|
+
params[paramNames[i]] = maybeVals[i];
|
|
228
|
+
}
|
|
229
|
+
return { params };
|
|
230
|
+
}
|
|
231
|
+
function isDynamicPagePath(path) {
|
|
232
|
+
return !!path.match(/\[[^/]*\]/);
|
|
233
|
+
}
|
|
234
|
+
function matchesCompMeta(lookup, meta) {
|
|
235
|
+
if (lookup.projectId && meta.projectId !== lookup.projectId) {
|
|
236
|
+
return false;
|
|
237
|
+
}
|
|
238
|
+
return isNameSpec(lookup) ? (lookup.name === meta.name || lookup.rawName === meta.name || lookup.rawName === meta.displayName) && (lookup.isCode == null || lookup.isCode === meta.isCode) : !!(meta.path && matchesPagePath(meta.path, lookup.path));
|
|
239
|
+
}
|
|
240
|
+
function getCompMetas(metas, lookup) {
|
|
241
|
+
const full = toFullLookup(lookup);
|
|
242
|
+
return metas.filter((meta) => matchesCompMeta(full, meta)).map((meta) => {
|
|
243
|
+
if (isNameSpec(full) || !meta.path) {
|
|
244
|
+
return meta;
|
|
245
|
+
}
|
|
246
|
+
const match = matchesPagePath(meta.path, full.path);
|
|
247
|
+
if (!match) {
|
|
248
|
+
return meta;
|
|
249
|
+
}
|
|
250
|
+
return __spreadProps(__spreadValues({}, meta), { params: match.params });
|
|
251
|
+
}).sort(
|
|
252
|
+
(meta1, meta2) => (
|
|
253
|
+
// We sort the matched component metas by the number of path params, so
|
|
254
|
+
// if there are two pages `/products/foo` and `/products/[slug]`,
|
|
255
|
+
// the first one will have higher precedence.
|
|
256
|
+
Array.from(Object.keys(meta1.params || {})).length - Array.from(Object.keys(meta2.params || {})).length
|
|
257
|
+
)
|
|
258
|
+
);
|
|
259
|
+
}
|
|
260
|
+
function getLookupSpecName(lookup) {
|
|
261
|
+
if (typeof lookup === "string") {
|
|
262
|
+
return lookup;
|
|
263
|
+
} else if (lookup.projectId) {
|
|
264
|
+
return `${lookup.name} (project ${lookup.projectId})`;
|
|
265
|
+
} else {
|
|
266
|
+
return lookup.name;
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
// src/loader-react-server.ts
|
|
271
|
+
var ReactServerPlasmicComponentLoader = class {
|
|
272
|
+
constructor(args) {
|
|
273
|
+
this.bundle = {
|
|
274
|
+
modules: {
|
|
275
|
+
browser: [],
|
|
276
|
+
server: []
|
|
277
|
+
},
|
|
278
|
+
components: [],
|
|
279
|
+
globalGroups: [],
|
|
280
|
+
external: [],
|
|
281
|
+
projects: [],
|
|
282
|
+
activeSplits: []
|
|
283
|
+
};
|
|
284
|
+
this.opts = args.opts;
|
|
285
|
+
this.fetcher = args.fetcher;
|
|
286
|
+
this.tracker = args.tracker;
|
|
287
|
+
this.onBundleMerged = args.onBundleMerged;
|
|
288
|
+
this.onBundleFetched = args.onBundleFetched;
|
|
289
|
+
}
|
|
290
|
+
maybeGetCompMetas(...specs) {
|
|
291
|
+
const found = /* @__PURE__ */ new Set();
|
|
292
|
+
const missing = [];
|
|
293
|
+
for (const spec of specs) {
|
|
294
|
+
const filteredMetas = getCompMetas(this.bundle.components, spec);
|
|
295
|
+
if (filteredMetas.length > 0) {
|
|
296
|
+
filteredMetas.forEach((meta) => found.add(meta));
|
|
297
|
+
} else {
|
|
298
|
+
missing.push(spec);
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
return { found: Array.from(found.keys()), missing };
|
|
302
|
+
}
|
|
303
|
+
maybeFetchComponentData(...args) {
|
|
304
|
+
return __async(this, null, function* () {
|
|
305
|
+
const { specs, opts } = parseFetchComponentDataArgs(...args);
|
|
306
|
+
const returnWithSpecsToFetch = (specsToFetch) => __async(this, null, function* () {
|
|
307
|
+
yield this.fetchMissingData({ missingSpecs: specsToFetch });
|
|
308
|
+
const { found: existingMetas2, missing: missingSpecs2 } = this.maybeGetCompMetas(...specs);
|
|
309
|
+
if (missingSpecs2.length > 0) {
|
|
310
|
+
return null;
|
|
311
|
+
}
|
|
312
|
+
return prepComponentData(this.bundle, existingMetas2, opts);
|
|
313
|
+
});
|
|
314
|
+
if (this.opts.alwaysFresh) {
|
|
315
|
+
return yield returnWithSpecsToFetch(specs);
|
|
316
|
+
}
|
|
317
|
+
const { found: existingMetas, missing: missingSpecs } = this.maybeGetCompMetas(...specs);
|
|
318
|
+
if (missingSpecs.length === 0) {
|
|
319
|
+
return prepComponentData(this.bundle, existingMetas, opts);
|
|
320
|
+
}
|
|
321
|
+
return yield returnWithSpecsToFetch(missingSpecs);
|
|
322
|
+
});
|
|
323
|
+
}
|
|
324
|
+
fetchComponentData(...args) {
|
|
325
|
+
return __async(this, null, function* () {
|
|
326
|
+
const { specs, opts } = parseFetchComponentDataArgs(...args);
|
|
327
|
+
const data = yield this.maybeFetchComponentData(specs, opts);
|
|
328
|
+
if (!data) {
|
|
329
|
+
const { missing: missingSpecs } = this.maybeGetCompMetas(...specs);
|
|
330
|
+
throw new Error(
|
|
331
|
+
`Unable to find components ${missingSpecs.map(getLookupSpecName).join(", ")}`
|
|
332
|
+
);
|
|
333
|
+
}
|
|
334
|
+
return data;
|
|
335
|
+
});
|
|
336
|
+
}
|
|
337
|
+
fetchPages(opts) {
|
|
338
|
+
return __async(this, null, function* () {
|
|
339
|
+
this.maybeReportClientSideFetch(
|
|
340
|
+
() => `Plasmic: fetching all page metadata in the browser`
|
|
341
|
+
);
|
|
342
|
+
const data = yield this.fetchAllData();
|
|
343
|
+
return data.components.filter(
|
|
344
|
+
(comp) => comp.isPage && comp.path && ((opts == null ? void 0 : opts.includeDynamicPages) || !isDynamicPagePath(comp.path))
|
|
345
|
+
);
|
|
346
|
+
});
|
|
347
|
+
}
|
|
348
|
+
fetchComponents() {
|
|
349
|
+
return __async(this, null, function* () {
|
|
350
|
+
this.maybeReportClientSideFetch(
|
|
351
|
+
() => `Plasmic: fetching all component metadata in the browser`
|
|
352
|
+
);
|
|
353
|
+
const data = yield this.fetchAllData();
|
|
354
|
+
return data.components;
|
|
355
|
+
});
|
|
356
|
+
}
|
|
357
|
+
getActiveSplits() {
|
|
358
|
+
return this.bundle.activeSplits;
|
|
359
|
+
}
|
|
360
|
+
fetchMissingData(opts) {
|
|
361
|
+
return __async(this, null, function* () {
|
|
362
|
+
this.maybeReportClientSideFetch(
|
|
363
|
+
() => `Plasmic: fetching missing components in the browser: ${opts.missingSpecs.map((spec) => getLookupSpecName(spec)).join(", ")}`
|
|
364
|
+
);
|
|
365
|
+
return this.fetchAllData();
|
|
366
|
+
});
|
|
367
|
+
}
|
|
368
|
+
maybeReportClientSideFetch(mkMsg) {
|
|
369
|
+
if (isBrowser && this.opts.onClientSideFetch) {
|
|
370
|
+
const msg = mkMsg();
|
|
371
|
+
if (this.opts.onClientSideFetch === "warn") {
|
|
372
|
+
console.warn(msg);
|
|
373
|
+
} else {
|
|
374
|
+
throw new Error(msg);
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
fetchAllData() {
|
|
379
|
+
return __async(this, null, function* () {
|
|
380
|
+
var _a;
|
|
381
|
+
const bundle = yield this.fetcher.fetchAllData();
|
|
382
|
+
this.tracker.trackFetch();
|
|
383
|
+
this.mergeBundle(bundle);
|
|
384
|
+
(_a = this.onBundleFetched) == null ? void 0 : _a.call(this);
|
|
385
|
+
return bundle;
|
|
386
|
+
});
|
|
387
|
+
}
|
|
388
|
+
mergeBundle(bundle) {
|
|
389
|
+
var _a;
|
|
390
|
+
this.bundle = mergeBundles(bundle, this.bundle);
|
|
391
|
+
(_a = this.onBundleMerged) == null ? void 0 : _a.call(this);
|
|
392
|
+
}
|
|
393
|
+
getBundle() {
|
|
394
|
+
return this.bundle;
|
|
395
|
+
}
|
|
396
|
+
clearCache() {
|
|
397
|
+
this.bundle = {
|
|
398
|
+
modules: {
|
|
399
|
+
browser: [],
|
|
400
|
+
server: []
|
|
401
|
+
},
|
|
402
|
+
components: [],
|
|
403
|
+
globalGroups: [],
|
|
404
|
+
external: [],
|
|
405
|
+
projects: [],
|
|
406
|
+
activeSplits: []
|
|
407
|
+
};
|
|
408
|
+
}
|
|
409
|
+
};
|
|
410
|
+
function parseFetchComponentDataArgs(...args) {
|
|
411
|
+
let specs;
|
|
412
|
+
let opts;
|
|
413
|
+
if (Array.isArray(args[0])) {
|
|
414
|
+
specs = args[0];
|
|
415
|
+
opts = args[1];
|
|
416
|
+
} else {
|
|
417
|
+
specs = args;
|
|
418
|
+
opts = void 0;
|
|
419
|
+
}
|
|
420
|
+
return { specs, opts };
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
// src/react-server.ts
|
|
424
|
+
function initPlasmicLoader(opts) {
|
|
425
|
+
return new ReactServerPlasmicComponentLoader({
|
|
426
|
+
opts,
|
|
427
|
+
fetcher: new PlasmicModulesFetcher(opts),
|
|
428
|
+
tracker: new PlasmicTracker({
|
|
429
|
+
projectIds: opts.projects.map((p) => p.id),
|
|
430
|
+
platform: opts.platform,
|
|
431
|
+
preview: opts.preview
|
|
432
|
+
})
|
|
433
|
+
});
|
|
434
|
+
}
|
|
435
|
+
export {
|
|
436
|
+
ReactServerPlasmicComponentLoader,
|
|
437
|
+
convertBundlesToComponentRenderData,
|
|
438
|
+
initPlasmicLoader,
|
|
439
|
+
matchesPagePath
|
|
440
|
+
};
|
|
441
|
+
//# sourceMappingURL=react-server.esm.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 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, returns false.\n *\n * For example,\n * - `matchesPagePath(\"/hello/[name]\", \"/hello/world\")` -> `{params: {name:\n * \"world\"}}`\n * - `matchesPagePath(\"/hello/[name]\", \"/\")` -> `false`\n * - `matchesPagePath(\"/\", \"\")` -> `{params: {}}`\n */\nexport function matchesPagePath(\n pagePath: string,\n lookup: string\n): { params: Record<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]/[variant]\" it will contain [\"slug\", \"variant\"].\n const paramNames = (pagePath.match(/\\[([^\\]]*)\\]/g) || []).map((group) =>\n group.slice(1, -1)\n );\n\n const pagePathRegExp = new RegExp(\n '^' + pagePath.replace(/\\[[^\\]]*\\]/g, '([^/]+)') + '$'\n );\n const maybeVals = lookup.match(pagePathRegExp)?.slice(1);\n if (!maybeVals) {\n return false;\n }\n\n const params: Record<string, string> = {};\n for (let i = 0; i < paramNames.length; i++) {\n params[paramNames[i]] = maybeVals[i];\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> }>((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 .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 { mergeBundles, 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/** 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 this.bundle = mergeBundles(bundle, this.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];\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