|
1 | 1 | # Initialization Options
|
2 | 2 |
|
3 |
| -... |
| 3 | +## Browser |
| 4 | + |
| 5 | +In the browser Picard.js automatically runs - all you need to do is follow [the installation guide](../../guide/variants/browser.md). |
| 6 | + |
| 7 | +To set the initial configuration you can use a callback, e.g., on the `load` event: |
| 8 | + |
| 9 | +```html |
| 10 | +<script> |
| 11 | +function configure({ target }) { |
| 12 | + // Place a `config` property on the associated `<script>` element, e.g.,: |
| 13 | + target.config = { |
| 14 | + // ... |
| 15 | + }; |
| 16 | +} |
| 17 | +</script> |
| 18 | +<script src="./dist/picard.js" onload="configure(event)"></script> |
| 19 | +``` |
| 20 | + |
| 21 | +The provided configuration has to follow the definition for the client. All options except `feed` and `state` can be set. |
| 22 | + |
| 23 | +## Client |
| 24 | + |
| 25 | +The `initializePicard` function can be called with an options object respecting the following interface: |
| 26 | + |
| 27 | +```ts |
| 28 | +interface PicardOptions { |
| 29 | + /** |
| 30 | + * The name of the pi-component. |
| 31 | + * @default pi-component |
| 32 | + */ |
| 33 | + componentName?: string; |
| 34 | + /** |
| 35 | + * The name of the pi-slot. |
| 36 | + * @default pi-slot |
| 37 | + */ |
| 38 | + slotName?: string; |
| 39 | + /** |
| 40 | + * The name of the pi-part. |
| 41 | + * @default pi-part |
| 42 | + */ |
| 43 | + partName?: string; |
| 44 | + /** |
| 45 | + * The micro frontend discovery service URL, |
| 46 | + * data from calling it, or callback function |
| 47 | + * to call it manually. |
| 48 | + */ |
| 49 | + feed?: FeedDefinition; |
| 50 | + /** |
| 51 | + * The initial state of Picard.js - if resumed. |
| 52 | + */ |
| 53 | + state?: any; |
| 54 | + /** |
| 55 | + * The application's meta data. |
| 56 | + */ |
| 57 | + meta?: any; |
| 58 | + /** |
| 59 | + * The additional services to register. |
| 60 | + */ |
| 61 | + services?: Record<string, any>; |
| 62 | + /** |
| 63 | + * The centrally shared dependencies to use. |
| 64 | + */ |
| 65 | + dependencies?: Record<string, () => Promise<any>>; |
| 66 | +} |
| 67 | +``` |
| 68 | + |
| 69 | +## Node |
| 70 | + |
| 71 | +The `initializePicard` function can be called with an options object respecting the following interface: |
| 72 | + |
| 73 | +```ts |
| 74 | +interface PicardOptions { |
| 75 | + /** |
| 76 | + * The name of the pi-component. |
| 77 | + * @default pi-component |
| 78 | + */ |
| 79 | + componentName?: string; |
| 80 | + /** |
| 81 | + * The name of the pi-slot. |
| 82 | + * @default pi-slot |
| 83 | + */ |
| 84 | + slotName?: string; |
| 85 | + /** |
| 86 | + * The name of the pi-part. |
| 87 | + * @default pi-part |
| 88 | + */ |
| 89 | + partName?: string; |
| 90 | + /** |
| 91 | + * The URL of the fragment service, if any. |
| 92 | + */ |
| 93 | + fragmentUrl?: string; |
| 94 | + /** |
| 95 | + * The micro frontend discovery service URL, |
| 96 | + * data from calling it, or callback function |
| 97 | + * to call it manually. |
| 98 | + */ |
| 99 | + feed?: FeedDefinition; |
| 100 | + /** |
| 101 | + * The initial state of Picard.js - if resumed. |
| 102 | + */ |
| 103 | + state?: any; |
| 104 | + /** |
| 105 | + * The additional services to register. |
| 106 | + */ |
| 107 | + services?: Record<string, any>; |
| 108 | + /** |
| 109 | + * The centrally shared dependencies to use. |
| 110 | + */ |
| 111 | + dependencies?: Record<string, () => Promise<any>>; |
| 112 | +} |
| 113 | +``` |
0 commit comments