@open-pioneer/test-utils 4.7.0-dev.20260713101438 → 4.7.0-dev.20260727091735

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,10 +1,14 @@
1
1
  # @open-pioneer/test-utils
2
2
 
3
- ## 4.7.0-dev.20260713101438
3
+ ## 4.7.0-dev.20260727091735
4
4
 
5
5
  ### Minor Changes
6
6
 
7
- - e433296: Update Chakra UI to 3.36.0
7
+ - e433296: Update Chakra UI to 3.36.1
8
+
9
+ ### Patch Changes
10
+
11
+ - 9d84f1e: Migrated from eslint to oxlint.
8
12
 
9
13
  ## 4.6.0
10
14
 
@@ -42,20 +46,20 @@
42
46
  - 9fa7f7c: The `createService` helper no longer returns a promise.
43
47
  It can now be used in a synchronous fashion (no `await`).
44
48
 
45
- Note that this change is backwards compatible.
46
- But if you have been using this function in your code, you can simply remove the `await`.
49
+ Note that this change is backwards compatible.
50
+ But if you have been using this function in your code, you can simply remove the `await`.
47
51
 
48
- It originally returned a promise to support (future) asynchronous initialization of services,
49
- which has not been implemented and seems not to be needed.
52
+ It originally returned a promise to support (future) asynchronous initialization of services,
53
+ which has not been implemented and seems not to be needed.
50
54
 
51
- Example:
55
+ Example:
52
56
 
53
- ```ts
54
- // In your unit tests:
55
- import { createService } from "@open-pioneer/test-utils/services";
57
+ ```ts
58
+ // In your unit tests:
59
+ import { createService } from "@open-pioneer/test-utils/services";
56
60
 
57
- const service = createService(MyServiceClass, options);
58
- ```
61
+ const service = createService(MyServiceClass, options);
62
+ ```
59
63
 
60
64
  - 1b95a62: Update chakra-ui to 3.28.0
61
65
 
@@ -91,13 +95,13 @@
91
95
  ### Major Changes
92
96
 
93
97
  - 9477e54: Update dependencies
94
- - React 19
95
- - Vite 6
96
- - FormatJS 3
97
- - Open Pioneer Build Tools
98
- - ...
98
+ - React 19
99
+ - Vite 6
100
+ - FormatJS 3
101
+ - Open Pioneer Build Tools
102
+ - ...
99
103
 
100
- For more details, see https://github.com/open-pioneer/trails-core-packages/pull/81
104
+ For more details, see https://github.com/open-pioneer/trails-core-packages/pull/81
101
105
 
102
106
  ## 2.4.0
103
107
 
package/README.md CHANGED
@@ -121,7 +121,9 @@ import { createIntl } from "@open-pioneer/test-utils/vanilla";
121
121
 
122
122
  // In your test:
123
123
  const intl = createIntl(/* optional arguments such as messages or locale */);
124
- intl.formatMessage({/* ... */});
124
+ intl.formatMessage({
125
+ /* ... */
126
+ });
125
127
  ```
126
128
 
127
129
  ## License
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "type": "module",
3
3
  "name": "@open-pioneer/test-utils",
4
- "version": "4.7.0-dev.20260713101438",
4
+ "version": "4.7.0-dev.20260727091735",
5
5
  "description": "Contains test utilities that make it easier to test parts of an Open Pioneer Trails application.",
6
6
  "keywords": [
7
7
  "open-pioneer-trails"
@@ -15,12 +15,12 @@
15
15
  },
16
16
  "dependencies": {
17
17
  "@conterra/reactivity-core": "^0.8.6",
18
- "@testing-library/react": "^16.3.2",
19
- "react": "^19.2.7",
20
- "react-dom": "^19.2.7",
18
+ "@formatjs/intl": "^4.1.17",
21
19
  "@testing-library/dom": "^10.4.1",
22
- "@formatjs/intl": "^4.1.15",
23
- "@open-pioneer/runtime": "4.7.0-dev.20260713101438"
20
+ "@testing-library/react": "^16.3.2",
21
+ "react": "^19.2.8",
22
+ "react-dom": "^19.2.8",
23
+ "@open-pioneer/runtime": "4.7.0-dev.20260727091735"
24
24
  },
25
25
  "exports": {
26
26
  "./package.json": "./package.json",
package/react.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"react.js","sources":["react.tsx"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport type { ColorModeValue, PackageIntl, Service } from \"@open-pioneer/runtime\";\nimport { computed, constant, ReadonlyReactive } from \"@conterra/reactivity-core\";\nimport {\n APP_ROOT_CLASS,\n CustomChakraProvider,\n PackageContext,\n PackageContextMethods\n} from \"@open-pioneer/runtime/test-support\";\nimport { FC, ReactNode, useInsertionEffect, useMemo } from \"react\";\nimport { createIntl } from \"./vanilla\";\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type AnyService = Service<any>;\n\nexport interface PackageContextProviderProps {\n /** Interface implementations, keyed by interface name. */\n services?: {\n [interfaceName: string]: AnyService;\n };\n\n /** Interface implementations, keyed by interface name and then by qualifier. */\n qualifiedServices?: {\n [interfaceName: string]: {\n [qualifier: string]: AnyService;\n };\n };\n\n /** Package properties (keyed by package name). */\n properties?: {\n [packageName: string]: Record<string, unknown>;\n };\n\n /**\n * The locale for i18n messages and formatting.\n *\n * @default \"en\"\n */\n locale?: string;\n\n /**\n * The color mode.\n */\n colorMode?: ColorModeValue;\n\n /**\n * I18n messages for packages\n */\n messages?: {\n /**\n * I18n messages as (messageId, message) entries.\n *\n * @default {}\n */\n [packageName: string]: Record<string, string>;\n };\n\n /** Children to render */\n children?: ReactNode;\n}\n\n/**\n * Injects services and properties into the component tree.\n * React components using Open Pioneer Trails hooks like `useService` and `useProperties`\n * will receive the mocked properties here instead.\n * Currently also wrapped with the CustomChakraProvider to support chakra-ui elements\n */\nexport const PackageContextProvider: FC<PackageContextProviderProps> = (props) => {\n const { children, ...rest } = props;\n const [locale, colorMode, contextMethods] = useMemo(\n () => createPackageContextMethods(rest),\n [rest]\n );\n\n useInsertionEffect(() => {\n // Needed for chakra tokens / theme etc. to be applied correctly.\n // In real applications, this is done as part of the web component startup code.\n // In test scenarios, the body is used as the root node (see props below).\n document.body.classList.add(APP_ROOT_CLASS);\n return () => {\n document.body.classList.remove(APP_ROOT_CLASS);\n };\n }, []);\n\n return (\n <CustomChakraProvider\n rootNode={document}\n appRoot={document.body}\n locale={locale}\n colorMode={colorMode}\n >\n <PackageContext.Provider value={contextMethods}>{children}</PackageContext.Provider>\n </CustomChakraProvider>\n );\n};\n\nfunction createPackageContextMethods(\n options: Omit<PackageContextProviderProps, \"children\">\n): [\n locale: ReadonlyReactive<string>,\n colorMode: ReadonlyReactive<ColorModeValue>,\n methods: PackageContextMethods\n] {\n const services = options?.services ?? {};\n const qualifiedServices = options?.qualifiedServices ?? {};\n const properties = options?.properties ?? {};\n const locale = options?.locale ?? \"en\";\n const messages = options?.messages ?? {};\n const cachedIntl: Record<string, PackageIntl> = {};\n const colorMode = computed(() => options?.colorMode ?? \"light\");\n const methods: PackageContextMethods = {\n getService(packageName, interfaceName, options) {\n if (!options.qualifier) {\n const service = services[interfaceName];\n if (service) {\n return service;\n }\n const qualified = qualifiedServices[interfaceName];\n if (qualified) {\n for (const value of Object.values(qualified)) {\n return value; // Return any implementation\n }\n }\n throw new Error(\n `Interface name not bound for testing: '${interfaceName}'. Update the configuration of PackageContextProvider.`\n );\n }\n\n const qualifiedService = qualifiedServices[interfaceName]?.[options.qualifier];\n if (!qualifiedService) {\n throw new Error(\n `Interface name not bound for testing: '${interfaceName}' (qualifier '${options.qualifier}'). Update the configuration of PackageContextProvider.`\n );\n }\n return qualifiedService;\n },\n getServices(packageName, interfaceName) {\n const unqualified = services[interfaceName];\n const results = Object.values(qualifiedServices[interfaceName] ?? {});\n if (unqualified) {\n results.push(unqualified);\n }\n return results;\n },\n getProperties(packageName) {\n const packageProperties = properties[packageName];\n if (!packageProperties) {\n throw new Error(\n `No properties for package '${packageName}' bound for testing. Update the configuration of PackageContextProvider.`\n );\n }\n return packageProperties;\n },\n getIntl(packageName) {\n const initIntl = () => {\n const packageMessages = messages[packageName];\n return createIntl({\n locale: locale,\n messages: packageMessages\n });\n };\n return (cachedIntl[packageName] ??= initIntl());\n }\n };\n return [constant(locale), colorMode, methods];\n}\n"],"names":["options"],"mappings":";;;;;;AAoEO,MAAM,sBAAA,GAA0D,CAAC,KAAA,KAAU;AAC9E,EAAA,MAAM,EAAE,QAAA,EAAU,GAAG,IAAA,EAAK,GAAI,KAAA;AAC9B,EAAA,MAAM,CAAC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A,OAAO,iBAAA;AAAA,IACX,CAAA;AAAA,IACA,QAAQ,WAAA,EAAa;AACjB,MAAA,MAAM,WAAW,MAAM;AACnB,QAAA,MAAM,eAAA,GAAkB,SAAS,WAAW,CAAA;AAC5C,QAAA,OAAO,UAAA,CAAW;AAAA,UACd,MAAA;AAAA,UACA,QAAA,EAAU;AAAA,SACb,CAAA;AAAA,MACL,CAAA;AACA,MAAA,OAAQ,UAAA,CAAW,WAAW,CAAA,KAAM,QAAA,EAAS;AAAA,IACjD;AAAA,GACJ;AACA,EAAA,OAAO,CAAC,QAAA,CAAS,MAAM,CAAA,EAAG,WAAW,OAAO,CAAA;AAChD;;;;"}
1
+ {"version":3,"file":"react.js","sources":["react.tsx"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\n\nimport { computed, constant, ReadonlyReactive } from \"@conterra/reactivity-core\";\nimport type { ColorModeValue, PackageIntl, Service } from \"@open-pioneer/runtime\";\nimport {\n APP_ROOT_CLASS,\n CustomChakraProvider,\n PackageContext,\n PackageContextMethods\n} from \"@open-pioneer/runtime/test-support\";\nimport { FC, ReactNode, useInsertionEffect, useMemo } from \"react\";\nimport { createIntl } from \"./vanilla\";\n\n// oxlint-disable-next-line @typescript-eslint/no-explicit-any\nexport type AnyService = Service<any>;\n\nexport interface PackageContextProviderProps {\n /** Interface implementations, keyed by interface name. */\n services?: {\n [interfaceName: string]: AnyService;\n };\n\n /** Interface implementations, keyed by interface name and then by qualifier. */\n qualifiedServices?: {\n [interfaceName: string]: {\n [qualifier: string]: AnyService;\n };\n };\n\n /** Package properties (keyed by package name). */\n properties?: {\n [packageName: string]: Record<string, unknown>;\n };\n\n /**\n * The locale for i18n messages and formatting.\n *\n * @default \"en\"\n */\n locale?: string;\n\n /**\n * The color mode.\n */\n colorMode?: ColorModeValue;\n\n /**\n * I18n messages for packages\n */\n messages?: {\n /**\n * I18n messages as (messageId, message) entries.\n *\n * @default {}\n */\n [packageName: string]: Record<string, string>;\n };\n\n /** Children to render */\n children?: ReactNode;\n}\n\n/**\n * Injects services and properties into the component tree.\n * React components using Open Pioneer Trails hooks like `useService` and `useProperties`\n * will receive the mocked properties here instead.\n * Currently also wrapped with the CustomChakraProvider to support chakra-ui elements\n */\nexport const PackageContextProvider: FC<PackageContextProviderProps> = (props) => {\n const { children, ...rest } = props;\n const [locale, colorMode, contextMethods] = useMemo(\n () => createPackageContextMethods(rest),\n [rest]\n );\n\n useInsertionEffect(() => {\n // Needed for chakra tokens / theme etc. to be applied correctly.\n // In real applications, this is done as part of the web component startup code.\n // In test scenarios, the body is used as the root node (see props below).\n document.body.classList.add(APP_ROOT_CLASS);\n return () => {\n document.body.classList.remove(APP_ROOT_CLASS);\n };\n }, []);\n\n return (\n <CustomChakraProvider\n rootNode={document}\n appRoot={document.body}\n locale={locale}\n colorMode={colorMode}\n >\n <PackageContext.Provider value={contextMethods}>{children}</PackageContext.Provider>\n </CustomChakraProvider>\n );\n};\n\nfunction createPackageContextMethods(\n options: Omit<PackageContextProviderProps, \"children\">\n): [\n locale: ReadonlyReactive<string>,\n colorMode: ReadonlyReactive<ColorModeValue>,\n methods: PackageContextMethods\n] {\n const services = options?.services ?? {};\n const qualifiedServices = options?.qualifiedServices ?? {};\n const properties = options?.properties ?? {};\n const locale = options?.locale ?? \"en\";\n const messages = options?.messages ?? {};\n const cachedIntl: Record<string, PackageIntl> = {};\n const colorMode = computed(() => options?.colorMode ?? \"light\");\n const methods: PackageContextMethods = {\n getService(packageName, interfaceName, options) {\n if (!options.qualifier) {\n const service = services[interfaceName];\n if (service) {\n return service;\n }\n const qualified = qualifiedServices[interfaceName];\n if (qualified) {\n for (const value of Object.values(qualified)) {\n return value; // Return any implementation\n }\n }\n throw new Error(\n `Interface name not bound for testing: '${interfaceName}'. Update the configuration of PackageContextProvider.`\n );\n }\n\n const qualifiedService = qualifiedServices[interfaceName]?.[options.qualifier];\n if (!qualifiedService) {\n throw new Error(\n `Interface name not bound for testing: '${interfaceName}' (qualifier '${options.qualifier}'). Update the configuration of PackageContextProvider.`\n );\n }\n return qualifiedService;\n },\n getServices(packageName, interfaceName) {\n const unqualified = services[interfaceName];\n const results = Object.values(qualifiedServices[interfaceName] ?? {});\n if (unqualified) {\n results.push(unqualified);\n }\n return results;\n },\n getProperties(packageName) {\n const packageProperties = properties[packageName];\n if (!packageProperties) {\n throw new Error(\n `No properties for package '${packageName}' bound for testing. Update the configuration of PackageContextProvider.`\n );\n }\n return packageProperties;\n },\n getIntl(packageName) {\n const initIntl = () => {\n const packageMessages = messages[packageName];\n return createIntl({\n locale: locale,\n messages: packageMessages\n });\n };\n return (cachedIntl[packageName] ??= initIntl());\n }\n };\n return [constant(locale), colorMode, methods];\n}\n"],"names":["options"],"mappings":";;;;;;AAqEO,MAAM,sBAAA,GAA0D,CAAC,KAAA,KAAU;AAC9E,EAAA,MAAM,EAAE,QAAA,EAAU,GAAG,IAAA,EAAK,GAAI,KAAA;AAC9B,EAAA,MAAM,CAAC,MAAA,EAAQ,SAAA,EAAW,cAAc,CAAA,GAAI,OAAA;AAAA,IACxC,MAAM,4BAA4B,IAAI,CAAA;AAAA,IACtC,CAAC,IAAI;AAAA,GACT;AAEA,EAAA,kBAAA,CAAmB,MAAM;AAIrB,IAAA,QAAA,CAAS,IAAA,CAAK,SAAA,CAAU,GAAA,CAAI,cAAc,CAAA;AAC1C,IAAA,OAAO,MAAM;AACT,MAAA,QAAA,CAAS,IAAA,CAAK,SAAA,CAAU,MAAA,CAAO,cAAc,CAAA;AAAA,IACjD,CAAA;AAAA,EACJ,CAAA,EAAG,EAAE,CAAA;AAEL,EAAA,uBACI,GAAA;AAAA,IAAC,oBAAA;AAAA,IAAA;AAAA,MACG,QAAA,EAAU,QAAA;AAAA,MACV,SAAS,QAAA,CAAS,IAAA;AAAA,MAClB,MAAA;AAAA,MACA,SAAA;AAAA,MAEA,8BAAC,cAAA,CAAe,QAAA,EAAf,EAAwB,KAA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,CAAA,cAAA,EAAiBA,QAAAA,CAAQ,SAAS,CAAA,uDAAA;AAAA,SAC7F;AAAA,MACJ;AACA,MAAA,OAAO,gBAAA;AAAA,IACX,CAAA;AAAA,IACA,WAAA,CAAY,aAAa,aAAA,EAAe;AACpC,MAAA,MAAM,WAAA,GAAc,SAAS,aAAa,CAAA;AAC1C,MAAA,MAAM,UAAU,MAAA,CAAO,MAAA,CAAO,kBAAkB,aAAa,CAAA,IAAK,EAAE,CAAA;AACpE,MAAA,IAAI,WAAA,EAAa;AACb,QAAA,OAAA,CAAQ,KAAK,WAAW,CAAA;AAAA,MAC5B;AACA,MAAA,OAAO,OAAA;AAAA,IACX,CAAA;AAAA,IACA,cAAc,WAAA,EAAa;AACvB,MAAA,MAAM,iBAAA,GAAoB,WAAW,WAAW,CAAA;AAChD,MAAA,IAAI,CAAC,iBAAA,EAAmB;AACpB,QAAA,MAAM,IAAI,KAAA;AAAA,UACN,8BAA8B,WAAW,CAAA,wEAAA;AAAA,SAC7C;AAAA,MACJ;AACA,MAAA,OAAO,iBAAA;AAAA,IACX,CAAA;AAAA,IACA,QAAQ,WAAA,EAAa;AACjB,MAAA,MAAM,WAAW,MAAM;AACnB,QAAA,MAAM,eAAA,GAAkB,SAAS,WAAW,CAAA;AAC5C,QAAA,OAAO,UAAA,CAAW;AAAA,UACd,MAAA;AAAA,UACA,QAAA,EAAU;AAAA,SACb,CAAA;AAAA,MACL,CAAA;AACA,MAAA,OAAQ,UAAA,CAAW,WAAW,CAAA,KAAM,QAAA,EAAS;AAAA,IACjD;AAAA,GACJ;AACA,EAAA,OAAO,CAAC,QAAA,CAAS,MAAM,CAAA,EAAG,WAAW,OAAO,CAAA;AAChD;;;;"}
package/services.js CHANGED
@@ -11,9 +11,9 @@ function createService(clazz, options) {
11
11
  );
12
12
  const intl = createIntl(options);
13
13
  return new clazz({
14
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
14
+ // oxlint-disable-next-line @typescript-eslint/no-explicit-any
15
15
  references,
16
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
16
+ // oxlint-disable-next-line @typescript-eslint/no-explicit-any
17
17
  referencesMeta,
18
18
  properties: options?.properties ?? {},
19
19
  intl,
package/services.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"services.js","sources":["services.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport { reactive } from \"@conterra/reactivity-core\";\nimport { ReferenceMeta, Service, ServiceConstructor } from \"@open-pioneer/runtime\";\nimport { createIntl } from \"./vanilla\";\n\n/**\n * Options for the {@link createService} function.\n */\nexport interface CreateServiceOptions<References> {\n /**\n * References provided to the service constructor.\n *\n * @default {}\n */\n references?: PartialServiceReferences<References>;\n\n /**\n * Properties provided to the service constructor.\n *\n * @default {}\n */\n properties?: Record<string, unknown>;\n\n /**\n * The locale for i18n messages and formatting.\n *\n * @default \"en\"\n */\n locale?: string;\n\n /**\n * The locale for embedded default messages.\n *\n * See also https://formatjs.io/docs/intl#message-descriptor\n *\n * @default \"en\"\n */\n defaultMessageLocale?: string;\n\n /**\n * I18n messages as (messageId, message) entries.\n *\n * @default {}\n */\n messages?: Record<string, string>;\n}\n\ntype PartialServiceReferences<References> = {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n [referenceName in keyof References]?: References[referenceName] extends any[]\n ? Partial<References[referenceName][number]>[]\n : Partial<References[referenceName]>;\n};\n\n/**\n * Creates a new service instance of `clazz`.\n *\n * The options passed into the constructor of `clazz` are taking from the `options` parameter.\n *\n * This function allows the user to define mock- or test objects as service references.\n *\n * Most type-checking features are disabled for convenience, but by default this function's types\n * enforce that a value provided for a reference must match the partial interface of the actually required type.\n *\n * For example, if a service depends on `{ ctx: ApplicationContext }`, this function ensures\n * that the test value for `ctx` implements `Partial<ApplicationContext>`.\n * This can of course be disabled by casting the value explicitly.\n *\n * @param clazz a service class\n * @param options options passed to the service constructor\n * @returns a new instance of the given service class\n */\nexport function createService<References extends {}, Interface extends {}>(\n clazz: ServiceConstructor<References, Interface>,\n options?: CreateServiceOptions<References>\n): Service<Interface> {\n const references = options?.references ?? {};\n const referencesMeta = Object.fromEntries(\n Object.entries(references).map(([referenceName, reference]) => [\n referenceName,\n referenceMeta(referenceName, reference)\n ])\n );\n\n const intl = createIntl(options);\n return new clazz({\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n references: references as any,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n referencesMeta: referencesMeta as any,\n properties: options?.properties ?? {},\n intl,\n currentIntl: reactive(intl)\n });\n}\n\nfunction referenceMeta(referenceName: string, reference: unknown): ReferenceMeta | ReferenceMeta[] {\n if (Array.isArray(reference)) {\n return reference.map<ReferenceMeta>((_, index) => ({\n serviceId: `test-utils::${referenceName}-${index}`\n }));\n }\n return {\n serviceId: `test-utils::${referenceName}`\n };\n}\n"],"names":[],"mappings":";;;AAyEO,SAAS,aAAA,CACZ,OACA,OAAA,EACkB;AAClB,EAAA,MAAM,UAAA,GAAa,OAAA,EAAS,UAAA,IAAc,EAAC;AAC3C,EAAA,MAAM,iBAAiB,MAAA,CAAO,WAAA;AAAA,IAC1B,MAAA,CAAO,QAAQ,UAAU,CAAA,CAAE,IAAI,CAAC,CAAC,aAAA,EAAe,SAAS,CAAA,KAAM;AAAA,MAC3D,aAAA;AAAA,MACA,aAAA,CAAc,eAAe,SAAS;AAAA,KACzC;AAAA,GACL;AAEA,EAAA,MAAM,IAAA,GAAO,WAAW,OAAO,CAAA;AAC/B,EAAA,OAAO,IAAI,KAAA,CAAM;AAAA;AAAA,IAEb,UAAA;AAAA;AAAA,IAEA,cAAA;AAAA,IACA,UAAA,EAAY,OAAA,EAAS,UAAA,IAAc,EAAC;AAAA,IACpC,IAAA;AAAA,IACA,WAAA,EAAa,SAAS,IAAI;AAAA,GAC7B,CAAA;AACL;AAEA,SAAS,aAAA,CAAc,eAAuB,SAAA,EAAqD;AAC/F,EAAA,IAAI,KAAA,CAAM,OAAA,CAAQ,SAAS,CAAA,EAAG;AAC1B,IAAA,OAAO,SAAA,CAAU,GAAA,CAAmB,CAAC,CAAA,EAAG,KAAA,MAAW;AAAA,MAC/C,SAAA,EAAW,CAAA,YAAA,EAAe,aAAa,CAAA,CAAA,EAAI,KAAK,CAAA;AAAA,KACpD,CAAE,CAAA;AAAA,EACN;AACA,EAAA,OAAO;AAAA,IACH,SAAA,EAAW,eAAe,aAAa,CAAA;AAAA,GAC3C;AACJ;;;;"}
1
+ {"version":3,"file":"services.js","sources":["services.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\n\nimport { reactive } from \"@conterra/reactivity-core\";\nimport { ReferenceMeta, Service, ServiceConstructor } from \"@open-pioneer/runtime\";\nimport { createIntl } from \"./vanilla\";\n\n/**\n * Options for the {@link createService} function.\n */\nexport interface CreateServiceOptions<References> {\n /**\n * References provided to the service constructor.\n *\n * @default {}\n */\n references?: PartialServiceReferences<References>;\n\n /**\n * Properties provided to the service constructor.\n *\n * @default {}\n */\n properties?: Record<string, unknown>;\n\n /**\n * The locale for i18n messages and formatting.\n *\n * @default \"en\"\n */\n locale?: string;\n\n /**\n * The locale for embedded default messages.\n *\n * See also https://formatjs.io/docs/intl#message-descriptor\n *\n * @default \"en\"\n */\n defaultMessageLocale?: string;\n\n /**\n * I18n messages as (messageId, message) entries.\n *\n * @default {}\n */\n messages?: Record<string, string>;\n}\n\ntype PartialServiceReferences<References> = {\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n [referenceName in keyof References]?: References[referenceName] extends any[]\n ? Partial<References[referenceName][number]>[]\n : Partial<References[referenceName]>;\n};\n\n/**\n * Creates a new service instance of `clazz`.\n *\n * The options passed into the constructor of `clazz` are taking from the `options` parameter.\n *\n * This function allows the user to define mock- or test objects as service references.\n *\n * Most type-checking features are disabled for convenience, but by default this function's types\n * enforce that a value provided for a reference must match the partial interface of the actually required type.\n *\n * For example, if a service depends on `{ ctx: ApplicationContext }`, this function ensures\n * that the test value for `ctx` implements `Partial<ApplicationContext>`.\n * This can of course be disabled by casting the value explicitly.\n *\n * @param clazz a service class\n * @param options options passed to the service constructor\n * @returns a new instance of the given service class\n */\nexport function createService<References extends {}, Interface extends {}>(\n clazz: ServiceConstructor<References, Interface>,\n options?: CreateServiceOptions<References>\n): Service<Interface> {\n const references = options?.references ?? {};\n const referencesMeta = Object.fromEntries(\n Object.entries(references).map(([referenceName, reference]) => [\n referenceName,\n referenceMeta(referenceName, reference)\n ])\n );\n\n const intl = createIntl(options);\n return new clazz({\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n references: references as any,\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n referencesMeta: referencesMeta as any,\n properties: options?.properties ?? {},\n intl,\n currentIntl: reactive(intl)\n });\n}\n\nfunction referenceMeta(referenceName: string, reference: unknown): ReferenceMeta | ReferenceMeta[] {\n if (Array.isArray(reference)) {\n return reference.map<ReferenceMeta>((_, index) => ({\n serviceId: `test-utils::${referenceName}-${index}`\n }));\n }\n return {\n serviceId: `test-utils::${referenceName}`\n };\n}\n"],"names":[],"mappings":";;;AA0EO,SAAS,aAAA,CACZ,OACA,OAAA,EACkB;AAClB,EAAA,MAAM,UAAA,GAAa,OAAA,EAAS,UAAA,IAAc,EAAC;AAC3C,EAAA,MAAM,iBAAiB,MAAA,CAAO,WAAA;AAAA,IAC1B,MAAA,CAAO,QAAQ,UAAU,CAAA,CAAE,IAAI,CAAC,CAAC,aAAA,EAAe,SAAS,CAAA,KAAM;AAAA,MAC3D,aAAA;AAAA,MACA,aAAA,CAAc,eAAe,SAAS;AAAA,KACzC;AAAA,GACL;AAEA,EAAA,MAAM,IAAA,GAAO,WAAW,OAAO,CAAA;AAC/B,EAAA,OAAO,IAAI,KAAA,CAAM;AAAA;AAAA,IAEb,UAAA;AAAA;AAAA,IAEA,cAAA;AAAA,IACA,UAAA,EAAY,OAAA,EAAS,UAAA,IAAc,EAAC;AAAA,IACpC,IAAA;AAAA,IACA,WAAA,EAAa,SAAS,IAAI;AAAA,GAC7B,CAAA;AACL;AAEA,SAAS,aAAA,CAAc,eAAuB,SAAA,EAAqD;AAC/F,EAAA,IAAI,KAAA,CAAM,OAAA,CAAQ,SAAS,CAAA,EAAG;AAC1B,IAAA,OAAO,SAAA,CAAU,GAAA,CAAmB,CAAC,CAAA,EAAG,KAAA,MAAW;AAAA,MAC/C,SAAA,EAAW,CAAA,YAAA,EAAe,aAAa,CAAA,CAAA,EAAI,KAAK,CAAA;AAAA,KACpD,CAAE,CAAA;AAAA,EACN;AACA,EAAA,OAAO;AAAA,IACH,SAAA,EAAW,eAAe,aAAa,CAAA;AAAA,GAC3C;AACJ;;;;"}
package/vanilla.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"vanilla.js","sources":["vanilla.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport { PackageIntl } from \"@open-pioneer/runtime\";\nimport { createPackageIntl } from \"@open-pioneer/runtime/test-support\";\n\n/** Options for `createIntl`. */\nexport interface I18nOptions {\n /**\n * The locale for i18n messages and formatting.\n *\n * @default \"en\"\n */\n locale?: string;\n\n /**\n * The locale for embedded default messages (e.g. `defaultMessage` property in `intl.formatMessage(...)`).\n * It is usually not necessary to specify this option.\n *\n * See also https://formatjs.io/docs/intl#message-descriptor\n *\n * @default \"en\"\n */\n defaultMessageLocale?: string;\n\n /**\n * I18n messages as (messageId, message) entries.\n *\n * @default {}\n */\n messages?: Record<string, string>;\n}\n\n/**\n * Creates an `intl` instance that can be used for testing.\n *\n * Other than the default implementation provided by `@formatjs/intl`, this\n * `intl` object will not warn if a message is not defined.\n * Instead, it will simply render the fallback message.\n * This behavior makes testing easier.\n *\n * Note that messages can still be defined by using the `messages` parameter.\n */\nexport function createIntl(options?: I18nOptions): PackageIntl {\n const messages = options?.messages ?? {};\n const locale = options?.locale ?? \"en\";\n const defaultMessageLocale = options?.defaultMessageLocale ?? \"en\";\n return createPackageIntl(locale, messages, {\n defaultLocale: defaultMessageLocale,\n suppressNotFoundError: true\n });\n}\n"],"names":[],"mappings":";;AA0CO,SAAS,WAAW,OAAA,EAAoC;AAC3D,EAAA,MAAM,QAAA,GAAW,OAAA,EAAS,QAAA,IAAY,EAAC;AACvC,EAAA,MAAM,MAAA,GAAS,SAAS,MAAA,IAAU,IAAA;AAClC,EAAA,MAAM,oBAAA,GAAuB,SAAS,oBAAA,IAAwB,IAAA;AAC9D,EAAA,OAAO,iBAAA,CAAkB,QAAQ,QAAA,EAAU;AAAA,IACvC,aAAA,EAAe,oBAAA;AAAA,IACf,qBAAA,EAAuB;AAAA,GAC1B,CAAA;AACL;;;;"}
1
+ {"version":3,"file":"vanilla.js","sources":["vanilla.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\n\nimport { PackageIntl } from \"@open-pioneer/runtime\";\nimport { createPackageIntl } from \"@open-pioneer/runtime/test-support\";\n\n/** Options for `createIntl`. */\nexport interface I18nOptions {\n /**\n * The locale for i18n messages and formatting.\n *\n * @default \"en\"\n */\n locale?: string;\n\n /**\n * The locale for embedded default messages (e.g. `defaultMessage` property in `intl.formatMessage(...)`).\n * It is usually not necessary to specify this option.\n *\n * See also https://formatjs.io/docs/intl#message-descriptor\n *\n * @default \"en\"\n */\n defaultMessageLocale?: string;\n\n /**\n * I18n messages as (messageId, message) entries.\n *\n * @default {}\n */\n messages?: Record<string, string>;\n}\n\n/**\n * Creates an `intl` instance that can be used for testing.\n *\n * Other than the default implementation provided by `@formatjs/intl`, this\n * `intl` object will not warn if a message is not defined.\n * Instead, it will simply render the fallback message.\n * This behavior makes testing easier.\n *\n * Note that messages can still be defined by using the `messages` parameter.\n */\nexport function createIntl(options?: I18nOptions): PackageIntl {\n const messages = options?.messages ?? {};\n const locale = options?.locale ?? \"en\";\n const defaultMessageLocale = options?.defaultMessageLocale ?? \"en\";\n return createPackageIntl(locale, messages, {\n defaultLocale: defaultMessageLocale,\n suppressNotFoundError: true\n });\n}\n"],"names":[],"mappings":";;AA2CO,SAAS,WAAW,OAAA,EAAoC;AAC3D,EAAA,MAAM,QAAA,GAAW,OAAA,EAAS,QAAA,IAAY,EAAC;AACvC,EAAA,MAAM,MAAA,GAAS,SAAS,MAAA,IAAU,IAAA;AAClC,EAAA,MAAM,oBAAA,GAAuB,SAAS,oBAAA,IAAwB,IAAA;AAC9D,EAAA,OAAO,iBAAA,CAAkB,QAAQ,QAAA,EAAU;AAAA,IACvC,aAAA,EAAe,oBAAA;AAAA,IACf,qBAAA,EAAuB;AAAA,GAC1B,CAAA;AACL;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"web-components.js","sources":["web-components.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport { waitFor, within } from \"@testing-library/dom\";\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nconst GLOBAL = global as any;\n\nfunction nextId(): number {\n GLOBAL[\"__WEB_COMPONENT_COUNT__\"] ??= 0;\n const id = (GLOBAL[\"__WEB_COMPONENT_COUNT__\"] += 1);\n return id;\n}\n\n/**\n * Renders the given component into the DOM and returns the new node.\n */\nexport async function renderComponent(\n component: CustomElementConstructor | string,\n options?: {\n container?: HTMLElement;\n attributes?: Record<string, string>;\n }\n) {\n const tag = typeof component === \"string\" ? component : defineComponent(component);\n const container = options?.container ?? document.body;\n const node = container.ownerDocument.createElement(tag);\n for (const [key, value] of Object.entries(options?.attributes ?? {})) {\n node.setAttribute(key, value);\n }\n container.innerHTML = \"\";\n container.appendChild(node);\n return {\n node\n };\n}\n\n/**\n * Renders the given component into the DOM (via {@link renderComponent}) and works on its shadow root.\n * In order to use this function, the shadow root should be attached as `open` from inside the component class.\n *\n * After the shadow root has been accessed, the function searches (and waits) for an inner root container (by default `.pioneer-root`)\n * where all other searches should be executed.\n *\n * Returns the shadow root, the inner container, and a bound queries object that automatically searches in the inner container\n * instead of the whole document.\n */\nexport async function renderComponentShadowDOM(\n component: CustomElementConstructor | string,\n options?: {\n container?: HTMLElement;\n attributes?: Record<string, string>;\n innerContainerSelector?: string;\n }\n) {\n const { node } = await renderComponent(component, options);\n const selector = options?.innerContainerSelector ?? \".pioneer-root\";\n const { shadowRoot, innerContainer } = await waitFor(() => {\n const shadowRoot = node.shadowRoot;\n if (!shadowRoot) {\n throw new Error(\"Shadow root not attached.\");\n }\n const innerContainer = shadowRoot.querySelector<HTMLElement>(selector);\n if (!innerContainer) {\n throw new Error(\"Inner container not ready.\");\n }\n return { shadowRoot, innerContainer };\n });\n\n const queries = within(innerContainer);\n return {\n node,\n shadowRoot,\n innerContainer,\n queries\n };\n}\n\n/**\n * Defines the given component and returns the unique tag name.\n * This helper is necessary because tag names must not collide in the global elements registry (and\n * un-registration is not possible).\n */\nexport function defineComponent(\n component: CustomElementConstructor,\n options?: {\n nameHint?: string;\n }\n) {\n const nameHint = options?.nameHint ?? \"test-component\";\n const tag = `${nameHint}-${nextId()}`;\n customElements.define(tag, component);\n return tag;\n}\n"],"names":["shadowRoot","innerContainer"],"mappings":";;AAKA,MAAM,MAAA,GAAS,MAAA;AAEf,SAAS,MAAA,GAAiB;AACtB,EAAA,MAAA,CAAO,yBAAyB,CAAA,KAAM,CAAA;AACtC,EAAA,MAAM,EAAA,GAAM,MAAA,CAAO,yBAAyB,CAAA,IAAK,CAAA;AACjD,EAAA,OAAO,EAAA;AACX;AAKA,eAAsB,eAAA,CAClB,WACA,OAAA,EAIF;AACE,EAAA,MAAM,MAAM,OAAO,SAAA,KAAc,QAAA,GAAW,SAAA,GAAY,gBAAgB,SAAS,CAAA;AACjF,EAAA,MAAM,SAAA,GAAY,OAAA,EAAS,SAAA,IAAa,QAAA,CAAS,IAAA;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,EAGF;AACE,EAAA,MAAM,QAAA,GAAW,SAAS,QAAA,IAAY,gBAAA;AACtC,EAAA,MAAM,GAAA,GAAM,CAAA,EAAG,QAAQ,CAAA,CAAA,EAAI,QAAQ,CAAA,CAAA;AACnC,EAAA,cAAA,CAAe,MAAA,CAAO,KAAK,SAAS,CAAA;AACpC,EAAA,OAAO,GAAA;AACX;;;;"}
1
+ {"version":3,"file":"web-components.js","sources":["web-components.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\n\nimport { waitFor, within } from \"@testing-library/dom\";\n\n// oxlint-disable-next-line @typescript-eslint/no-explicit-any\nconst GLOBAL = global as any;\n\nfunction nextId(): number {\n GLOBAL[\"__WEB_COMPONENT_COUNT__\"] ??= 0;\n const id = (GLOBAL[\"__WEB_COMPONENT_COUNT__\"] += 1);\n return id;\n}\n\n/**\n * Renders the given component into the DOM and returns the new node.\n */\nexport async function renderComponent(\n component: CustomElementConstructor | string,\n options?: {\n container?: HTMLElement;\n attributes?: Record<string, string>;\n }\n) {\n const tag = typeof component === \"string\" ? component : defineComponent(component);\n const container = options?.container ?? document.body;\n const node = container.ownerDocument.createElement(tag);\n for (const [key, value] of Object.entries(options?.attributes ?? {})) {\n node.setAttribute(key, value);\n }\n container.innerHTML = \"\";\n container.appendChild(node);\n return {\n node\n };\n}\n\n/**\n * Renders the given component into the DOM (via {@link renderComponent}) and works on its shadow root.\n * In order to use this function, the shadow root should be attached as `open` from inside the component class.\n *\n * After the shadow root has been accessed, the function searches (and waits) for an inner root container (by default `.pioneer-root`)\n * where all other searches should be executed.\n *\n * Returns the shadow root, the inner container, and a bound queries object that automatically searches in the inner container\n * instead of the whole document.\n */\nexport async function renderComponentShadowDOM(\n component: CustomElementConstructor | string,\n options?: {\n container?: HTMLElement;\n attributes?: Record<string, string>;\n innerContainerSelector?: string;\n }\n) {\n const { node } = await renderComponent(component, options);\n const selector = options?.innerContainerSelector ?? \".pioneer-root\";\n const { shadowRoot, innerContainer } = await waitFor(() => {\n const shadowRoot = node.shadowRoot;\n if (!shadowRoot) {\n throw new Error(\"Shadow root not attached.\");\n }\n const innerContainer = shadowRoot.querySelector<HTMLElement>(selector);\n if (!innerContainer) {\n throw new Error(\"Inner container not ready.\");\n }\n return { shadowRoot, innerContainer };\n });\n\n const queries = within(innerContainer);\n return {\n node,\n shadowRoot,\n innerContainer,\n queries\n };\n}\n\n/**\n * Defines the given component and returns the unique tag name.\n * This helper is necessary because tag names must not collide in the global elements registry (and\n * un-registration is not possible).\n */\nexport function defineComponent(\n component: CustomElementConstructor,\n options?: {\n nameHint?: string;\n }\n) {\n const nameHint = options?.nameHint ?? \"test-component\";\n const tag = `${nameHint}-${nextId()}`;\n customElements.define(tag, component);\n return tag;\n}\n"],"names":["shadowRoot","innerContainer"],"mappings":";;AAMA,MAAM,MAAA,GAAS,MAAA;AAEf,SAAS,MAAA,GAAiB;AACtB,EAAA,MAAA,CAAO,yBAAyB,CAAA,KAAM,CAAA;AACtC,EAAA,MAAM,EAAA,GAAM,MAAA,CAAO,yBAAyB,CAAA,IAAK,CAAA;AACjD,EAAA,OAAO,EAAA;AACX;AAKA,eAAsB,eAAA,CAClB,WACA,OAAA,EAIF;AACE,EAAA,MAAM,MAAM,OAAO,SAAA,KAAc,QAAA,GAAW,SAAA,GAAY,gBAAgB,SAAS,CAAA;AACjF,EAAA,MAAM,SAAA,GAAY,OAAA,EAAS,SAAA,IAAa,QAAA,CAAS,IAAA;AACjD,EAAA,MAAM,IAAA,GAAO,SAAA,CAAU,aAAA,CAAc,aAAA,CAAc,GAAG,CAAA;AACtD,EAAA,KAAA,MAAW,CAAC,GAAA,EAAK,KAAK,CAAA,IAAK,MAAA,CAAO,QAAQ,OAAA,EAAS,UAAA,IAAc,EAAE,CAAA,EAAG;AAClE,IAAA,IAAA,CAAK,YAAA,CAAa,KAAK,KAAK,CAAA;AAAA,EAChC;AACA,EAAA,SAAA,C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