@arcgis/lumina-compiler 5.2.0-next.2 → 5.2.0-next.21

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 (102) hide show
  1. package/dist/context/index.d.ts +158 -296
  2. package/dist/context/types.d.ts +18 -34
  3. package/dist/defaultAssetsUrl.d.ts +6 -6
  4. package/dist/dependencies/discover.d.ts +43 -35
  5. package/dist/dependencies/updateLumina.d.ts +10 -11
  6. package/dist/docs/vsCodeCustomData/types.d.ts +5 -42
  7. package/dist/docs/webTypes/types.d.ts +5 -76
  8. package/dist/index.d.ts +20 -20
  9. package/dist/index.js +12 -8
  10. package/dist/jsxToLitHtml/config.d.ts +93 -121
  11. package/dist/options.d.ts +675 -0
  12. package/dist/puppeteerTesting/index.d.ts +18 -11
  13. package/dist/puppeteerTesting/index.js +104 -7
  14. package/dist/puppeteerTesting/puppeteer/element.d.ts +250 -217
  15. package/dist/puppeteerTesting/puppeteer/events.d.ts +15 -21
  16. package/dist/puppeteerTesting/puppeteer/page.d.ts +8 -5
  17. package/dist/puppeteerTesting/puppeteer/types.d.ts +130 -132
  18. package/dist/puppeteerTesting/vitest/matchers/index.d.ts +33 -30
  19. package/dist/testing/index.d.ts +4 -11
  20. package/dist/testing/mount.d.ts +113 -93
  21. package/dist/testing/wrapController.d.ts +5 -11
  22. package/dist/useLumina.d.ts +5 -2
  23. package/package.json +15 -7
  24. package/dist/context/logger.d.ts +0 -8
  25. package/dist/context/typeScript.d.ts +0 -6
  26. package/dist/context/utils.d.ts +0 -4
  27. package/dist/dependencies/arcgisCore.d.ts +0 -30
  28. package/dist/dependencies/index.d.ts +0 -12
  29. package/dist/dependencies/loaders.d.ts +0 -5
  30. package/dist/dependencies/lumina.d.ts +0 -3
  31. package/dist/dependencies/stencil.d.ts +0 -17
  32. package/dist/dependencies/testSetupFiles.d.ts +0 -13
  33. package/dist/dependencies/utils.d.ts +0 -15
  34. package/dist/docs/config.d.ts +0 -9
  35. package/dist/docs/index.d.ts +0 -10
  36. package/dist/docs/stencilDocsJson.d.ts +0 -130
  37. package/dist/docs/types.d.ts +0 -1
  38. package/dist/docs/vsCodeCustomData/index.d.ts +0 -16
  39. package/dist/docs/vsCodeCustomData/utils.d.ts +0 -3
  40. package/dist/docs/webTypes/description.d.ts +0 -2
  41. package/dist/docs/webTypes/index.d.ts +0 -19
  42. package/dist/docs/webTypes/utils.d.ts +0 -6
  43. package/dist/entrypoints/addNonLazyImports.d.ts +0 -13
  44. package/dist/entrypoints/config.d.ts +0 -17
  45. package/dist/entrypoints/dtsUtils.d.ts +0 -19
  46. package/dist/entrypoints/findUtils.d.ts +0 -6
  47. package/dist/entrypoints/handleComponentImports.d.ts +0 -13
  48. package/dist/entrypoints/resolveTagName.d.ts +0 -18
  49. package/dist/jsxToLitHtml/autoAddNothing.d.ts +0 -8
  50. package/dist/jsxToLitHtml/comments.d.ts +0 -19
  51. package/dist/jsxToLitHtml/convertProps.d.ts +0 -10
  52. package/dist/jsxToLitHtml/imports.d.ts +0 -27
  53. package/dist/jsxToLitHtml/importsConfig.d.ts +0 -17
  54. package/dist/jsxToLitHtml/index.d.ts +0 -20
  55. package/dist/jsxToLitHtml/inferPropType.d.ts +0 -40
  56. package/dist/jsxToLitHtml/insertRepeatCall.d.ts +0 -51
  57. package/dist/jsxToLitHtml/jsxVisitor.d.ts +0 -15
  58. package/dist/jsxToLitHtml/templateParts.d.ts +0 -17
  59. package/dist/jsxToLitHtml/throwOnImportingExternalized.d.ts +0 -10
  60. package/dist/jsxToLitHtml/types.d.ts +0 -74
  61. package/dist/jsxToLitHtml/utils.d.ts +0 -14
  62. package/dist/loader/css.d.ts +0 -20
  63. package/dist/loader/extractor.d.ts +0 -2
  64. package/dist/loader/index.d.ts +0 -21
  65. package/dist/loader/lazy.d.ts +0 -21
  66. package/dist/loader/storybookApiJson.d.ts +0 -6
  67. package/dist/plugins/buildCdn.d.ts +0 -73
  68. package/dist/plugins/buildWebApp.d.ts +0 -3
  69. package/dist/plugins/buildWrappers.d.ts +0 -4
  70. package/dist/plugins/configureVite.d.ts +0 -20
  71. package/dist/plugins/externalizeDependencies.d.ts +0 -30
  72. package/dist/plugins/handleDynamicAssets.d.ts +0 -8
  73. package/dist/plugins/handleStaticAssets.d.ts +0 -9
  74. package/dist/plugins/loadLitCss.d.ts +0 -127
  75. package/dist/plugins/printTotalBuildSize.d.ts +0 -7
  76. package/dist/plugins/provideAssets.d.ts +0 -35
  77. package/dist/plugins/setAssetsPath.d.ts +0 -10
  78. package/dist/plugins/updatePackageJson.d.ts +0 -14
  79. package/dist/publicTypes.d.ts +0 -653
  80. package/dist/puppeteerTesting/globalSetup.d.ts +0 -73
  81. package/dist/puppeteerTesting/injected.d.ts +0 -8
  82. package/dist/puppeteerTesting/puppeteer/browser.d.ts +0 -6
  83. package/dist/puppeteerTesting/vitest/matchers/attributes.d.ts +0 -4
  84. package/dist/puppeteerTesting/vitest/matchers/classList.d.ts +0 -4
  85. package/dist/puppeteerTesting/vitest/matchers/events.d.ts +0 -7
  86. package/dist/puppeteerTesting/vitest/matchers/text.d.ts +0 -2
  87. package/dist/puppeteerTesting/vitest/matchers/utils.d.ts +0 -1
  88. package/dist/puppeteerTesting/vitest/runner.d.ts +0 -19
  89. package/dist/puppeteerTesting/vitest/setupFile.d.ts +0 -1
  90. package/dist/puppeteerTesting/vitest/types.d.ts +0 -6
  91. package/dist/testing/failOnConsole.d.ts +0 -6
  92. package/dist/testing/setupFile.d.ts +0 -1
  93. package/dist/testing/snapshotSerializer.d.ts +0 -12
  94. package/dist/tests/utils.d.ts +0 -4
  95. package/dist/transformers/customElementDeclaration.d.ts +0 -2
  96. package/dist/transformers/index.d.ts +0 -20
  97. package/dist/transformers/injectRuntimeOptions.d.ts +0 -18
  98. package/dist/transformers/liftDecorators.d.ts +0 -21
  99. package/dist/transformers/members.d.ts +0 -10
  100. package/dist/transformers/property.d.ts +0 -10
  101. package/dist/transformers/propertyOptions.d.ts +0 -110
  102. package/dist/transformers/utils.d.ts +0 -9
@@ -1,149 +1,147 @@
1
- import { HTTPResponse, Page, WaitForOptions } from 'puppeteer';
2
- import { EventSpy } from './events.ts';
3
- import { E2EElement } from './element.ts';
1
+ import type { HTTPResponse, Page, WaitForOptions } from "puppeteer";
2
+ import type { EventSpy } from "./events.js";
3
+ import type { E2EElement } from "./element.js";
4
+
4
5
  export interface PageDiagnostic {
5
- type: "error" | "pageerror" | "requestfailed";
6
- message?: string;
7
- location?: string;
6
+ type: "error" | "pageerror" | "requestfailed";
7
+ message?: string;
8
+ location?: string;
8
9
  }
10
+
9
11
  /**
10
12
  * The E2EPage is a wrapper utility to Puppeteer in order to
11
13
  * to create easier to write and read end-to-end tests.
12
14
  */
13
15
  export interface E2EPage extends Page {
14
- /**
15
- * Sets a debugger;
16
- */
17
- debugger: () => Promise<void>;
18
- /**
19
- * Find an element that matches the selector, which is the same as
20
- * `document.querySelector(selector)`. Use `>>>` within the
21
- * selector to find an element within the host element's shadow root.
22
- * For example, to select the first `div` inside of the component
23
- * `my-cmp`, the call would be `page.find('my-cmp >>> div')`.
24
- * Returns `null` if an element was not found.
25
- */
26
- find: (selector: FindSelector) => Promise<E2EElement>;
27
- /**
28
- * Find all elements that match the selector, which is the same as
29
- * `document.querySelectorAll(selector)`. Use `>>>` within the
30
- * selector to find elements within the host element's shadow root.
31
- * For example, to select all of the `li` elements inside of the component
32
- * `my-cmp`, the call would be `page.findAll('my-cmp >>> li')`.
33
- * Returns an empty array if no elements were found.
34
- */
35
- findAll: (selector: string) => Promise<E2EElement[]>;
36
- /**
37
- * During an end-to-end test, a dev-server is started so `page.goto(url)` can be used
38
- * on the app being tested. Urls are always relative since the dev server provides
39
- * a localhost address. A shortcut to `page.goto(url)` is to set the `url` option
40
- * when creating a new page, such as `const page = await newE2EPage({ url })`.
41
- */
42
- goTo: (url: string, options?: WaitForOptions) => Promise<HTTPResponse | null>;
43
- /**
44
- * Instead of testing a url directly, html content can be mocked using
45
- * `page.setContent(html)`. A shortcut to `page.setContent(html)` is to set
46
- * the `html` option when creating a new page, such as
47
- * `const page = await newE2EPage({ html })`.
48
- */
49
- setContent: (html: string, options?: WaitForOptions) => Promise<void>;
50
- /**
51
- * Used to test if an event was, or was not dispatched. This method
52
- * returns a promise, that resolves with an EventSpy. The EventSpy
53
- * can be used along with `expect(spy).toHaveReceivedEvent()`,
54
- * `expect(spy).toHaveReceivedEventTimes(x)` and
55
- * `expect(spy).toHaveReceivedEventDetail({...})`.
56
- */
57
- spyOnEvent: <Detail = unknown>(eventName: string, selector?: "document" | "window") => Promise<EventSpy<Detail>>;
58
- /**
59
- * Puppeteer has asynchronous architecture. Since all calls are async, it's
60
- * required that `await page.waitForChanges()` is called when changes are
61
- * made to components.
62
- * An error will be thrown if changes were made to a component but
63
- * `waitForChanges()` was not called.
64
- *
65
- * @param delay - The number of milliseconds to wait after components
66
- * finish updating. Default value is determined by the
67
- * `puppeteerTesting.waitForChangesDelay` option passed to useLumina().
68
- */
69
- waitForChanges: (delay?: number) => Promise<void>;
70
- /**
71
- * Waits for the event to be received on `window`. The optional second argument
72
- * allows the listener to be set to `document` if needed.
73
- */
74
- waitForEvent: <Detail = unknown>(eventName: string) => Promise<SerializedEvent<Detail>>;
75
- getDiagnostics: () => PageDiagnostic[];
76
- isClosed: () => boolean;
77
- /**
78
- * Causes your script to wait for the given number of milliseconds.
79
- *
80
- * @remarks
81
- *
82
- * It's generally recommended to not wait for a number of seconds, but instead
83
- * use {@link Frame.waitForSelector}, {@link Frame.waitForXPath} or
84
- * {@link Frame.waitForFunction} to wait for exactly the conditions you want.
85
- *
86
- * @example
87
- *
88
- * Wait for 1 second:
89
- *
90
- * ```ts
91
- * await page.waitForTimeout(1000);
92
- * ```
93
- *
94
- * @param milliseconds - the number of milliseconds to wait.
95
- */
96
- waitForTimeout: (milliseconds: number) => Promise<void>;
97
- /** @private */
98
- _e2eElements: E2EElement[];
99
- /** @private */
100
- _e2eEvents: Map<number, WaitForEvent>;
101
- /** @private */
102
- _e2eEventIds: number;
103
- /** @private */
104
- _originalClose: Page["close"];
105
- /** @private */
106
- _isWaitingForAllReady: boolean;
107
- /** @private */
108
- _unhandledError: unknown;
16
+ /** Sets a debugger; */
17
+ debugger(): Promise<void>;
18
+ /**
19
+ * Find an element that matches the selector, which is the same as
20
+ * `document.querySelector(selector)`. Use `>>>` within the
21
+ * selector to find an element within the host element's shadow root.
22
+ * For example, to select the first `div` inside of the component
23
+ * `my-cmp`, the call would be `page.find('my-cmp >>> div')`.
24
+ * Returns `null` if an element was not found.
25
+ *
26
+ * @param selector
27
+ */
28
+ find(selector: FindSelector): Promise<E2EElement>;
29
+ /**
30
+ * Find all elements that match the selector, which is the same as
31
+ * `document.querySelectorAll(selector)`. Use `>>>` within the
32
+ * selector to find elements within the host element's shadow root.
33
+ * For example, to select all of the `li` elements inside of the component
34
+ * `my-cmp`, the call would be `page.findAll('my-cmp >>> li')`.
35
+ * Returns an empty array if no elements were found.
36
+ *
37
+ * @param selector
38
+ */
39
+ findAll(selector: string): Promise<E2EElement[]>;
40
+ /**
41
+ * During an end-to-end test, a dev-server is started so `page.goto(url)` can be used
42
+ * on the app being tested. Urls are always relative since the dev server provides
43
+ * a localhost address. A shortcut to `page.goto(url)` is to set the `url` option
44
+ * when creating a new page, such as `const page = await newE2EPage({ url })`.
45
+ *
46
+ * @param url
47
+ * @param options
48
+ */
49
+ goTo(url: string, options?: WaitForOptions): Promise<HTTPResponse | null>;
50
+ /**
51
+ * Instead of testing a url directly, html content can be mocked using
52
+ * `page.setContent(html)`. A shortcut to `page.setContent(html)` is to set
53
+ * the `html` option when creating a new page, such as
54
+ * `const page = await newE2EPage({ html })`.
55
+ *
56
+ * @param html
57
+ * @param options
58
+ */
59
+ setContent(html: string, options?: WaitForOptions): Promise<void>;
60
+ /**
61
+ * Used to test if an event was, or was not dispatched. This method
62
+ * returns a promise, that resolves with an EventSpy. The EventSpy
63
+ * can be used along with `expect(spy).toHaveReceivedEvent()`,
64
+ * `expect(spy).toHaveReceivedEventTimes(x)` and
65
+ * `expect(spy).toHaveReceivedEventDetail({...})`.
66
+ *
67
+ * @param eventName
68
+ * @param selector
69
+ */
70
+ spyOnEvent<Detail = unknown>(eventName: string, selector?: "document" | "window"): Promise<EventSpy<Detail>>;
71
+ /**
72
+ * Puppeteer has asynchronous architecture. Since all calls are async, it's
73
+ * required that `await page.waitForChanges()` is called when changes are
74
+ * made to components.
75
+ * An error will be thrown if changes were made to a component but
76
+ * `waitForChanges()` was not called.
77
+ *
78
+ * @param delay - The number of milliseconds to wait after components
79
+ * finish updating. Default value is determined by the
80
+ * `puppeteerTesting.waitForChangesDelay` option passed to useLumina().
81
+ */
82
+ waitForChanges(delay?: number): Promise<void>;
83
+ /**
84
+ * Waits for the event to be received on `window`. The optional second argument
85
+ * allows the listener to be set to `document` if needed.
86
+ *
87
+ * @param eventName
88
+ */
89
+ waitForEvent<Detail = unknown>(eventName: string): Promise<SerializedEvent<Detail>>;
90
+ getDiagnostics(): PageDiagnostic[];
91
+ isClosed(): boolean;
92
+ /**
93
+ * Causes your script to wait for the given number of milliseconds.
94
+ *
95
+ * It's generally recommended to not wait for a number of seconds, but instead
96
+ * use Frame.waitForSelector, Frame.waitForXPath or
97
+ * Frame.waitForFunction to wait for exactly the conditions you want.
98
+ *
99
+ * @param milliseconds - the number of milliseconds to wait.
100
+ * @example
101
+ * Wait for 1 second:
102
+ *
103
+ * ```ts
104
+ * await page.waitForTimeout(1000);
105
+ * ```
106
+ */
107
+ waitForTimeout(milliseconds: number): Promise<void>;
109
108
  }
109
+
110
110
  export interface SerializedEvent<Detail = unknown> {
111
- bubbles: boolean;
112
- cancelable: boolean;
113
- composed: boolean;
114
- currentTarget: SerializedElement;
115
- defaultPrevented: boolean;
116
- detail: Detail;
117
- eventPhase: number;
118
- isTrusted: boolean;
119
- target: SerializedElement;
120
- timeStamp: number;
121
- type: string;
122
- isSerializedEvent: boolean;
111
+ bubbles: boolean;
112
+ cancelable: boolean;
113
+ composed: boolean;
114
+ currentTarget: SerializedElement;
115
+ defaultPrevented: boolean;
116
+ detail: Detail;
117
+ eventPhase: number;
118
+ isTrusted: boolean;
119
+ target: SerializedElement;
120
+ timeStamp: number;
121
+ type: string;
122
+ isSerializedEvent: boolean;
123
123
  }
124
+
124
125
  export type SerializedElement = Record<string, unknown> | null;
126
+
125
127
  export type FindSelector = FindSelectorOptions | string;
128
+
126
129
  export interface FindSelectorOptions {
127
- /**
128
- * Finds an element with text content matching this
129
- * exact value after the whitespace has been trimmed.
130
- */
131
- text?: string;
132
- /**
133
- * Finds an element with text content containing this value.
134
- */
135
- contains?: string;
130
+ /**
131
+ * Finds an element with text content matching this
132
+ * exact value after the whitespace has been trimmed.
133
+ */
134
+ text?: string;
135
+ /** Finds an element with text content containing this value. */
136
+ contains?: string;
136
137
  }
138
+
137
139
  export interface WaitForEventOptions {
138
- timeout?: number;
140
+ timeout?: number;
139
141
  }
142
+
140
143
  export interface WaitForEvent {
141
- eventName: string;
142
- callback: (event: SerializedEvent) => void;
143
- }
144
- export interface BrowserWindow extends Window {
145
- puppeteerAwaitAllReady: () => Promise<void>;
146
- puppeteerOnEvent: (id: number, event: SerializedEvent) => void;
147
- puppeteerSerializeEvent: <Detail = unknown>(event: CustomEvent | Event) => SerializedEvent<Detail>;
148
- puppeteerSerializeEventTarget: (target: Element | EventTarget | null) => SerializedElement;
149
- }
144
+ eventName: string;
145
+ /** @param event */
146
+ callback(event: SerializedEvent): void;
147
+ }
@@ -1,31 +1,34 @@
1
- export declare const expectExtend: {
2
- toEqualAttribute: import('vitest').Matcher<import('vitest').MatcherState, any[]>;
3
- toEqualAttributes: import('vitest').Matcher<import('vitest').MatcherState, any[]>;
4
- toEqualText: import('vitest').Matcher<import('vitest').MatcherState, any[]>;
5
- toHaveAttribute: import('vitest').Matcher<import('vitest').MatcherState, any[]>;
6
- toHaveClass: import('vitest').Matcher<import('vitest').MatcherState, any[]>;
7
- toHaveClasses: (element: unknown, expectClassNames: string[]) => import('@vitest/expect').SyncExpectationResult;
8
- toMatchClasses: import('vitest').Matcher<import('vitest').MatcherState, any[]>;
9
- toHaveReceivedEvent: import('vitest').Matcher<import('vitest').MatcherState, any[]>;
10
- toHaveReceivedEventTimes: import('vitest').Matcher<import('vitest').MatcherState, any[]>;
11
- toHaveReceivedEventDetail: import('vitest').Matcher<import('vitest').MatcherState, any[]>;
12
- toHaveFirstReceivedEventDetail: import('vitest').Matcher<import('vitest').MatcherState, any[]>;
13
- toHaveLastReceivedEventDetail: import('vitest').Matcher<import('vitest').MatcherState, any[]>;
14
- toHaveNthReceivedEventDetail: import('vitest').Matcher<import('vitest').MatcherState, any[]>;
15
- };
1
+ /**
2
+ * @internal
3
+ * @knipIgnore Used in ../../index.ts inside a namespace
4
+ */
16
5
  export interface PuppeteerMatchers<R = unknown> {
17
- toEqualAttribute: (expectedAttribute: string, expectedValue: unknown) => R;
18
- toEqualAttributes: (expectedAttributes: Record<string, unknown>) => R;
19
- toEqualHtml: (expectedHtml: string) => R;
20
- toEqualLightHtml: (expectedHtml: string) => R;
21
- toEqualText: (expectedTextContent: string) => R;
22
- toHaveAttribute: (expectedAttributeName: string) => R;
23
- toHaveClass: (classNames: string) => R;
24
- toHaveClasses: (classNames: string[]) => R;
25
- toHaveReceivedEvent: () => R;
26
- toHaveReceivedEventTimes: (count: number) => R;
27
- toHaveReceivedEventDetail: (eventDetail: unknown) => R;
28
- toHaveFirstReceivedEventDetail: (eventDetail: unknown) => R;
29
- toHaveLastReceivedEventDetail: (eventDetail: unknown) => R;
30
- toHaveNthReceivedEventDetail: (index: number, eventDetail: unknown) => R;
31
- }
6
+ /** @internal */
7
+ toEqualAttribute: (expectedAttribute: string, expectedValue: unknown) => R;
8
+ /** @internal */
9
+ toEqualAttributes: (expectedAttributes: Record<string, unknown>) => R;
10
+ /** @internal */
11
+ toEqualHtml: (expectedHtml: string) => R;
12
+ /** @internal */
13
+ toEqualLightHtml: (expectedHtml: string) => R;
14
+ /** @internal */
15
+ toEqualText: (expectedTextContent: string) => R;
16
+ /** @internal */
17
+ toHaveAttribute: (expectedAttributeName: string) => R;
18
+ /** @internal */
19
+ toHaveClass: (classNames: string) => R;
20
+ /** @internal */
21
+ toHaveClasses: (classNames: string[]) => R;
22
+ /** @internal */
23
+ toHaveReceivedEvent: () => R;
24
+ /** @internal */
25
+ toHaveReceivedEventTimes: (count: number) => R;
26
+ /** @internal */
27
+ toHaveReceivedEventDetail: (eventDetail: unknown) => R;
28
+ /** @internal */
29
+ toHaveFirstReceivedEventDetail: (eventDetail: unknown) => R;
30
+ /** @internal */
31
+ toHaveLastReceivedEventDetail: (eventDetail: unknown) => R;
32
+ /** @internal */
33
+ toHaveNthReceivedEventDetail: (index: number, eventDetail: unknown) => R;
34
+ }
@@ -1,11 +1,4 @@
1
- /**
2
- * Unlike most of lumina-compiler code, this entrypoint may be executed in the
3
- * browser (or in node.js), depending on where the tests are running.
4
- *
5
- * Thus, make sure to not import anything from the rest of the lumina-compiler
6
- * in this bundle.
7
- */
8
- export type { RenderOptions, RenderResult } from './mount.ts';
9
- export { mount, findFirstComponent } from './mount.ts';
10
- export { setupLuminaTest } from './setupFile.ts';
11
- export { wrapController } from './wrapController.ts';
1
+ export { type RenderOptions, type RenderResult } from "./mount.js";
2
+ export { mount, findFirstComponent } from "./mount.js";
3
+ export { wrapController } from "./wrapController.js";
4
+
@@ -1,89 +1,90 @@
1
- import { TemplateResult } from 'lit';
2
- import { JsxNode, LitElement, ToElement } from '@arcgis/lumina';
3
- export type RenderResult<Component extends HTMLElement> = {
4
- /**
5
- * The custom element proxy that is attached to the DOM.
6
- *
7
- * This element will contain all the public properties and public methods of
8
- * your custom element, but it will not contain any internal members.
9
- */
10
- readonly el: ToElement<Component> & {
11
- shadowRoot: ShadowRoot;
12
- };
13
- /**
14
- * This is the actual LitElement that you authored in the code.
15
- *
16
- * It is not directly connected to the DOM (instead, a proxy element is used
17
- * to facilitate lazy-loading).
18
- *
19
- * All public and private members of your custom element are available here.
20
- */
21
- readonly component: Component;
22
- /**
23
- * The container element that was used to render the component.
24
- *
25
- * This element is useful to inspect for functional components and components
26
- * that do not use shadow DOM.
27
- */
28
- readonly container: HTMLElement;
29
- /**
30
- * A callback for triggering component re-render. Optionally, if the first
31
- * argument to `mount()` was a function, that function will be called
32
- * again to get a new template.
33
- *
34
- * @example
35
- * ```tsx
36
- * let someValue = 1;
37
- * const { el, component, reRender } = await mount<ArcgisCounter>(
38
- * ()=><arcgis-counter someProp={someValue} />
39
- * );
40
- *
41
- * someValue = 2;
42
- * await reRender();
43
- * ```
44
- *
45
- * The above is roughly equivalent to manually setting `el.someProp = 2`.
46
- */
47
- readonly reRender: () => Promise<boolean>;
48
- };
49
- export type RenderOptions<Component extends HTMLElement = HTMLElement> = {
50
- /**
51
- * The parent to attach this component to.
52
- *
53
- * @default document.body
54
- */
55
- readonly parent?: DocumentFragment | HTMLElement;
56
- /**
57
- * `mount()` will return a promise that resolves after the element
58
- * is connected to the DOM, fully loaded and rendered.
59
- *
60
- * This callback is for executing code right after the element is connected to
61
- * the DOM, but before it is fully loaded and rendered.
62
- */
63
- readonly afterConnect?: (el: ToElement<Component> & {
64
- shadowRoot: ShadowRoot;
65
- }) => Promise<void> | void;
66
- /**
67
- * This option only needs to be used if you created the custom element
68
- * dynamically (inside the test file), rather than in a separate .tsx file.
69
- * Also, if you already passed the dynamic custom element class as the first
70
- * argument to `mount()`, you don't need to provide it again here.
71
- */
72
- readonly dynamicComponents?: (typeof LitElement)[];
73
- /**
74
- * Whether to cleanup the document body after the test. Set this to false if
75
- * you wish to reuse the same component between different test() blocks.
76
- *
77
- * @default true
78
- */
79
- readonly cleanupAfterTest?: boolean;
80
- };
1
+ import type { DeclareElements, JsxNode, LitElement, ToElement } from "@arcgis/lumina";
2
+ import type { TemplateResult } from "lit";
3
+
4
+ export interface RenderResult<Component extends HTMLElement> {
5
+ /**
6
+ * The custom element proxy that is attached to the DOM.
7
+ *
8
+ * This element will contain all the public properties and public methods of
9
+ * your custom element, but it will not contain any internal members.
10
+ */
11
+ readonly el: ToElement<Component> & { shadowRoot: ShadowRoot; };
12
+ /**
13
+ * This is the actual LitElement that you authored in the code.
14
+ *
15
+ * It is not directly connected to the DOM (instead, a proxy element is used
16
+ * to facilitate lazy-loading).
17
+ *
18
+ * All public and private members of your custom element are available here.
19
+ */
20
+ readonly component: Component;
21
+ /**
22
+ * The container element that was used to render the component.
23
+ *
24
+ * This element is useful to inspect for functional components and components
25
+ * that do not use shadow DOM.
26
+ */
27
+ readonly container: HTMLElement;
28
+ /**
29
+ * A callback for triggering component re-render. Optionally, if the first
30
+ * argument to `mount()` was a function, that function will be called
31
+ * again to get a new template.
32
+ *
33
+ * @example
34
+ * ```tsx
35
+ * let someValue = 1;
36
+ * const { el, component, reRender } = await mount<ArcgisCounter>(
37
+ * ()=><arcgis-counter someProp={someValue} />
38
+ * );
39
+ *
40
+ * someValue = 2;
41
+ * await reRender();
42
+ * ```
43
+ *
44
+ * The above is roughly equivalent to manually setting `el.someProp = 2`.
45
+ */
46
+ reRender(): Promise<boolean>;
47
+ }
48
+
49
+ export interface RenderOptions<Component extends HTMLElement = HTMLElement> {
50
+ /**
51
+ * The parent to attach this component to.
52
+ *
53
+ * @default document.body
54
+ */
55
+ readonly parent?: DocumentFragment | HTMLElement;
56
+ /**
57
+ * `mount()` will return a promise that resolves after the element
58
+ * is connected to the DOM, fully loaded and rendered.
59
+ *
60
+ * This callback is for executing code right after the element is connected to
61
+ * the DOM, but before it is fully loaded and rendered.
62
+ *
63
+ * @param el
64
+ */
65
+ afterConnect?(el: ToElement<Component> & { shadowRoot: ShadowRoot; }): Promise<void> | void;
66
+ /**
67
+ * This option only needs to be used if you created the custom element
68
+ * dynamically (inside the test file), rather than in a separate .tsx file.
69
+ * Also, if you already passed the dynamic custom element class as the first
70
+ * argument to `mount()`, you don't need to provide it again here.
71
+ */
72
+ readonly dynamicComponents?: (typeof LitElement)[];
73
+ /**
74
+ * Whether to cleanup the document body after the test. Set this to false if
75
+ * you wish to reuse the same component between different test() blocks.
76
+ *
77
+ * @default true
78
+ */
79
+ readonly cleanupAfterTest?: boolean;
80
+ }
81
+
81
82
  /**
82
83
  * Render Lit Element in a test environment.
83
84
  *
84
- * See documentation:
85
- * https://webgis.esri.com/references/lumina/testing
86
- *
85
+ * @param tagName
86
+ * @param options
87
+ * @see https://webgis.esri.com/references/lumina/testing
87
88
  * @example
88
89
  * ```tsx
89
90
  * // Create component based on a tag name
@@ -93,8 +94,7 @@ export type RenderOptions<Component extends HTMLElement = HTMLElement> = {
93
94
  * // You can also use the component class as the explicit type annotation:
94
95
  * const { el, component } = await mount<ArcgisCounter>(<arcgis-counter />);
95
96
  * ```
96
- *
97
- * @remarks
97
+ * @example
98
98
  * In it's simplest form, what this function is doing is the following:
99
99
  *
100
100
  * ```tsx
@@ -104,17 +104,37 @@ export type RenderOptions<Component extends HTMLElement = HTMLElement> = {
104
104
  * await el.componentOnReady();
105
105
  * ```
106
106
  */
107
- export declare function mount<const TagName extends keyof DeclareElements>(tagName: TagName, options?: RenderOptions<DeclareElements[TagName]>): Promise<RenderResult<DeclareElements[TagName]>>;
108
- export declare function mount<Class extends typeof LitElement>(template: TemplateResult | (() => JsxNode), options?: RenderOptions<InstanceType<Class>> & {
109
- dynamicComponents: [Class];
110
- }): Promise<RenderResult<InstanceType<Class>>>;
111
- export declare function mount<TagName extends keyof DeclareElements = never>(jsx: TemplateResult | (() => JsxNode), options?: RenderOptions<[TagName] extends [never] ? LitElement : DeclareElements[TagName]>): Promise<RenderResult<[TagName] extends [never] ? LitElement : DeclareElements[TagName]>>;
112
- export declare function mount<Class extends typeof LitElement>(template: Class | TemplateResult | (() => JsxNode), options?: RenderOptions<InstanceType<Class>>): Promise<RenderResult<InstanceType<Class>>>;
113
- export declare function mount<Component extends LitElement>(template: TemplateResult | (() => JsxNode) | (new () => Component), options?: RenderOptions<Component>): Promise<RenderResult<Component>>;
107
+ export function mount<const TagName extends keyof DeclareElements>(tagName: TagName, options?: RenderOptions<DeclareElements[TagName]>): Promise<RenderResult<DeclareElements[TagName]>>;
108
+
109
+ /**
110
+ * @param template
111
+ * @param options
112
+ */
113
+ export function mount<Class extends typeof LitElement>(template: TemplateResult | (() => JsxNode), options?: RenderOptions<InstanceType<Class>> & { dynamicComponents: [Class]; }): Promise<RenderResult<InstanceType<Class>>>;
114
+
115
+ /**
116
+ * @param jsx
117
+ * @param options
118
+ */
119
+ export function mount<TagName extends keyof DeclareElements = never>(jsx: TemplateResult | (() => JsxNode), options?: RenderOptions<[TagName] extends [never] ? LitElement : DeclareElements[TagName]>): Promise<RenderResult<[TagName] extends [never] ? LitElement : DeclareElements[TagName]>>;
120
+
121
+ /**
122
+ * @param template
123
+ * @param options
124
+ */
125
+ export function mount<Class extends typeof LitElement>(template: Class | TemplateResult | (() => JsxNode), options?: RenderOptions<InstanceType<Class>>): Promise<RenderResult<InstanceType<Class>>>;
126
+
127
+ /**
128
+ * @param template
129
+ * @param options
130
+ */
131
+ export function mount<Component extends LitElement>(template: TemplateResult | (() => JsxNode) | (new () => Component), options?: RenderOptions<Component>): Promise<RenderResult<Component>>;
132
+
114
133
  /**
115
134
  * Find the first direct child Lumina component element. If failed to find a
116
135
  * direct child, do a priority-first search in the children of the children.
117
136
  *
137
+ * @param container
118
138
  * @experimental
119
139
  */
120
- export declare function findFirstComponent(container: ParentNode): Element | undefined;
140
+ export function findFirstComponent(container: ParentNode): Element | undefined;
@@ -1,15 +1,17 @@
1
- import { LitElement } from '@arcgis/lumina';
1
+ import type { LitElement } from "@arcgis/lumina";
2
+
2
3
  /**
3
4
  * Wrap a controller in a small component - useful when you are interested in
4
5
  * only testing the controller behavior.
5
6
  *
7
+ * @param controller
8
+ * @param afterConstruct
6
9
  * @example
7
10
  * ```ts
8
11
  * const testController = (): string => makeController(()=>'a');
9
12
  * const { component } = await mount(wrapController(testController));
10
13
  * expect(component.controller).toEqual("a");
11
14
  * ```
12
- *
13
15
  * @example
14
16
  * ```ts
15
17
  * class TestController extends Controller {
@@ -21,12 +23,4 @@ import { LitElement } from '@arcgis/lumina';
21
23
  * expect(controller.a).toEqual("a");
22
24
  * ```
23
25
  */
24
- export declare function wrapController<T>(controller: ((component: LitElement) => T) | (new (component: LitElement) => T),
25
- /**
26
- * An optional callback to call right after controller constructor
27
- */
28
- afterConstruct?: (component: LitElement & {
29
- controller: T;
30
- }) => Promise<void> | void): typeof LitElement & (new () => LitElement & {
31
- controller: T;
32
- });
26
+ export function wrapController<T>(controller: ((component: LitElement) => T) | (new (component: LitElement) => T), afterConstruct?: (component: LitElement & { controller: T; }) => Promise<void> | void): typeof LitElement & (new () => LitElement & { controller: T; });