@builder.io/sdk-svelte 0.5.4 → 0.5.5
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/package/--package.json +1 -1
- package/package/CHANGELOG.md +4 -0
- package/package/helpers/preview-lru-cache/get.d.ts +2 -1
- package/package/helpers/preview-lru-cache/get.js +2 -6
- package/package/helpers/preview-lru-cache/helpers.d.ts +0 -1
- package/package/helpers/preview-lru-cache/helpers.js +1 -9
- package/package/helpers/preview-lru-cache/init.js +1 -10
- package/package/helpers/preview-lru-cache/set.js +0 -4
- package/package/helpers/preview-lru-cache/types.d.ts +0 -12
- package/package/helpers/preview-lru-cache/types.js +1 -6
- package/package.json +1 -1
- package/src/helpers/preview-lru-cache/get.ts +3 -7
- package/src/helpers/preview-lru-cache/helpers.ts +0 -9
- package/src/helpers/preview-lru-cache/init.ts +1 -11
- package/src/helpers/preview-lru-cache/set.ts +0 -6
- package/src/helpers/preview-lru-cache/types.ts +0 -12
package/package/--package.json
CHANGED
package/package/CHANGELOG.md
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import type { BuilderContent } from '../../types/builder-content';
|
|
2
|
+
export declare function getPreviewContent(_searchParams: URLSearchParams): BuilderContent | undefined;
|
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export function getPreviewContent(searchParams) {
|
|
4
|
-
init();
|
|
5
|
-
const id = getIdFromSearchParams(searchParams);
|
|
6
|
-
return typeof id === 'string' ? globalThis._BUILDER_PREVIEW_LRU_CACHE.get(id) : undefined;
|
|
1
|
+
export function getPreviewContent(_searchParams) {
|
|
2
|
+
return undefined;
|
|
7
3
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const getIdFromSearchParams: (searchParams: URLSearchParams) => string | null;
|
|
@@ -1,9 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export const getIdFromSearchParams = (searchParams) => {
|
|
3
|
-
const previewedModel = searchParams.get('preview');
|
|
4
|
-
const previewedId = searchParams.get('overrides.' + previewedModel);
|
|
5
|
-
if (!previewedId) {
|
|
6
|
-
logger.warn('No previewed ID found in search params.');
|
|
7
|
-
}
|
|
8
|
-
return previewedId;
|
|
9
|
-
};
|
|
1
|
+
"use strict";
|
|
@@ -3,13 +3,4 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Note: This logic is only used by the NextJS SDK.
|
|
5
5
|
*/
|
|
6
|
-
|
|
7
|
-
export function init() {
|
|
8
|
-
if (!globalThis._BUILDER_PREVIEW_LRU_CACHE) {
|
|
9
|
-
globalThis._BUILDER_PREVIEW_LRU_CACHE = new LRUCache({
|
|
10
|
-
max: 500,
|
|
11
|
-
// how long to live in ms
|
|
12
|
-
ttl: 1000 * 60 * 5
|
|
13
|
-
});
|
|
14
|
-
}
|
|
15
|
-
}
|
|
6
|
+
export function init() { }
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This is an LRU cache to hold preview content on the server-side.
|
|
3
|
-
*
|
|
4
|
-
* Note: This logic is only used by the NextJS SDK.
|
|
5
|
-
*/
|
|
6
|
-
import type { LRUCache } from 'lru-cache';
|
|
7
|
-
import type { BuilderContent } from '../../types/builder-content';
|
|
8
|
-
type BuilderLRUCache = LRUCache<string, BuilderContent>;
|
|
9
|
-
export type GlobalWCache = typeof globalThis & {
|
|
10
|
-
_BUILDER_PREVIEW_LRU_CACHE: BuilderLRUCache;
|
|
11
|
-
};
|
|
12
|
-
export {};
|
package/package.json
CHANGED
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
export function getPreviewContent(searchParams: URLSearchParams) {
|
|
5
|
-
init();
|
|
6
|
-
const id = getIdFromSearchParams(searchParams);
|
|
7
|
-
return typeof id === 'string' ? (globalThis as GlobalWCache)._BUILDER_PREVIEW_LRU_CACHE.get(id) : undefined;
|
|
1
|
+
import type { BuilderContent } from '../../types/builder-content';
|
|
2
|
+
export function getPreviewContent(_searchParams: URLSearchParams): BuilderContent | undefined {
|
|
3
|
+
return undefined;
|
|
8
4
|
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { logger } from '../logger';
|
|
2
|
-
export const getIdFromSearchParams = (searchParams: URLSearchParams) => {
|
|
3
|
-
const previewedModel = searchParams.get('preview');
|
|
4
|
-
const previewedId = searchParams.get('overrides.' + previewedModel);
|
|
5
|
-
if (!previewedId) {
|
|
6
|
-
logger.warn('No previewed ID found in search params.');
|
|
7
|
-
}
|
|
8
|
-
return previewedId;
|
|
9
|
-
}
|
|
@@ -4,14 +4,4 @@
|
|
|
4
4
|
* Note: This logic is only used by the NextJS SDK.
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
import type { GlobalWCache } from './types';
|
|
9
|
-
export function init() {
|
|
10
|
-
if (!(globalThis as GlobalWCache)._BUILDER_PREVIEW_LRU_CACHE) {
|
|
11
|
-
(globalThis as GlobalWCache)._BUILDER_PREVIEW_LRU_CACHE = new LRUCache({
|
|
12
|
-
max: 500,
|
|
13
|
-
// how long to live in ms
|
|
14
|
-
ttl: 1000 * 60 * 5
|
|
15
|
-
});
|
|
16
|
-
}
|
|
17
|
-
}
|
|
7
|
+
export function init() {}
|
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
'use server';
|
|
2
|
-
|
|
3
1
|
import type { BuilderContent } from '../../types/builder-content';
|
|
4
|
-
import { init } from './init';
|
|
5
|
-
import type { GlobalWCache } from './types';
|
|
6
2
|
export async function postPreviewContent({
|
|
7
3
|
key,
|
|
8
4
|
value
|
|
@@ -10,8 +6,6 @@ export async function postPreviewContent({
|
|
|
10
6
|
key: string;
|
|
11
7
|
value: BuilderContent;
|
|
12
8
|
}) {
|
|
13
|
-
init();
|
|
14
|
-
(globalThis as GlobalWCache)._BUILDER_PREVIEW_LRU_CACHE.set(key, value);
|
|
15
9
|
return {
|
|
16
10
|
[key]: value
|
|
17
11
|
};
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This is an LRU cache to hold preview content on the server-side.
|
|
3
|
-
*
|
|
4
|
-
* Note: This logic is only used by the NextJS SDK.
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
import type { LRUCache } from 'lru-cache';
|
|
8
|
-
import type { BuilderContent } from '../../types/builder-content';
|
|
9
|
-
type BuilderLRUCache = LRUCache<string, BuilderContent>;
|
|
10
|
-
export type GlobalWCache = typeof globalThis & {
|
|
11
|
-
_BUILDER_PREVIEW_LRU_CACHE: BuilderLRUCache;
|
|
12
|
-
}
|