@builder.io/sdk-qwik 0.3.0 → 0.4.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 +1012 -656
- package/lib/index.qwik.mjs +1013 -657
- package/package.json +3 -6
- package/types/components/render-block/render-block.helpers.d.ts +0 -1
- package/types/components/render-block/render-component-with-context.d.ts +3 -0
- package/types/components/render-content/render-content.d.ts +1 -1
- package/types/components/render-content/render-content.types.d.ts +11 -2
- package/types/components/render-content/wrap-component-ref.d.ts +6 -0
- package/types/components/render-content-variants/helpers.d.ts +17 -0
- package/types/components/render-content-variants/render-content-variants.d.ts +3 -0
- package/types/components/render-inlined-styles.d.ts +1 -0
- package/types/constants/sdk-version.d.ts +1 -0
- package/types/context/types.d.ts +17 -2
- package/types/functions/convert-style-object.d.ts +1 -0
- package/types/functions/evaluate.d.ts +4 -3
- package/types/functions/evaluate.test.d.ts +1 -0
- package/types/functions/get-block-actions-handler.d.ts +1 -1
- package/types/functions/get-block-actions.d.ts +1 -1
- package/types/functions/get-block-styles.d.ts +6 -0
- package/types/functions/get-block-tag.d.ts +3 -0
- package/types/functions/get-content/fn.test.d.ts +1 -0
- package/types/functions/get-content/index.d.ts +7 -2
- package/types/functions/get-content/types.d.ts +6 -0
- package/types/functions/get-processed-block.d.ts +2 -2
- package/types/functions/mark-mutable.d.ts +2 -0
- package/types/functions/sanitize-styles.d.ts +4 -0
- package/types/functions/track.d.ts +56 -0
- package/types/helpers/ab-tests.d.ts +8 -7
- package/types/helpers/canTrack.d.ts +1 -0
- package/types/helpers/cookie.d.ts +7 -3
- package/types/helpers/logger.d.ts +1 -0
- package/types/index-helpers/blocks-exports.d.ts +1 -1
- package/types/index.d.ts +8 -7
- package/types/scripts/init-editing.d.ts +1 -0
- package/types/talk/generators-updated.d.ts +1 -0
- package/types/talk/generators.d.ts +6 -0
- package/types/types/builder-content.d.ts +1 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@builder.io/sdk-qwik",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "Builder.io Qwik SDK",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./lib/index.qwik.cjs",
|
|
@@ -22,13 +22,10 @@
|
|
|
22
22
|
},
|
|
23
23
|
"scripts": {
|
|
24
24
|
"typecheck": "tsc --noEmit",
|
|
25
|
-
"build": "tsc && vite build --mode lib"
|
|
26
|
-
"release:patch": "yarn run build && npm version patch && npm publish",
|
|
27
|
-
"release:minor": "yarn run build && npm version minor && npm publish",
|
|
28
|
-
"release:dev": "yarn run build && npm version prerelease && npm publish --tag dev"
|
|
25
|
+
"build": "tsc && vite build --mode lib"
|
|
29
26
|
},
|
|
30
27
|
"devDependencies": {
|
|
31
|
-
"@builder.io/qwik": "^0.
|
|
28
|
+
"@builder.io/qwik": "^1.0.0",
|
|
32
29
|
"@types/node": "latest",
|
|
33
30
|
"typescript": "^4",
|
|
34
31
|
"vite": "^3.0.4"
|
|
@@ -3,7 +3,7 @@ import { Breakpoints, BuilderContent } from "../../types/builder-content.js";
|
|
|
3
3
|
import { RenderContentProps } from "./render-content.types.js";
|
|
4
4
|
export declare const mergeNewContent: (props: any, state: any, elementRef: any, newContent: BuilderContent) => void;
|
|
5
5
|
export declare const setBreakpoints: (props: any, state: any, elementRef: any, breakpoints: Breakpoints) => void;
|
|
6
|
-
export declare const
|
|
6
|
+
export declare const contentSetState: (props: any, state: any, elementRef: any, newRootState: BuilderRenderState) => void;
|
|
7
7
|
export declare const processMessage: (props: any, state: any, elementRef: any, event: MessageEvent) => void;
|
|
8
8
|
export declare const evaluateJsCode: (props: any, state: any, elementRef: any) => void;
|
|
9
9
|
export declare const onClick: (props: any, state: any, elementRef: any, event: any) => void;
|
|
@@ -2,7 +2,7 @@ import type { BuilderRenderContext, RegisteredComponent, BuilderRenderState } fr
|
|
|
2
2
|
import type { BuilderContent } from '../../types/builder-content';
|
|
3
3
|
import type { Nullable } from '../../types/typescript';
|
|
4
4
|
import type { ApiVersion } from '../../types/api-version';
|
|
5
|
-
export
|
|
5
|
+
export interface RenderContentProps {
|
|
6
6
|
content?: Nullable<BuilderContent>;
|
|
7
7
|
model?: string;
|
|
8
8
|
data?: {
|
|
@@ -14,8 +14,17 @@ export type RenderContentProps = {
|
|
|
14
14
|
customComponents?: RegisteredComponent[];
|
|
15
15
|
canTrack?: boolean;
|
|
16
16
|
locale?: string;
|
|
17
|
+
/** @deprecated use `enrich` instead **/
|
|
17
18
|
includeRefs?: boolean;
|
|
18
|
-
|
|
19
|
+
enrich?: boolean;
|
|
20
|
+
/**
|
|
21
|
+
* TO-DO: improve qwik generator to not remap this name for non-HTML tags, then name it `className`
|
|
22
|
+
*/
|
|
23
|
+
classNameProp?: string;
|
|
24
|
+
hideContent?: boolean;
|
|
25
|
+
parentContentId?: string;
|
|
26
|
+
isSsrAbTest?: boolean;
|
|
27
|
+
}
|
|
19
28
|
export interface BuilderComponentStateChange {
|
|
20
29
|
state: BuilderRenderState;
|
|
21
30
|
ref: {
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { Nullable } from '../../helpers/nullable';
|
|
2
|
+
import type { BuilderContent } from '../../types/builder-content';
|
|
3
|
+
export declare const getVariants: (content: Nullable<BuilderContent>) => import("../../types/builder-content").BuilderContentVariation[];
|
|
4
|
+
export declare const checkShouldRunVariants: ({ canTrack, content, }: {
|
|
5
|
+
canTrack: Nullable<boolean>;
|
|
6
|
+
content: Nullable<BuilderContent>;
|
|
7
|
+
}) => boolean;
|
|
8
|
+
type VariantData = {
|
|
9
|
+
id: string;
|
|
10
|
+
testRatio?: number;
|
|
11
|
+
};
|
|
12
|
+
export declare const getVariantsScriptString: (variants: VariantData[], contentId: string) => string;
|
|
13
|
+
export declare const getRenderContentScriptString: ({ parentContentId, contentId, }: {
|
|
14
|
+
contentId: string;
|
|
15
|
+
parentContentId: string;
|
|
16
|
+
}) => string;
|
|
17
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const SDK_VERSION = "0.4.0";
|
package/types/context/types.d.ts
CHANGED
|
@@ -11,8 +11,23 @@ export type BuilderRenderContext = Record<string, unknown>;
|
|
|
11
11
|
export interface BuilderContextInterface {
|
|
12
12
|
content: Nullable<BuilderContent>;
|
|
13
13
|
context: BuilderRenderContext;
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
/**
|
|
15
|
+
* The state of the application.
|
|
16
|
+
*
|
|
17
|
+
* NOTE: see `localState` below to understand how it is different from `rootState`.
|
|
18
|
+
*/
|
|
19
|
+
rootState: BuilderRenderState;
|
|
20
|
+
/**
|
|
21
|
+
* Some frameworks have a `setState` function which needs to be invoked to notify
|
|
22
|
+
* the framework of state change. (other frameworks don't in which case it is `undefined')
|
|
23
|
+
*/
|
|
24
|
+
rootSetState: ((rootState: BuilderRenderState) => void) | undefined;
|
|
25
|
+
/**
|
|
26
|
+
* The local state of the current component. This is different from `rootState` in that
|
|
27
|
+
* it can be a child state created by a repeater containing local state.
|
|
28
|
+
* The `rootState` is where all of the state mutations are actually stored.
|
|
29
|
+
*/
|
|
30
|
+
localState: BuilderRenderState | undefined;
|
|
16
31
|
apiKey: string | null;
|
|
17
32
|
apiVersion: ApiVersion | undefined;
|
|
18
33
|
registeredComponents: RegisteredComponents;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const convertStyleObject: (obj: Partial<CSSStyleDeclaration>) => Partial<CSSStyleDeclaration>;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import type { BuilderContextInterface } from '../context/types.js';
|
|
2
|
-
export declare function evaluate({ code, context,
|
|
1
|
+
import type { BuilderContextInterface, BuilderRenderState } from '../context/types.js';
|
|
2
|
+
export declare function evaluate({ code, context, localState, rootState, rootSetState, event, isExpression, }: {
|
|
3
3
|
code: string;
|
|
4
4
|
event?: Event;
|
|
5
5
|
isExpression?: boolean;
|
|
6
|
-
} & Pick<BuilderContextInterface, '
|
|
6
|
+
} & Pick<BuilderContextInterface, 'localState' | 'context' | 'rootState' | 'rootSetState'>): any;
|
|
7
|
+
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 {};
|
|
@@ -2,4 +2,4 @@ import type { BuilderContextInterface } from '../context/types.js';
|
|
|
2
2
|
import type { BuilderBlock } from '../types/builder-block.js';
|
|
3
3
|
export declare function createEventHandler(value: string, options: {
|
|
4
4
|
block: BuilderBlock;
|
|
5
|
-
} & Pick<BuilderContextInterface, '
|
|
5
|
+
} & Pick<BuilderContextInterface, 'localState' | 'context' | 'rootState' | 'rootSetState'>): (event: Event) => any;
|
|
@@ -5,5 +5,5 @@ type Actions = {
|
|
|
5
5
|
};
|
|
6
6
|
export declare function getBlockActions(options: {
|
|
7
7
|
block: BuilderBlock;
|
|
8
|
-
} & Pick<BuilderContextInterface, '
|
|
8
|
+
} & Pick<BuilderContextInterface, 'localState' | 'context' | 'rootState' | 'rootSetState'>): Actions;
|
|
9
9
|
export {};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { BuilderContextInterface } from '../context/types.js';
|
|
2
|
+
import type { BuilderBlock } from '../types/builder-block.js';
|
|
3
|
+
export declare function getBlockStyles({ block, context, }: {
|
|
4
|
+
block: BuilderBlock;
|
|
5
|
+
context: BuilderContextInterface;
|
|
6
|
+
}): Partial<CSSStyleDeclaration>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
import type { BuilderContent } from '../../types/builder-content.js';
|
|
2
2
|
import type { GetContentOptions } from './types.js';
|
|
3
3
|
export declare function getContent(options: GetContentOptions): Promise<BuilderContent | null>;
|
|
4
|
-
type
|
|
4
|
+
type ContentResults = {
|
|
5
5
|
results: BuilderContent[];
|
|
6
|
-
}
|
|
6
|
+
};
|
|
7
|
+
type ContentResponse = ContentResults | {
|
|
7
8
|
status: number;
|
|
8
9
|
message: string;
|
|
9
10
|
};
|
|
11
|
+
/**
|
|
12
|
+
* Exported only for testing purposes. Should not be used directly.
|
|
13
|
+
*/
|
|
14
|
+
export declare const processContentResult: (options: GetContentOptions, content: ContentResults) => Promise<ContentResults>;
|
|
10
15
|
export declare function getAllContent(options: GetContentOptions): Promise<ContentResponse | null>;
|
|
11
16
|
export {};
|
|
@@ -19,6 +19,7 @@ export interface GetContentOptions {
|
|
|
19
19
|
/**
|
|
20
20
|
* If set to `true`, it will lazy load symbols/references.
|
|
21
21
|
* If set to `false`, it will render the entire content tree eagerly.
|
|
22
|
+
* @deprecated use `enrich` instead
|
|
22
23
|
*/
|
|
23
24
|
noTraverse?: boolean;
|
|
24
25
|
/**
|
|
@@ -30,8 +31,13 @@ export interface GetContentOptions {
|
|
|
30
31
|
canTrack?: boolean;
|
|
31
32
|
/**
|
|
32
33
|
* Include references in the response. Defaults to `true`.
|
|
34
|
+
* @deprecated use `enrich` instead
|
|
33
35
|
*/
|
|
34
36
|
includeRefs?: boolean;
|
|
37
|
+
/**
|
|
38
|
+
* Include multilevel references in the response.
|
|
39
|
+
*/
|
|
40
|
+
enrich?: boolean;
|
|
35
41
|
/**
|
|
36
42
|
* If provided, the API will auto-resolve localized objects to the value of this `locale` key.
|
|
37
43
|
*/
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import type { BuilderContextInterface } from '../context/types.js';
|
|
2
2
|
import type { BuilderBlock } from '../types/builder-block.js';
|
|
3
|
-
export declare function getProcessedBlock({ block, context, shouldEvaluateBindings,
|
|
3
|
+
export declare function getProcessedBlock({ block, context, shouldEvaluateBindings, localState, rootState, rootSetState, }: {
|
|
4
4
|
block: BuilderBlock;
|
|
5
5
|
/**
|
|
6
6
|
* In some cases, we want to avoid evaluating bindings and only want framework-specific block transformation. It is
|
|
7
7
|
* also sometimes too early to consider bindings, e.g. when we might be looking at a repeated block.
|
|
8
8
|
*/
|
|
9
9
|
shouldEvaluateBindings: boolean;
|
|
10
|
-
} & Pick<BuilderContextInterface, '
|
|
10
|
+
} & Pick<BuilderContextInterface, 'localState' | 'context' | 'rootState' | 'rootSetState'>): BuilderBlock;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import type { CanTrack } from '../types/can-track.js';
|
|
2
|
+
interface Event {
|
|
3
|
+
/**
|
|
4
|
+
* The type of your event.
|
|
5
|
+
*
|
|
6
|
+
* Examples: `click`, `conversion`, `pageview`, `impression`
|
|
7
|
+
*/
|
|
8
|
+
type: string;
|
|
9
|
+
data: {
|
|
10
|
+
/**
|
|
11
|
+
* (Optional) The content's ID. Useful if this event pertains to a specific piece of content.
|
|
12
|
+
*/
|
|
13
|
+
contentId?: string;
|
|
14
|
+
/**
|
|
15
|
+
* This is the ID of the space that the content belongs to.
|
|
16
|
+
*/
|
|
17
|
+
ownerId: string;
|
|
18
|
+
/**
|
|
19
|
+
* Stringified JSON object containing any additional metadata you want to track.
|
|
20
|
+
*/
|
|
21
|
+
metadata?: string;
|
|
22
|
+
/**
|
|
23
|
+
* Session ID of the user. This is provided by the SDK by checking session storage.
|
|
24
|
+
*/
|
|
25
|
+
sessionId: string | undefined;
|
|
26
|
+
/**
|
|
27
|
+
* Visitor ID of the user. This is provided by the SDK by checking cookies.
|
|
28
|
+
*/
|
|
29
|
+
visitorId: string | undefined;
|
|
30
|
+
/**
|
|
31
|
+
* (Optional) If running an A/B test, the ID of the variation that the user is in.
|
|
32
|
+
*/
|
|
33
|
+
variationId?: string;
|
|
34
|
+
[index: string]: any;
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
declare type EventProperties = Pick<Event, 'type'> & Pick<Event['data'], 'contentId' | 'variationId'> & {
|
|
38
|
+
/**
|
|
39
|
+
* Your organization's API key.
|
|
40
|
+
*/
|
|
41
|
+
apiKey: Event['data']['ownerId'];
|
|
42
|
+
/**
|
|
43
|
+
* (Optional) metadata that you want to provide with your event.
|
|
44
|
+
*/
|
|
45
|
+
metadata?: {
|
|
46
|
+
[index: string]: any;
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
* (Optional) Any additional (non-metadata) properties to add to the event.
|
|
50
|
+
*/
|
|
51
|
+
[index: string]: any;
|
|
52
|
+
};
|
|
53
|
+
export declare type EventProps = EventProperties & CanTrack;
|
|
54
|
+
export declare function _track(eventProps: EventProps): Promise<void | Response>;
|
|
55
|
+
export declare const track: (args: EventProperties) => Promise<void | Response>;
|
|
56
|
+
export {};
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import type { CanTrack } from '../types/can-track.js';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
2
|
+
import type { BuilderContent } from '../types/builder-content.js';
|
|
3
|
+
import type { Nullable } from '../types/typescript.js';
|
|
4
|
+
export declare const handleABTestingSync: ({ item, canTrack, }: {
|
|
5
|
+
item: Nullable<BuilderContent>;
|
|
6
|
+
} & CanTrack) => Nullable<BuilderContent>;
|
|
7
|
+
export declare const handleABTesting: ({ item, canTrack, }: {
|
|
8
|
+
item: BuilderContent;
|
|
9
|
+
} & CanTrack) => Promise<BuilderContent>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const getDefaultCanTrack: (canTrack?: boolean) => boolean;
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import type { CanTrack } from '../types/can-track.js';
|
|
2
|
+
type GetCookieArgs = {
|
|
3
|
+
name: string;
|
|
4
|
+
} & CanTrack;
|
|
5
|
+
export declare const getCookieSync: ({ name, canTrack, }: GetCookieArgs) => string | undefined;
|
|
2
6
|
/**
|
|
3
7
|
* NOTE: This function is `async` because its react-native override is async. Do not remove the `async` keyword!
|
|
8
|
+
* The sync version is only safe to use in code blocks that `react-native` is guaranteed not to not run.
|
|
4
9
|
*/
|
|
5
|
-
export declare const getCookie: (
|
|
6
|
-
name: string;
|
|
7
|
-
} & CanTrack) => Promise<string | undefined>;
|
|
10
|
+
export declare const getCookie: (args: GetCookieArgs) => Promise<string | undefined>;
|
|
8
11
|
/**
|
|
9
12
|
* NOTE: This function is `async` because its react-native override is async. Do not remove the `async` keyword!
|
|
10
13
|
*/
|
|
@@ -13,3 +16,4 @@ export declare const setCookie: ({ name, value, expires, canTrack, }: {
|
|
|
13
16
|
value: string;
|
|
14
17
|
expires?: Date | undefined;
|
|
15
18
|
} & CanTrack) => Promise<void>;
|
|
19
|
+
export {};
|
|
@@ -3,8 +3,8 @@ export { default as Columns } from '../blocks/columns/columns';
|
|
|
3
3
|
export { default as Fragment } from '../blocks/fragment/fragment';
|
|
4
4
|
export { default as Image } from '../blocks/image/image';
|
|
5
5
|
export { default as RenderBlocks } from '../components/render-blocks';
|
|
6
|
-
export { default as RenderContent } from '../components/render-content/render-content';
|
|
7
6
|
export { default as Section } from '../blocks/section/section';
|
|
8
7
|
export { default as Symbol } from '../blocks/symbol/symbol';
|
|
9
8
|
export { default as Text } from '../blocks/text/text';
|
|
10
9
|
export { default as Video } from '../blocks/video/video';
|
|
10
|
+
export { default as RenderContent } from '../components/render-content-variants/render-content-variants';
|
package/types/index.d.ts
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
export * from './index-helpers/top-of-file.js';
|
|
2
2
|
export * from './index-helpers/blocks-exports.js';
|
|
3
|
-
export
|
|
4
|
-
export
|
|
5
|
-
export
|
|
6
|
-
export
|
|
7
|
-
export
|
|
8
|
-
export
|
|
9
|
-
export
|
|
3
|
+
export { isEditing } from './functions/is-editing.js';
|
|
4
|
+
export { isPreviewing } from './functions/is-previewing.js';
|
|
5
|
+
export { createRegisterComponentMessage } from './functions/register-component.js';
|
|
6
|
+
export { register } from './functions/register.js';
|
|
7
|
+
export type { InsertMenuConfig, InsertMenuItem } from './functions/register.js';
|
|
8
|
+
export { setEditorSettings } from './functions/set-editor-settings.js';
|
|
9
|
+
export type { Settings } from './functions/set-editor-settings.js';
|
|
10
|
+
export { getAllContent, getContent, processContentResult, } from './functions/get-content/index.js';
|
|
10
11
|
export { track } from './functions/track/index.js';
|
|
11
12
|
export type { RegisteredComponent } from './context/types';
|
|
12
13
|
export type { ComponentInfo } from './types/components';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
declare const ON_MOUNT_CODE: "\n Object.values(props.customComponents).forEach((registeredComponent) => {\n sendComponentToVisualEditor(registeredComponent);\n });\n";
|
|
2
|
+
declare const REACT_CODE: string;
|
|
3
|
+
declare const VUE_CODE: string;
|
|
4
|
+
declare const SVELTE_CODE: string;
|
|
5
|
+
declare const SOLIDJS_CODE: string;
|
|
6
|
+
declare const QWIK_CODE: string;
|
|
@@ -30,8 +30,6 @@ export interface BuilderContentVariation {
|
|
|
30
30
|
}
|
|
31
31
|
export interface BuilderContent extends BuilderContentVariation {
|
|
32
32
|
'@version'?: number;
|
|
33
|
-
id?: string;
|
|
34
|
-
name?: string;
|
|
35
33
|
published?: 'published' | 'draft' | 'archived';
|
|
36
34
|
modelId?: string;
|
|
37
35
|
priority?: number;
|
|
@@ -39,7 +37,7 @@ export interface BuilderContent extends BuilderContentVariation {
|
|
|
39
37
|
startDate?: number;
|
|
40
38
|
endDate?: number;
|
|
41
39
|
variations?: {
|
|
42
|
-
[id: string]: BuilderContentVariation
|
|
40
|
+
[id: string]: BuilderContentVariation;
|
|
43
41
|
};
|
|
44
42
|
testVariationId?: string;
|
|
45
43
|
testVariationName?: string;
|