@open-pioneer/runtime 4.7.0-dev.20260727091735 → 4.7.1-dev-test-snapshot.20260821120534

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,6 +1,12 @@
1
1
  # @open-pioneer/runtime
2
2
 
3
- ## 4.7.0-dev.20260727091735
3
+ ## 4.7.1-dev-test-snapshot.20260821120534
4
+
5
+ ### Patch Changes
6
+
7
+ - 7d5283e: Updated dependencies.
8
+
9
+ ## 4.7.0
4
10
 
5
11
  ### Minor Changes
6
12
 
@@ -19,7 +25,7 @@
19
25
  ### Patch Changes
20
26
 
21
27
  - 8c277a2: Include service id in deprecation message of 'serviceOptions.intl'.
22
- - 9d84f1e: Migrated from eslint to oxlint.
28
+ - 9d84f1e: Migrated from eslint to oxlint and from prettier to oxfmt.
23
29
  - 78aad9d: Refactor: use private javascript properties instead of typescript private keyword.
24
30
  - 7c7e6d1: Refactor equality comparisons using shallow equals from @open-pioneer/core.
25
31
  - 8b5c324: Fix 'useIntl' not transporting reactive changes of the intl object in production (e.g. when the locale changes).
package/CustomElement.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { createLogger, Error } from '@open-pioneer/core';
2
- import { sourceId$6 as sourceId } from './_virtual/source-info.js';
2
+ import { sourceId$7 as sourceId } from './_virtual/source-info.js';
3
3
  import { AppInstance } from './app/AppInstance.js';
4
4
  import { ErrorId } from './errors.js';
5
5
 
@@ -1,16 +1,18 @@
1
- const sourceId$6 = "@open-pioneer/runtime/CustomElement";
1
+ const sourceId$7 = "@open-pioneer/runtime/CustomElement";
2
2
 
3
- const sourceId$5 = "@open-pioneer/runtime/app/AppInstance";
3
+ const sourceId$6 = "@open-pioneer/runtime/app/AppInstance";
4
4
 
5
- const sourceId$4 = "@open-pioneer/runtime/i18n/AppIntl";
5
+ const sourceId$5 = "@open-pioneer/runtime/i18n/AppIntl";
6
6
 
7
- const sourceId$3 = "@open-pioneer/runtime/builtin-services/ApplicationContextImpl";
7
+ const sourceId$4 = "@open-pioneer/runtime/builtin-services/ApplicationContextImpl";
8
8
 
9
- const sourceId$2 = "@open-pioneer/runtime/builtin-services/ApplicationLifecycleEventService";
9
+ const sourceId$3 = "@open-pioneer/runtime/builtin-services/ApplicationLifecycleEventService";
10
10
 
11
- const sourceId$1 = "@open-pioneer/runtime/builtin-services/NumberParserServiceImpl";
11
+ const sourceId$2 = "@open-pioneer/runtime/builtin-services/NumberParserServiceImpl";
12
12
 
13
- const sourceId = "@open-pioneer/runtime/service-layer/ServiceLayer";
13
+ const sourceId$1 = "@open-pioneer/runtime/service-layer/ServiceLayer";
14
14
 
15
- export { sourceId$4 as sourceId, sourceId$3 as sourceId$1, sourceId$2, sourceId$1 as sourceId$3, sourceId as sourceId$4, sourceId$5, sourceId$6 };
15
+ const sourceId = "@open-pioneer/runtime/app/logErrors";
16
+
17
+ export { sourceId$5 as sourceId, sourceId$4 as sourceId$1, sourceId$3 as sourceId$2, sourceId$2 as sourceId$3, sourceId$1 as sourceId$4, sourceId as sourceId$5, sourceId$6, sourceId$7 };
16
18
  //# sourceMappingURL=source-info.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"source-info.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"source-info.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;"}
@@ -1,6 +1,6 @@
1
1
  import { watchValue, computed, constant, reactive, effect } from '@conterra/reactivity-core';
2
2
  import { createLogger, Error, createAbortError, destroyResource, createManualPromise, throwAbortError } from '@open-pioneer/core';
3
- import { sourceId$5 as sourceId } from '../_virtual/source-info.js';
3
+ import { sourceId$6 as sourceId } from '../_virtual/source-info.js';
4
4
  import { createElement } from 'react';
5
5
  import { createBuiltinPackage, RUNTIME_THEME_SERVICE, RUNTIME_API_SERVICE, RUNTIME_APPLICATION_LIFECYCLE_EVENT_SERVICE, RUNTIME_LOCALE_SERVICE, RUNTIME_AUTO_START } from '../builtin-services/index.js';
6
6
  import { DEFAULT_INITIAL_COLOR_MODE } from '../builtin-services/ThemeServiceImpl.js';
package/app/logErrors.js CHANGED
@@ -1,19 +1,21 @@
1
- import { getErrorChain } from '@open-pioneer/core';
1
+ import { createLogger, getErrorChain } from '@open-pioneer/core';
2
+ import { sourceId$5 as sourceId } from '../_virtual/source-info.js';
2
3
 
4
+ const LOG = createLogger(sourceId);
3
5
  function logError(e) {
4
6
  if (e instanceof Error) {
5
7
  const chain = getErrorChain(e).reverse();
6
8
  if (chain.length === 1) {
7
- console.error(e);
9
+ LOG.error(e);
8
10
  return;
9
11
  }
10
12
  let n = 1;
11
13
  for (const error of chain) {
12
- console.error(`#${n}`, error);
14
+ LOG.error(`#${n}`, error);
13
15
  ++n;
14
16
  }
15
17
  } else {
16
- console.error("Unexpected error", e);
18
+ LOG.error("Unexpected error", e);
17
19
  }
18
20
  }
19
21
 
@@ -1 +1 @@
1
- {"version":3,"file":"logErrors.js","sources":["logErrors.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\n\nimport { getErrorChain } from \"@open-pioneer/core\";\n\nexport function logError(e: unknown) {\n if (e instanceof Error) {\n const chain = getErrorChain(e).reverse();\n if (chain.length === 1) {\n console.error(e);\n return;\n }\n\n let n = 1;\n for (const error of chain) {\n console.error(`#${n}`, error);\n ++n;\n }\n } else {\n console.error(\"Unexpected error\", e);\n }\n}\n"],"names":[],"mappings":";;AAKO,SAAS,SAAS,CAAA,EAAY;AACjC,EAAA,IAAI,aAAa,KAAA,EAAO;AACpB,IAAA,MAAM,KAAA,GAAQ,aAAA,CAAc,CAAC,CAAA,CAAE,OAAA,EAAQ;AACvC,IAAA,IAAI,KAAA,CAAM,WAAW,CAAA,EAAG;AACpB,MAAA,OAAA,CAAQ,MAAM,CAAC,CAAA;AACf,MAAA;AAAA,IACJ;AAEA,IAAA,IAAI,CAAA,GAAI,CAAA;AACR,IAAA,KAAA,MAAW,SAAS,KAAA,EAAO;AACvB,MAAA,OAAA,CAAQ,KAAA,CAAM,CAAA,CAAA,EAAI,CAAC,CAAA,CAAA,EAAI,KAAK,CAAA;AAC5B,MAAA,EAAE,CAAA;AAAA,IACN;AAAA,EACJ,CAAA,MAAO;AACH,IAAA,OAAA,CAAQ,KAAA,CAAM,oBAAoB,CAAC,CAAA;AAAA,EACvC;AACJ;;;;"}
1
+ {"version":3,"file":"logErrors.js","sources":["logErrors.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\n\nimport { getErrorChain, createLogger } from \"@open-pioneer/core\";\nimport { sourceId } from \"open-pioneer:source-info\";\n\nconst LOG = createLogger(sourceId);\n\nexport function logError(e: unknown) {\n if (e instanceof Error) {\n const chain = getErrorChain(e).reverse();\n if (chain.length === 1) {\n LOG.error(e);\n return;\n }\n\n let n = 1;\n for (const error of chain) {\n LOG.error(`#${n}`, error);\n ++n;\n }\n } else {\n LOG.error(\"Unexpected error\", e);\n }\n}\n"],"names":[],"mappings":";;;AAMA,MAAM,GAAA,GAAM,aAAa,QAAQ,CAAA;AAE1B,SAAS,SAAS,CAAA,EAAY;AACjC,EAAA,IAAI,aAAa,KAAA,EAAO;AACpB,IAAA,MAAM,KAAA,GAAQ,aAAA,CAAc,CAAC,CAAA,CAAE,OAAA,EAAQ;AACvC,IAAA,IAAI,KAAA,CAAM,WAAW,CAAA,EAAG;AACpB,MAAA,GAAA,CAAI,MAAM,CAAC,CAAA;AACX,MAAA;AAAA,IACJ;AAEA,IAAA,IAAI,CAAA,GAAI,CAAA;AACR,IAAA,KAAA,MAAW,SAAS,KAAA,EAAO;AACvB,MAAA,GAAA,CAAI,KAAA,CAAM,CAAA,CAAA,EAAI,CAAC,CAAA,CAAA,EAAI,KAAK,CAAA;AACxB,MAAA,EAAE,CAAA;AAAA,IACN;AAAA,EACJ,CAAA,MAAO;AACH,IAAA,GAAA,CAAI,KAAA,CAAM,oBAAoB,CAAC,CAAA;AAAA,EACnC;AACJ;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"PackageIntl.js","sources":["PackageIntl.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\n\nimport {\n createIntl,\n createIntlCache,\n IntlConfig,\n IntlErrorCode,\n IntlFormatters,\n IntlShape,\n MessageDescriptor,\n OnErrorFn\n} from \"@formatjs/intl\";\nimport {\n type FormatXMLElementFn,\n type Options as IntlMessageFormatOptions,\n type PrimitiveType\n} from \"intl-messageformat\"; // not a dependency, this is a dependency of formatjs\nimport { Children, createElement, Fragment, isValidElement, ReactNode } from \"react\";\n\ntype BaseIntl = Pick<IntlShape, \"locale\" | \"timeZone\"> &\n Omit<IntlFormatters<string>, \"formatMessage\">;\n\n/**\n * Gives access to the package's i18n messages for the current locale.\n *\n * See also https://formatjs.io/docs/intl\n */\nexport type PackageIntl = BaseIntl & PackageIntlExtensions;\n\n/**\n * Trails specific extensions to FormatJS' intl API.\n */\nexport interface PackageIntlExtensions {\n /**\n * Formats a message with the given descriptor and values.\n *\n * This is a method directly implemented by FormatJS see\n * - [Documentation](<https://formatjs.github.io/docs/intl/#formatmessage>)\n * - {@link IntlShape.formatMessage | Base Implementation}\n *\n * The typings here make the signature a little bit stricter: only primitive values\n * are allowed for formatting.\n *\n * If you need rich text (react) formatting, see {@link PackageIntlExtensions.formatRichMessage}.\n */\n formatMessage(\n this: void,\n descriptor: MessageDescriptor,\n values?: Record<string, PrimitiveType | FormatXMLElementFn<string, string>>,\n opts?: IntlMessageFormatOptions\n ): string;\n\n /**\n * Similar to `formatMessage()`, but supports _rich text formatting_.\n *\n * React nodes are supported as input values, and custom tags can be implemented as react components.\n * Note that the output is always a single react node.\n *\n * *Example with react node as value:*\n *\n * ```tsx\n * function Example() {\n * const intl = useIntl();\n * // Given i18n message \"Hello, {name}!\"\n * // replaces 'name' with the given react node:\n * const message = intl.formatRichMessage({ id: \"foo\"}, {\n * name: <FancyUserName />\n * });\n * return <Box>{message}</Box>;\n * }\n * ```\n *\n * *Example with basic formatting:*\n *\n * ```tsx\n * function Example() {\n * const intl = useIntl();\n * // Given i18n message \"Hello, <strong>{name}</strong>!\"\n * // renders with actual <strong> html node:\n * return <Box>{intl.formatRichMessage({ id: \"foo\"}, { name: \"User\" })}</Box>;\n * }\n * ```\n *\n * Note that only a few basic formatting tags are predefined (\"b\", \"strong\", \"i\", \"em\", \"code\", \"br\").\n * If you need more advanced tags, you can define your own, see below.\n *\n * *Example with custom tag:*\n *\n * ```tsx\n * function Example() {\n * const intl = useIntl();\n * // Given i18n message \"Open <foo>the door</foo>!\",\n * // renders 'foo' using the formatter function below:\n * const message = intl.formatRichMessage({ id: \"foo\"}, {\n * foo: (parts) => <FancyTag>{parts}</FancyTag>\n * });\n * return <Box>{message}</Box>;\n * }\n * ```\n */\n formatRichMessage: (\n descriptor: MessageDescriptor,\n values?: Record<string, RichTextValue>,\n opts?: IntlMessageFormatOptions\n ) => ReactNode;\n}\n\n/**\n * Value types supported when rendering rich text messages.\n * Primitive values (or single react nodes) are used for normal values.\n * Functions are used to define how tags should be rendered.\n *\n * See {@link PackageIntlExtensions.formatRichMessage}\n */\nexport type RichTextValue = PrimitiveType | ReactNode | FormatXMLElementFn<ReactNode>;\n\n/**\n * Creates a package intl instance with the given locale and messages.\n *\n * @internal\n */\nexport function createPackageIntl(\n locale: string,\n messages: Record<string, string>,\n options?: {\n /** Used during testing to suppress console messages. */\n suppressNotFoundError?: boolean;\n\n /** Also used during testing */\n defaultLocale?: string;\n }\n): PackageIntl {\n const cache = createIntlCache();\n const config: IntlConfig = {\n locale,\n messages\n };\n if (options?.suppressNotFoundError) {\n config.onError = ignoreMissingTranslationError;\n }\n if (options?.defaultLocale) {\n config.defaultLocale = options.defaultLocale;\n }\n\n const intl = createIntl(config, cache) as unknown as PackageIntl;\n intl.formatRichMessage = formatRichMessage.bind(undefined, intl);\n return intl;\n}\n\n/** Creates an empty i18n instance, e.g. for tests. */\nexport function createEmptyPackageIntl(locale = \"en\"): PackageIntl {\n return createPackageIntl(locale, {});\n}\n\nconst RICH_TEXT_TAGS = Object.freeze({\n \"b\": renderTag(\"b\"),\n \"strong\": renderTag(\"strong\"),\n \"i\": renderTag(\"i\"),\n \"em\": renderTag(\"em\"),\n \"code\": renderTag(\"code\"),\n \"br\": renderTag(\"br\")\n});\n\nfunction formatRichMessage(\n intl: PackageIntl,\n descriptor: MessageDescriptor,\n values: Record<string, RichTextValue> | undefined,\n opts: IntlMessageFormatOptions | undefined\n): ReactNode {\n values = {\n ...RICH_TEXT_TAGS,\n ...values\n };\n\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n const chunks: any = intl.formatMessage(descriptor, preprocessValues(values) as any, opts);\n const nodes = assignKeys(chunks);\n return createElement(Fragment, undefined, ...nodes);\n}\n\nfunction preprocessValues(values: Record<string, RichTextValue> | undefined) {\n if (!values) {\n return undefined;\n }\n\n const fixedValues: Record<string, RichTextValue> = {};\n for (const [key, valueOrFn] of Object.entries(values)) {\n let fixedValue = valueOrFn;\n if (typeof valueOrFn === \"function\") {\n fixedValue = (parts) => valueOrFn(assignKeys(parts));\n }\n fixedValues[key] = fixedValue;\n }\n return fixedValues;\n}\n\nfunction renderTag(tag: string): FormatXMLElementFn<ReactNode> {\n return function renderRichTag(parts) {\n return createElement(tag, undefined, ...parts);\n };\n}\n\n// Seems to be required to get rid of \"key\" warnings.\n// See https://github.com/formatjs/formatjs/pull/4895/files\n// oxlint-disable-next-line @typescript-eslint/no-explicit-any\nfunction assignKeys(chunks: any): any[] {\n const nodes = Children.map(chunks, assignKey) ?? [];\n return Children.toArray(nodes);\n}\n\nconst ANY_KEY = { key: 42 };\n\nfunction assignKey(reactNode: React.ReactNode) {\n return isValidElement(reactNode) ? createElement(Fragment, ANY_KEY, reactNode) : reactNode;\n}\n\n/** Hides missing translation errors during tests */\nconst ignoreMissingTranslationError: OnErrorFn = (err) => {\n if (err.code === IntlErrorCode.MISSING_TRANSLATION) {\n return;\n }\n\n console.error(err);\n};\n"],"names":[],"mappings":";;;AA0HO,SAAS,iBAAA,CACZ,MAAA,EACA,QAAA,EACA,OAAA,EAOW;AACX,EAAA,MAAM,QAAQ,eAAA,EAAgB;AAC9B,EAAA,MAAM,MAAA,GAAqB;AAAA,IACvB,MAAA;AAAA,IACA;AAAA,GACJ;AACA,EAAA,IAAI,SAAS,qBAAA,EAAuB;AAChC,IAAA,MAAA,CAAO,OAAA,GAAU,6BAAA;AAAA,EACrB;AACA,EAAA,IAAI,SAAS,aAAA,EAAe;AACxB,IAAA,MAAA,CAAO,gBAAgB,OAAA,CAAQ,aAAA;AAAA,EACnC;AAEA,EAAA,MAAM,IAAA,GAAO,UAAA,CAAW,MAAA,EAAQ,KAAK,CAAA;AACrC,EAAA,IAAA,CAAK,iBAAA,GAAoB,iBAAA,CAAkB,IAAA,CAAK,MAAA,EAAW,IAAI,CAAA;AAC/D,EAAA,OAAO,IAAA;AACX;AAGO,SAAS,sBAAA,CAAuB,SAAS,IAAA,EAAmB;AAC/D,EAAA,OAAO,iBAAA,CAAkB,MAAA,EAAQ,EAAE,CAAA;AACvC;AAEA,MAAM,cAAA,GAAiB,OAAO,MAAA,CAAO;AAAA,EACjC,GAAA,EAAK,UAAU,GAAG,CAAA;AAAA,EAClB,QAAA,EAAU,UAAU,QAAQ,CAAA;AAAA,EAC5B,GAAA,EAAK,UAAU,GAAG,CAAA;AAAA,EAClB,IAAA,EAAM,UAAU,IAAI,CAAA;AAAA,EACpB,MAAA,EAAQ,UAAU,MAAM,CAAA;AAAA,EACxB,IAAA,EAAM,UAAU,IAAI;AACxB,CAAC,CAAA;AAED,SAAS,iBAAA,CACL,IAAA,EACA,UAAA,EACA,MAAA,EACA,IAAA,EACS;AACT,EAAA,MAAA,GAAS;AAAA,IACL,GAA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EAAU,OAAA,EAAS,SAAS,CAAA,GAAI,SAAA;AACrF;AAGA,MAAM,6BAAA,GAA2C,CAAC,GAAA,KAAQ;AACtD,EAAA,IAAI,GAAA,CAAI,IAAA,KAAS,aAAA,CAAc,mBAAA,EAAqB;AAChD,IAAA;AAAA,EACJ;AAEA,EAAA,OAAA,CAAQ,MAAM,GAAG,CAAA;AACrB,CAAA;;;;"}
1
+ {"version":3,"file":"PackageIntl.js","sources":["PackageIntl.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\n\nimport {\n createIntl,\n createIntlCache,\n IntlConfig,\n IntlErrorCode,\n IntlFormatters,\n IntlShape,\n MessageDescriptor,\n OnErrorFn\n} from \"@formatjs/intl\";\nimport {\n type FormatXMLElementFn,\n type Options as IntlMessageFormatOptions,\n type PrimitiveType\n} from \"intl-messageformat\"; // not a dependency, this is a dependency of formatjs\nimport { Children, createElement, Fragment, isValidElement, ReactNode } from \"react\";\n\ntype BaseIntl = Pick<IntlShape, \"locale\" | \"timeZone\"> &\n Omit<IntlFormatters<string>, \"formatMessage\">;\n\n/**\n * Gives access to the package's i18n messages for the current locale.\n *\n * See also https://formatjs.io/docs/intl\n */\nexport type PackageIntl = BaseIntl & PackageIntlExtensions;\n\n/**\n * Trails specific extensions to FormatJS' intl API.\n */\nexport interface PackageIntlExtensions {\n /**\n * Formats a message with the given descriptor and values.\n *\n * This is a method directly implemented by FormatJS see\n * - [Documentation](<https://formatjs.github.io/docs/intl/#formatmessage>)\n * - {@link IntlShape.formatMessage | Base Implementation}\n *\n * The typings here make the signature a little bit stricter: only primitive values\n * are allowed for formatting.\n *\n * If you need rich text (react) formatting, see {@link PackageIntlExtensions.formatRichMessage}.\n */\n formatMessage(\n this: void,\n descriptor: MessageDescriptor,\n values?: Record<string, PrimitiveType | FormatXMLElementFn<string, string>>,\n opts?: IntlMessageFormatOptions\n ): string;\n\n /**\n * Similar to `formatMessage()`, but supports _rich text formatting_.\n *\n * React nodes are supported as input values, and custom tags can be implemented as react components.\n * Note that the output is always a single react node.\n *\n * *Example with react node as value:*\n *\n * ```tsx\n * function Example() {\n * const intl = useIntl();\n * // Given i18n message \"Hello, {name}!\"\n * // replaces 'name' with the given react node:\n * const message = intl.formatRichMessage({ id: \"foo\"}, {\n * name: <FancyUserName />\n * });\n * return <Box>{message}</Box>;\n * }\n * ```\n *\n * *Example with basic formatting:*\n *\n * ```tsx\n * function Example() {\n * const intl = useIntl();\n * // Given i18n message \"Hello, <strong>{name}</strong>!\"\n * // renders with actual <strong> html node:\n * return <Box>{intl.formatRichMessage({ id: \"foo\"}, { name: \"User\" })}</Box>;\n * }\n * ```\n *\n * Note that only a few basic formatting tags are predefined (\"b\", \"strong\", \"i\", \"em\", \"code\", \"br\").\n * If you need more advanced tags, you can define your own, see below.\n *\n * *Example with custom tag:*\n *\n * ```tsx\n * function Example() {\n * const intl = useIntl();\n * // Given i18n message \"Open <foo>the door</foo>!\",\n * // renders 'foo' using the formatter function below:\n * const message = intl.formatRichMessage({ id: \"foo\"}, {\n * foo: (parts) => <FancyTag>{parts}</FancyTag>\n * });\n * return <Box>{message}</Box>;\n * }\n * ```\n */\n formatRichMessage: (\n descriptor: MessageDescriptor,\n values?: Record<string, RichTextValue>,\n opts?: IntlMessageFormatOptions\n ) => ReactNode;\n}\n\n/**\n * Value types supported when rendering rich text messages.\n * Primitive values (or single react nodes) are used for normal values.\n * Functions are used to define how tags should be rendered.\n *\n * See {@link PackageIntlExtensions.formatRichMessage}\n */\nexport type RichTextValue = PrimitiveType | ReactNode | FormatXMLElementFn<ReactNode>;\n\n/**\n * Creates a package intl instance with the given locale and messages.\n *\n * @internal\n */\nexport function createPackageIntl(\n locale: string,\n messages: Record<string, string>,\n options?: {\n /** Used during testing to suppress console messages. */\n suppressNotFoundError?: boolean;\n\n /** Also used during testing */\n defaultLocale?: string;\n }\n): PackageIntl {\n const cache = createIntlCache();\n const config: IntlConfig = {\n locale,\n messages\n };\n if (options?.suppressNotFoundError) {\n config.onError = ignoreMissingTranslationError;\n }\n if (options?.defaultLocale) {\n config.defaultLocale = options.defaultLocale;\n }\n\n const intl = createIntl(config, cache) as unknown as PackageIntl;\n intl.formatRichMessage = formatRichMessage.bind(undefined, intl);\n return intl;\n}\n\n/** Creates an empty i18n instance, e.g. for tests. */\nexport function createEmptyPackageIntl(locale = \"en\"): PackageIntl {\n return createPackageIntl(locale, {});\n}\n\nconst RICH_TEXT_TAGS = Object.freeze({\n \"b\": renderTag(\"b\"),\n \"strong\": renderTag(\"strong\"),\n \"i\": renderTag(\"i\"),\n \"em\": renderTag(\"em\"),\n \"code\": renderTag(\"code\"),\n \"br\": renderTag(\"br\")\n});\n\nfunction formatRichMessage(\n intl: PackageIntl,\n descriptor: MessageDescriptor,\n values: Record<string, RichTextValue> | undefined,\n opts: IntlMessageFormatOptions | undefined\n): ReactNode {\n values = {\n ...RICH_TEXT_TAGS,\n ...values\n };\n\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n const chunks: any = intl.formatMessage(descriptor, preprocessValues(values) as any, opts);\n const nodes = assignKeys(chunks);\n return createElement(Fragment, undefined, ...nodes);\n}\n\nfunction preprocessValues(values: Record<string, RichTextValue> | undefined) {\n if (!values) {\n return undefined;\n }\n\n const fixedValues: Record<string, RichTextValue> = {};\n for (const [key, valueOrFn] of Object.entries(values)) {\n let fixedValue = valueOrFn;\n if (typeof valueOrFn === \"function\") {\n fixedValue = (parts) => valueOrFn(assignKeys(parts));\n }\n fixedValues[key] = fixedValue;\n }\n return fixedValues;\n}\n\nfunction renderTag(tag: string): FormatXMLElementFn<ReactNode> {\n return function renderRichTag(parts) {\n return createElement(tag, undefined, ...parts);\n };\n}\n\n// Seems to be required to get rid of \"key\" warnings.\n// See https://github.com/formatjs/formatjs/pull/4895/files\n// oxlint-disable-next-line @typescript-eslint/no-explicit-any\nfunction assignKeys(chunks: any): any[] {\n const nodes = Children.map(chunks, assignKey) ?? [];\n return Children.toArray(nodes);\n}\n\nconst ANY_KEY = { key: 42 };\n\nfunction assignKey(reactNode: React.ReactNode) {\n return isValidElement(reactNode) ? createElement(Fragment, ANY_KEY, reactNode) : reactNode;\n}\n\n/** Hides missing translation errors during tests */\nconst ignoreMissingTranslationError: OnErrorFn = (err) => {\n if (err.code === IntlErrorCode.MISSING_TRANSLATION) {\n return;\n }\n\n // oxlint-disable-next-line no-console\n console.error(err);\n};\n"],"names":[],"mappings":";;;AA0HO,SAAS,iBAAA,CACZ,MAAA,EACA,QAAA,EACA,OAAA,EAOW;AACX,EAAA,MAAM,QAAQ,eAAA,EAAgB;AAC9B,EAAA,MAAM,MAAA,GAAqB;AAAA,IACvB,MAAA;AAAA,IACA;AAAA,GACJ;AACA,EAAA,IAAI,SAAS,qBAAA,EAAuB;AAChC,IAAA,MAAA,CAAO,OAAA,GAAU,6BAAA;AAAA,EACrB;AACA,EAAA,IAAI,SAAS,aAAA,EAAe;AACxB,IAAA,MAAA,CAAO,gBAAgB,OAAA,CAAQ,aAAA;AAAA,EACnC;AAEA,EAAA,MAAM,IAAA,GAAO,UAAA,CAAW,MAAA,EAAQ,KAAK,CAAA;AACrC,EAAA,IAAA,CAAK,iBAAA,GAAoB,iBAAA,CAAkB,IAAA,CAAK,MAAA,EAAW,IAAI,CAAA;AAC/D,EAAA,OAAO,IAAA;AACX;AAGO,SAAS,sBAAA,CAAuB,SAAS,IAAA,EAAmB;AAC/D,EAAA,OAAO,iBAAA,CAAkB,MAAA,EAAQ,EAAE,CAAA;AACvC;AAEA,MAAM,cAAA,GAAiB,OAAO,MAAA,CAAO;AAAA,EACjC,GAAA,EAAK,UAAU,GAAG,CAAA;AAAA,EAClB,QAAA,EAAU,UAAU,QAAQ,CAAA;AAAA,EAC5B,GAAA,EAAK,UAAU,GAAG,CAAA;AAAA,EAClB,IAAA,EAAM,UAAU,IAAI,CAAA;AAAA,EACpB,MAAA,EAAQ,UAAU,MAAM,CAAA;AAAA,EACxB,I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C;AAEA,MAAM,OAAA,GAAU,EAAE,GAAA,EAAK,EAAA,EAAG;AAE1B,SAAS,UAAU,SAAA,EAA4B;AAC3C,EAAA,OAAO,eAAe,SAAS,CAAA,GAAI,cAAc,QAAA,EAAU,OAAA,EAAS,SAAS,CAAA,GAAI,SAAA;AACrF;AAGA,MAAM,6BAAA,GAA2C,CAAC,GAAA,KAAQ;AACtD,EAAA,IAAI,GAAA,CAAI,IAAA,KAAS,aAAA,CAAc,mBAAA,EAAqB;AAChD,IAAA;AAAA,EACJ;AAGA,EAAA,OAAA,CAAQ,MAAM,GAAG,CAAA;AACrB,CAAA;;;;"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "type": "module",
3
3
  "name": "@open-pioneer/runtime",
4
- "version": "4.7.0-dev.20260727091735",
4
+ "version": "4.7.1-dev-test-snapshot.20260821120534",
5
5
  "description": "Implements the runtime environment for Open Pioneer Trails apps.",
6
6
  "keywords": [
7
7
  "open-pioneer-trails"
@@ -18,13 +18,17 @@
18
18
  "@conterra/reactivity-core": "^0.8.6",
19
19
  "@emotion/cache": "^11.14.0",
20
20
  "@emotion/react": "^11.14.0",
21
- "@formatjs/intl": "^4.1.17",
21
+ "@formatjs/intl": "^4.1.18",
22
22
  "@formatjs/intl-localematcher": "^0.8.13",
23
23
  "react": "^19.2.8",
24
24
  "react-dom": "^19.2.8",
25
- "@open-pioneer/base-theme": "4.7.0-dev.20260727091735",
26
- "@open-pioneer/reactivity": "4.7.0-dev.20260727091735",
27
- "@open-pioneer/core": "4.7.0-dev.20260727091735"
25
+ "@open-pioneer/base-theme": "4.7.1-dev-test-snapshot.20260821120534",
26
+ "@open-pioneer/core": "4.7.1-dev-test-snapshot.20260821120534",
27
+ "@open-pioneer/reactivity": "4.7.1-dev-test-snapshot.20260821120534"
28
+ },
29
+ "publishConfig": {
30
+ "directory": "dist",
31
+ "linkDirectory": false
28
32
  },
29
33
  "exports": {
30
34
  "./package.json": "./package.json",