@builder.io/sdk 1.1.34 → 1.1.35

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.
Files changed (43) hide show
  1. package/CHANGELOG.md +3 -0
  2. package/dist/index.browser.js +1 -1
  3. package/dist/index.browser.js.map +1 -1
  4. package/dist/index.cjs.js +85 -24
  5. package/dist/index.cjs.js.map +1 -1
  6. package/dist/index.d.ts +7 -6
  7. package/dist/index.esm.js +85 -24
  8. package/dist/index.esm.js.map +1 -1
  9. package/dist/index.js.map +1 -1
  10. package/dist/index.umd.js +96 -35
  11. package/dist/index.umd.js.map +1 -1
  12. package/dist/package.json +16 -14
  13. package/dist/src/builder.class.d.ts +842 -837
  14. package/dist/src/builder.class.js +46 -6
  15. package/dist/src/builder.class.js.map +1 -1
  16. package/dist/src/classes/animator.class.d.ts +26 -26
  17. package/dist/src/classes/cookies.class.d.ts +15 -15
  18. package/dist/src/classes/observable.class.d.ts +26 -26
  19. package/dist/src/classes/promise.class.d.ts +17 -17
  20. package/dist/src/classes/query-string.class.d.ts +9 -9
  21. package/dist/src/classes/query-string.class.test.d.ts +1 -1
  22. package/dist/src/constants/builder.d.ts +2 -2
  23. package/dist/src/functions/assign.function.d.ts +1 -1
  24. package/dist/src/functions/fetch.function.d.ts +28 -28
  25. package/dist/src/functions/finder.function.d.ts +10 -10
  26. package/dist/src/functions/finder.function.js +1 -1
  27. package/dist/src/functions/get-top-level-domain.d.ts +6 -6
  28. package/dist/src/functions/next-tick.function.d.ts +1 -1
  29. package/dist/src/functions/omit.function.d.ts +1 -1
  30. package/dist/src/functions/server-only-require.function.d.ts +3 -3
  31. package/dist/src/functions/throttle.function.d.ts +1 -1
  32. package/dist/src/functions/to-error.d.ts +13 -13
  33. package/dist/src/functions/uuid.d.ts +8 -8
  34. package/dist/src/types/api-version.d.ts +2 -0
  35. package/dist/src/types/api-version.js +5 -0
  36. package/dist/src/types/api-version.js.map +1 -0
  37. package/dist/src/types/content.d.ts +31 -31
  38. package/dist/src/types/element.d.ts +60 -60
  39. package/dist/src/url.d.ts +9 -9
  40. package/dist/src/url.test.d.ts +1 -1
  41. package/dist/src/url.test.js +1 -1
  42. package/dist/tsconfig.tsbuildinfo +1 -1
  43. package/package.json +17 -15
@@ -1,837 +1,842 @@
1
- /// <reference types="@types/node" />
2
- import './polyfills/custom-event-polyfill';
3
- import { IncomingMessage, ServerResponse } from 'http';
4
- import { nextTick } from './functions/next-tick.function';
5
- import { BehaviorSubject } from './classes/observable.class';
6
- import { throttle } from './functions/throttle.function';
7
- import { Animator } from './classes/animator.class';
8
- import { BuilderElement } from './types/element';
9
- import Cookies from './classes/cookies.class';
10
- import { BuilderContent } from './types/content';
11
- export declare type Url = any;
12
- export declare const isReactNative: boolean;
13
- export declare const validEnvList: string[];
14
- export declare const isBrowser: boolean;
15
- export declare const isIframe: boolean;
16
- export interface ParamsMap {
17
- [key: string]: any;
18
- }
19
- declare type TrackingHook = (eventData: Event, context: {
20
- content?: BuilderContent;
21
- [key: string]: any;
22
- }) => Event | undefined;
23
- interface EventData {
24
- contentId?: string;
25
- ownerId: string;
26
- variationId?: string;
27
- userAttributes?: any;
28
- targetSelector?: string;
29
- targetBuilderElement?: string;
30
- unique?: boolean;
31
- metadata?: any | string;
32
- meta?: any | string;
33
- sessionId?: string;
34
- visitorId?: string;
35
- amount?: number;
36
- }
37
- interface Event {
38
- type: string;
39
- data: EventData;
40
- }
41
- /**
42
- * Attributes that can be used for custom targeting. {@link
43
- * https://www.builder.io/c/docs/guides/targeting-and-scheduling}
44
- */
45
- export interface UserAttributes {
46
- [key: string]: undefined | string | string[] | boolean | boolean[] | number | number[] | Record<string, any>;
47
- /**
48
- * URL path of the current user.
49
- */
50
- urlPath?: string;
51
- /**
52
- * @deprecated
53
- * @hidden
54
- */
55
- queryString?: string | ParamsMap;
56
- /**
57
- * @deprecated
58
- * @hidden
59
- */
60
- device?: 'mobile' | 'tablet' | 'desktop';
61
- /**
62
- * @deprecated
63
- * @hidden
64
- */
65
- location?: any;
66
- /**
67
- * @deprecated
68
- * @hidden
69
- */
70
- userAgent?: string;
71
- /**
72
- * @deprecated
73
- * @hidden
74
- */
75
- referrer?: string;
76
- /**
77
- * @deprecated
78
- * @hidden
79
- */
80
- entryMedium?: string;
81
- /**
82
- * @deprecated
83
- * @hidden
84
- */
85
- language?: string;
86
- /**
87
- * @deprecated
88
- * @hidden
89
- */
90
- browser?: string;
91
- /**
92
- * @deprecated
93
- * @hidden
94
- */
95
- cookie?: string;
96
- /**
97
- * @deprecated
98
- * @hidden
99
- */
100
- newVisitor?: boolean;
101
- /**
102
- * @deprecated
103
- * @hidden
104
- */
105
- operatingSystem?: string;
106
- }
107
- export interface GetContentOptions {
108
- /**
109
- * User attribute key value pairs to be used for targeting
110
- * https://www.builder.io/c/docs/custom-targeting-attributes
111
- *
112
- * e.g.
113
- * ```js
114
- * userAttributes: {
115
- * urlPath: '/',
116
- * returnVisitor: true,
117
- * }
118
- * ```
119
- */
120
- userAttributes?: UserAttributes;
121
- /**
122
- * Alias for userAttributes.urlPath except it can handle a full URL (optionally with host,
123
- * protocol, query, etc) and we will parse out the path.
124
- */
125
- url?: string;
126
- /**
127
- * @package
128
- */
129
- includeUrl?: boolean;
130
- /**
131
- * Follow references. If you use the `reference` field to pull in other content without this
132
- * enabled we will not fetch that content for the final response.
133
- */
134
- includeRefs?: boolean;
135
- /**
136
- * How long in seconds content should be cached for. Sets the max-age of the cache-control header
137
- * response header.
138
- *
139
- * Use a higher value for better performance, lower for content that will change more frequently
140
- *
141
- * @see {@link https://www.builder.io/c/docs/query-api#__next:~:text=%26includeRefs%3Dtrue-,cacheSeconds,-No}
142
- */
143
- cacheSeconds?: number;
144
- /**
145
- * Builder.io uses stale-while-revalidate caching at the CDN level. This means we always serve
146
- * from edge cache and update caches in the background for maximum possible performance. This also
147
- * means that the more frequently content is requested, the more fresh it will be. The longest we
148
- * will ever hold something in stale cache is 1 day by default, and you can set this to be shorter
149
- * yourself as well. We suggest keeping this high unless you have content that must change rapidly
150
- * and gets very little traffic.
151
- *
152
- * @see {@link https://www.fastly.com/blog/prevent-application-network-instability-serve-stale-content}
153
- */
154
- staleCacheSeconds?: number;
155
- /**
156
- * Maximum number of results to return. Defaults to `1`.
157
- */
158
- limit?: number;
159
- /**
160
- * Mongodb style query of your data. E.g.:
161
- *
162
- * ```js
163
- * query: {
164
- * id: 'abc123',
165
- * data: {
166
- * myCustomField: { $gt: 20 },
167
- * }
168
- * }
169
- * ```
170
- *
171
- * See more info on MongoDB's query operators and format.
172
- *
173
- * @see {@link https://docs.mongodb.com/manual/reference/operator/query/}
174
- */
175
- query?: any;
176
- /**
177
- * Bust through all caches. Not recommended for production (for performance),
178
- * but can be useful for development and static builds (so the static site has
179
- * fully fresh / up to date content)
180
- */
181
- cachebust?: boolean;
182
- /**
183
- * Convert any visual builder content to HTML.
184
- *
185
- * This will be on data.html of the response's content entry object json.
186
- */
187
- prerender?: boolean;
188
- /**
189
- * Extract any styles to a separate css property when generating HTML.
190
- */
191
- extractCss?: boolean;
192
- /**
193
- * Pagination results offset. Defaults to zero.
194
- */
195
- offset?: number;
196
- /**
197
- * @package
198
- *
199
- * `BuilderContent` to render instead of fetching.
200
- */
201
- initialContent?: any;
202
- /**
203
- * The name of the model to fetch content for.
204
- */
205
- model?: string;
206
- /**
207
- * Set to `false` to not cache responses when running on the client.
208
- */
209
- cache?: boolean;
210
- /**
211
- * Set to the current locale in your application if you want localized inputs to be auto-resolved, should match one of the locales keys in your space settings
212
- * Learn more about adding or removing locales [here](https://www.builder.io/c/docs/add-remove-locales)
213
- */
214
- locale?: string;
215
- /**
216
- * @package
217
- *
218
- * Indicate that the fetch request is for preview purposes.
219
- */
220
- preview?: boolean;
221
- /**
222
- * Specific content entry ID to fetch.
223
- */
224
- entry?: string;
225
- /**
226
- * @package
227
- * @deprecated
228
- * @hidden
229
- */
230
- alias?: string;
231
- fields?: string;
232
- /**
233
- * Omit only these fields.
234
- *
235
- * @example
236
- * ```
237
- * &omit=data.bigField,data.blocks
238
- * ```
239
- */
240
- omit?: string;
241
- key?: string;
242
- /**
243
- * @package
244
- *
245
- * Affects HTML generation for specific targets.
246
- */
247
- format?: 'amp' | 'email' | 'html' | 'react' | 'solid';
248
- /**
249
- * @deprecated
250
- * @hidden
251
- */
252
- noWrap?: true;
253
- /**
254
- * @package
255
- *
256
- * Specific string to use for cache busting. e.g. every time we generate
257
- * HTML we generate a rev (a revision ID) and we send that with each request
258
- * on the client, such that if we generate new server HTML we get a new rev
259
- * and we use that to bust the cache because even though the content ID may
260
- * be the same, it could be an updated version of this content that needs to
261
- * be fresh.
262
- */
263
- rev?: string;
264
- /**
265
- * @package
266
- *
267
- * Tell the API that when generating HTML to generate it in static mode for
268
- * a/b tests instead of the older way we did this
269
- */
270
- static?: boolean;
271
- /**
272
- * Additional query params of the Content API to send.
273
- */
274
- options?: {
275
- [key: string]: any;
276
- };
277
- /**
278
- * @package
279
- *
280
- * Don't listen to updates in the editor - this is useful for embedded
281
- * symbols so they don't accidentally listen to messages as you are editing
282
- * content thinking they should updates when they actually shouldn't.
283
- */
284
- noEditorUpdates?: boolean;
285
- }
286
- export declare type Class = {
287
- name?: string;
288
- new (...args: any[]): any;
289
- };
290
- interface Map<K, V> {
291
- clear(): void;
292
- delete(key: K): boolean;
293
- entries(): IterableIterator<[K, V]>;
294
- forEach(callbackfn: (value: V, index: K, map: Map<K, V>) => void, thisArg?: any): void;
295
- get(key: K): V;
296
- has(key: K): boolean;
297
- keys(): IterableIterator<K>;
298
- set(key: K, value?: V): Map<K, V>;
299
- size: number;
300
- values(): IterableIterator<V>;
301
- [Symbol.iterator](): IterableIterator<[K, V]>;
302
- }
303
- /**
304
- * This is the interface for inputs in `Builder.registerComponent`
305
- *
306
- * ```js
307
- * Builder.registerComponent(MyComponent, {
308
- * inputs: [{ name: 'title', type: 'text' }] // <- Input[]
309
- * })
310
- * ```
311
- *
312
- * Learn more about registering custom components [here](https://www.builder.io/c/docs/custom-react-components)
313
- */
314
- export interface Input {
315
- /** This is the name of the component prop this input represents */
316
- name: string;
317
- /** A friendlier name to show in the UI if the component prop name is not ideal for end users */
318
- friendlyName?: string;
319
- /** @hidden @deprecated */
320
- description?: string;
321
- /** A default value to use */
322
- defaultValue?: any;
323
- /**
324
- * The type of input to use, such as 'text'
325
- *
326
- * See all available inputs [here](https://www.builder.io/c/docs/custom-react-components#input-types)
327
- * and you can create your own custom input types and associated editor UIs with [plugins](https://www.builder.io/c/docs/extending/plugins)
328
- */
329
- type: string;
330
- /** Is this input mandatory or not */
331
- required?: boolean;
332
- /** @hidden */
333
- autoFocus?: boolean;
334
- subFields?: Input[];
335
- /**
336
- * Additional text to render in the UI to give guidance on how to use this
337
- *
338
- * @example
339
- * ```js
340
- * helperText: 'Be sure to use a proper URL, starting with "https://"'
341
- * 111
342
- */
343
- helperText?: string;
344
- /** @hidden */
345
- allowedFileTypes?: string[];
346
- /** @hidden */
347
- imageHeight?: number;
348
- /** @hidden */
349
- imageWidth?: number;
350
- /** @hidden */
351
- mediaHeight?: number;
352
- /** @hidden */
353
- mediaWidth?: number;
354
- /** @hidden */
355
- hideFromUI?: boolean;
356
- /** @hidden */
357
- modelId?: string;
358
- /**
359
- * Number field type validation maximum accepted input
360
- */
361
- max?: number;
362
- /**
363
- * Number field type validation minimum accepted input
364
- */
365
- min?: number;
366
- /**
367
- * Number field type step size when using arrows
368
- */
369
- step?: number;
370
- /**
371
- * Set this to `true` to show the editor for this input when
372
- * children of this component are selected. This is useful for things
373
- * like Tabs, such that users may not always select the Tabs component
374
- * directly but will still be looking for how to add additional tabs
375
- */
376
- broadcast?: boolean;
377
- /**
378
- * Set this to `true` to show the editor for this input when
379
- * group locked parents of this component are selected. This is useful
380
- * to bubble up important inputs for locked groups, like text and images
381
- */
382
- bubble?: boolean;
383
- /**
384
- * Set this to `true` if you want this component to be translatable
385
- */
386
- localized?: boolean;
387
- /** @hidden */
388
- options?: {
389
- [key: string]: any;
390
- };
391
- /**
392
- * For "text" input type, specifying an enum will show a dropdown of options instead
393
- */
394
- enum?: string[] | {
395
- label: string;
396
- value: string | number | boolean;
397
- helperText?: string;
398
- }[];
399
- /** Regex field validation for all string types (text, longText, html, url, etc) */
400
- regex?: {
401
- /** pattern to test, like "^\/[a-z]$" */
402
- pattern: string;
403
- /** flags for the RegExp constructor, e.g. "gi" */
404
- options?: string;
405
- /**
406
- * Friendly message to display to end-users if the regex fails, e.g.
407
- * "You must use a relative url starting with '/...' "
408
- */
409
- message: string;
410
- };
411
- /**
412
- * Set this to `true` to put this under the "show more" section of
413
- * the options editor. Useful for things that are more advanced
414
- * or more rarely used and don't need to be too prominent
415
- */
416
- advanced?: boolean;
417
- /** @hidden */
418
- onChange?: Function | string;
419
- /** @hidden */
420
- code?: boolean;
421
- /** @hidden */
422
- richText?: boolean;
423
- /** @hidden */
424
- showIf?: ((options: Map<string, any>) => boolean) | string;
425
- /** @hidden */
426
- copyOnAdd?: boolean;
427
- /**
428
- * Use optionally with inputs of type `reference`. Restricts the content entry picker to a specific model by name.
429
- */
430
- model?: string;
431
- }
432
- /**
433
- * This is the interface for the options for `Builder.registerComponent`
434
- *
435
- * ```js
436
- * Builder.registerComponent(YourComponent, {
437
- * // <- Component options
438
- * })
439
- * ```
440
- *
441
- * Learn more about registering custom components [here](https://www.builder.io/c/docs/custom-react-components)
442
- */
443
- export interface Component {
444
- /**
445
- * Name your component something unique, e.g. 'MyButton'. You can override built-in components
446
- * by registering a component with the same name, e.g. 'Text', to replace the built-in text component
447
- */
448
- name: string;
449
- /** @hidden @deprecated */
450
- description?: string;
451
- /**
452
- * Link to a documentation page for this component
453
- */
454
- docsLink?: string;
455
- /**
456
- * Link to an image to be used as an icon for this component in Builder's editor
457
- *
458
- * @example
459
- * ```js
460
- * image: 'https://some-cdn.com/my-icon-for-this-component.png'
461
- * ```
462
- */
463
- image?: string;
464
- /**
465
- * Link to a screenshot shown when user hovers over the component in Builder's editor
466
- * use https://builder.io/upload to upload your screeshot, for easier resizing by Builder.
467
- */
468
- screenshot?: string;
469
- /**
470
- * When overriding built-in components, if you don't want any special behavior that
471
- * the original has, set this to `true` to skip the default behavior
472
- *
473
- * Default behaviors include special "virtual options", such as a custom
474
- * aspect ratio editor for Images, or a special column editor for Columns
475
- *
476
- * Learn more about overriding built-in components here: https://www.builder.io/c/docs/custom-components-overriding
477
- */
478
- override?: boolean;
479
- /**
480
- * Input schema for your component for users to fill in the options via a UI
481
- * that translate to this components props
482
- */
483
- inputs?: Input[];
484
- /** @hidden @deprecated */
485
- class?: any;
486
- /** @hidden @deprecated */
487
- type?: 'angular' | 'webcomponent' | 'react' | 'vue';
488
- /**
489
- * Default styles to apply when droppged into the Builder.io editor
490
- *
491
- * @example
492
- * ```js
493
- * defaultStyles: {
494
- * // large (default) breakpoint
495
- * large: {
496
- * backgroundColor: 'black'
497
- * },
498
- * }
499
- * ```
500
- */
501
- defaultStyles?: {
502
- [key: string]: string;
503
- };
504
- /**
505
- * Turn on if your component can accept children. Be sure to use in combination with
506
- * withChildren(YourComponent) like here
507
- * github.com/BuilderIO/builder/blob/master/examples/react-design-system/src/components/HeroWithChildren/HeroWithChildren.builder.js#L5
508
- */
509
- canHaveChildren?: boolean;
510
- /** @hidden */
511
- fragment?: boolean;
512
- /**
513
- * Do not wrap a component in a dom element. Be sure to use {...props.attributes} with this option
514
- * like here github.com/BuilderIO/builder/blob/master/packages/react/src/blocks/forms/Input.tsx#L34
515
- */
516
- noWrap?: boolean;
517
- /**
518
- * Default children
519
- */
520
- defaultChildren?: BuilderElement[];
521
- /**
522
- * Default options to merge in when creating this block
523
- */
524
- defaults?: Partial<BuilderElement>;
525
- /** @hidden @deprecated */
526
- hooks?: {
527
- [key: string]: string | Function;
528
- };
529
- /**
530
- * Hide your component in editor, useful for gradually deprecating components
531
- */
532
- hideFromInsertMenu?: boolean;
533
- /** Custom tag name (for custom webcomponents only) */
534
- tag?: string;
535
- /** @hidden @deprecated */
536
- static?: boolean;
537
- /**
538
- * Passing a list of model names will restrict using the component to only the models listed here, otherwise it'll be available for all models
539
- */
540
- models?: string[];
541
- /**
542
- * Specify restrictions direct children must match
543
- */
544
- childRequirements?: {
545
- /** Message to show when this doesn't match, e.g. "Children of 'Columns' must be a 'Column'" */
546
- message: string;
547
- /** Simple way to say children must be a specific component name */
548
- component?: string;
549
- /**
550
- * More advanced - specify a MongoDB-style query (using sift.js github.com/crcn/sift.js)
551
- * of what the children objects should match, e.g.
552
- *
553
- * @example
554
- * query: {
555
- * // Child of this element must be a 'Button' or 'Text' component
556
- * 'component.name': { $in: ['Button', 'Text'] }
557
- * }
558
- */
559
- query?: any;
560
- };
561
- /**
562
- * Specify restrictions any parent must match
563
- */
564
- requiresParent?: {
565
- /** Message to show when this doesn't match, e.g. "'Add to cart' buttons must be within a 'Product box'" */
566
- message: string;
567
- /** Simple way to say a parent must be a specific component name, e.g. 'Product box' */
568
- component?: string;
569
- /**
570
- * More advanced - specify a MongoDB-style query (using sift.js github.com/crcn/sift.js)
571
- * of what at least one parent in the parents hierarchy should match, e.g.
572
- *
573
- * @example
574
- * query: {
575
- * // Thils element must be somewhere inside either a 'Product box' or 'Collection' component
576
- * 'component.name': { $in: ['Product Box', 'Collection'] }
577
- * }
578
- */
579
- query?: any;
580
- };
581
- /** @hidden @deprecated */
582
- friendlyName?: string;
583
- /**
584
- * Use to restrict access to your component based on a the current user permissions
585
- * By default components will show to all users
586
- * for more information on permissions in builder check https://www.builder.io/c/docs/guides/roles-and-permissions
587
- */
588
- requiredPermissions?: Array<Permission>;
589
- }
590
- declare type Permission = 'read' | 'publish' | 'editCode' | 'editDesigns' | 'admin' | 'create';
591
- declare type DeepPartial<T> = {
592
- [P in keyof T]?: T[P] extends Array<infer U> ? Array<DeepPartial<U>> : T[P] extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>> : DeepPartial<T[P]>;
593
- };
594
- export interface InsertMenuItem {
595
- name: string;
596
- icon?: string;
597
- item: DeepPartial<BuilderElement>;
598
- }
599
- /**
600
- * Use this to register custom sections in the Insert menu, for instance
601
- * to make new sections to organize your custom components
602
- *
603
- * ![Example of what a custom section looks like](https://cdn.builder.io/api/v1/image/assets%2F7f7bbcf72a1a4d72bac5daa359e7befd%2Fe5f2792e9c0f44ed89a9dcb77b945858)
604
- *
605
- * @example
606
- * ```js
607
- * Builder.register('insertMenu', {
608
- * name: 'Our components',
609
- * items: [
610
- * { name: 'Hero' },
611
- * { name: 'Double Columns' },
612
- * { name: 'Triple Columns' },
613
- * { name: 'Dynamic Columns' },
614
- * ],
615
- * })
616
- * ```
617
- *
618
- * You can make as many custom sections as you like
619
- *
620
- * See a complete usage example [here](https://github.com/builderio/builder/blob/main/examples/react-design-system/src/builder-settings.js)
621
- */
622
- export interface InsertMenuConfig {
623
- name: string;
624
- priority?: number;
625
- persist?: boolean;
626
- advanced?: boolean;
627
- items: InsertMenuItem[];
628
- }
629
- export declare function BuilderComponent(info?: Partial<Component>): (component: Class) => Class;
630
- declare type Settings = any;
631
- export interface Action {
632
- name: string;
633
- inputs?: Input[];
634
- returnType?: Input;
635
- action: Function | string;
636
- }
637
- export declare class Builder {
638
- protected request?: IncomingMessage | undefined;
639
- protected response?: ServerResponse | undefined;
640
- /**
641
- * @hidden
642
- * @deprecated. This is buggy, and always behind by a version.
643
- */
644
- static VERSION: string;
645
- static components: Component[];
646
- static singletonInstance: Builder;
647
- /**
648
- * Makes it so that a/b tests generate code like {@link
649
- * https://www.builder.io/blog/high-performance-no-code#__next:~:text=Static%20generated%20A%2FB%20testing}
650
- * instead of the old way where we render only one test group at a time on the
651
- * server. This is the preferred/better way not and we should ultimately make it
652
- * the default
653
- */
654
- static isStatic: boolean;
655
- static animator: Animator;
656
- static nextTick: typeof nextTick;
657
- static throttle: typeof throttle;
658
- static editors: any[];
659
- static trustedHosts: string[];
660
- static plugins: any[];
661
- static actions: Action[];
662
- static registry: {
663
- [key: string]: any[];
664
- };
665
- static overrideHost: string | undefined;
666
- /**
667
- * @todo `key` property on any info where if a key matches a current
668
- * key it gets removed
669
- */
670
- static register(type: 'insertMenu', info: InsertMenuConfig): void;
671
- static register(type: string, info: any): void;
672
- static registryChange: BehaviorSubject<{
673
- [key: string]: any[];
674
- }, any>;
675
- static registerEditor(info: any): void;
676
- static registerPlugin(info: any): void;
677
- static registerAction(action: Action): void;
678
- static registerTrustedHost(host: string): void;
679
- static isTrustedHost(hostname: string): boolean;
680
- static runAction(action: Action | string): void;
681
- static fields(name: string, fields: Input[]): void;
682
- private static _editingPage;
683
- static isIframe: boolean;
684
- static isBrowser: boolean;
685
- static isReactNative: boolean;
686
- static isServer: boolean;
687
- static previewingModel: string | false | null;
688
- static settings: Settings;
689
- static settingsChange: BehaviorSubject<any, any>;
690
- /**
691
- * @deprecated
692
- * @hidden
693
- *
694
- * Use Builder.register('editor.settings', {}) instead.
695
- */
696
- static set(settings: Settings): void;
697
- static import(packageName: string): any;
698
- static isEditing: boolean;
699
- static isPreviewing: boolean;
700
- static get editingPage(): boolean;
701
- static set editingPage(editingPage: boolean);
702
- private static prepareComponentSpecToSend;
703
- static registerBlock(component: any, options: Component): void;
704
- static registerComponent(component: any, options: Component): void;
705
- private static addComponent;
706
- static component(info?: Partial<Component>): (component: Class) => Class;
707
- static isReact: boolean;
708
- static get Component(): typeof Builder.component;
709
- private eventsQueue;
710
- private throttledClearEventsQueue;
711
- private processEventsQueue;
712
- env: string;
713
- sessionId: string;
714
- targetContent: boolean;
715
- contentPerRequest: number;
716
- allowCustomFonts: boolean;
717
- private cookies;
718
- private cachebust;
719
- private overrideParams;
720
- private noCache;
721
- private preview;
722
- get browserTrackingDisabled(): boolean;
723
- get canTrack(): boolean;
724
- set canTrack(canTrack: boolean);
725
- private canTrack$;
726
- private apiKey$;
727
- private authToken$;
728
- userAttributesChanged: BehaviorSubject<any, any>;
729
- get editingMode(): boolean;
730
- set editingMode(value: boolean);
731
- editingMode$: BehaviorSubject<boolean, any>;
732
- get editingModel(): string | null;
733
- set editingModel(value: string | null);
734
- private findParentElement;
735
- private findBuilderParent;
736
- editingModel$: BehaviorSubject<string | null, any>;
737
- setUserAgent(userAgent: string): void;
738
- userAgent: string;
739
- trackingHooks: TrackingHook[];
740
- /**
741
- * Set a hook to modify events being tracked from builder, such as impressions and clicks
742
- *
743
- * For example, to track the model ID of each event associated with content for querying
744
- * by mode, you can do
745
- *
746
- * builder.setTrackingHook((event, context) => {
747
- * if (context.content) {
748
- * event.data.metadata.modelId = context.content.modelId
749
- * }
750
- * })
751
- */
752
- setTrackingHook(hook: TrackingHook): void;
753
- track(eventName: string, properties?: Partial<EventData>, context?: any): void;
754
- getSessionId(): string;
755
- visitorId: string;
756
- getVisitorId(): string;
757
- trackImpression(contentId: string, variationId?: string, properties?: any, context?: any): void;
758
- trackConversion(amount?: number, customProperties?: any): void;
759
- autoTrack: boolean;
760
- private get isDevelopmentEnv();
761
- trackInteraction(contentId: string, variationId?: string, alreadyTrackedOne?: boolean, event?: MouseEvent, context?: any): void;
762
- static overrideUserAttributes: Partial<UserAttributes>;
763
- trackingUserAttributes: {
764
- [key: string]: any;
765
- };
766
- component(info?: Partial<Component>): (component: Class) => Class;
767
- get apiKey(): string | null;
768
- set apiKey(key: string | null);
769
- get authToken(): string | null;
770
- set authToken(token: string | null);
771
- constructor(apiKey?: string | null, request?: IncomingMessage | undefined, response?: ServerResponse | undefined, forceNewInstance?: boolean, authToken?: string | null);
772
- private modifySearch;
773
- setTestsFromUrl(): void;
774
- resetOverrides(): void;
775
- getOverridesFromQueryString(): void;
776
- private messageFrameLoaded;
777
- private blockContentLoading;
778
- private bindMessageListeners;
779
- observersByKey: {
780
- [key: string]: BehaviorSubject<BuilderContent[]> | undefined;
781
- };
782
- noEditorUpdates: {
783
- [key: string]: boolean;
784
- };
785
- get defaultCanTrack(): boolean;
786
- init(apiKey: string, canTrack?: boolean, req?: IncomingMessage, res?: ServerResponse, authToken?: string): this;
787
- get previewingModel(): string;
788
- getLocation(): Url;
789
- getUserAttributes(userAgent?: string): UserAttributes;
790
- protected overrides: {
791
- [key: string]: string;
792
- };
793
- protected queryOptions: {
794
- [key: string]: string;
795
- };
796
- private getContentQueue;
797
- private priorContentQueue;
798
- setUserAttributes(options: object): void;
799
- /**
800
- * Set user attributes just for tracking purposes.
801
- *
802
- * Do this so properties exist on event objects for querying insights, but
803
- * won't affect targeting
804
- *
805
- * Use this when you want to track properties but don't need to target off
806
- * of them to optimize cache efficiency
807
- */
808
- setTrackingUserAttributes(attributes: object): void;
809
- get(modelName: string, options?: GetContentOptions & {
810
- req?: IncomingMessage;
811
- res?: ServerResponse;
812
- apiKey?: string;
813
- authToken?: string;
814
- }): BehaviorSubject<any, any>;
815
- queueGetContent(modelName: string, options?: GetContentOptions): BehaviorSubject<BuilderContent[], any>;
816
- requestUrl(url: string, options?: {
817
- headers: {
818
- [header: string]: number | string | string[] | undefined;
819
- };
820
- }): Promise<any>;
821
- get host(): string;
822
- private flushGetContentQueue;
823
- private testCookiePrefix;
824
- private processResultsForTests;
825
- private getTestCookie;
826
- private cookieQueue;
827
- private setTestCookie;
828
- getCookie(name: string): any;
829
- setCookie(name: string, value: any, expires?: Date): false | void | Cookies;
830
- getContent(modelName: string, options?: GetContentOptions): BehaviorSubject<BuilderContent[], any>;
831
- getAll(modelName: string, options?: GetContentOptions & {
832
- req?: IncomingMessage;
833
- res?: ServerResponse;
834
- apiKey?: string;
835
- }): Promise<BuilderContent[]>;
836
- }
837
- export {};
1
+ /// <reference types="@types/node" />
2
+ import './polyfills/custom-event-polyfill';
3
+ import { IncomingMessage, ServerResponse } from 'http';
4
+ import { nextTick } from './functions/next-tick.function';
5
+ import { BehaviorSubject } from './classes/observable.class';
6
+ import { throttle } from './functions/throttle.function';
7
+ import { Animator } from './classes/animator.class';
8
+ import { BuilderElement } from './types/element';
9
+ import Cookies from './classes/cookies.class';
10
+ import { BuilderContent } from './types/content';
11
+ import type { ApiVersion } from './types/api-version';
12
+ export type Url = any;
13
+ export declare const isReactNative: boolean;
14
+ export declare const validEnvList: string[];
15
+ export declare const isBrowser: boolean;
16
+ export declare const isIframe: boolean;
17
+ export interface ParamsMap {
18
+ [key: string]: any;
19
+ }
20
+ type TrackingHook = (eventData: Event, context: {
21
+ content?: BuilderContent;
22
+ [key: string]: any;
23
+ }) => Event | undefined;
24
+ interface EventData {
25
+ contentId?: string;
26
+ ownerId: string;
27
+ variationId?: string;
28
+ userAttributes?: any;
29
+ targetSelector?: string;
30
+ targetBuilderElement?: string;
31
+ unique?: boolean;
32
+ metadata?: any | string;
33
+ meta?: any | string;
34
+ sessionId?: string;
35
+ visitorId?: string;
36
+ amount?: number;
37
+ }
38
+ interface Event {
39
+ type: string;
40
+ data: EventData;
41
+ }
42
+ /**
43
+ * Attributes that can be used for custom targeting. {@link
44
+ * https://www.builder.io/c/docs/guides/targeting-and-scheduling}
45
+ */
46
+ export interface UserAttributes {
47
+ [key: string]: undefined | string | string[] | boolean | boolean[] | number | number[] | Record<string, any>;
48
+ /**
49
+ * URL path of the current user.
50
+ */
51
+ urlPath?: string;
52
+ /**
53
+ * @deprecated
54
+ * @hidden
55
+ */
56
+ queryString?: string | ParamsMap;
57
+ /**
58
+ * @deprecated
59
+ * @hidden
60
+ */
61
+ device?: 'mobile' | 'tablet' | 'desktop';
62
+ /**
63
+ * @deprecated
64
+ * @hidden
65
+ */
66
+ location?: any;
67
+ /**
68
+ * @deprecated
69
+ * @hidden
70
+ */
71
+ userAgent?: string;
72
+ /**
73
+ * @deprecated
74
+ * @hidden
75
+ */
76
+ referrer?: string;
77
+ /**
78
+ * @deprecated
79
+ * @hidden
80
+ */
81
+ entryMedium?: string;
82
+ /**
83
+ * @deprecated
84
+ * @hidden
85
+ */
86
+ language?: string;
87
+ /**
88
+ * @deprecated
89
+ * @hidden
90
+ */
91
+ browser?: string;
92
+ /**
93
+ * @deprecated
94
+ * @hidden
95
+ */
96
+ cookie?: string;
97
+ /**
98
+ * @deprecated
99
+ * @hidden
100
+ */
101
+ newVisitor?: boolean;
102
+ /**
103
+ * @deprecated
104
+ * @hidden
105
+ */
106
+ operatingSystem?: string;
107
+ }
108
+ export interface GetContentOptions {
109
+ /**
110
+ * User attribute key value pairs to be used for targeting
111
+ * https://www.builder.io/c/docs/custom-targeting-attributes
112
+ *
113
+ * e.g.
114
+ * ```js
115
+ * userAttributes: {
116
+ * urlPath: '/',
117
+ * returnVisitor: true,
118
+ * }
119
+ * ```
120
+ */
121
+ userAttributes?: UserAttributes;
122
+ /**
123
+ * Alias for userAttributes.urlPath except it can handle a full URL (optionally with host,
124
+ * protocol, query, etc) and we will parse out the path.
125
+ */
126
+ url?: string;
127
+ /**
128
+ * @package
129
+ */
130
+ includeUrl?: boolean;
131
+ /**
132
+ * Follow references. If you use the `reference` field to pull in other content without this
133
+ * enabled we will not fetch that content for the final response.
134
+ */
135
+ includeRefs?: boolean;
136
+ /**
137
+ * How long in seconds content should be cached for. Sets the max-age of the cache-control header
138
+ * response header.
139
+ *
140
+ * Use a higher value for better performance, lower for content that will change more frequently
141
+ *
142
+ * @see {@link https://www.builder.io/c/docs/query-api#__next:~:text=%26includeRefs%3Dtrue-,cacheSeconds,-No}
143
+ */
144
+ cacheSeconds?: number;
145
+ /**
146
+ * Builder.io uses stale-while-revalidate caching at the CDN level. This means we always serve
147
+ * from edge cache and update caches in the background for maximum possible performance. This also
148
+ * means that the more frequently content is requested, the more fresh it will be. The longest we
149
+ * will ever hold something in stale cache is 1 day by default, and you can set this to be shorter
150
+ * yourself as well. We suggest keeping this high unless you have content that must change rapidly
151
+ * and gets very little traffic.
152
+ *
153
+ * @see {@link https://www.fastly.com/blog/prevent-application-network-instability-serve-stale-content}
154
+ */
155
+ staleCacheSeconds?: number;
156
+ /**
157
+ * Maximum number of results to return. Defaults to `1`.
158
+ */
159
+ limit?: number;
160
+ /**
161
+ * Mongodb style query of your data. E.g.:
162
+ *
163
+ * ```js
164
+ * query: {
165
+ * id: 'abc123',
166
+ * data: {
167
+ * myCustomField: { $gt: 20 },
168
+ * }
169
+ * }
170
+ * ```
171
+ *
172
+ * See more info on MongoDB's query operators and format.
173
+ *
174
+ * @see {@link https://docs.mongodb.com/manual/reference/operator/query/}
175
+ */
176
+ query?: any;
177
+ /**
178
+ * Bust through all caches. Not recommended for production (for performance),
179
+ * but can be useful for development and static builds (so the static site has
180
+ * fully fresh / up to date content)
181
+ */
182
+ cachebust?: boolean;
183
+ /**
184
+ * Convert any visual builder content to HTML.
185
+ *
186
+ * This will be on data.html of the response's content entry object json.
187
+ */
188
+ prerender?: boolean;
189
+ /**
190
+ * Extract any styles to a separate css property when generating HTML.
191
+ */
192
+ extractCss?: boolean;
193
+ /**
194
+ * Pagination results offset. Defaults to zero.
195
+ */
196
+ offset?: number;
197
+ /**
198
+ * @package
199
+ *
200
+ * `BuilderContent` to render instead of fetching.
201
+ */
202
+ initialContent?: any;
203
+ /**
204
+ * The name of the model to fetch content for.
205
+ */
206
+ model?: string;
207
+ /**
208
+ * Set to `false` to not cache responses when running on the client.
209
+ */
210
+ cache?: boolean;
211
+ /**
212
+ * Set to the current locale in your application if you want localized inputs to be auto-resolved, should match one of the locales keys in your space settings
213
+ * Learn more about adding or removing locales [here](https://www.builder.io/c/docs/add-remove-locales)
214
+ */
215
+ locale?: string;
216
+ /**
217
+ * @package
218
+ *
219
+ * Indicate that the fetch request is for preview purposes.
220
+ */
221
+ preview?: boolean;
222
+ /**
223
+ * Specific content entry ID to fetch.
224
+ */
225
+ entry?: string;
226
+ /**
227
+ * @package
228
+ * @deprecated
229
+ * @hidden
230
+ */
231
+ alias?: string;
232
+ fields?: string;
233
+ /**
234
+ * Omit only these fields.
235
+ *
236
+ * @example
237
+ * ```
238
+ * &omit=data.bigField,data.blocks
239
+ * ```
240
+ */
241
+ omit?: string;
242
+ key?: string;
243
+ /**
244
+ * @package
245
+ *
246
+ * Affects HTML generation for specific targets.
247
+ */
248
+ format?: 'amp' | 'email' | 'html' | 'react' | 'solid';
249
+ /**
250
+ * @deprecated
251
+ * @hidden
252
+ */
253
+ noWrap?: true;
254
+ /**
255
+ * @package
256
+ *
257
+ * Specific string to use for cache busting. e.g. every time we generate
258
+ * HTML we generate a rev (a revision ID) and we send that with each request
259
+ * on the client, such that if we generate new server HTML we get a new rev
260
+ * and we use that to bust the cache because even though the content ID may
261
+ * be the same, it could be an updated version of this content that needs to
262
+ * be fresh.
263
+ */
264
+ rev?: string;
265
+ /**
266
+ * @package
267
+ *
268
+ * Tell the API that when generating HTML to generate it in static mode for
269
+ * a/b tests instead of the older way we did this
270
+ */
271
+ static?: boolean;
272
+ /**
273
+ * Additional query params of the Content API to send.
274
+ */
275
+ options?: {
276
+ [key: string]: any;
277
+ };
278
+ /**
279
+ * @package
280
+ *
281
+ * Don't listen to updates in the editor - this is useful for embedded
282
+ * symbols so they don't accidentally listen to messages as you are editing
283
+ * content thinking they should updates when they actually shouldn't.
284
+ */
285
+ noEditorUpdates?: boolean;
286
+ apiVersion?: ApiVersion;
287
+ }
288
+ export type Class = {
289
+ name?: string;
290
+ new (...args: any[]): any;
291
+ };
292
+ interface Map<K, V> {
293
+ clear(): void;
294
+ delete(key: K): boolean;
295
+ entries(): IterableIterator<[K, V]>;
296
+ forEach(callbackfn: (value: V, index: K, map: Map<K, V>) => void, thisArg?: any): void;
297
+ get(key: K): V;
298
+ has(key: K): boolean;
299
+ keys(): IterableIterator<K>;
300
+ set(key: K, value?: V): Map<K, V>;
301
+ size: number;
302
+ values(): IterableIterator<V>;
303
+ [Symbol.iterator](): IterableIterator<[K, V]>;
304
+ }
305
+ /**
306
+ * This is the interface for inputs in `Builder.registerComponent`
307
+ *
308
+ * ```js
309
+ * Builder.registerComponent(MyComponent, {
310
+ * inputs: [{ name: 'title', type: 'text' }] // <- Input[]
311
+ * })
312
+ * ```
313
+ *
314
+ * Learn more about registering custom components [here](https://www.builder.io/c/docs/custom-react-components)
315
+ */
316
+ export interface Input {
317
+ /** This is the name of the component prop this input represents */
318
+ name: string;
319
+ /** A friendlier name to show in the UI if the component prop name is not ideal for end users */
320
+ friendlyName?: string;
321
+ /** @hidden @deprecated */
322
+ description?: string;
323
+ /** A default value to use */
324
+ defaultValue?: any;
325
+ /**
326
+ * The type of input to use, such as 'text'
327
+ *
328
+ * See all available inputs [here](https://www.builder.io/c/docs/custom-react-components#input-types)
329
+ * and you can create your own custom input types and associated editor UIs with [plugins](https://www.builder.io/c/docs/extending/plugins)
330
+ */
331
+ type: string;
332
+ /** Is this input mandatory or not */
333
+ required?: boolean;
334
+ /** @hidden */
335
+ autoFocus?: boolean;
336
+ subFields?: Input[];
337
+ /**
338
+ * Additional text to render in the UI to give guidance on how to use this
339
+ *
340
+ * @example
341
+ * ```js
342
+ * helperText: 'Be sure to use a proper URL, starting with "https://"'
343
+ * 111
344
+ */
345
+ helperText?: string;
346
+ /** @hidden */
347
+ allowedFileTypes?: string[];
348
+ /** @hidden */
349
+ imageHeight?: number;
350
+ /** @hidden */
351
+ imageWidth?: number;
352
+ /** @hidden */
353
+ mediaHeight?: number;
354
+ /** @hidden */
355
+ mediaWidth?: number;
356
+ /** @hidden */
357
+ hideFromUI?: boolean;
358
+ /** @hidden */
359
+ modelId?: string;
360
+ /**
361
+ * Number field type validation maximum accepted input
362
+ */
363
+ max?: number;
364
+ /**
365
+ * Number field type validation minimum accepted input
366
+ */
367
+ min?: number;
368
+ /**
369
+ * Number field type step size when using arrows
370
+ */
371
+ step?: number;
372
+ /**
373
+ * Set this to `true` to show the editor for this input when
374
+ * children of this component are selected. This is useful for things
375
+ * like Tabs, such that users may not always select the Tabs component
376
+ * directly but will still be looking for how to add additional tabs
377
+ */
378
+ broadcast?: boolean;
379
+ /**
380
+ * Set this to `true` to show the editor for this input when
381
+ * group locked parents of this component are selected. This is useful
382
+ * to bubble up important inputs for locked groups, like text and images
383
+ */
384
+ bubble?: boolean;
385
+ /**
386
+ * Set this to `true` if you want this component to be translatable
387
+ */
388
+ localized?: boolean;
389
+ /** @hidden */
390
+ options?: {
391
+ [key: string]: any;
392
+ };
393
+ /**
394
+ * For "text" input type, specifying an enum will show a dropdown of options instead
395
+ */
396
+ enum?: string[] | {
397
+ label: string;
398
+ value: string | number | boolean;
399
+ helperText?: string;
400
+ }[];
401
+ /** Regex field validation for all string types (text, longText, html, url, etc) */
402
+ regex?: {
403
+ /** pattern to test, like "^\/[a-z]$" */
404
+ pattern: string;
405
+ /** flags for the RegExp constructor, e.g. "gi" */
406
+ options?: string;
407
+ /**
408
+ * Friendly message to display to end-users if the regex fails, e.g.
409
+ * "You must use a relative url starting with '/...' "
410
+ */
411
+ message: string;
412
+ };
413
+ /**
414
+ * Set this to `true` to put this under the "show more" section of
415
+ * the options editor. Useful for things that are more advanced
416
+ * or more rarely used and don't need to be too prominent
417
+ */
418
+ advanced?: boolean;
419
+ /** @hidden */
420
+ onChange?: Function | string;
421
+ /** @hidden */
422
+ code?: boolean;
423
+ /** @hidden */
424
+ richText?: boolean;
425
+ /** @hidden */
426
+ showIf?: ((options: Map<string, any>) => boolean) | string;
427
+ /** @hidden */
428
+ copyOnAdd?: boolean;
429
+ /**
430
+ * Use optionally with inputs of type `reference`. Restricts the content entry picker to a specific model by name.
431
+ */
432
+ model?: string;
433
+ }
434
+ /**
435
+ * This is the interface for the options for `Builder.registerComponent`
436
+ *
437
+ * ```js
438
+ * Builder.registerComponent(YourComponent, {
439
+ * // <- Component options
440
+ * })
441
+ * ```
442
+ *
443
+ * Learn more about registering custom components [here](https://www.builder.io/c/docs/custom-react-components)
444
+ */
445
+ export interface Component {
446
+ /**
447
+ * Name your component something unique, e.g. 'MyButton'. You can override built-in components
448
+ * by registering a component with the same name, e.g. 'Text', to replace the built-in text component
449
+ */
450
+ name: string;
451
+ /** @hidden @deprecated */
452
+ description?: string;
453
+ /**
454
+ * Link to a documentation page for this component
455
+ */
456
+ docsLink?: string;
457
+ /**
458
+ * Link to an image to be used as an icon for this component in Builder's editor
459
+ *
460
+ * @example
461
+ * ```js
462
+ * image: 'https://some-cdn.com/my-icon-for-this-component.png'
463
+ * ```
464
+ */
465
+ image?: string;
466
+ /**
467
+ * Link to a screenshot shown when user hovers over the component in Builder's editor
468
+ * use https://builder.io/upload to upload your screeshot, for easier resizing by Builder.
469
+ */
470
+ screenshot?: string;
471
+ /**
472
+ * When overriding built-in components, if you don't want any special behavior that
473
+ * the original has, set this to `true` to skip the default behavior
474
+ *
475
+ * Default behaviors include special "virtual options", such as a custom
476
+ * aspect ratio editor for Images, or a special column editor for Columns
477
+ *
478
+ * Learn more about overriding built-in components here: https://www.builder.io/c/docs/custom-components-overriding
479
+ */
480
+ override?: boolean;
481
+ /**
482
+ * Input schema for your component for users to fill in the options via a UI
483
+ * that translate to this components props
484
+ */
485
+ inputs?: Input[];
486
+ /** @hidden @deprecated */
487
+ class?: any;
488
+ /** @hidden @deprecated */
489
+ type?: 'angular' | 'webcomponent' | 'react' | 'vue';
490
+ /**
491
+ * Default styles to apply when droppged into the Builder.io editor
492
+ *
493
+ * @example
494
+ * ```js
495
+ * defaultStyles: {
496
+ * // large (default) breakpoint
497
+ * large: {
498
+ * backgroundColor: 'black'
499
+ * },
500
+ * }
501
+ * ```
502
+ */
503
+ defaultStyles?: {
504
+ [key: string]: string;
505
+ };
506
+ /**
507
+ * Turn on if your component can accept children. Be sure to use in combination with
508
+ * withChildren(YourComponent) like here
509
+ * github.com/BuilderIO/builder/blob/master/examples/react-design-system/src/components/HeroWithChildren/HeroWithChildren.builder.js#L5
510
+ */
511
+ canHaveChildren?: boolean;
512
+ /** @hidden */
513
+ fragment?: boolean;
514
+ /**
515
+ * Do not wrap a component in a dom element. Be sure to use {...props.attributes} with this option
516
+ * like here github.com/BuilderIO/builder/blob/master/packages/react/src/blocks/forms/Input.tsx#L34
517
+ */
518
+ noWrap?: boolean;
519
+ /**
520
+ * Default children
521
+ */
522
+ defaultChildren?: BuilderElement[];
523
+ /**
524
+ * Default options to merge in when creating this block
525
+ */
526
+ defaults?: Partial<BuilderElement>;
527
+ /** @hidden @deprecated */
528
+ hooks?: {
529
+ [key: string]: string | Function;
530
+ };
531
+ /**
532
+ * Hide your component in editor, useful for gradually deprecating components
533
+ */
534
+ hideFromInsertMenu?: boolean;
535
+ /** Custom tag name (for custom webcomponents only) */
536
+ tag?: string;
537
+ /** @hidden @deprecated */
538
+ static?: boolean;
539
+ /**
540
+ * Passing a list of model names will restrict using the component to only the models listed here, otherwise it'll be available for all models
541
+ */
542
+ models?: string[];
543
+ /**
544
+ * Specify restrictions direct children must match
545
+ */
546
+ childRequirements?: {
547
+ /** Message to show when this doesn't match, e.g. "Children of 'Columns' must be a 'Column'" */
548
+ message: string;
549
+ /** Simple way to say children must be a specific component name */
550
+ component?: string;
551
+ /**
552
+ * More advanced - specify a MongoDB-style query (using sift.js github.com/crcn/sift.js)
553
+ * of what the children objects should match, e.g.
554
+ *
555
+ * @example
556
+ * query: {
557
+ * // Child of this element must be a 'Button' or 'Text' component
558
+ * 'component.name': { $in: ['Button', 'Text'] }
559
+ * }
560
+ */
561
+ query?: any;
562
+ };
563
+ /**
564
+ * Specify restrictions any parent must match
565
+ */
566
+ requiresParent?: {
567
+ /** Message to show when this doesn't match, e.g. "'Add to cart' buttons must be within a 'Product box'" */
568
+ message: string;
569
+ /** Simple way to say a parent must be a specific component name, e.g. 'Product box' */
570
+ component?: string;
571
+ /**
572
+ * More advanced - specify a MongoDB-style query (using sift.js github.com/crcn/sift.js)
573
+ * of what at least one parent in the parents hierarchy should match, e.g.
574
+ *
575
+ * @example
576
+ * query: {
577
+ * // Thils element must be somewhere inside either a 'Product box' or 'Collection' component
578
+ * 'component.name': { $in: ['Product Box', 'Collection'] }
579
+ * }
580
+ */
581
+ query?: any;
582
+ };
583
+ /** @hidden @deprecated */
584
+ friendlyName?: string;
585
+ /**
586
+ * Use to restrict access to your component based on a the current user permissions
587
+ * By default components will show to all users
588
+ * for more information on permissions in builder check https://www.builder.io/c/docs/guides/roles-and-permissions
589
+ */
590
+ requiredPermissions?: Array<Permission>;
591
+ }
592
+ type Permission = 'read' | 'publish' | 'editCode' | 'editDesigns' | 'admin' | 'create';
593
+ type DeepPartial<T> = {
594
+ [P in keyof T]?: T[P] extends Array<infer U> ? Array<DeepPartial<U>> : T[P] extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>> : DeepPartial<T[P]>;
595
+ };
596
+ export interface InsertMenuItem {
597
+ name: string;
598
+ icon?: string;
599
+ item: DeepPartial<BuilderElement>;
600
+ }
601
+ /**
602
+ * Use this to register custom sections in the Insert menu, for instance
603
+ * to make new sections to organize your custom components
604
+ *
605
+ * ![Example of what a custom section looks like](https://cdn.builder.io/api/v1/image/assets%2F7f7bbcf72a1a4d72bac5daa359e7befd%2Fe5f2792e9c0f44ed89a9dcb77b945858)
606
+ *
607
+ * @example
608
+ * ```js
609
+ * Builder.register('insertMenu', {
610
+ * name: 'Our components',
611
+ * items: [
612
+ * { name: 'Hero' },
613
+ * { name: 'Double Columns' },
614
+ * { name: 'Triple Columns' },
615
+ * { name: 'Dynamic Columns' },
616
+ * ],
617
+ * })
618
+ * ```
619
+ *
620
+ * You can make as many custom sections as you like
621
+ *
622
+ * See a complete usage example [here](https://github.com/builderio/builder/blob/main/examples/react-design-system/src/builder-settings.js)
623
+ */
624
+ export interface InsertMenuConfig {
625
+ name: string;
626
+ priority?: number;
627
+ persist?: boolean;
628
+ advanced?: boolean;
629
+ items: InsertMenuItem[];
630
+ }
631
+ export declare function BuilderComponent(info?: Partial<Component>): (component: Class) => Class;
632
+ type Settings = any;
633
+ export interface Action {
634
+ name: string;
635
+ inputs?: Input[];
636
+ returnType?: Input;
637
+ action: Function | string;
638
+ }
639
+ export declare class Builder {
640
+ protected request?: IncomingMessage | undefined;
641
+ protected response?: ServerResponse | undefined;
642
+ /**
643
+ * @hidden
644
+ * @deprecated. This is buggy, and always behind by a version.
645
+ */
646
+ static VERSION: string;
647
+ static components: Component[];
648
+ static singletonInstance: Builder;
649
+ /**
650
+ * Makes it so that a/b tests generate code like {@link
651
+ * https://www.builder.io/blog/high-performance-no-code#__next:~:text=Static%20generated%20A%2FB%20testing}
652
+ * instead of the old way where we render only one test group at a time on the
653
+ * server. This is the preferred/better way not and we should ultimately make it
654
+ * the default
655
+ */
656
+ static isStatic: boolean;
657
+ static animator: Animator;
658
+ static nextTick: typeof nextTick;
659
+ static throttle: typeof throttle;
660
+ static editors: any[];
661
+ static trustedHosts: string[];
662
+ static plugins: any[];
663
+ static actions: Action[];
664
+ static registry: {
665
+ [key: string]: any[];
666
+ };
667
+ static overrideHost: string | undefined;
668
+ /**
669
+ * @todo `key` property on any info where if a key matches a current
670
+ * key it gets removed
671
+ */
672
+ static register(type: 'insertMenu', info: InsertMenuConfig): void;
673
+ static register(type: string, info: any): void;
674
+ static registryChange: BehaviorSubject<{
675
+ [key: string]: any[];
676
+ }, any>;
677
+ static registerEditor(info: any): void;
678
+ static registerPlugin(info: any): void;
679
+ static registerAction(action: Action): void;
680
+ static registerTrustedHost(host: string): void;
681
+ static isTrustedHost(hostname: string): boolean;
682
+ static runAction(action: Action | string): void;
683
+ static fields(name: string, fields: Input[]): void;
684
+ private static _editingPage;
685
+ static isIframe: boolean;
686
+ static isBrowser: boolean;
687
+ static isReactNative: boolean;
688
+ static isServer: boolean;
689
+ static previewingModel: string | false | null;
690
+ static settings: Settings;
691
+ static settingsChange: BehaviorSubject<any, any>;
692
+ /**
693
+ * @deprecated
694
+ * @hidden
695
+ *
696
+ * Use Builder.register('editor.settings', {}) instead.
697
+ */
698
+ static set(settings: Settings): void;
699
+ static import(packageName: string): any;
700
+ static isEditing: boolean;
701
+ static isPreviewing: boolean;
702
+ static get editingPage(): boolean;
703
+ static set editingPage(editingPage: boolean);
704
+ private static prepareComponentSpecToSend;
705
+ static registerBlock(component: any, options: Component): void;
706
+ static registerComponent(component: any, options: Component): void;
707
+ private static addComponent;
708
+ static component(info?: Partial<Component>): (component: Class) => Class;
709
+ static isReact: boolean;
710
+ static get Component(): typeof Builder.component;
711
+ private eventsQueue;
712
+ private throttledClearEventsQueue;
713
+ private processEventsQueue;
714
+ env: string;
715
+ sessionId: string;
716
+ targetContent: boolean;
717
+ contentPerRequest: number;
718
+ allowCustomFonts: boolean;
719
+ private cookies;
720
+ private cachebust;
721
+ private overrideParams;
722
+ private noCache;
723
+ private preview;
724
+ get browserTrackingDisabled(): boolean;
725
+ get canTrack(): boolean;
726
+ set canTrack(canTrack: boolean);
727
+ get apiVersion(): ApiVersion | undefined;
728
+ set apiVersion(apiVersion: ApiVersion | undefined);
729
+ private apiVersion$;
730
+ private canTrack$;
731
+ private apiKey$;
732
+ private authToken$;
733
+ userAttributesChanged: BehaviorSubject<any, any>;
734
+ get editingMode(): boolean;
735
+ set editingMode(value: boolean);
736
+ editingMode$: BehaviorSubject<boolean, any>;
737
+ get editingModel(): string | null;
738
+ set editingModel(value: string | null);
739
+ private findParentElement;
740
+ private findBuilderParent;
741
+ editingModel$: BehaviorSubject<string | null, any>;
742
+ setUserAgent(userAgent: string): void;
743
+ userAgent: string;
744
+ trackingHooks: TrackingHook[];
745
+ /**
746
+ * Set a hook to modify events being tracked from builder, such as impressions and clicks
747
+ *
748
+ * For example, to track the model ID of each event associated with content for querying
749
+ * by mode, you can do
750
+ *
751
+ * builder.setTrackingHook((event, context) => {
752
+ * if (context.content) {
753
+ * event.data.metadata.modelId = context.content.modelId
754
+ * }
755
+ * })
756
+ */
757
+ setTrackingHook(hook: TrackingHook): void;
758
+ track(eventName: string, properties?: Partial<EventData>, context?: any): void;
759
+ getSessionId(): string;
760
+ visitorId: string;
761
+ getVisitorId(): string;
762
+ trackImpression(contentId: string, variationId?: string, properties?: any, context?: any): void;
763
+ trackConversion(amount?: number, customProperties?: any): void;
764
+ autoTrack: boolean;
765
+ private get isDevelopmentEnv();
766
+ trackInteraction(contentId: string, variationId?: string, alreadyTrackedOne?: boolean, event?: MouseEvent, context?: any): void;
767
+ static overrideUserAttributes: Partial<UserAttributes>;
768
+ trackingUserAttributes: {
769
+ [key: string]: any;
770
+ };
771
+ component(info?: Partial<Component>): (component: Class) => Class;
772
+ get apiKey(): string | null;
773
+ set apiKey(key: string | null);
774
+ get authToken(): string | null;
775
+ set authToken(token: string | null);
776
+ constructor(apiKey?: string | null, request?: IncomingMessage | undefined, response?: ServerResponse | undefined, forceNewInstance?: boolean, authToken?: string | null, apiVersion?: ApiVersion);
777
+ private modifySearch;
778
+ setTestsFromUrl(): void;
779
+ resetOverrides(): void;
780
+ getOverridesFromQueryString(): void;
781
+ private messageFrameLoaded;
782
+ private blockContentLoading;
783
+ private bindMessageListeners;
784
+ observersByKey: {
785
+ [key: string]: BehaviorSubject<BuilderContent[]> | undefined;
786
+ };
787
+ noEditorUpdates: {
788
+ [key: string]: boolean;
789
+ };
790
+ get defaultCanTrack(): boolean;
791
+ init(apiKey: string, canTrack?: boolean, req?: IncomingMessage, res?: ServerResponse, authToken?: string | null, apiVersion?: ApiVersion): this;
792
+ get previewingModel(): string;
793
+ getLocation(): Url;
794
+ getUserAttributes(userAgent?: string): UserAttributes;
795
+ protected overrides: {
796
+ [key: string]: string;
797
+ };
798
+ protected queryOptions: {
799
+ [key: string]: string;
800
+ };
801
+ private getContentQueue;
802
+ private priorContentQueue;
803
+ setUserAttributes(options: object): void;
804
+ /**
805
+ * Set user attributes just for tracking purposes.
806
+ *
807
+ * Do this so properties exist on event objects for querying insights, but
808
+ * won't affect targeting
809
+ *
810
+ * Use this when you want to track properties but don't need to target off
811
+ * of them to optimize cache efficiency
812
+ */
813
+ setTrackingUserAttributes(attributes: object): void;
814
+ get(modelName: string, options?: GetContentOptions & {
815
+ req?: IncomingMessage;
816
+ res?: ServerResponse;
817
+ apiKey?: string;
818
+ authToken?: string;
819
+ }): BehaviorSubject<any, any>;
820
+ queueGetContent(modelName: string, options?: GetContentOptions): BehaviorSubject<BuilderContent[], any>;
821
+ requestUrl(url: string, options?: {
822
+ headers: {
823
+ [header: string]: number | string | string[] | undefined;
824
+ };
825
+ }): Promise<any>;
826
+ get host(): string;
827
+ private flushGetContentQueue;
828
+ private testCookiePrefix;
829
+ private processResultsForTests;
830
+ private getTestCookie;
831
+ private cookieQueue;
832
+ private setTestCookie;
833
+ getCookie(name: string): any;
834
+ setCookie(name: string, value: any, expires?: Date): false | void | Cookies;
835
+ getContent(modelName: string, options?: GetContentOptions): BehaviorSubject<BuilderContent[], any>;
836
+ getAll(modelName: string, options?: GetContentOptions & {
837
+ req?: IncomingMessage;
838
+ res?: ServerResponse;
839
+ apiKey?: string;
840
+ }): Promise<BuilderContent[]>;
841
+ }
842
+ export {};