@builder.io/sdk-qwik 0.5.7 → 0.5.9
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 +127 -137
- package/lib/index.qwik.mjs +128 -138
- package/package.json +1 -1
- package/types/components/content/content.types.d.ts +2 -2
- package/types/components/content-variants/content-variants.d.ts +2 -2
- package/types/components/content-variants/content-variants.types.d.ts +1 -1
- package/types/constants/sdk-version.d.ts +1 -1
- package/types/functions/evaluate/browser-runtime/browser.d.ts +4 -0
- package/types/functions/evaluate/browser-runtime/index.d.ts +1 -0
- package/types/functions/evaluate/evaluate.d.ts +4 -8
- package/types/functions/evaluate/helpers.d.ts +18 -0
- package/types/functions/evaluate/index.d.ts +1 -1
- package/types/functions/evaluate/node-runtime/index.d.ts +1 -0
- package/types/functions/evaluate/non-node-runtime/acorn-interpreter.d.ts +2 -0
- package/types/functions/evaluate/non-node-runtime/non-node-runtime.d.ts +2 -2
- package/types/functions/fetch-builder-props.d.ts +2 -2
- package/types/index-helpers/blocks-exports.d.ts +1 -1
- package/types/index.d.ts +5 -14
- package/types/server-index.d.ts +15 -0
- package/types/src/components/block/components/component-ref/component-ref.helpers.d.ts +1 -1
- package/types/src/components/blocks/blocks.d.ts +1 -1
- package/types/src/components/content/content.types.d.ts +2 -2
- package/types/src/components/content/index.d.ts +1 -1
- package/types/src/components/content-variants/content-variants.d.ts +2 -2
- package/types/src/components/content-variants/content-variants.types.d.ts +1 -1
- package/types/src/constants/sdk-version.d.ts +1 -1
- package/types/src/constants/target.d.ts +1 -1
- package/types/src/functions/evaluate/evaluate.d.ts +4 -8
- package/types/src/functions/evaluate/index.d.ts +1 -1
- package/types/src/functions/evaluate/node-runtime/index.d.ts +1 -1
- package/types/src/functions/evaluate/non-node-runtime/index.d.ts +1 -1
- package/types/src/functions/evaluate/non-node-runtime/non-node-runtime.d.ts +2 -2
- package/types/src/functions/evaluate/placeholder-runtime.d.ts +1 -1
- package/types/src/functions/fetch-builder-props.d.ts +4 -4
- package/types/src/helpers/preview-lru-cache/get.d.ts +1 -1
- package/types/src/helpers/preview-lru-cache/set.d.ts +1 -1
- package/types/src/index-helpers/blocks-exports.d.ts +12 -12
- package/types/src/index.d.ts +5 -14
- package/types/src/server-index.d.ts +15 -0
package/lib/index.qwik.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { componentQrl, inlinedQrl, useStylesScopedQrl, _jsxC, _jsxS, _fnSignal, createContextId, _jsxQ, _jsxBranch, useStore, useComputedQrl, useLexicalScope, _IMMUTABLE, Slot, useContextProvider, useContext, createElement, Fragment as Fragment$1, useSignal, useTaskQrl, useVisibleTaskQrl } from "@builder.io/qwik";
|
|
1
|
+
import { componentQrl, inlinedQrl, useStylesScopedQrl, _jsxC, _jsxS, _fnSignal, createContextId, _jsxQ, _jsxBranch, useStore, useComputedQrl, useLexicalScope, _IMMUTABLE, Slot, useContextProvider, _wrapProp, useContext, createElement, Fragment as Fragment$1, useSignal, useTaskQrl, useVisibleTaskQrl } from "@builder.io/qwik";
|
|
2
2
|
import { Fragment } from "@builder.io/qwik/jsx-runtime";
|
|
3
3
|
const Button = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props) => {
|
|
4
4
|
useStylesScopedQrl(/* @__PURE__ */ inlinedQrl(STYLES$3, "Button_component_useStylesScoped_a1JZ0Q0Q2Oc"));
|
|
@@ -66,12 +66,84 @@ function isIframe() {
|
|
|
66
66
|
function isEditing() {
|
|
67
67
|
return isIframe() && window.location.search.indexOf("builder.frameEditing=") !== -1;
|
|
68
68
|
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
69
|
+
const getLocation = () => {
|
|
70
|
+
if (isBrowser()) {
|
|
71
|
+
const parsedLocation = new URL(location.href);
|
|
72
|
+
if (parsedLocation.pathname === "")
|
|
73
|
+
parsedLocation.pathname = "/";
|
|
74
|
+
return parsedLocation;
|
|
75
|
+
} else {
|
|
76
|
+
console.warn("Cannot get location for tracking in non-browser environment");
|
|
77
|
+
return null;
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
const getUserAgent = () => typeof navigator === "object" && navigator.userAgent || "";
|
|
81
|
+
const getUserAttributes = () => {
|
|
82
|
+
const userAgent = getUserAgent();
|
|
83
|
+
const isMobile = {
|
|
84
|
+
Android() {
|
|
85
|
+
return userAgent.match(/Android/i);
|
|
86
|
+
},
|
|
87
|
+
BlackBerry() {
|
|
88
|
+
return userAgent.match(/BlackBerry/i);
|
|
89
|
+
},
|
|
90
|
+
iOS() {
|
|
91
|
+
return userAgent.match(/iPhone|iPod/i);
|
|
92
|
+
},
|
|
93
|
+
Opera() {
|
|
94
|
+
return userAgent.match(/Opera Mini/i);
|
|
95
|
+
},
|
|
96
|
+
Windows() {
|
|
97
|
+
return userAgent.match(/IEMobile/i) || userAgent.match(/WPDesktop/i);
|
|
98
|
+
},
|
|
99
|
+
any() {
|
|
100
|
+
return isMobile.Android() || isMobile.BlackBerry() || isMobile.iOS() || isMobile.Opera() || isMobile.Windows() || TARGET === "reactNative";
|
|
101
|
+
}
|
|
73
102
|
};
|
|
74
|
-
|
|
103
|
+
const isTablet = userAgent.match(/Tablet|iPad/i);
|
|
104
|
+
const url = getLocation();
|
|
105
|
+
return {
|
|
106
|
+
urlPath: url == null ? void 0 : url.pathname,
|
|
107
|
+
host: (url == null ? void 0 : url.host) || (url == null ? void 0 : url.hostname),
|
|
108
|
+
device: isTablet ? "tablet" : isMobile.any() ? "mobile" : "desktop"
|
|
109
|
+
};
|
|
110
|
+
};
|
|
111
|
+
const getFunctionArguments = ({ builder, context, event, state }) => {
|
|
112
|
+
return Object.entries({
|
|
113
|
+
state,
|
|
114
|
+
Builder: builder,
|
|
115
|
+
// legacy
|
|
116
|
+
builder,
|
|
117
|
+
context,
|
|
118
|
+
event
|
|
119
|
+
});
|
|
120
|
+
};
|
|
121
|
+
const runInBrowser = ({ code, builder, context, event, localState, rootSetState, rootState }) => {
|
|
122
|
+
const functionArgs = getFunctionArguments({
|
|
123
|
+
builder,
|
|
124
|
+
context,
|
|
125
|
+
event,
|
|
126
|
+
state: flattenState(rootState, localState, rootSetState)
|
|
127
|
+
});
|
|
128
|
+
return new Function(...functionArgs.map(([name]) => name), code)(...functionArgs.map(([, value]) => value));
|
|
129
|
+
};
|
|
130
|
+
function flattenState(rootState, localState, rootSetState) {
|
|
131
|
+
if (rootState === localState)
|
|
132
|
+
throw new Error("rootState === localState");
|
|
133
|
+
return new Proxy(rootState, {
|
|
134
|
+
get: (_, prop) => {
|
|
135
|
+
if (localState && prop in localState)
|
|
136
|
+
return localState[prop];
|
|
137
|
+
return rootState[prop];
|
|
138
|
+
},
|
|
139
|
+
set: (_, prop, value) => {
|
|
140
|
+
if (localState && prop in localState)
|
|
141
|
+
throw new Error("Writing to local state is not allowed as it is read-only.");
|
|
142
|
+
rootState[prop] = value;
|
|
143
|
+
rootSetState == null ? void 0 : rootSetState(rootState);
|
|
144
|
+
return true;
|
|
145
|
+
}
|
|
146
|
+
});
|
|
75
147
|
}
|
|
76
148
|
const set = (obj, _path, value) => {
|
|
77
149
|
if (Object(obj) !== obj)
|
|
@@ -3260,20 +3332,19 @@ const processCode = (code) => {
|
|
|
3260
3332
|
}).filter(Boolean).join("\n");
|
|
3261
3333
|
};
|
|
3262
3334
|
const getJSONValName = (val) => val + "JSON";
|
|
3263
|
-
const runInNonNode = ({ builder, context, event, rootState, localState, rootSetState,
|
|
3335
|
+
const runInNonNode = ({ builder, context, event, rootState, localState, rootSetState, code }) => {
|
|
3264
3336
|
const state = {
|
|
3265
3337
|
...rootState,
|
|
3266
3338
|
...localState
|
|
3267
3339
|
};
|
|
3268
|
-
const properties = {
|
|
3269
|
-
state,
|
|
3270
|
-
Builder: builder,
|
|
3340
|
+
const properties = getFunctionArguments({
|
|
3271
3341
|
builder,
|
|
3272
3342
|
context,
|
|
3273
|
-
event
|
|
3274
|
-
|
|
3275
|
-
|
|
3276
|
-
const
|
|
3343
|
+
event,
|
|
3344
|
+
state
|
|
3345
|
+
});
|
|
3346
|
+
const prependedCode = properties.map(([key]) => `var ${key} = JSON.parse(${getJSONValName(key)});`).join("\n");
|
|
3347
|
+
const cleanedCode = processCode(code);
|
|
3277
3348
|
if (cleanedCode === "") {
|
|
3278
3349
|
logger.warn("Skipping evaluation of empty code block.");
|
|
3279
3350
|
return;
|
|
@@ -3291,8 +3362,7 @@ theFunction();
|
|
|
3291
3362
|
rootSetState == null ? void 0 : rootSetState(newState);
|
|
3292
3363
|
};
|
|
3293
3364
|
const initFunc = function(interpreter, globalObject) {
|
|
3294
|
-
|
|
3295
|
-
const val = properties[key] || {};
|
|
3365
|
+
properties.forEach(([key, val]) => {
|
|
3296
3366
|
const jsonVal = JSON.stringify(val);
|
|
3297
3367
|
interpreter.setProperty(globalObject, getJSONValName(key), jsonVal);
|
|
3298
3368
|
});
|
|
@@ -3310,6 +3380,13 @@ theFunction();
|
|
|
3310
3380
|
return;
|
|
3311
3381
|
}
|
|
3312
3382
|
};
|
|
3383
|
+
function isNonNodeServer() {
|
|
3384
|
+
const hasNode = () => {
|
|
3385
|
+
var _a;
|
|
3386
|
+
return typeof process !== "undefined" && ((_a = process == null ? void 0 : process.versions) == null ? void 0 : _a.node);
|
|
3387
|
+
};
|
|
3388
|
+
return !isBrowser() && !hasNode();
|
|
3389
|
+
}
|
|
3313
3390
|
function evaluate({ code, context, localState, rootState, rootSetState, event, isExpression = true }) {
|
|
3314
3391
|
if (code === "") {
|
|
3315
3392
|
logger.warn("Skipping evaluation of empty code block.");
|
|
@@ -3318,7 +3395,8 @@ function evaluate({ code, context, localState, rootState, rootSetState, event, i
|
|
|
3318
3395
|
const builder = {
|
|
3319
3396
|
isEditing: isEditing(),
|
|
3320
3397
|
isBrowser: isBrowser(),
|
|
3321
|
-
isServer: !isBrowser()
|
|
3398
|
+
isServer: !isBrowser(),
|
|
3399
|
+
getUserAttributes: () => getUserAttributes()
|
|
3322
3400
|
};
|
|
3323
3401
|
const useReturn = (
|
|
3324
3402
|
// we disable this for cases where we definitely don't want a return
|
|
@@ -3326,7 +3404,7 @@ function evaluate({ code, context, localState, rootState, rootSetState, event, i
|
|
|
3326
3404
|
);
|
|
3327
3405
|
const useCode = useReturn ? `return (${code});` : code;
|
|
3328
3406
|
const args = {
|
|
3329
|
-
useCode,
|
|
3407
|
+
code: useCode,
|
|
3330
3408
|
builder,
|
|
3331
3409
|
context,
|
|
3332
3410
|
event,
|
|
@@ -3334,40 +3412,18 @@ function evaluate({ code, context, localState, rootState, rootSetState, event, i
|
|
|
3334
3412
|
rootState,
|
|
3335
3413
|
localState
|
|
3336
3414
|
};
|
|
3337
|
-
if (isBrowser())
|
|
3338
|
-
return runInBrowser(args);
|
|
3339
|
-
if (isNonNodeServer())
|
|
3340
|
-
return runInNonNode(args);
|
|
3341
|
-
return runInNode(args);
|
|
3342
|
-
}
|
|
3343
|
-
const runInBrowser = ({ useCode, builder, context, event, localState, rootSetState, rootState }) => {
|
|
3344
|
-
const state = flattenState(rootState, localState, rootSetState);
|
|
3345
3415
|
try {
|
|
3346
|
-
|
|
3416
|
+
if (isBrowser())
|
|
3417
|
+
return runInBrowser(args);
|
|
3418
|
+
if (isNonNodeServer())
|
|
3419
|
+
return runInNonNode(args);
|
|
3420
|
+
return runInBrowser(args);
|
|
3347
3421
|
} catch (e) {
|
|
3348
|
-
logger.
|
|
3422
|
+
logger.error("Failed code evaluation: " + e.message, {
|
|
3423
|
+
code
|
|
3424
|
+
});
|
|
3425
|
+
return void 0;
|
|
3349
3426
|
}
|
|
3350
|
-
};
|
|
3351
|
-
const runInNode = (args) => {
|
|
3352
|
-
return runInBrowser(args);
|
|
3353
|
-
};
|
|
3354
|
-
function flattenState(rootState, localState, rootSetState) {
|
|
3355
|
-
if (rootState === localState)
|
|
3356
|
-
throw new Error("rootState === localState");
|
|
3357
|
-
return new Proxy(rootState, {
|
|
3358
|
-
get: (_, prop) => {
|
|
3359
|
-
if (localState && prop in localState)
|
|
3360
|
-
return localState[prop];
|
|
3361
|
-
return rootState[prop];
|
|
3362
|
-
},
|
|
3363
|
-
set: (_, prop, value) => {
|
|
3364
|
-
if (localState && prop in localState)
|
|
3365
|
-
throw new Error("Writing to local state is not allowed as it is read-only.");
|
|
3366
|
-
rootState[prop] = value;
|
|
3367
|
-
rootSetState == null ? void 0 : rootSetState(rootState);
|
|
3368
|
-
return true;
|
|
3369
|
-
}
|
|
3370
|
-
});
|
|
3371
3427
|
}
|
|
3372
3428
|
const fastClone = (obj) => JSON.parse(JSON.stringify(obj));
|
|
3373
3429
|
function transformBlock(block) {
|
|
@@ -3798,11 +3854,9 @@ const ComponentRef = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((pr
|
|
|
3798
3854
|
contextValue: props.context
|
|
3799
3855
|
}),
|
|
3800
3856
|
children: [
|
|
3801
|
-
(props.blockChildren || []).map(
|
|
3857
|
+
(props.blockChildren || []).map((child) => {
|
|
3802
3858
|
return /* @__PURE__ */ _jsxC(Block, {
|
|
3803
|
-
|
|
3804
|
-
return child;
|
|
3805
|
-
},
|
|
3859
|
+
block: child,
|
|
3806
3860
|
get context() {
|
|
3807
3861
|
return props.context;
|
|
3808
3862
|
},
|
|
@@ -3810,7 +3864,6 @@ const ComponentRef = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((pr
|
|
|
3810
3864
|
return props.registeredComponents;
|
|
3811
3865
|
},
|
|
3812
3866
|
[_IMMUTABLE]: {
|
|
3813
|
-
block: _IMMUTABLE,
|
|
3814
3867
|
context: _fnSignal((p0) => p0.context, [
|
|
3815
3868
|
props
|
|
3816
3869
|
], "p0.context"),
|
|
@@ -3820,16 +3873,13 @@ const ComponentRef = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((pr
|
|
|
3820
3873
|
}
|
|
3821
3874
|
}, 3, "block-" + child.id);
|
|
3822
3875
|
}),
|
|
3823
|
-
(props.blockChildren || []).map(
|
|
3876
|
+
(props.blockChildren || []).map((child) => {
|
|
3824
3877
|
return /* @__PURE__ */ _jsxC(BlockStyles, {
|
|
3825
|
-
|
|
3826
|
-
return child;
|
|
3827
|
-
},
|
|
3878
|
+
block: child,
|
|
3828
3879
|
get context() {
|
|
3829
3880
|
return props.context;
|
|
3830
3881
|
},
|
|
3831
3882
|
[_IMMUTABLE]: {
|
|
3832
|
-
block: _IMMUTABLE,
|
|
3833
3883
|
context: _fnSignal((p0) => p0.context, [
|
|
3834
3884
|
props
|
|
3835
3885
|
], "p0.context")
|
|
@@ -3985,7 +4035,7 @@ const Block = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props) =>
|
|
|
3985
4035
|
hasChildren: _IMMUTABLE
|
|
3986
4036
|
}
|
|
3987
4037
|
}, 3, "jN_0") : null,
|
|
3988
|
-
!isEmptyHtmlElement(Tag.value) && repeatItem.value ? (repeatItem.value || []).map(
|
|
4038
|
+
!isEmptyHtmlElement(Tag.value) && repeatItem.value ? (repeatItem.value || []).map((data, index) => {
|
|
3989
4039
|
return /* @__PURE__ */ _jsxC(RepeatedBlock, {
|
|
3990
4040
|
get repeatContext() {
|
|
3991
4041
|
return data.context;
|
|
@@ -3997,11 +4047,11 @@ const Block = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props) =>
|
|
|
3997
4047
|
return props.registeredComponents;
|
|
3998
4048
|
},
|
|
3999
4049
|
[_IMMUTABLE]: {
|
|
4000
|
-
block:
|
|
4050
|
+
block: _wrapProp(data, "block"),
|
|
4001
4051
|
registeredComponents: _fnSignal((p0) => p0.registeredComponents, [
|
|
4002
4052
|
props
|
|
4003
4053
|
], "p0.registeredComponents"),
|
|
4004
|
-
repeatContext:
|
|
4054
|
+
repeatContext: _wrapProp(data, "context")
|
|
4005
4055
|
}
|
|
4006
4056
|
}, 3, index);
|
|
4007
4057
|
}) : null,
|
|
@@ -4019,11 +4069,9 @@ const Block = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props) =>
|
|
|
4019
4069
|
/* @__PURE__ */ _jsxC(ComponentRef, {
|
|
4020
4070
|
...componentRefProps.value
|
|
4021
4071
|
}, 0, "jN_1"),
|
|
4022
|
-
(childrenWithoutParentComponent.value || []).map(
|
|
4072
|
+
(childrenWithoutParentComponent.value || []).map((child) => {
|
|
4023
4073
|
return /* @__PURE__ */ _jsxC(Block, {
|
|
4024
|
-
|
|
4025
|
-
return child;
|
|
4026
|
-
},
|
|
4074
|
+
block: child,
|
|
4027
4075
|
get context() {
|
|
4028
4076
|
return state.childrenContext;
|
|
4029
4077
|
},
|
|
@@ -4031,7 +4079,6 @@ const Block = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props) =>
|
|
|
4031
4079
|
return props.registeredComponents;
|
|
4032
4080
|
},
|
|
4033
4081
|
[_IMMUTABLE]: {
|
|
4034
|
-
block: _IMMUTABLE,
|
|
4035
4082
|
context: _fnSignal((p0) => p0.childrenContext, [
|
|
4036
4083
|
state
|
|
4037
4084
|
], "p0.childrenContext"),
|
|
@@ -4041,16 +4088,13 @@ const Block = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props) =>
|
|
|
4041
4088
|
}
|
|
4042
4089
|
}, 3, "block-" + child.id);
|
|
4043
4090
|
}),
|
|
4044
|
-
(childrenWithoutParentComponent.value || []).map(
|
|
4091
|
+
(childrenWithoutParentComponent.value || []).map((child) => {
|
|
4045
4092
|
return /* @__PURE__ */ _jsxC(BlockStyles, {
|
|
4046
|
-
|
|
4047
|
-
return child;
|
|
4048
|
-
},
|
|
4093
|
+
block: child,
|
|
4049
4094
|
get context() {
|
|
4050
4095
|
return state.childrenContext;
|
|
4051
4096
|
},
|
|
4052
4097
|
[_IMMUTABLE]: {
|
|
4053
|
-
block: _IMMUTABLE,
|
|
4054
4098
|
context: _fnSignal((p0) => p0.childrenContext, [
|
|
4055
4099
|
state
|
|
4056
4100
|
], "p0.childrenContext")
|
|
@@ -4171,11 +4215,9 @@ const Blocks = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props) =
|
|
|
4171
4215
|
return props.styleProp;
|
|
4172
4216
|
},
|
|
4173
4217
|
children: [
|
|
4174
|
-
props.blocks ? (props.blocks || []).map(
|
|
4218
|
+
props.blocks ? (props.blocks || []).map((block) => {
|
|
4175
4219
|
return /* @__PURE__ */ _jsxC(Block, {
|
|
4176
|
-
|
|
4177
|
-
return block;
|
|
4178
|
-
},
|
|
4220
|
+
block,
|
|
4179
4221
|
get context() {
|
|
4180
4222
|
return props.context || builderContext$1;
|
|
4181
4223
|
},
|
|
@@ -4183,7 +4225,6 @@ const Blocks = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props) =
|
|
|
4183
4225
|
return props.registeredComponents || componentsContext.registeredComponents;
|
|
4184
4226
|
},
|
|
4185
4227
|
[_IMMUTABLE]: {
|
|
4186
|
-
block: _IMMUTABLE,
|
|
4187
4228
|
context: _fnSignal((p0, p1) => p1.context || p0, [
|
|
4188
4229
|
builderContext$1,
|
|
4189
4230
|
props
|
|
@@ -4195,16 +4236,13 @@ const Blocks = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props) =
|
|
|
4195
4236
|
}
|
|
4196
4237
|
}, 3, "render-block-" + block.id);
|
|
4197
4238
|
}) : null,
|
|
4198
|
-
props.blocks ? (props.blocks || []).map(
|
|
4239
|
+
props.blocks ? (props.blocks || []).map((block) => {
|
|
4199
4240
|
return /* @__PURE__ */ _jsxC(BlockStyles, {
|
|
4200
|
-
|
|
4201
|
-
return block;
|
|
4202
|
-
},
|
|
4241
|
+
block,
|
|
4203
4242
|
get context() {
|
|
4204
4243
|
return props.context || builderContext$1;
|
|
4205
4244
|
},
|
|
4206
4245
|
[_IMMUTABLE]: {
|
|
4207
|
-
block: _IMMUTABLE,
|
|
4208
4246
|
context: _fnSignal((p0, p1) => p1.context || p0, [
|
|
4209
4247
|
builderContext$1,
|
|
4210
4248
|
props
|
|
@@ -4347,7 +4385,7 @@ const Columns = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props)
|
|
|
4347
4385
|
], "p0.value")
|
|
4348
4386
|
}
|
|
4349
4387
|
}, 3, "c0_0"),
|
|
4350
|
-
(props.columns || []).map(
|
|
4388
|
+
(props.columns || []).map((column, index) => {
|
|
4351
4389
|
return /* @__PURE__ */ createElement("div", {
|
|
4352
4390
|
class: "builder-column div-Columns-2",
|
|
4353
4391
|
style: columnCssVars(props, state, index),
|
|
@@ -4356,9 +4394,7 @@ const Columns = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props)
|
|
|
4356
4394
|
get blocks() {
|
|
4357
4395
|
return column.blocks;
|
|
4358
4396
|
},
|
|
4359
|
-
|
|
4360
|
-
return `component.options.columns.${index}.blocks`;
|
|
4361
|
-
},
|
|
4397
|
+
path: `component.options.columns.${index}.blocks`,
|
|
4362
4398
|
get parent() {
|
|
4363
4399
|
return props.builderBlock.id;
|
|
4364
4400
|
},
|
|
@@ -4374,14 +4410,13 @@ const Columns = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props)
|
|
|
4374
4410
|
return props.builderComponents;
|
|
4375
4411
|
},
|
|
4376
4412
|
[_IMMUTABLE]: {
|
|
4377
|
-
blocks:
|
|
4413
|
+
blocks: _wrapProp(column, "blocks"),
|
|
4378
4414
|
context: _fnSignal((p0) => p0.builderContext, [
|
|
4379
4415
|
props
|
|
4380
4416
|
], "p0.builderContext"),
|
|
4381
4417
|
parent: _fnSignal((p0) => p0.builderBlock.id, [
|
|
4382
4418
|
props
|
|
4383
4419
|
], "p0.builderBlock.id"),
|
|
4384
|
-
path: _IMMUTABLE,
|
|
4385
4420
|
registeredComponents: _fnSignal((p0) => p0.builderComponents, [
|
|
4386
4421
|
props
|
|
4387
4422
|
], "p0.builderComponents"),
|
|
@@ -5782,7 +5817,7 @@ const getDefaultRegisteredComponents = () => [
|
|
|
5782
5817
|
const components = [];
|
|
5783
5818
|
const createRegisterComponentMessage = (info) => ({
|
|
5784
5819
|
type: "builder.registerComponent",
|
|
5785
|
-
data: info
|
|
5820
|
+
data: serializeComponentInfo(info)
|
|
5786
5821
|
});
|
|
5787
5822
|
const serializeFn = (fnValue) => {
|
|
5788
5823
|
const fnStr = fnValue.toString().trim();
|
|
@@ -6182,48 +6217,6 @@ const setVisitorId = ({ id: id2, canTrack }) => setLocalStorageItem({
|
|
|
6182
6217
|
value: id2,
|
|
6183
6218
|
canTrack
|
|
6184
6219
|
});
|
|
6185
|
-
const getLocation = () => {
|
|
6186
|
-
if (isBrowser()) {
|
|
6187
|
-
const parsedLocation = new URL(location.href);
|
|
6188
|
-
if (parsedLocation.pathname === "")
|
|
6189
|
-
parsedLocation.pathname = "/";
|
|
6190
|
-
return parsedLocation;
|
|
6191
|
-
} else {
|
|
6192
|
-
console.warn("Cannot get location for tracking in non-browser environment");
|
|
6193
|
-
return null;
|
|
6194
|
-
}
|
|
6195
|
-
};
|
|
6196
|
-
const getUserAgent = () => typeof navigator === "object" && navigator.userAgent || "";
|
|
6197
|
-
const getUserAttributes = () => {
|
|
6198
|
-
const userAgent = getUserAgent();
|
|
6199
|
-
const isMobile = {
|
|
6200
|
-
Android() {
|
|
6201
|
-
return userAgent.match(/Android/i);
|
|
6202
|
-
},
|
|
6203
|
-
BlackBerry() {
|
|
6204
|
-
return userAgent.match(/BlackBerry/i);
|
|
6205
|
-
},
|
|
6206
|
-
iOS() {
|
|
6207
|
-
return userAgent.match(/iPhone|iPod/i);
|
|
6208
|
-
},
|
|
6209
|
-
Opera() {
|
|
6210
|
-
return userAgent.match(/Opera Mini/i);
|
|
6211
|
-
},
|
|
6212
|
-
Windows() {
|
|
6213
|
-
return userAgent.match(/IEMobile/i) || userAgent.match(/WPDesktop/i);
|
|
6214
|
-
},
|
|
6215
|
-
any() {
|
|
6216
|
-
return isMobile.Android() || isMobile.BlackBerry() || isMobile.iOS() || isMobile.Opera() || isMobile.Windows() || TARGET === "reactNative";
|
|
6217
|
-
}
|
|
6218
|
-
};
|
|
6219
|
-
const isTablet = userAgent.match(/Tablet|iPad/i);
|
|
6220
|
-
const url = getLocation();
|
|
6221
|
-
return {
|
|
6222
|
-
urlPath: url == null ? void 0 : url.pathname,
|
|
6223
|
-
host: (url == null ? void 0 : url.host) || (url == null ? void 0 : url.hostname),
|
|
6224
|
-
device: isTablet ? "tablet" : isMobile.any() ? "mobile" : "desktop"
|
|
6225
|
-
};
|
|
6226
|
-
};
|
|
6227
6220
|
const getTrackingEventData = async ({ canTrack }) => {
|
|
6228
6221
|
if (!canTrack)
|
|
6229
6222
|
return {
|
|
@@ -6336,7 +6329,7 @@ const getInteractionPropertiesForEvent = (event) => {
|
|
|
6336
6329
|
}
|
|
6337
6330
|
};
|
|
6338
6331
|
};
|
|
6339
|
-
const SDK_VERSION = "0.5.
|
|
6332
|
+
const SDK_VERSION = "0.5.9";
|
|
6340
6333
|
const registry = {};
|
|
6341
6334
|
function register(type, info) {
|
|
6342
6335
|
let typeList = registry[type];
|
|
@@ -6586,7 +6579,7 @@ const emitStateUpdate = function emitStateUpdate2(props, state, elementRef) {
|
|
|
6586
6579
|
if (isEditing())
|
|
6587
6580
|
window.dispatchEvent(new CustomEvent("builder:component:stateChange", {
|
|
6588
6581
|
detail: {
|
|
6589
|
-
state: props.builderContextSignal.rootState,
|
|
6582
|
+
state: fastClone(props.builderContextSignal.rootState),
|
|
6590
6583
|
ref: {
|
|
6591
6584
|
name: props.model
|
|
6592
6585
|
}
|
|
@@ -7149,11 +7142,9 @@ const ContentVariants = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl(
|
|
|
7149
7142
|
], "p0.value")
|
|
7150
7143
|
}
|
|
7151
7144
|
}, 3, "XM_2"),
|
|
7152
|
-
(getVariants(props.content) || []).map(
|
|
7145
|
+
(getVariants(props.content) || []).map((variant) => {
|
|
7153
7146
|
return /* @__PURE__ */ _jsxC(ContentComponent, {
|
|
7154
|
-
|
|
7155
|
-
return variant;
|
|
7156
|
-
},
|
|
7147
|
+
content: variant,
|
|
7157
7148
|
showContent: false,
|
|
7158
7149
|
get classNameProp() {
|
|
7159
7150
|
return void 0;
|
|
@@ -7202,7 +7193,6 @@ const ContentVariants = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl(
|
|
|
7202
7193
|
props
|
|
7203
7194
|
], "p0.canTrack"),
|
|
7204
7195
|
classNameProp: _IMMUTABLE,
|
|
7205
|
-
content: _IMMUTABLE,
|
|
7206
7196
|
context: _fnSignal((p0) => p0.context, [
|
|
7207
7197
|
props
|
|
7208
7198
|
], "p0.context"),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { BuilderRenderState } from '../../context/types.js';
|
|
2
2
|
import type { EnforcePartials } from '../../types/enforced-partials.js';
|
|
3
|
-
import type {
|
|
3
|
+
import type { ContentVariantsPrps } from '../content-variants/content-variants.types.js';
|
|
4
4
|
interface InternalRenderProps {
|
|
5
5
|
/**
|
|
6
6
|
* TO-DO: improve qwik generator to not remap this name for non-HTML tags, then name it `className`
|
|
@@ -9,7 +9,7 @@ interface InternalRenderProps {
|
|
|
9
9
|
showContent: boolean;
|
|
10
10
|
isSsrAbTest: boolean;
|
|
11
11
|
}
|
|
12
|
-
export type ContentProps = InternalRenderProps & EnforcePartials<
|
|
12
|
+
export type ContentProps = InternalRenderProps & EnforcePartials<ContentVariantsPrps>;
|
|
13
13
|
export interface BuilderComponentStateChange {
|
|
14
14
|
state: BuilderRenderState;
|
|
15
15
|
ref: {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
type VariantsProviderProps =
|
|
1
|
+
import { ContentVariantsPrps } from "./content-variants.types.js";
|
|
2
|
+
type VariantsProviderProps = ContentVariantsPrps & {
|
|
3
3
|
/**
|
|
4
4
|
* For internal use only. Do not provide this prop.
|
|
5
5
|
*/
|
|
@@ -2,7 +2,7 @@ import type { BuilderRenderContext, RegisteredComponent } from '../../context/ty
|
|
|
2
2
|
import type { ApiVersion } from '../../types/api-version.js';
|
|
3
3
|
import type { BuilderContent } from '../../types/builder-content.js';
|
|
4
4
|
import type { Nullable } from '../../types/typescript.js';
|
|
5
|
-
export interface
|
|
5
|
+
export interface ContentVariantsPrps {
|
|
6
6
|
content?: Nullable<BuilderContent>;
|
|
7
7
|
model?: string;
|
|
8
8
|
data?: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const SDK_VERSION = "0.5.
|
|
1
|
+
export declare const SDK_VERSION = "0.5.9";
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { BuilderRenderState } from '../../../context/types.js';
|
|
2
|
+
import type { ExecutorArgs } from '../helpers.js';
|
|
3
|
+
export declare const runInBrowser: ({ code, builder, context, event, localState, rootSetState, rootState }: ExecutorArgs) => any;
|
|
4
|
+
export declare function flattenState(rootState: Record<string | symbol, any>, localState: Record<string | symbol, any> | undefined, rootSetState: ((rootState: BuilderRenderState) => void) | undefined): BuilderRenderState;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { runInBrowser as evaluator } from './browser.js';
|
|
@@ -1,10 +1,6 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
3
|
-
export declare function evaluate({ code, context, localState, rootState, rootSetState, event, isExpression }: {
|
|
4
|
-
code: string;
|
|
1
|
+
import type { ExecutorArgs } from './helpers.js';
|
|
2
|
+
export type EvaluatorArgs = Omit<ExecutorArgs, 'builder' | 'event'> & {
|
|
5
3
|
event?: Event;
|
|
6
4
|
isExpression?: boolean;
|
|
7
|
-
}
|
|
8
|
-
export declare
|
|
9
|
-
export declare const runInNode: (args: ExecutorArgs) => any;
|
|
10
|
-
export declare function flattenState(rootState: Record<string | symbol, any>, localState: Record<string | symbol, any> | undefined, rootSetState: ((rootState: BuilderRenderState) => void) | undefined): BuilderRenderState;
|
|
5
|
+
};
|
|
6
|
+
export declare function evaluate({ code, context, localState, rootState, rootSetState, event, isExpression }: EvaluatorArgs): any;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { BuilderContextInterface, BuilderRenderState } from '../../context/types.js';
|
|
2
|
+
import type { getUserAttributes } from '../track/helpers.js';
|
|
3
|
+
export type BuilderGlobals = {
|
|
4
|
+
isEditing: boolean | undefined;
|
|
5
|
+
isBrowser: boolean | undefined;
|
|
6
|
+
isServer: boolean | undefined;
|
|
7
|
+
getUserAttributes: typeof getUserAttributes;
|
|
8
|
+
};
|
|
9
|
+
export type ExecutorArgs = Pick<BuilderContextInterface, 'localState' | 'context' | 'rootState' | 'rootSetState'> & {
|
|
10
|
+
code: string;
|
|
11
|
+
builder: BuilderGlobals;
|
|
12
|
+
event: Event | undefined;
|
|
13
|
+
};
|
|
14
|
+
export type Executor = (args: ExecutorArgs) => any;
|
|
15
|
+
export type FunctionArguments = ReturnType<typeof getFunctionArguments>;
|
|
16
|
+
export declare const getFunctionArguments: ({ builder, context, event, state }: Pick<ExecutorArgs, "context" | "builder" | "event"> & {
|
|
17
|
+
state: BuilderRenderState;
|
|
18
|
+
}) => [string, Event | BuilderRenderState | import("../../context/types.js").BuilderRenderContext | BuilderGlobals | undefined][];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { evaluate } from './evaluate';
|
|
1
|
+
export { evaluate } from './evaluate.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { evaluator } from '../browser-runtime/index.js';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { ExecutorArgs } from '../
|
|
2
|
-
export declare const runInNonNode: ({ builder, context, event, rootState, localState, rootSetState,
|
|
1
|
+
import type { ExecutorArgs } from '../helpers.js';
|
|
2
|
+
export declare const runInNonNode: ({ builder, context, event, rootState, localState, rootSetState, code }: ExecutorArgs) => any;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ContentVariantsPrps } from '../components/content-variants/content-variants.types.js';
|
|
2
2
|
import type { Dictionary } from '../types/typescript.js';
|
|
3
3
|
import type { GetContentOptions } from './get-content/types.js';
|
|
4
4
|
type GetBuilderPropsOptions = (Omit<GetContentOptions, 'model'> & {
|
|
@@ -35,5 +35,5 @@ type GetBuilderPropsOptions = (Omit<GetContentOptions, 'model'> & {
|
|
|
35
35
|
/**
|
|
36
36
|
* Fetches builder content, and returns it along with sensible defaults for other props that `Content` needs to render.
|
|
37
37
|
*/
|
|
38
|
-
export declare const fetchBuilderProps: (_args: GetBuilderPropsOptions) => Promise<
|
|
38
|
+
export declare const fetchBuilderProps: (_args: GetBuilderPropsOptions) => Promise<ContentVariantsPrps>;
|
|
39
39
|
export {};
|
|
@@ -16,6 +16,6 @@ export declare const RenderBlocks: import("@builder.io/qwik").Component<import("
|
|
|
16
16
|
/**
|
|
17
17
|
* @deprecated Use `Content` instead.
|
|
18
18
|
*/
|
|
19
|
-
export declare const RenderContent: import("@builder.io/qwik").Component<import("../components/content-variants/content-variants.types.js").
|
|
19
|
+
export declare const RenderContent: import("@builder.io/qwik").Component<import("../components/content-variants/content-variants.types.js").ContentVariantsPrps & {
|
|
20
20
|
__isNestedRender?: boolean | undefined;
|
|
21
21
|
}>;
|
package/types/index.d.ts
CHANGED
|
@@ -1,16 +1,7 @@
|
|
|
1
1
|
export * from './index-helpers/top-of-file.js';
|
|
2
2
|
export * from './index-helpers/blocks-exports.js';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
export
|
|
8
|
-
export { setEditorSettings } from './functions/set-editor-settings.js';
|
|
9
|
-
export type { Settings } from './functions/set-editor-settings.js';
|
|
10
|
-
export { fetchEntries, fetchOneEntry, getAllContent, getContent, _processContentResult } from './functions/get-content/index.js';
|
|
11
|
-
export { getBuilderSearchParams } from './functions/get-builder-search-params/index.js';
|
|
12
|
-
export { track } from './functions/track/index.js';
|
|
13
|
-
export type { RegisteredComponent } from './context/types.js';
|
|
14
|
-
export type { ComponentInfo } from './types/components.js';
|
|
15
|
-
export type { ContentProps } from './components/content/content.types.js';
|
|
16
|
-
export { fetchBuilderProps } from './functions/fetch-builder-props.js';
|
|
3
|
+
/**
|
|
4
|
+
* We have a separate entry point to the SDKs that guarantees no components are being imported. This is useful
|
|
5
|
+
* for React SDK, which would break in the NextJS App directory because the component imports have `use client` in them.
|
|
6
|
+
*/
|
|
7
|
+
export * from './server-index.js';
|