@weaverse/hydrogen 5.8.0 → 5.8.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +11 -12
- package/dist/index.d.ts +11 -12
- package/dist/index.js +47 -44
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +48 -45
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.d.mts
CHANGED
|
@@ -4,7 +4,8 @@ export { PositionInputValue, WeaverseImage, WeaverseVideo, isBrowser, isIframe,
|
|
|
4
4
|
import { PageType, InspectorGroup, SchemaType, ComponentPresets, SchemaValidationResult } from '@weaverse/schema';
|
|
5
5
|
export * from '@weaverse/schema';
|
|
6
6
|
export { BasicInput, HeadingInput, InputType, InspectorGroup, PageType, SchemaValidationIssue, SchemaValidationResult } from '@weaverse/schema';
|
|
7
|
-
import { createWithCache, I18nBase, HydrogenContext, HydrogenEnv } from '@shopify/hydrogen';
|
|
7
|
+
import { createWithCache, CachingStrategy, I18nBase, HydrogenContext, HydrogenEnv } from '@shopify/hydrogen';
|
|
8
|
+
export { CachingStrategy } from '@shopify/hydrogen';
|
|
8
9
|
import { LoaderFunctionArgs, AppLoadContext } from '@shopify/remix-oxygen';
|
|
9
10
|
import * as React$1 from 'react';
|
|
10
11
|
import { ComponentType, JSX, ForwardRefExoticComponent } from 'react';
|
|
@@ -164,21 +165,14 @@ declare class WeaverseClient {
|
|
|
164
165
|
private isLocalhost;
|
|
165
166
|
private getApiUrl;
|
|
166
167
|
fetchWithCache: <T = unknown>(url: string, options?: RequestInit & {
|
|
167
|
-
strategy?:
|
|
168
|
+
strategy?: CachingStrategy;
|
|
168
169
|
}) => Promise<T>;
|
|
169
|
-
loadThemeSettings: (strategy?:
|
|
170
|
+
loadThemeSettings: (strategy?: CachingStrategy) => Promise<ThemeSettingsResponse>;
|
|
170
171
|
generateFallbackPage: (message: string) => HydrogenPageData;
|
|
171
172
|
loadPage: (params?: LoadPageParams) => Promise<WeaverseLoaderData | null>;
|
|
172
173
|
execComponentLoader: (item: HydrogenComponentData) => Promise<HydrogenComponentData>;
|
|
173
174
|
}
|
|
174
175
|
|
|
175
|
-
type AllCacheOptions = {
|
|
176
|
-
mode?: 'must-revalidate' | 'no-cache' | 'no-store' | 'private' | 'public' | string;
|
|
177
|
-
maxAge?: number;
|
|
178
|
-
staleWhileRevalidate?: number;
|
|
179
|
-
sMaxAge?: number;
|
|
180
|
-
staleIfError?: number;
|
|
181
|
-
};
|
|
182
176
|
type ComponentLoaderArgs<T = any, _E = any> = {
|
|
183
177
|
data: T;
|
|
184
178
|
weaverse: WeaverseClient;
|
|
@@ -294,6 +288,11 @@ type HydrogenPageAssignment = {
|
|
|
294
288
|
type: PageType;
|
|
295
289
|
handle: string;
|
|
296
290
|
locale: string;
|
|
291
|
+
meta?: {
|
|
292
|
+
inherited: boolean;
|
|
293
|
+
sourceProjectId: string;
|
|
294
|
+
depth: number;
|
|
295
|
+
};
|
|
297
296
|
};
|
|
298
297
|
type WeaverseLoaderData = {
|
|
299
298
|
configs: Omit<WeaverseProjectConfigs, 'publicEnv'> & {
|
|
@@ -655,7 +654,7 @@ type LoadPageParams = {
|
|
|
655
654
|
* - Long-lived cache for static pages (1 hour+)
|
|
656
655
|
* - Short-lived cache for frequently updated content (5 minutes)
|
|
657
656
|
*/
|
|
658
|
-
strategy?:
|
|
657
|
+
strategy?: CachingStrategy;
|
|
659
658
|
/**
|
|
660
659
|
* Optional project override for this specific page load.
|
|
661
660
|
*
|
|
@@ -775,4 +774,4 @@ declare const IMAGES_PLACEHOLDERS: {
|
|
|
775
774
|
product_18: string;
|
|
776
775
|
};
|
|
777
776
|
|
|
778
|
-
export { type
|
|
777
|
+
export { type CacheResponseValidator, type ComponentLoaderArgs, type CreateHydrogenSchemaOptions, type DirectFetchResponse, type FetchProjectPayload, type FetchProjectRequestBody, type HydrogenComponent, type HydrogenComponentData, type HydrogenComponentPresets, type HydrogenComponentProps, type HydrogenComponentSchema, type HydrogenElement, type HydrogenPageAssignment, type HydrogenPageData, type HydrogenProjectType, type HydrogenSchemaValidationResult, type HydrogenThemeSchema, type HydrogenThemeSettings, IMAGES_PLACEHOLDERS, type LoadPageParams, type ProjectIdValidationResult, type ProjectIdValue, type PublicEnv, type RouteLoaderArgs, type ThemeSettingsResponse, type WeaverseArticle, type WeaverseBlog, WeaverseClient, type WeaverseClientArgs, type WeaverseCollection, type WeaverseDataContext, WeaverseError, WeaverseHydrogen, WeaverseHydrogenItem, type WeaverseHydrogenParams, WeaverseHydrogenRoot, type WeaverseI18n, type WeaverseInternal, type WeaverseLoaderData, type WeaverseLoaderRequestInfo, type WeaverseMetaObject, type WeaverseProduct, type WeaverseProjectConfigs, type WeaverseStudioQueries, type WithCacheFetchResponse, createWeaverseDataContext, defaultComponents, generateDataFromSchema, getPreviewData, getRequestQueries, getSelectedProductOptions, getWeaverseConfigs, hasError, isFetchProjectPayload, isProjectIdFunction, isThemeSettingsResponse, isValidHydrogenSchema, isWithCacheFetchResponse, registerComponent, useThemeSettings, useWeaverseDataContext, withWeaverse };
|
package/dist/index.d.ts
CHANGED
|
@@ -4,7 +4,8 @@ export { PositionInputValue, WeaverseImage, WeaverseVideo, isBrowser, isIframe,
|
|
|
4
4
|
import { PageType, InspectorGroup, SchemaType, ComponentPresets, SchemaValidationResult } from '@weaverse/schema';
|
|
5
5
|
export * from '@weaverse/schema';
|
|
6
6
|
export { BasicInput, HeadingInput, InputType, InspectorGroup, PageType, SchemaValidationIssue, SchemaValidationResult } from '@weaverse/schema';
|
|
7
|
-
import { createWithCache, I18nBase, HydrogenContext, HydrogenEnv } from '@shopify/hydrogen';
|
|
7
|
+
import { createWithCache, CachingStrategy, I18nBase, HydrogenContext, HydrogenEnv } from '@shopify/hydrogen';
|
|
8
|
+
export { CachingStrategy } from '@shopify/hydrogen';
|
|
8
9
|
import { LoaderFunctionArgs, AppLoadContext } from '@shopify/remix-oxygen';
|
|
9
10
|
import * as React$1 from 'react';
|
|
10
11
|
import { ComponentType, JSX, ForwardRefExoticComponent } from 'react';
|
|
@@ -164,21 +165,14 @@ declare class WeaverseClient {
|
|
|
164
165
|
private isLocalhost;
|
|
165
166
|
private getApiUrl;
|
|
166
167
|
fetchWithCache: <T = unknown>(url: string, options?: RequestInit & {
|
|
167
|
-
strategy?:
|
|
168
|
+
strategy?: CachingStrategy;
|
|
168
169
|
}) => Promise<T>;
|
|
169
|
-
loadThemeSettings: (strategy?:
|
|
170
|
+
loadThemeSettings: (strategy?: CachingStrategy) => Promise<ThemeSettingsResponse>;
|
|
170
171
|
generateFallbackPage: (message: string) => HydrogenPageData;
|
|
171
172
|
loadPage: (params?: LoadPageParams) => Promise<WeaverseLoaderData | null>;
|
|
172
173
|
execComponentLoader: (item: HydrogenComponentData) => Promise<HydrogenComponentData>;
|
|
173
174
|
}
|
|
174
175
|
|
|
175
|
-
type AllCacheOptions = {
|
|
176
|
-
mode?: 'must-revalidate' | 'no-cache' | 'no-store' | 'private' | 'public' | string;
|
|
177
|
-
maxAge?: number;
|
|
178
|
-
staleWhileRevalidate?: number;
|
|
179
|
-
sMaxAge?: number;
|
|
180
|
-
staleIfError?: number;
|
|
181
|
-
};
|
|
182
176
|
type ComponentLoaderArgs<T = any, _E = any> = {
|
|
183
177
|
data: T;
|
|
184
178
|
weaverse: WeaverseClient;
|
|
@@ -294,6 +288,11 @@ type HydrogenPageAssignment = {
|
|
|
294
288
|
type: PageType;
|
|
295
289
|
handle: string;
|
|
296
290
|
locale: string;
|
|
291
|
+
meta?: {
|
|
292
|
+
inherited: boolean;
|
|
293
|
+
sourceProjectId: string;
|
|
294
|
+
depth: number;
|
|
295
|
+
};
|
|
297
296
|
};
|
|
298
297
|
type WeaverseLoaderData = {
|
|
299
298
|
configs: Omit<WeaverseProjectConfigs, 'publicEnv'> & {
|
|
@@ -655,7 +654,7 @@ type LoadPageParams = {
|
|
|
655
654
|
* - Long-lived cache for static pages (1 hour+)
|
|
656
655
|
* - Short-lived cache for frequently updated content (5 minutes)
|
|
657
656
|
*/
|
|
658
|
-
strategy?:
|
|
657
|
+
strategy?: CachingStrategy;
|
|
659
658
|
/**
|
|
660
659
|
* Optional project override for this specific page load.
|
|
661
660
|
*
|
|
@@ -775,4 +774,4 @@ declare const IMAGES_PLACEHOLDERS: {
|
|
|
775
774
|
product_18: string;
|
|
776
775
|
};
|
|
777
776
|
|
|
778
|
-
export { type
|
|
777
|
+
export { type CacheResponseValidator, type ComponentLoaderArgs, type CreateHydrogenSchemaOptions, type DirectFetchResponse, type FetchProjectPayload, type FetchProjectRequestBody, type HydrogenComponent, type HydrogenComponentData, type HydrogenComponentPresets, type HydrogenComponentProps, type HydrogenComponentSchema, type HydrogenElement, type HydrogenPageAssignment, type HydrogenPageData, type HydrogenProjectType, type HydrogenSchemaValidationResult, type HydrogenThemeSchema, type HydrogenThemeSettings, IMAGES_PLACEHOLDERS, type LoadPageParams, type ProjectIdValidationResult, type ProjectIdValue, type PublicEnv, type RouteLoaderArgs, type ThemeSettingsResponse, type WeaverseArticle, type WeaverseBlog, WeaverseClient, type WeaverseClientArgs, type WeaverseCollection, type WeaverseDataContext, WeaverseError, WeaverseHydrogen, WeaverseHydrogenItem, type WeaverseHydrogenParams, WeaverseHydrogenRoot, type WeaverseI18n, type WeaverseInternal, type WeaverseLoaderData, type WeaverseLoaderRequestInfo, type WeaverseMetaObject, type WeaverseProduct, type WeaverseProjectConfigs, type WeaverseStudioQueries, type WithCacheFetchResponse, createWeaverseDataContext, defaultComponents, generateDataFromSchema, getPreviewData, getRequestQueries, getSelectedProductOptions, getWeaverseConfigs, hasError, isFetchProjectPayload, isProjectIdFunction, isThemeSettingsResponse, isValidHydrogenSchema, isWithCacheFetchResponse, registerComponent, useThemeSettings, useWeaverseDataContext, withWeaverse };
|
package/dist/index.js
CHANGED
|
@@ -354,15 +354,14 @@ function useStudio(weaverse) {
|
|
|
354
354
|
usePixel(weaverse);
|
|
355
355
|
}
|
|
356
356
|
function usePixel(context) {
|
|
357
|
-
let { projectId, pageId, isDesignMode } = context;
|
|
357
|
+
let { projectId, pageId, isDesignMode, weaverseHost } = context;
|
|
358
358
|
react$1.useEffect(() => {
|
|
359
359
|
if (!(projectId && pageId) || isDesignMode) {
|
|
360
360
|
return;
|
|
361
361
|
}
|
|
362
|
-
let url = "https://edge-usage-tracking-worker.weaverse.workers.dev/api/public/px";
|
|
363
362
|
let img = new Image();
|
|
364
363
|
img.onload = () => img.remove();
|
|
365
|
-
img.src = `${
|
|
364
|
+
img.src = `${weaverseHost}/api/public/px?projectId=${projectId}&pageId=${pageId}`;
|
|
366
365
|
}, []);
|
|
367
366
|
}
|
|
368
367
|
var WeaverseHydrogenItem = class extends react.WeaverseItemStore {
|
|
@@ -590,8 +589,11 @@ var WeaverseClient = class {
|
|
|
590
589
|
* Throws WeaverseError if projectId cannot be resolved.
|
|
591
590
|
*/
|
|
592
591
|
initializeConfigs(args) {
|
|
593
|
-
|
|
594
|
-
|
|
592
|
+
const baseConfigs = getWeaverseConfigs(
|
|
593
|
+
args.request,
|
|
594
|
+
args.env
|
|
595
|
+
);
|
|
596
|
+
const resolvedProjectId = this.resolveProjectIdSync(
|
|
595
597
|
args.projectId,
|
|
596
598
|
args.request,
|
|
597
599
|
args.env,
|
|
@@ -690,7 +692,7 @@ var WeaverseClient = class {
|
|
|
690
692
|
error: "Project ID cannot be empty"
|
|
691
693
|
};
|
|
692
694
|
}
|
|
693
|
-
|
|
695
|
+
const validPattern = /^[a-zA-Z0-9_-]+$/;
|
|
694
696
|
if (!validPattern.test(projectId)) {
|
|
695
697
|
return {
|
|
696
698
|
valid: false,
|
|
@@ -717,7 +719,7 @@ var WeaverseClient = class {
|
|
|
717
719
|
* Used for design mode and preview mode overrides.
|
|
718
720
|
*/
|
|
719
721
|
resolveFromQueryParams(request) {
|
|
720
|
-
|
|
722
|
+
const queries = getRequestQueries(request);
|
|
721
723
|
return queries.weaverseProjectId || null;
|
|
722
724
|
}
|
|
723
725
|
/**
|
|
@@ -735,7 +737,7 @@ var WeaverseClient = class {
|
|
|
735
737
|
);
|
|
736
738
|
}
|
|
737
739
|
try {
|
|
738
|
-
|
|
740
|
+
const result = projectId();
|
|
739
741
|
if (result instanceof Promise) {
|
|
740
742
|
throw new WeaverseError(
|
|
741
743
|
"Async projectId functions must be awaited before passing to WeaverseClient. Use: projectId: await getProjectAsync() instead of: projectId: getProjectAsync",
|
|
@@ -743,8 +745,8 @@ var WeaverseClient = class {
|
|
|
743
745
|
);
|
|
744
746
|
}
|
|
745
747
|
if (result && result.trim() !== "") {
|
|
746
|
-
|
|
747
|
-
|
|
748
|
+
const trimmed = result.trim();
|
|
749
|
+
const validation = this.validateProjectId(trimmed);
|
|
748
750
|
if (validation.valid) {
|
|
749
751
|
return trimmed;
|
|
750
752
|
}
|
|
@@ -773,11 +775,11 @@ var WeaverseClient = class {
|
|
|
773
775
|
if (typeof projectId !== "string") {
|
|
774
776
|
return null;
|
|
775
777
|
}
|
|
776
|
-
|
|
778
|
+
const trimmed = projectId.trim();
|
|
777
779
|
if (trimmed === "") {
|
|
778
780
|
return null;
|
|
779
781
|
}
|
|
780
|
-
|
|
782
|
+
const validation = this.validateProjectId(trimmed);
|
|
781
783
|
if (validation.valid) {
|
|
782
784
|
return trimmed;
|
|
783
785
|
}
|
|
@@ -790,7 +792,7 @@ var WeaverseClient = class {
|
|
|
790
792
|
* Priority 4: Resolve projectId from environment variables.
|
|
791
793
|
*/
|
|
792
794
|
resolveFromEnvironment(baseConfigs, request, env) {
|
|
793
|
-
|
|
795
|
+
const configs = baseConfigs || getWeaverseConfigs(request, env);
|
|
794
796
|
if (configs.projectId && configs.projectId.trim() !== "") {
|
|
795
797
|
return configs.projectId.trim();
|
|
796
798
|
}
|
|
@@ -802,18 +804,18 @@ var WeaverseClient = class {
|
|
|
802
804
|
* Includes 10-second timeout to prevent hanging requests.
|
|
803
805
|
*/
|
|
804
806
|
directFetch = async (url, options = {}, timeoutMs = this.fetchTimeoutMs) => {
|
|
805
|
-
|
|
806
|
-
|
|
807
|
+
const controller = new AbortController();
|
|
808
|
+
const timeoutId = setTimeout(
|
|
807
809
|
() => controller.abort(),
|
|
808
810
|
timeoutMs
|
|
809
811
|
);
|
|
810
812
|
try {
|
|
811
|
-
|
|
813
|
+
const response = await fetch(url, {
|
|
812
814
|
...options,
|
|
813
815
|
signal: controller.signal
|
|
814
816
|
});
|
|
815
817
|
if (!response.ok) {
|
|
816
|
-
|
|
818
|
+
const errorText = await response.text();
|
|
817
819
|
throw new WeaverseError(
|
|
818
820
|
`HTTP ${response.status}: ${response.statusText}`,
|
|
819
821
|
"FETCH_ERROR",
|
|
@@ -821,7 +823,7 @@ var WeaverseClient = class {
|
|
|
821
823
|
{ url, errorText }
|
|
822
824
|
);
|
|
823
825
|
}
|
|
824
|
-
|
|
826
|
+
const data = await response.json();
|
|
825
827
|
return { data, response };
|
|
826
828
|
} catch (err) {
|
|
827
829
|
if (err instanceof WeaverseError) {
|
|
@@ -849,7 +851,7 @@ var WeaverseClient = class {
|
|
|
849
851
|
};
|
|
850
852
|
// Helper method to detect if request is from localhost
|
|
851
853
|
isLocalhost() {
|
|
852
|
-
|
|
854
|
+
const hostname = this.parsedUrl.hostname;
|
|
853
855
|
return hostname === "localhost" || hostname === "127.0.0.1";
|
|
854
856
|
}
|
|
855
857
|
// Helper method for building API URLs consistently
|
|
@@ -861,7 +863,7 @@ var WeaverseClient = class {
|
|
|
861
863
|
return `${weaverseHost}/api/public/${endpoint}`;
|
|
862
864
|
}
|
|
863
865
|
fetchWithCache = async (url, options = {}) => {
|
|
864
|
-
const strategy = options.strategy ||
|
|
866
|
+
const strategy = options.strategy || hydrogen.CacheCustom(DEFAULT_CACHE_STRATEGY);
|
|
865
867
|
const cacheKey = [
|
|
866
868
|
"weaverse-fetch",
|
|
867
869
|
url,
|
|
@@ -885,15 +887,15 @@ var WeaverseClient = class {
|
|
|
885
887
|
return result.data;
|
|
886
888
|
};
|
|
887
889
|
loadThemeSettings = async (strategy) => {
|
|
888
|
-
|
|
890
|
+
const defaultThemeSettings = generateDataFromSchema(this.themeSchema);
|
|
889
891
|
try {
|
|
890
|
-
|
|
891
|
-
|
|
892
|
+
const { configs } = this;
|
|
893
|
+
const { projectId, isDesignMode } = configs;
|
|
892
894
|
if (!projectId) {
|
|
893
895
|
throw new Error("Missing Weaverse projectId!");
|
|
894
896
|
}
|
|
895
|
-
|
|
896
|
-
|
|
897
|
+
const url = this.getApiUrl("project_configs");
|
|
898
|
+
const body = JSON.stringify({ isDesignMode, projectId });
|
|
897
899
|
let data = await this.fetchWithCache(url, {
|
|
898
900
|
method: "POST",
|
|
899
901
|
strategy,
|
|
@@ -949,8 +951,8 @@ var WeaverseClient = class {
|
|
|
949
951
|
}
|
|
950
952
|
return data;
|
|
951
953
|
} catch (error) {
|
|
952
|
-
|
|
953
|
-
|
|
954
|
+
const errorMessage = "Unable to load theme settings";
|
|
955
|
+
const errorDetails = this.extractErrorMessage(error);
|
|
954
956
|
console.error(errorMessage, errorDetails);
|
|
955
957
|
return {
|
|
956
958
|
theme: defaultThemeSettings,
|
|
@@ -960,7 +962,7 @@ var WeaverseClient = class {
|
|
|
960
962
|
}
|
|
961
963
|
};
|
|
962
964
|
generateFallbackPage = (message) => {
|
|
963
|
-
|
|
965
|
+
const rootId = crypto.randomUUID();
|
|
964
966
|
return {
|
|
965
967
|
id: `fallback_page_${Date.now()}`,
|
|
966
968
|
rootId,
|
|
@@ -976,8 +978,8 @@ var WeaverseClient = class {
|
|
|
976
978
|
};
|
|
977
979
|
loadPage = async (params = {}) => {
|
|
978
980
|
try {
|
|
979
|
-
|
|
980
|
-
|
|
981
|
+
const { request, storefront, basePageRequestBody, basePageConfigs } = this;
|
|
982
|
+
const {
|
|
981
983
|
projectId: clientProjectId,
|
|
982
984
|
weaverseHost,
|
|
983
985
|
isPreviewMode,
|
|
@@ -990,7 +992,7 @@ var WeaverseClient = class {
|
|
|
990
992
|
);
|
|
991
993
|
return null;
|
|
992
994
|
}
|
|
993
|
-
|
|
995
|
+
const validation = this.validateProjectId(params.projectId);
|
|
994
996
|
if (!validation.valid) {
|
|
995
997
|
console.error(
|
|
996
998
|
`Route-level projectId validation failed: ${validation.error}`
|
|
@@ -998,22 +1000,22 @@ var WeaverseClient = class {
|
|
|
998
1000
|
return null;
|
|
999
1001
|
}
|
|
1000
1002
|
}
|
|
1001
|
-
|
|
1003
|
+
const effectiveProjectId = params.projectId || clientProjectId;
|
|
1002
1004
|
if (isPreviewMode) {
|
|
1003
1005
|
return getPreviewData(sectionType || "", this.components, weaverseHost);
|
|
1004
1006
|
}
|
|
1005
1007
|
if (!effectiveProjectId) {
|
|
1006
1008
|
throw new Error("Missing Weaverse projectId!");
|
|
1007
1009
|
}
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
+
const { strategy, ...pageLoadParams } = params;
|
|
1011
|
+
const body = {
|
|
1010
1012
|
...basePageRequestBody,
|
|
1011
1013
|
projectId: effectiveProjectId,
|
|
1012
1014
|
// Use effective (potentially overridden) projectId
|
|
1013
1015
|
params: pageLoadParams,
|
|
1014
1016
|
url: request.url
|
|
1015
1017
|
};
|
|
1016
|
-
|
|
1018
|
+
const reqInit = {
|
|
1017
1019
|
method: "POST",
|
|
1018
1020
|
body: JSON.stringify(body),
|
|
1019
1021
|
headers: {
|
|
@@ -1022,14 +1024,15 @@ var WeaverseClient = class {
|
|
|
1022
1024
|
"Accept-Encoding": "gzip, deflate, br"
|
|
1023
1025
|
}
|
|
1024
1026
|
};
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
+
const url = this.getApiUrl("project");
|
|
1028
|
+
const projectData = await this.fetchWithCache(url, {
|
|
1027
1029
|
...reqInit,
|
|
1028
1030
|
strategy
|
|
1029
1031
|
});
|
|
1030
1032
|
if (hasError(projectData)) {
|
|
1031
1033
|
throw new Error(projectData.error);
|
|
1032
1034
|
}
|
|
1035
|
+
console.log("projectData", projectData);
|
|
1033
1036
|
let page;
|
|
1034
1037
|
let project;
|
|
1035
1038
|
let pageAssignment;
|
|
@@ -1042,7 +1045,7 @@ var WeaverseClient = class {
|
|
|
1042
1045
|
"Invalid project data structure received from API, using fallback data",
|
|
1043
1046
|
{ projectId: effectiveProjectId }
|
|
1044
1047
|
);
|
|
1045
|
-
|
|
1048
|
+
const responseData = projectData;
|
|
1046
1049
|
page = responseData?.page;
|
|
1047
1050
|
project = responseData?.project;
|
|
1048
1051
|
pageAssignment = responseData?.pageAssignment;
|
|
@@ -1059,7 +1062,7 @@ var WeaverseClient = class {
|
|
|
1059
1062
|
page = this.generateFallbackPage("Please add new section to start.");
|
|
1060
1063
|
}
|
|
1061
1064
|
if (page?.items) {
|
|
1062
|
-
|
|
1065
|
+
const items = page.items;
|
|
1063
1066
|
page.items = await Promise.all(items.map(this.execComponentLoader));
|
|
1064
1067
|
}
|
|
1065
1068
|
return {
|
|
@@ -1077,8 +1080,8 @@ var WeaverseClient = class {
|
|
|
1077
1080
|
}
|
|
1078
1081
|
};
|
|
1079
1082
|
} catch (error) {
|
|
1080
|
-
|
|
1081
|
-
|
|
1083
|
+
const errorMessage = "\u274C Page load failed";
|
|
1084
|
+
const errorContext = {
|
|
1082
1085
|
url: this.request.url,
|
|
1083
1086
|
projectId: params.projectId || this.configs.projectId
|
|
1084
1087
|
};
|
|
@@ -1105,9 +1108,9 @@ var WeaverseClient = class {
|
|
|
1105
1108
|
}
|
|
1106
1109
|
};
|
|
1107
1110
|
execComponentLoader = async (item) => {
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
+
const { data = {}, type, id } = item;
|
|
1112
|
+
const component = this.componentsByType.get(type);
|
|
1113
|
+
const loader = component?.loader;
|
|
1111
1114
|
if (typeof loader === "function" && component) {
|
|
1112
1115
|
try {
|
|
1113
1116
|
return {
|