@builder.io/sdk-qwik 0.4.6-0 → 0.5.0
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/lib/index.qwik.cjs
CHANGED
|
@@ -45,6 +45,13 @@ function getBlockComponentOptions(block) {
|
|
|
45
45
|
builderBlock: block
|
|
46
46
|
};
|
|
47
47
|
}
|
|
48
|
+
const MSG_PREFIX = "[Builder.io]: ";
|
|
49
|
+
const logger = {
|
|
50
|
+
log: (...message) => console.log(MSG_PREFIX, ...message),
|
|
51
|
+
error: (...message) => console.error(MSG_PREFIX, ...message),
|
|
52
|
+
warn: (...message) => console.warn(MSG_PREFIX, ...message),
|
|
53
|
+
debug: (...message) => console.debug(MSG_PREFIX, ...message)
|
|
54
|
+
};
|
|
48
55
|
function isBrowser() {
|
|
49
56
|
return typeof window !== "undefined" && typeof document !== "undefined";
|
|
50
57
|
}
|
|
@@ -59,13 +66,6 @@ function isNonNodeServer() {
|
|
|
59
66
|
const hasNode = () => typeof process !== "undefined" && process?.versions?.node;
|
|
60
67
|
return !isBrowser() && !hasNode();
|
|
61
68
|
}
|
|
62
|
-
const MSG_PREFIX = "[Builder.io]: ";
|
|
63
|
-
const logger = {
|
|
64
|
-
log: (...message) => console.log(MSG_PREFIX, ...message),
|
|
65
|
-
error: (...message) => console.error(MSG_PREFIX, ...message),
|
|
66
|
-
warn: (...message) => console.warn(MSG_PREFIX, ...message),
|
|
67
|
-
debug: (...message) => console.debug(MSG_PREFIX, ...message)
|
|
68
|
-
};
|
|
69
69
|
const set = (obj, _path, value) => {
|
|
70
70
|
if (Object(obj) !== obj)
|
|
71
71
|
return obj;
|
|
@@ -8099,9 +8099,7 @@ const processCode = (code) => {
|
|
|
8099
8099
|
const setExpr = `setRootState('${setStr}', ${rhs.trim()})`;
|
|
8100
8100
|
return `
|
|
8101
8101
|
${line}
|
|
8102
|
-
|
|
8103
|
-
${setExpr}
|
|
8104
|
-
}
|
|
8102
|
+
${setExpr}
|
|
8105
8103
|
`;
|
|
8106
8104
|
}).filter(Boolean).join("\n");
|
|
8107
8105
|
};
|
|
@@ -8158,14 +8156,13 @@ theFunction();
|
|
|
8158
8156
|
};
|
|
8159
8157
|
function evaluate({ code, context, localState, rootState, rootSetState, event, isExpression = true }) {
|
|
8160
8158
|
if (code === "") {
|
|
8161
|
-
|
|
8159
|
+
logger.warn("Skipping evaluation of empty code block.");
|
|
8162
8160
|
return;
|
|
8163
8161
|
}
|
|
8164
8162
|
const builder = {
|
|
8165
8163
|
isEditing: isEditing(),
|
|
8166
8164
|
isBrowser: isBrowser(),
|
|
8167
|
-
isServer: !isBrowser()
|
|
8168
|
-
isNonNodeRuntime: isNonNodeServer()
|
|
8165
|
+
isServer: !isBrowser()
|
|
8169
8166
|
};
|
|
8170
8167
|
const useReturn = isExpression && !(code.includes(";") || code.includes(" return ") || code.trim().startsWith("return "));
|
|
8171
8168
|
const useCode = useReturn ? `return (${code});` : code;
|
|
@@ -8180,21 +8177,21 @@ function evaluate({ code, context, localState, rootState, rootSetState, event, i
|
|
|
8180
8177
|
};
|
|
8181
8178
|
if (isBrowser())
|
|
8182
8179
|
return runInBrowser(args);
|
|
8183
|
-
|
|
8184
|
-
|
|
8185
|
-
|
|
8186
|
-
localState,
|
|
8187
|
-
rootSetState
|
|
8188
|
-
});
|
|
8180
|
+
if (isNonNodeServer())
|
|
8181
|
+
return runInNonNode(args);
|
|
8182
|
+
return runInNode(args);
|
|
8189
8183
|
}
|
|
8190
8184
|
const runInBrowser = ({ useCode, builder, context, event, localState, rootSetState, rootState }) => {
|
|
8191
8185
|
const state = flattenState(rootState, localState, rootSetState);
|
|
8192
8186
|
try {
|
|
8193
8187
|
return new Function("builder", "Builder", "state", "context", "event", useCode)(builder, builder, state, context, event);
|
|
8194
8188
|
} catch (e) {
|
|
8195
|
-
|
|
8189
|
+
logger.warn("Builder custom code error: \n While Evaluating: \n ", useCode, "\n", e);
|
|
8196
8190
|
}
|
|
8197
8191
|
};
|
|
8192
|
+
const runInNode = (args) => {
|
|
8193
|
+
return runInBrowser(args);
|
|
8194
|
+
};
|
|
8198
8195
|
function flattenState(rootState, localState, rootSetState) {
|
|
8199
8196
|
if (rootState === localState)
|
|
8200
8197
|
throw new Error("rootState === localState");
|
|
@@ -10825,7 +10822,7 @@ async function getContent(options) {
|
|
|
10825
10822
|
...options,
|
|
10826
10823
|
limit: 1
|
|
10827
10824
|
});
|
|
10828
|
-
if (allContent
|
|
10825
|
+
if (allContent)
|
|
10829
10826
|
return allContent.results[0] || null;
|
|
10830
10827
|
return null;
|
|
10831
10828
|
}
|
|
@@ -10865,7 +10862,7 @@ async function getAllContent(options) {
|
|
|
10865
10862
|
content,
|
|
10866
10863
|
options
|
|
10867
10864
|
});
|
|
10868
|
-
return
|
|
10865
|
+
return null;
|
|
10869
10866
|
}
|
|
10870
10867
|
return processContentResult(options, content);
|
|
10871
10868
|
} catch (error) {
|
|
@@ -11112,7 +11109,7 @@ const getInteractionPropertiesForEvent = (event) => {
|
|
|
11112
11109
|
}
|
|
11113
11110
|
};
|
|
11114
11111
|
};
|
|
11115
|
-
const SDK_VERSION = "0.
|
|
11112
|
+
const SDK_VERSION = "0.5.0";
|
|
11116
11113
|
const registry = {};
|
|
11117
11114
|
function register(type, info) {
|
|
11118
11115
|
let typeList = registry[type];
|
package/lib/index.qwik.mjs
CHANGED
|
@@ -43,6 +43,13 @@ function getBlockComponentOptions(block) {
|
|
|
43
43
|
builderBlock: block
|
|
44
44
|
};
|
|
45
45
|
}
|
|
46
|
+
const MSG_PREFIX = "[Builder.io]: ";
|
|
47
|
+
const logger = {
|
|
48
|
+
log: (...message) => console.log(MSG_PREFIX, ...message),
|
|
49
|
+
error: (...message) => console.error(MSG_PREFIX, ...message),
|
|
50
|
+
warn: (...message) => console.warn(MSG_PREFIX, ...message),
|
|
51
|
+
debug: (...message) => console.debug(MSG_PREFIX, ...message)
|
|
52
|
+
};
|
|
46
53
|
function isBrowser() {
|
|
47
54
|
return typeof window !== "undefined" && typeof document !== "undefined";
|
|
48
55
|
}
|
|
@@ -57,13 +64,6 @@ function isNonNodeServer() {
|
|
|
57
64
|
const hasNode = () => typeof process !== "undefined" && process?.versions?.node;
|
|
58
65
|
return !isBrowser() && !hasNode();
|
|
59
66
|
}
|
|
60
|
-
const MSG_PREFIX = "[Builder.io]: ";
|
|
61
|
-
const logger = {
|
|
62
|
-
log: (...message) => console.log(MSG_PREFIX, ...message),
|
|
63
|
-
error: (...message) => console.error(MSG_PREFIX, ...message),
|
|
64
|
-
warn: (...message) => console.warn(MSG_PREFIX, ...message),
|
|
65
|
-
debug: (...message) => console.debug(MSG_PREFIX, ...message)
|
|
66
|
-
};
|
|
67
67
|
const set = (obj, _path, value) => {
|
|
68
68
|
if (Object(obj) !== obj)
|
|
69
69
|
return obj;
|
|
@@ -8097,9 +8097,7 @@ const processCode = (code) => {
|
|
|
8097
8097
|
const setExpr = `setRootState('${setStr}', ${rhs.trim()})`;
|
|
8098
8098
|
return `
|
|
8099
8099
|
${line}
|
|
8100
|
-
|
|
8101
|
-
${setExpr}
|
|
8102
|
-
}
|
|
8100
|
+
${setExpr}
|
|
8103
8101
|
`;
|
|
8104
8102
|
}).filter(Boolean).join("\n");
|
|
8105
8103
|
};
|
|
@@ -8156,14 +8154,13 @@ theFunction();
|
|
|
8156
8154
|
};
|
|
8157
8155
|
function evaluate({ code, context, localState, rootState, rootSetState, event, isExpression = true }) {
|
|
8158
8156
|
if (code === "") {
|
|
8159
|
-
|
|
8157
|
+
logger.warn("Skipping evaluation of empty code block.");
|
|
8160
8158
|
return;
|
|
8161
8159
|
}
|
|
8162
8160
|
const builder = {
|
|
8163
8161
|
isEditing: isEditing(),
|
|
8164
8162
|
isBrowser: isBrowser(),
|
|
8165
|
-
isServer: !isBrowser()
|
|
8166
|
-
isNonNodeRuntime: isNonNodeServer()
|
|
8163
|
+
isServer: !isBrowser()
|
|
8167
8164
|
};
|
|
8168
8165
|
const useReturn = isExpression && !(code.includes(";") || code.includes(" return ") || code.trim().startsWith("return "));
|
|
8169
8166
|
const useCode = useReturn ? `return (${code});` : code;
|
|
@@ -8178,21 +8175,21 @@ function evaluate({ code, context, localState, rootState, rootSetState, event, i
|
|
|
8178
8175
|
};
|
|
8179
8176
|
if (isBrowser())
|
|
8180
8177
|
return runInBrowser(args);
|
|
8181
|
-
|
|
8182
|
-
|
|
8183
|
-
|
|
8184
|
-
localState,
|
|
8185
|
-
rootSetState
|
|
8186
|
-
});
|
|
8178
|
+
if (isNonNodeServer())
|
|
8179
|
+
return runInNonNode(args);
|
|
8180
|
+
return runInNode(args);
|
|
8187
8181
|
}
|
|
8188
8182
|
const runInBrowser = ({ useCode, builder, context, event, localState, rootSetState, rootState }) => {
|
|
8189
8183
|
const state = flattenState(rootState, localState, rootSetState);
|
|
8190
8184
|
try {
|
|
8191
8185
|
return new Function("builder", "Builder", "state", "context", "event", useCode)(builder, builder, state, context, event);
|
|
8192
8186
|
} catch (e) {
|
|
8193
|
-
|
|
8187
|
+
logger.warn("Builder custom code error: \n While Evaluating: \n ", useCode, "\n", e);
|
|
8194
8188
|
}
|
|
8195
8189
|
};
|
|
8190
|
+
const runInNode = (args) => {
|
|
8191
|
+
return runInBrowser(args);
|
|
8192
|
+
};
|
|
8196
8193
|
function flattenState(rootState, localState, rootSetState) {
|
|
8197
8194
|
if (rootState === localState)
|
|
8198
8195
|
throw new Error("rootState === localState");
|
|
@@ -10823,7 +10820,7 @@ async function getContent(options) {
|
|
|
10823
10820
|
...options,
|
|
10824
10821
|
limit: 1
|
|
10825
10822
|
});
|
|
10826
|
-
if (allContent
|
|
10823
|
+
if (allContent)
|
|
10827
10824
|
return allContent.results[0] || null;
|
|
10828
10825
|
return null;
|
|
10829
10826
|
}
|
|
@@ -10863,7 +10860,7 @@ async function getAllContent(options) {
|
|
|
10863
10860
|
content,
|
|
10864
10861
|
options
|
|
10865
10862
|
});
|
|
10866
|
-
return
|
|
10863
|
+
return null;
|
|
10867
10864
|
}
|
|
10868
10865
|
return processContentResult(options, content);
|
|
10869
10866
|
} catch (error) {
|
|
@@ -11110,7 +11107,7 @@ const getInteractionPropertiesForEvent = (event) => {
|
|
|
11110
11107
|
}
|
|
11111
11108
|
};
|
|
11112
11109
|
};
|
|
11113
|
-
const SDK_VERSION = "0.
|
|
11110
|
+
const SDK_VERSION = "0.5.0";
|
|
11114
11111
|
const registry = {};
|
|
11115
11112
|
function register(type, info) {
|
|
11116
11113
|
let typeList = registry[type];
|
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const SDK_VERSION = "0.
|
|
1
|
+
export declare const SDK_VERSION = "0.5.0";
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import type { BuilderContextInterface, BuilderRenderState } from '../../context/types.js';
|
|
2
2
|
import type { ExecutorArgs } from './types.js';
|
|
3
|
-
export declare const isNode: () => boolean;
|
|
4
3
|
export declare function evaluate({ code, context, localState, rootState, rootSetState, event, isExpression }: {
|
|
5
4
|
code: string;
|
|
6
5
|
event?: Event;
|
|
@@ -4,13 +4,9 @@ export declare function getContent(options: GetContentOptions): Promise<BuilderC
|
|
|
4
4
|
type ContentResults = {
|
|
5
5
|
results: BuilderContent[];
|
|
6
6
|
};
|
|
7
|
-
type ContentResponse = ContentResults | {
|
|
8
|
-
status: number;
|
|
9
|
-
message: string;
|
|
10
|
-
};
|
|
11
7
|
/**
|
|
12
8
|
* Exported only for testing purposes. Should not be used directly.
|
|
13
9
|
*/
|
|
14
10
|
export declare const processContentResult: (options: GetContentOptions, content: ContentResults, url?: URL) => Promise<ContentResults>;
|
|
15
|
-
export declare function getAllContent(options: GetContentOptions): Promise<
|
|
11
|
+
export declare function getAllContent(options: GetContentOptions): Promise<ContentResults | null>;
|
|
16
12
|
export {};
|