@builder.io/sdk-qwik 0.0.6 → 0.0.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/README.md +65 -2
- package/lib/index.97024df8.js +80165 -0
- package/lib/index.d8c1e37f.cjs +80165 -0
- package/lib/index.qwik.cjs +2521 -0
- package/lib/index.qwik.mjs +2521 -0
- package/package.json +1 -1
- package/src/components/render-content/render-content.jsx +22 -1
- package/src/scripts/init-editing.js +4 -5
- package/types.d.ts +7 -12
- package/root.json +0 -1176
package/package.json
CHANGED
|
@@ -14,6 +14,10 @@ import {
|
|
|
14
14
|
createRegisterComponentMessage,
|
|
15
15
|
} from "../../functions/register-component.js";
|
|
16
16
|
import { track } from "../../functions/track.js";
|
|
17
|
+
import {
|
|
18
|
+
registerInsertMenu,
|
|
19
|
+
setupBrowserForEditing,
|
|
20
|
+
} from "../../scripts/init-editing.js";
|
|
17
21
|
import RenderBlocks from "../render-blocks";
|
|
18
22
|
import RenderContentStyles from "./components/render-styles";
|
|
19
23
|
import {
|
|
@@ -186,6 +190,7 @@ export const shouldRenderContentStyles = function shouldRenderContentStyles(
|
|
|
186
190
|
export const RenderContent = component$((props) => {
|
|
187
191
|
const hostElement = useHostElement();
|
|
188
192
|
const state = useStore({
|
|
193
|
+
forceReRenderCount: 0,
|
|
189
194
|
overrideContent: null,
|
|
190
195
|
update: 0,
|
|
191
196
|
overrideState: {},
|
|
@@ -213,7 +218,11 @@ export const RenderContent = component$((props) => {
|
|
|
213
218
|
useClientEffect$(() => {
|
|
214
219
|
if (isBrowser()) {
|
|
215
220
|
if (isEditing()) {
|
|
221
|
+
state.forceReRenderCount++;
|
|
216
222
|
_useMutableProps(hostElement, true);
|
|
223
|
+
|
|
224
|
+
registerInsertMenu();
|
|
225
|
+
setupBrowserForEditing();
|
|
217
226
|
Object.values(allRegisteredComponents(props, state)).forEach(
|
|
218
227
|
(registeredComponent) => {
|
|
219
228
|
const message = createRegisterComponentMessage(registeredComponent);
|
|
@@ -303,6 +312,7 @@ export const RenderContent = component$((props) => {
|
|
|
303
312
|
) : null}
|
|
304
313
|
<RenderBlocks
|
|
305
314
|
blocks={useContent(props, state)?.data?.blocks}
|
|
315
|
+
key={state.forceReRenderCount}
|
|
306
316
|
></RenderBlocks>
|
|
307
317
|
</div>
|
|
308
318
|
) : null}
|
|
@@ -392,6 +402,13 @@ export const COMPONENT = {
|
|
|
392
402
|
},
|
|
393
403
|
path: "./components/render-styles.lite",
|
|
394
404
|
},
|
|
405
|
+
{
|
|
406
|
+
imports: {
|
|
407
|
+
registerInsertMenu: "registerInsertMenu",
|
|
408
|
+
setupBrowserForEditing: "setupBrowserForEditing",
|
|
409
|
+
},
|
|
410
|
+
path: "../../scripts/init-editing.js",
|
|
411
|
+
},
|
|
395
412
|
],
|
|
396
413
|
exports: {},
|
|
397
414
|
inputs: [],
|
|
@@ -413,6 +430,7 @@ export const COMPONENT = {
|
|
|
413
430
|
},
|
|
414
431
|
refs: {},
|
|
415
432
|
state: {
|
|
433
|
+
forceReRenderCount: 0,
|
|
416
434
|
useContent:
|
|
417
435
|
"@builder.io/mitosis/method:get useContent() {\n const mergedContent: BuilderContent = { ...props.content,\n ...state.overrideContent,\n data: { ...props.content?.data,\n ...props.data,\n ...state.overrideContent?.data\n }\n };\n return mergedContent;\n}",
|
|
418
436
|
overrideContent: null,
|
|
@@ -545,6 +563,9 @@ export const COMPONENT = {
|
|
|
545
563
|
blocks: {
|
|
546
564
|
code: "useContent(props,state)?.data?.blocks",
|
|
547
565
|
},
|
|
566
|
+
key: {
|
|
567
|
+
code: "state.forceReRenderCount",
|
|
568
|
+
},
|
|
548
569
|
},
|
|
549
570
|
children: [],
|
|
550
571
|
},
|
|
@@ -577,7 +598,7 @@ export const COMPONENT = {
|
|
|
577
598
|
],
|
|
578
599
|
hooks: {
|
|
579
600
|
onMount: {
|
|
580
|
-
code: "\n if (isBrowser()) {\n if (isEditing()) {\n _useMutableProps(hostElement, true);\n Object.values(allRegisteredComponents(props,state)).forEach(registeredComponent => {\n const message = createRegisterComponentMessage(registeredComponent);\n window.parent?.postMessage(message, '*');\n });\n window.addEventListener('message', processMessage.bind(null,props,state));\n window.addEventListener('builder:component:stateChangeListenerActivated', emitStateUpdate.bind(null,props,state));\n }\n\n if (useContent(props,state) && props.canTrack !== false) {\n track('impression', {\n contentId: useContent(props,state).id\n });\n } // override normal content in preview mode\n\n\n if (isPreviewing()) {\n const searchParams = new URL(location.href).searchParams;\n\n if (props.model && searchParams.get('builder.preview') === props.model) {\n const previewApiKey = searchParams.get('apiKey') || searchParams.get('builder.space');\n\n if (previewApiKey) {\n getContent({\n model: props.model,\n apiKey: previewApiKey\n }).then(content => {\n if (content) {\n state.overrideContent = content;\n }\n });\n }\n }\n }\n\n evaluateJsCode(props,state,);\n runHttpRequests(props,state,);\n emitStateUpdate(props,state,);\n }\n",
|
|
601
|
+
code: "\n if (isBrowser()) {\n if (isEditing()) {\n state.forceReRenderCount++; _useMutableProps(hostElement, true);\n\n registerInsertMenu();\n setupBrowserForEditing();\n Object.values(allRegisteredComponents(props,state)).forEach(registeredComponent => {\n const message = createRegisterComponentMessage(registeredComponent);\n window.parent?.postMessage(message, '*');\n });\n window.addEventListener('message', processMessage.bind(null,props,state));\n window.addEventListener('builder:component:stateChangeListenerActivated', emitStateUpdate.bind(null,props,state));\n }\n\n if (useContent(props,state) && props.canTrack !== false) {\n track('impression', {\n contentId: useContent(props,state).id\n });\n } // override normal content in preview mode\n\n\n if (isPreviewing()) {\n const searchParams = new URL(location.href).searchParams;\n\n if (props.model && searchParams.get('builder.preview') === props.model) {\n const previewApiKey = searchParams.get('apiKey') || searchParams.get('builder.space');\n\n if (previewApiKey) {\n getContent({\n model: props.model,\n apiKey: previewApiKey\n }).then(content => {\n if (content) {\n state.overrideContent = content;\n }\n });\n }\n }\n }\n\n evaluateJsCode(props,state,);\n runHttpRequests(props,state,);\n emitStateUpdate(props,state,);\n }\n",
|
|
581
602
|
},
|
|
582
603
|
onUpdate: [
|
|
583
604
|
{
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { TARGET } from "../constants/target.js";
|
|
2
2
|
import { isBrowser } from "../functions/is-browser.js";
|
|
3
|
-
import { isEditing } from "../functions/is-editing.js";
|
|
4
3
|
import { register } from "../functions/register.js";
|
|
5
4
|
const registerInsertMenu = () => {
|
|
6
5
|
register("insertMenu", {
|
|
@@ -74,7 +73,7 @@ const setupBrowserForEditing = () => {
|
|
|
74
73
|
});
|
|
75
74
|
}
|
|
76
75
|
};
|
|
77
|
-
|
|
78
|
-
registerInsertMenu
|
|
79
|
-
setupBrowserForEditing
|
|
80
|
-
}
|
|
76
|
+
export {
|
|
77
|
+
registerInsertMenu,
|
|
78
|
+
setupBrowserForEditing
|
|
79
|
+
};
|
package/types.d.ts
CHANGED
|
@@ -1,13 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
declare const get: (obj: any, key: string) => any;
|
|
9
|
-
declare const set: (obj: any, key: string, value: any) => void;
|
|
10
|
-
interface CSSProperties {
|
|
11
|
-
flexDirection: any;
|
|
1
|
+
declare module '@builder.io/sdk-qwik' {
|
|
2
|
+
const getContent: (options: {
|
|
3
|
+
model: string;
|
|
4
|
+
apiKey: string;
|
|
5
|
+
userAttributes: Record<string, string>;
|
|
6
|
+
}) => Promise<any>;
|
|
7
|
+
const RenderContent: any;
|
|
12
8
|
}
|
|
13
|
-
declare const BuilderBlocks: (props: any) => any;
|