frosty 0.0.154 → 0.0.156
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/dist/_native.d.mts +2 -1
- package/dist/_native.d.mts.map +1 -1
- package/dist/_native.d.ts +2 -1
- package/dist/_native.d.ts.map +1 -1
- package/dist/_native.js +3 -3
- package/dist/_native.mjs +1 -1
- package/dist/dom.d.mts +3 -2
- package/dist/dom.d.mts.map +1 -1
- package/dist/dom.d.ts +3 -2
- package/dist/dom.d.ts.map +1 -1
- package/dist/dom.js +3 -3
- package/dist/dom.mjs +2 -2
- package/dist/i18n.d.mts +38 -0
- package/dist/i18n.d.mts.map +1 -0
- package/dist/i18n.d.ts +38 -0
- package/dist/i18n.d.ts.map +1 -0
- package/dist/i18n.js +79 -0
- package/dist/i18n.js.map +1 -0
- package/dist/i18n.mjs +72 -0
- package/dist/i18n.mjs.map +1 -0
- package/dist/index.js +47 -42
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +4 -2
- package/dist/index.mjs.map +1 -1
- package/dist/internals/callback-DEKCuARB.mjs +170 -0
- package/dist/internals/callback-DEKCuARB.mjs.map +1 -0
- package/dist/internals/callback-DVD1MTA9.js +180 -0
- package/dist/internals/callback-DVD1MTA9.js.map +1 -0
- package/dist/internals/{events-BgboMOG9.js → events-CcBnpWOF.js} +7 -3
- package/dist/internals/{events-BgboMOG9.js.map → events-CcBnpWOF.js.map} +1 -1
- package/dist/internals/{form-BGe5OdHZ.js → form-CC8A5nkh.js} +40 -205
- package/dist/internals/form-CC8A5nkh.js.map +1 -0
- package/dist/internals/{form-RKmiM_eK.mjs → form-Cee86QUZ.mjs} +4 -168
- package/dist/internals/form-Cee86QUZ.mjs.map +1 -0
- package/dist/internals/{index-CHID44Lo.js → index-Bvwj3lIq.js} +39 -35
- package/dist/internals/{index-CHID44Lo.js.map → index-Bvwj3lIq.js.map} +1 -1
- package/dist/internals/{index-DCYqTHyF.d.mts → index-BzVLlTCa.d.mts} +3 -1
- package/dist/internals/index-BzVLlTCa.d.mts.map +1 -0
- package/dist/internals/{index-BXYwGmMq.d.ts → index-OvcTjmzX.d.ts} +3 -1
- package/dist/internals/index-OvcTjmzX.d.ts.map +1 -0
- package/dist/internals/{renderer-BtM_6vlI.d.mts → renderer-BluiQ1F-.d.mts} +2 -2
- package/dist/internals/{renderer-BtM_6vlI.d.mts.map → renderer-BluiQ1F-.d.mts.map} +1 -1
- package/dist/internals/{renderer-CRJ6yD_V.mjs → renderer-BvM6i6Cl.mjs} +2 -2
- package/dist/internals/{renderer-CRJ6yD_V.mjs.map → renderer-BvM6i6Cl.mjs.map} +1 -1
- package/dist/internals/{renderer-1wYRgACC.d.ts → renderer-C1RBQB2f.d.ts} +2 -2
- package/dist/internals/{renderer-1wYRgACC.d.ts.map → renderer-C1RBQB2f.d.ts.map} +1 -1
- package/dist/internals/{renderer-BXTVLEhY.js → renderer-C5NIsxDg.js} +67 -61
- package/dist/internals/{renderer-BXTVLEhY.js.map → renderer-C5NIsxDg.js.map} +1 -1
- package/dist/internals/{renderer-FQADFg6I.js → renderer-DR_CVQzd.js} +17 -11
- package/dist/internals/renderer-DR_CVQzd.js.map +1 -0
- package/dist/internals/{renderer-DxQAalyV.mjs → renderer-DaX4zUo8.mjs} +3 -2
- package/dist/internals/renderer-DaX4zUo8.mjs.map +1 -0
- package/dist/server-dom.d.mts +3 -2
- package/dist/server-dom.d.mts.map +1 -1
- package/dist/server-dom.d.ts +3 -2
- package/dist/server-dom.d.ts.map +1 -1
- package/dist/server-dom.js +3 -3
- package/dist/server-dom.mjs +2 -2
- package/dist/web.d.mts +3 -2
- package/dist/web.d.mts.map +1 -1
- package/dist/web.d.ts +3 -2
- package/dist/web.d.ts.map +1 -1
- package/dist/web.js +31 -26
- package/dist/web.js.map +1 -1
- package/dist/web.mjs +5 -4
- package/dist/web.mjs.map +1 -1
- package/package.json +2 -1
- package/packages/frosty-cli/webpack.mjs +2 -2
- package/packages/frosty-cli/yarn.lock +3 -3
- package/dist/internals/form-BGe5OdHZ.js.map +0 -1
- package/dist/internals/form-RKmiM_eK.mjs.map +0 -1
- package/dist/internals/index-BXYwGmMq.d.ts.map +0 -1
- package/dist/internals/index-DCYqTHyF.d.mts.map +0 -1
- package/dist/internals/renderer-DxQAalyV.mjs.map +0 -1
- package/dist/internals/renderer-FQADFg6I.js.map +0 -1
package/dist/_native.d.mts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { N as NativeElementType, c as PropsType, a as ComponentNode } from './internals/common-DU6Re-Mj.mjs';
|
|
2
|
-
export { V as VNode, _ as _Renderer } from './internals/index-
|
|
2
|
+
export { V as VNode, _ as _Renderer } from './internals/index-BzVLlTCa.mjs';
|
|
3
3
|
export { u as uniqueId } from './internals/utils-ukNJhgdU.mjs';
|
|
4
4
|
import '@o2ter/utils-js';
|
|
5
5
|
import 'lodash';
|
|
6
6
|
import 'csstype';
|
|
7
|
+
import 'nextick';
|
|
7
8
|
|
|
8
9
|
declare class EventEmitter {
|
|
9
10
|
#private;
|
package/dist/_native.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"_native.d.mts","sources":["../src/core/reconciler/events.ts","../src/renderer/native.ts"],"sourcesContent":["//\n// events.ts\n//\n// The MIT License\n// Copyright (c) 2021 - 2026 O2ter Limited. All rights reserved.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n// THE SOFTWARE.\n//\n\nimport _ from 'lodash';\n\nexport class EventEmitter {\n\n #listeners: Record<string, ((...args: any[]) => void)[]> = {};\n\n register(event: string, callback: (event: string, ...args: any[]) => void) {\n if (_.isNil(this.#listeners[event])) this.#listeners[event] = [];\n const _callback = (...args: any[]) => callback(event, ...args);\n this.#listeners[event].push(_callback);\n return {\n remove: () => {\n this.#listeners[event] = _.filter(this.#listeners[event], x => x !== _callback);\n },\n };\n }\n\n emit(event: string, ...args: any[]) {\n this.#listeners[event]?.forEach(async callback => {\n try {\n await callback(...args)\n } catch (e) {\n console.error(e);\n }\n });\n }\n}\n","//\n// native.ts\n//\n// The MIT License\n// Copyright (c) 2021 - 2026 O2ter Limited. All rights reserved.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n// THE SOFTWARE.\n//\n\nimport { _createElement, PropsType } from '../core/types/runtime';\nimport { ComponentNode, NativeElementType } from '../core/types/component';\n\nexport { _Renderer } from '../core/renderer';\nexport { uniqueId } from '../core/utils';\nexport { EventEmitter } from '../core/reconciler/events';\nexport type { VNode } from '../core/reconciler';\nexport { NativeElementType } from '../core/types/component';\n\nexport function _createNativeElement(\n type: typeof NativeElementType,\n props: PropsType,\n key?: string | number\n): ComponentNode {\n return _createElement(type, { ...props, key });\n}\n"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"_native.d.mts","sources":["../src/core/reconciler/events.ts","../src/renderer/native.ts"],"sourcesContent":["//\n// events.ts\n//\n// The MIT License\n// Copyright (c) 2021 - 2026 O2ter Limited. All rights reserved.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n// THE SOFTWARE.\n//\n\nimport _ from 'lodash';\n\nexport class EventEmitter {\n\n #listeners: Record<string, ((...args: any[]) => void)[]> = {};\n\n register(event: string, callback: (event: string, ...args: any[]) => void) {\n if (_.isNil(this.#listeners[event])) this.#listeners[event] = [];\n const _callback = (...args: any[]) => callback(event, ...args);\n this.#listeners[event].push(_callback);\n return {\n remove: () => {\n this.#listeners[event] = _.filter(this.#listeners[event], x => x !== _callback);\n },\n };\n }\n\n emit(event: string, ...args: any[]) {\n this.#listeners[event]?.forEach(async callback => {\n try {\n await callback(...args)\n } catch (e) {\n console.error(e);\n }\n });\n }\n}\n","//\n// native.ts\n//\n// The MIT License\n// Copyright (c) 2021 - 2026 O2ter Limited. All rights reserved.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n// THE SOFTWARE.\n//\n\nimport { _createElement, PropsType } from '../core/types/runtime';\nimport { ComponentNode, NativeElementType } from '../core/types/component';\n\nexport { _Renderer } from '../core/renderer';\nexport { uniqueId } from '../core/utils';\nexport { EventEmitter } from '../core/reconciler/events';\nexport type { VNode } from '../core/reconciler';\nexport { NativeElementType } from '../core/types/component';\n\nexport function _createNativeElement(\n type: typeof NativeElementType,\n props: PropsType,\n key?: string | number\n): ComponentNode {\n return _createElement(type, { ...props, key });\n}\n"],"names":[],"mappings":";;;;;;;;AAAO,cAAA,YAAA;AACP;AACA;AACA;AACA;AACA;AACA;;ACCO,iBAAA,oBAAA,cAAA,iBAAA,SAAA,SAAA,0BAAA,aAAA;;;;"}
|
package/dist/_native.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { N as NativeElementType, c as PropsType, a as ComponentNode } from './internals/common-DU6Re-Mj.js';
|
|
2
|
-
export { V as VNode, _ as _Renderer } from './internals/index-
|
|
2
|
+
export { V as VNode, _ as _Renderer } from './internals/index-OvcTjmzX.js';
|
|
3
3
|
export { u as uniqueId } from './internals/utils-BNdSbzPU.js';
|
|
4
4
|
import '@o2ter/utils-js';
|
|
5
5
|
import 'lodash';
|
|
6
6
|
import 'csstype';
|
|
7
|
+
import 'nextick';
|
|
7
8
|
|
|
8
9
|
declare class EventEmitter {
|
|
9
10
|
#private;
|
package/dist/_native.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"_native.d.ts","sources":["../src/core/reconciler/events.ts","../src/renderer/native.ts"],"sourcesContent":["//\n// events.ts\n//\n// The MIT License\n// Copyright (c) 2021 - 2026 O2ter Limited. All rights reserved.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n// THE SOFTWARE.\n//\n\nimport _ from 'lodash';\n\nexport class EventEmitter {\n\n #listeners: Record<string, ((...args: any[]) => void)[]> = {};\n\n register(event: string, callback: (event: string, ...args: any[]) => void) {\n if (_.isNil(this.#listeners[event])) this.#listeners[event] = [];\n const _callback = (...args: any[]) => callback(event, ...args);\n this.#listeners[event].push(_callback);\n return {\n remove: () => {\n this.#listeners[event] = _.filter(this.#listeners[event], x => x !== _callback);\n },\n };\n }\n\n emit(event: string, ...args: any[]) {\n this.#listeners[event]?.forEach(async callback => {\n try {\n await callback(...args)\n } catch (e) {\n console.error(e);\n }\n });\n }\n}\n","//\n// native.ts\n//\n// The MIT License\n// Copyright (c) 2021 - 2026 O2ter Limited. All rights reserved.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n// THE SOFTWARE.\n//\n\nimport { _createElement, PropsType } from '../core/types/runtime';\nimport { ComponentNode, NativeElementType } from '../core/types/component';\n\nexport { _Renderer } from '../core/renderer';\nexport { uniqueId } from '../core/utils';\nexport { EventEmitter } from '../core/reconciler/events';\nexport type { VNode } from '../core/reconciler';\nexport { NativeElementType } from '../core/types/component';\n\nexport function _createNativeElement(\n type: typeof NativeElementType,\n props: PropsType,\n key?: string | number\n): ComponentNode {\n return _createElement(type, { ...props, key });\n}\n"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"_native.d.ts","sources":["../src/core/reconciler/events.ts","../src/renderer/native.ts"],"sourcesContent":["//\n// events.ts\n//\n// The MIT License\n// Copyright (c) 2021 - 2026 O2ter Limited. All rights reserved.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n// THE SOFTWARE.\n//\n\nimport _ from 'lodash';\n\nexport class EventEmitter {\n\n #listeners: Record<string, ((...args: any[]) => void)[]> = {};\n\n register(event: string, callback: (event: string, ...args: any[]) => void) {\n if (_.isNil(this.#listeners[event])) this.#listeners[event] = [];\n const _callback = (...args: any[]) => callback(event, ...args);\n this.#listeners[event].push(_callback);\n return {\n remove: () => {\n this.#listeners[event] = _.filter(this.#listeners[event], x => x !== _callback);\n },\n };\n }\n\n emit(event: string, ...args: any[]) {\n this.#listeners[event]?.forEach(async callback => {\n try {\n await callback(...args)\n } catch (e) {\n console.error(e);\n }\n });\n }\n}\n","//\n// native.ts\n//\n// The MIT License\n// Copyright (c) 2021 - 2026 O2ter Limited. All rights reserved.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n// THE SOFTWARE.\n//\n\nimport { _createElement, PropsType } from '../core/types/runtime';\nimport { ComponentNode, NativeElementType } from '../core/types/component';\n\nexport { _Renderer } from '../core/renderer';\nexport { uniqueId } from '../core/utils';\nexport { EventEmitter } from '../core/reconciler/events';\nexport type { VNode } from '../core/reconciler';\nexport { NativeElementType } from '../core/types/component';\n\nexport function _createNativeElement(\n type: typeof NativeElementType,\n props: PropsType,\n key?: string | number\n): ComponentNode {\n return _createElement(type, { ...props, key });\n}\n"],"names":[],"mappings":";;;;;;;;AAAO,cAAA,YAAA;AACP;AACA;AACA;AACA;AACA;AACA;;ACCO,iBAAA,oBAAA,cAAA,iBAAA,SAAA,SAAA,0BAAA,aAAA;;;;"}
|
package/dist/_native.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var runtime = require('./internals/runtime-CeVOFcK_.js');
|
|
4
|
-
var renderer = require('./internals/renderer-
|
|
5
|
-
var index = require('./internals/index-
|
|
6
|
-
var events = require('./internals/events-
|
|
4
|
+
var renderer = require('./internals/renderer-DR_CVQzd.js');
|
|
5
|
+
var index = require('./internals/index-Bvwj3lIq.js');
|
|
6
|
+
var events = require('./internals/events-CcBnpWOF.js');
|
|
7
7
|
require('lodash');
|
|
8
8
|
require('nextick');
|
|
9
9
|
require('myers.js');
|
package/dist/_native.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { _ as _createElement } from './internals/runtime-Bpq-U9sI.mjs';
|
|
2
2
|
export { N as NativeElementType } from './internals/runtime-Bpq-U9sI.mjs';
|
|
3
|
-
export { _ as _Renderer } from './internals/renderer-
|
|
3
|
+
export { _ as _Renderer } from './internals/renderer-DaX4zUo8.mjs';
|
|
4
4
|
export { u as uniqueId } from './internals/index-CODWK-gF.mjs';
|
|
5
5
|
export { E as EventEmitter } from './internals/events-BOkAQTmE.mjs';
|
|
6
6
|
import 'lodash';
|
package/dist/dom.d.mts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { _ as _DOMRenderer } from './internals/renderer-
|
|
2
|
-
import './internals/index-
|
|
1
|
+
import { _ as _DOMRenderer } from './internals/renderer-BluiQ1F-.mjs';
|
|
2
|
+
import './internals/index-BzVLlTCa.mjs';
|
|
3
3
|
import './internals/common-DU6Re-Mj.mjs';
|
|
4
4
|
import '@o2ter/utils-js';
|
|
5
5
|
import 'lodash';
|
|
6
6
|
import 'csstype';
|
|
7
|
+
import 'nextick';
|
|
7
8
|
import 'jsdom';
|
|
8
9
|
|
|
9
10
|
declare class DOMRenderer extends _DOMRenderer {
|
package/dist/dom.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dom.d.mts","sources":["../src/renderer/dom.ts"],"sourcesContent":["//\n// dom.ts\n//\n// The MIT License\n// Copyright (c) 2021 - 2026 O2ter Limited. All rights reserved.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n// THE SOFTWARE.\n//\n\nimport _ from 'lodash';\nimport { _DOMRenderer } from './common';\n\nexport class DOMRenderer extends _DOMRenderer {\n\n static default = new DOMRenderer(window);\n\n static createRoot(root: Element): ReturnType<typeof DOMRenderer.default.createRoot> {\n return this.default.createRoot(root);\n }\n\n get _server(): boolean {\n return false;\n }\n}\n"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"dom.d.mts","sources":["../src/renderer/dom.ts"],"sourcesContent":["//\n// dom.ts\n//\n// The MIT License\n// Copyright (c) 2021 - 2026 O2ter Limited. All rights reserved.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n// THE SOFTWARE.\n//\n\nimport _ from 'lodash';\nimport { _DOMRenderer } from './common';\n\nexport class DOMRenderer extends _DOMRenderer {\n\n static default = new DOMRenderer(window);\n\n static createRoot(root: Element): ReturnType<typeof DOMRenderer.default.createRoot> {\n return this.default.createRoot(root);\n }\n\n get _server(): boolean {\n return false;\n }\n}\n"],"names":[],"mappings":";;;;;;;;;AACO,cAAA,WAAA,SAAA,YAAA;AACP,oBAAA,WAAA;AACA,4BAAA,OAAA,GAAA,UAAA,QAAA,WAAA,CAAA,OAAA,CAAA,UAAA;AACA;AACA;;;;"}
|
package/dist/dom.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { _ as _DOMRenderer } from './internals/renderer-
|
|
2
|
-
import './internals/index-
|
|
1
|
+
import { _ as _DOMRenderer } from './internals/renderer-C1RBQB2f.js';
|
|
2
|
+
import './internals/index-OvcTjmzX.js';
|
|
3
3
|
import './internals/common-DU6Re-Mj.js';
|
|
4
4
|
import '@o2ter/utils-js';
|
|
5
5
|
import 'lodash';
|
|
6
6
|
import 'csstype';
|
|
7
|
+
import 'nextick';
|
|
7
8
|
import 'jsdom';
|
|
8
9
|
|
|
9
10
|
declare class DOMRenderer extends _DOMRenderer {
|
package/dist/dom.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dom.d.ts","sources":["../src/renderer/dom.ts"],"sourcesContent":["//\n// dom.ts\n//\n// The MIT License\n// Copyright (c) 2021 - 2026 O2ter Limited. All rights reserved.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n// THE SOFTWARE.\n//\n\nimport _ from 'lodash';\nimport { _DOMRenderer } from './common';\n\nexport class DOMRenderer extends _DOMRenderer {\n\n static default = new DOMRenderer(window);\n\n static createRoot(root: Element): ReturnType<typeof DOMRenderer.default.createRoot> {\n return this.default.createRoot(root);\n }\n\n get _server(): boolean {\n return false;\n }\n}\n"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"dom.d.ts","sources":["../src/renderer/dom.ts"],"sourcesContent":["//\n// dom.ts\n//\n// The MIT License\n// Copyright (c) 2021 - 2026 O2ter Limited. All rights reserved.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n// THE SOFTWARE.\n//\n\nimport _ from 'lodash';\nimport { _DOMRenderer } from './common';\n\nexport class DOMRenderer extends _DOMRenderer {\n\n static default = new DOMRenderer(window);\n\n static createRoot(root: Element): ReturnType<typeof DOMRenderer.default.createRoot> {\n return this.default.createRoot(root);\n }\n\n get _server(): boolean {\n return false;\n }\n}\n"],"names":[],"mappings":";;;;;;;;;AACO,cAAA,WAAA,SAAA,YAAA;AACP,oBAAA,WAAA;AACA,4BAAA,OAAA,GAAA,UAAA,QAAA,WAAA,CAAA,OAAA,CAAA,UAAA;AACA;AACA;;;;"}
|
package/dist/dom.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var renderer = require('./internals/renderer-
|
|
3
|
+
var renderer = require('./internals/renderer-C5NIsxDg.js');
|
|
4
4
|
require('lodash');
|
|
5
5
|
require('myers.js');
|
|
6
|
-
require('./internals/renderer-
|
|
7
|
-
require('./internals/index-
|
|
6
|
+
require('./internals/renderer-DR_CVQzd.js');
|
|
7
|
+
require('./internals/index-Bvwj3lIq.js');
|
|
8
8
|
require('./internals/runtime-CeVOFcK_.js');
|
|
9
9
|
require('nextick');
|
|
10
10
|
require('postcss');
|
package/dist/dom.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { _ as _DOMRenderer } from './internals/renderer-
|
|
1
|
+
import { _ as _DOMRenderer } from './internals/renderer-BvM6i6Cl.mjs';
|
|
2
2
|
import 'lodash';
|
|
3
3
|
import 'myers.js';
|
|
4
|
-
import './internals/renderer-
|
|
4
|
+
import './internals/renderer-DaX4zUo8.mjs';
|
|
5
5
|
import './internals/index-CODWK-gF.mjs';
|
|
6
6
|
import './internals/runtime-Bpq-U9sI.mjs';
|
|
7
7
|
import 'nextick';
|
package/dist/i18n.d.mts
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import _ from 'lodash';
|
|
2
|
+
import { Opts } from '@formatjs/intl-localematcher';
|
|
3
|
+
|
|
4
|
+
type I18nStateOPts = Partial<Opts> & {
|
|
5
|
+
locales: string[];
|
|
6
|
+
availableLocales: string[];
|
|
7
|
+
preferredLocale?: string;
|
|
8
|
+
fallback: string;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* A hook that provides the current i18n state based on the provided options.
|
|
12
|
+
*
|
|
13
|
+
* @param opts - An object containing the following properties:
|
|
14
|
+
* - `locales`: An array of preferred locales.
|
|
15
|
+
* - `availableLocales`: An array of available locales.
|
|
16
|
+
* - `preferredLocale`: An optional preferred locale to use if available.
|
|
17
|
+
* - `fallback`: A fallback locale to use if no match is found.
|
|
18
|
+
* - Additional options for locale matching can be provided as well.
|
|
19
|
+
*
|
|
20
|
+
* @returns The matched locale string based on the provided options.
|
|
21
|
+
*/
|
|
22
|
+
declare const useI18nState: (opts: I18nStateOPts) => string;
|
|
23
|
+
/**
|
|
24
|
+
* A hook that provides a localization function based on the current i18n state.
|
|
25
|
+
*
|
|
26
|
+
* @param opts - An object containing the following properties:
|
|
27
|
+
* - `locales`: An array of preferred locales.
|
|
28
|
+
* - `availableLocales`: An array of available locales.
|
|
29
|
+
* - `preferredLocale`: An optional preferred locale to use if available.
|
|
30
|
+
* - `fallback`: A fallback locale to use if no match is found.
|
|
31
|
+
* - Additional options for locale matching can be provided as well.
|
|
32
|
+
*
|
|
33
|
+
* @returns A function that takes a record of localized strings and an optional selector, returning the localized string based on the current i18n state.
|
|
34
|
+
*/
|
|
35
|
+
declare const useLocalize: (opts: I18nStateOPts) => <TObject extends unknown>(strings: Record<string, TObject>, selector?: _.PropertyPath) => any;
|
|
36
|
+
|
|
37
|
+
export { useI18nState, useLocalize };
|
|
38
|
+
//# sourceMappingURL=i18n.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"i18n.d.mts","sources":["../src/i18n/index.ts"],"sourcesContent":["//\n// index.ts\n//\n// The MIT License\n// Copyright (c) 2021 - 2026 O2ter Limited. All rights reserved.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n// THE SOFTWARE.\n//\n\nimport _ from 'lodash';\nimport { match, Opts } from '@formatjs/intl-localematcher';\nimport { useMemo } from '../core/hooks/memo';\nimport { useCallback } from '../core/hooks/callback';\n\ntype I18nStateOPts = Partial<Opts> & {\n locales: string[];\n availableLocales: string[];\n preferredLocale?: string;\n fallback: string;\n};\n\n/**\n * A hook that provides the current i18n state based on the provided options.\n *\n * @param opts - An object containing the following properties:\n * - `locales`: An array of preferred locales.\n * - `availableLocales`: An array of available locales.\n * - `preferredLocale`: An optional preferred locale to use if available.\n * - `fallback`: A fallback locale to use if no match is found.\n * - Additional options for locale matching can be provided as well.\n *\n * @returns The matched locale string based on the provided options.\n */\nexport const useI18nState = (opts: I18nStateOPts) => useMemo(() => {\n const { locales, availableLocales, preferredLocale, fallback: defaultLocale, ...options } = opts;\n if (preferredLocale && _.includes(availableLocales, preferredLocale)) {\n return preferredLocale;\n }\n return match(locales, availableLocales, defaultLocale, {\n algorithm: 'best fit',\n ...options,\n });\n}, [opts]);\n\n/**\n * A hook that provides a localization function based on the current i18n state.\n *\n * @param opts - An object containing the following properties:\n * - `locales`: An array of preferred locales.\n * - `availableLocales`: An array of available locales.\n * - `preferredLocale`: An optional preferred locale to use if available.\n * - `fallback`: A fallback locale to use if no match is found.\n * - Additional options for locale matching can be provided as well.\n * \n * @returns A function that takes a record of localized strings and an optional selector, returning the localized string based on the current i18n state.\n */\nexport const useLocalize = (opts: I18nStateOPts) => {\n const i18nState = useI18nState(opts);\n return useCallback(<TObject extends unknown>(\n strings: Record<string, TObject>,\n selector?: _.PropertyPath,\n ) => selector ? _.get(strings[i18nState], selector) : strings[i18nState]);\n};"],"names":[],"mappings":";;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO;;"}
|
package/dist/i18n.d.ts
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import _ from 'lodash';
|
|
2
|
+
import { Opts } from '@formatjs/intl-localematcher';
|
|
3
|
+
|
|
4
|
+
type I18nStateOPts = Partial<Opts> & {
|
|
5
|
+
locales: string[];
|
|
6
|
+
availableLocales: string[];
|
|
7
|
+
preferredLocale?: string;
|
|
8
|
+
fallback: string;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* A hook that provides the current i18n state based on the provided options.
|
|
12
|
+
*
|
|
13
|
+
* @param opts - An object containing the following properties:
|
|
14
|
+
* - `locales`: An array of preferred locales.
|
|
15
|
+
* - `availableLocales`: An array of available locales.
|
|
16
|
+
* - `preferredLocale`: An optional preferred locale to use if available.
|
|
17
|
+
* - `fallback`: A fallback locale to use if no match is found.
|
|
18
|
+
* - Additional options for locale matching can be provided as well.
|
|
19
|
+
*
|
|
20
|
+
* @returns The matched locale string based on the provided options.
|
|
21
|
+
*/
|
|
22
|
+
declare const useI18nState: (opts: I18nStateOPts) => string;
|
|
23
|
+
/**
|
|
24
|
+
* A hook that provides a localization function based on the current i18n state.
|
|
25
|
+
*
|
|
26
|
+
* @param opts - An object containing the following properties:
|
|
27
|
+
* - `locales`: An array of preferred locales.
|
|
28
|
+
* - `availableLocales`: An array of available locales.
|
|
29
|
+
* - `preferredLocale`: An optional preferred locale to use if available.
|
|
30
|
+
* - `fallback`: A fallback locale to use if no match is found.
|
|
31
|
+
* - Additional options for locale matching can be provided as well.
|
|
32
|
+
*
|
|
33
|
+
* @returns A function that takes a record of localized strings and an optional selector, returning the localized string based on the current i18n state.
|
|
34
|
+
*/
|
|
35
|
+
declare const useLocalize: (opts: I18nStateOPts) => <TObject extends unknown>(strings: Record<string, TObject>, selector?: _.PropertyPath) => any;
|
|
36
|
+
|
|
37
|
+
export { useI18nState, useLocalize };
|
|
38
|
+
//# sourceMappingURL=i18n.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"i18n.d.ts","sources":["../src/i18n/index.ts"],"sourcesContent":["//\n// index.ts\n//\n// The MIT License\n// Copyright (c) 2021 - 2026 O2ter Limited. All rights reserved.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n// THE SOFTWARE.\n//\n\nimport _ from 'lodash';\nimport { match, Opts } from '@formatjs/intl-localematcher';\nimport { useMemo } from '../core/hooks/memo';\nimport { useCallback } from '../core/hooks/callback';\n\ntype I18nStateOPts = Partial<Opts> & {\n locales: string[];\n availableLocales: string[];\n preferredLocale?: string;\n fallback: string;\n};\n\n/**\n * A hook that provides the current i18n state based on the provided options.\n *\n * @param opts - An object containing the following properties:\n * - `locales`: An array of preferred locales.\n * - `availableLocales`: An array of available locales.\n * - `preferredLocale`: An optional preferred locale to use if available.\n * - `fallback`: A fallback locale to use if no match is found.\n * - Additional options for locale matching can be provided as well.\n *\n * @returns The matched locale string based on the provided options.\n */\nexport const useI18nState = (opts: I18nStateOPts) => useMemo(() => {\n const { locales, availableLocales, preferredLocale, fallback: defaultLocale, ...options } = opts;\n if (preferredLocale && _.includes(availableLocales, preferredLocale)) {\n return preferredLocale;\n }\n return match(locales, availableLocales, defaultLocale, {\n algorithm: 'best fit',\n ...options,\n });\n}, [opts]);\n\n/**\n * A hook that provides a localization function based on the current i18n state.\n *\n * @param opts - An object containing the following properties:\n * - `locales`: An array of preferred locales.\n * - `availableLocales`: An array of available locales.\n * - `preferredLocale`: An optional preferred locale to use if available.\n * - `fallback`: A fallback locale to use if no match is found.\n * - Additional options for locale matching can be provided as well.\n * \n * @returns A function that takes a record of localized strings and an optional selector, returning the localized string based on the current i18n state.\n */\nexport const useLocalize = (opts: I18nStateOPts) => {\n const i18nState = useI18nState(opts);\n return useCallback(<TObject extends unknown>(\n strings: Record<string, TObject>,\n selector?: _.PropertyPath,\n ) => selector ? _.get(strings[i18nState], selector) : strings[i18nState]);\n};"],"names":[],"mappings":";;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO;;"}
|
package/dist/i18n.js
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var _ = require('lodash');
|
|
4
|
+
var intlLocalematcher = require('@formatjs/intl-localematcher');
|
|
5
|
+
var callback = require('./internals/callback-DVD1MTA9.js');
|
|
6
|
+
require('./internals/index-Bvwj3lIq.js');
|
|
7
|
+
require('./internals/runtime-CeVOFcK_.js');
|
|
8
|
+
require('myers.js');
|
|
9
|
+
|
|
10
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
11
|
+
|
|
12
|
+
var ___default = /*#__PURE__*/_interopDefault(_);
|
|
13
|
+
|
|
14
|
+
//
|
|
15
|
+
// index.ts
|
|
16
|
+
//
|
|
17
|
+
// The MIT License
|
|
18
|
+
// Copyright (c) 2021 - 2026 O2ter Limited. All rights reserved.
|
|
19
|
+
//
|
|
20
|
+
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
21
|
+
// of this software and associated documentation files (the "Software"), to deal
|
|
22
|
+
// in the Software without restriction, including without limitation the rights
|
|
23
|
+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
24
|
+
// copies of the Software, and to permit persons to whom the Software is
|
|
25
|
+
// furnished to do so, subject to the following conditions:
|
|
26
|
+
//
|
|
27
|
+
// The above copyright notice and this permission notice shall be included in
|
|
28
|
+
// all copies or substantial portions of the Software.
|
|
29
|
+
//
|
|
30
|
+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
31
|
+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
32
|
+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
33
|
+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
34
|
+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
35
|
+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
36
|
+
// THE SOFTWARE.
|
|
37
|
+
//
|
|
38
|
+
/**
|
|
39
|
+
* A hook that provides the current i18n state based on the provided options.
|
|
40
|
+
*
|
|
41
|
+
* @param opts - An object containing the following properties:
|
|
42
|
+
* - `locales`: An array of preferred locales.
|
|
43
|
+
* - `availableLocales`: An array of available locales.
|
|
44
|
+
* - `preferredLocale`: An optional preferred locale to use if available.
|
|
45
|
+
* - `fallback`: A fallback locale to use if no match is found.
|
|
46
|
+
* - Additional options for locale matching can be provided as well.
|
|
47
|
+
*
|
|
48
|
+
* @returns The matched locale string based on the provided options.
|
|
49
|
+
*/
|
|
50
|
+
const useI18nState = (opts) => callback.useMemo(() => {
|
|
51
|
+
const { locales, availableLocales, preferredLocale, fallback: defaultLocale, ...options } = opts;
|
|
52
|
+
if (preferredLocale && ___default.default.includes(availableLocales, preferredLocale)) {
|
|
53
|
+
return preferredLocale;
|
|
54
|
+
}
|
|
55
|
+
return intlLocalematcher.match(locales, availableLocales, defaultLocale, {
|
|
56
|
+
algorithm: 'best fit',
|
|
57
|
+
...options,
|
|
58
|
+
});
|
|
59
|
+
}, [opts]);
|
|
60
|
+
/**
|
|
61
|
+
* A hook that provides a localization function based on the current i18n state.
|
|
62
|
+
*
|
|
63
|
+
* @param opts - An object containing the following properties:
|
|
64
|
+
* - `locales`: An array of preferred locales.
|
|
65
|
+
* - `availableLocales`: An array of available locales.
|
|
66
|
+
* - `preferredLocale`: An optional preferred locale to use if available.
|
|
67
|
+
* - `fallback`: A fallback locale to use if no match is found.
|
|
68
|
+
* - Additional options for locale matching can be provided as well.
|
|
69
|
+
*
|
|
70
|
+
* @returns A function that takes a record of localized strings and an optional selector, returning the localized string based on the current i18n state.
|
|
71
|
+
*/
|
|
72
|
+
const useLocalize = (opts) => {
|
|
73
|
+
const i18nState = useI18nState(opts);
|
|
74
|
+
return callback.useCallback((strings, selector) => selector ? ___default.default.get(strings[i18nState], selector) : strings[i18nState]);
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
exports.useI18nState = useI18nState;
|
|
78
|
+
exports.useLocalize = useLocalize;
|
|
79
|
+
//# sourceMappingURL=i18n.js.map
|
package/dist/i18n.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"i18n.js","sources":["../../src/i18n/index.ts"],"sourcesContent":["//\n// index.ts\n//\n// The MIT License\n// Copyright (c) 2021 - 2026 O2ter Limited. All rights reserved.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n// THE SOFTWARE.\n//\n\nimport _ from 'lodash';\nimport { match, Opts } from '@formatjs/intl-localematcher';\nimport { useMemo } from '../core/hooks/memo';\nimport { useCallback } from '../core/hooks/callback';\n\ntype I18nStateOPts = Partial<Opts> & {\n locales: string[];\n availableLocales: string[];\n preferredLocale?: string;\n fallback: string;\n};\n\n/**\n * A hook that provides the current i18n state based on the provided options.\n *\n * @param opts - An object containing the following properties:\n * - `locales`: An array of preferred locales.\n * - `availableLocales`: An array of available locales.\n * - `preferredLocale`: An optional preferred locale to use if available.\n * - `fallback`: A fallback locale to use if no match is found.\n * - Additional options for locale matching can be provided as well.\n *\n * @returns The matched locale string based on the provided options.\n */\nexport const useI18nState = (opts: I18nStateOPts) => useMemo(() => {\n const { locales, availableLocales, preferredLocale, fallback: defaultLocale, ...options } = opts;\n if (preferredLocale && _.includes(availableLocales, preferredLocale)) {\n return preferredLocale;\n }\n return match(locales, availableLocales, defaultLocale, {\n algorithm: 'best fit',\n ...options,\n });\n}, [opts]);\n\n/**\n * A hook that provides a localization function based on the current i18n state.\n *\n * @param opts - An object containing the following properties:\n * - `locales`: An array of preferred locales.\n * - `availableLocales`: An array of available locales.\n * - `preferredLocale`: An optional preferred locale to use if available.\n * - `fallback`: A fallback locale to use if no match is found.\n * - Additional options for locale matching can be provided as well.\n * \n * @returns A function that takes a record of localized strings and an optional selector, returning the localized string based on the current i18n state.\n */\nexport const useLocalize = (opts: I18nStateOPts) => {\n const i18nState = useI18nState(opts);\n return useCallback(<TObject extends unknown>(\n strings: Record<string, TObject>,\n selector?: _.PropertyPath,\n ) => selector ? _.get(strings[i18nState], selector) : strings[i18nState]);\n};"],"names":["useMemo","_","match","useCallback"],"mappings":";;;;;;;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAcA;;;;;;;;;;;AAWG;AACI,MAAM,YAAY,GAAG,CAAC,IAAmB,KAAKA,gBAAO,CAAC,MAAK;AAChE,IAAA,MAAM,EAAE,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,QAAQ,EAAE,aAAa,EAAE,GAAG,OAAO,EAAE,GAAG,IAAI;IAChG,IAAI,eAAe,IAAIC,kBAAC,CAAC,QAAQ,CAAC,gBAAgB,EAAE,eAAe,CAAC,EAAE;AACpE,QAAA,OAAO,eAAe;IACxB;AACA,IAAA,OAAOC,uBAAK,CAAC,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAAE;AACrD,QAAA,SAAS,EAAE,UAAU;AACrB,QAAA,GAAG,OAAO;AACX,KAAA,CAAC;AACJ,CAAC,EAAE,CAAC,IAAI,CAAC;AAET;;;;;;;;;;;AAWG;AACI,MAAM,WAAW,GAAG,CAAC,IAAmB,KAAI;AACjD,IAAA,MAAM,SAAS,GAAG,YAAY,CAAC,IAAI,CAAC;AACpC,IAAA,OAAOC,oBAAW,CAAC,CACjB,OAAgC,EAChC,QAAyB,KACtB,QAAQ,GAAGF,kBAAC,CAAC,GAAG,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE,QAAQ,CAAC,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC;AAC3E;;;;;"}
|
package/dist/i18n.mjs
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import _ from 'lodash';
|
|
2
|
+
import { match } from '@formatjs/intl-localematcher';
|
|
3
|
+
import { c as useMemo, u as useCallback } from './internals/callback-DEKCuARB.mjs';
|
|
4
|
+
import './internals/index-CODWK-gF.mjs';
|
|
5
|
+
import './internals/runtime-Bpq-U9sI.mjs';
|
|
6
|
+
import 'myers.js';
|
|
7
|
+
|
|
8
|
+
//
|
|
9
|
+
// index.ts
|
|
10
|
+
//
|
|
11
|
+
// The MIT License
|
|
12
|
+
// Copyright (c) 2021 - 2026 O2ter Limited. All rights reserved.
|
|
13
|
+
//
|
|
14
|
+
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
15
|
+
// of this software and associated documentation files (the "Software"), to deal
|
|
16
|
+
// in the Software without restriction, including without limitation the rights
|
|
17
|
+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
18
|
+
// copies of the Software, and to permit persons to whom the Software is
|
|
19
|
+
// furnished to do so, subject to the following conditions:
|
|
20
|
+
//
|
|
21
|
+
// The above copyright notice and this permission notice shall be included in
|
|
22
|
+
// all copies or substantial portions of the Software.
|
|
23
|
+
//
|
|
24
|
+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
25
|
+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
26
|
+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
27
|
+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
28
|
+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
29
|
+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
30
|
+
// THE SOFTWARE.
|
|
31
|
+
//
|
|
32
|
+
/**
|
|
33
|
+
* A hook that provides the current i18n state based on the provided options.
|
|
34
|
+
*
|
|
35
|
+
* @param opts - An object containing the following properties:
|
|
36
|
+
* - `locales`: An array of preferred locales.
|
|
37
|
+
* - `availableLocales`: An array of available locales.
|
|
38
|
+
* - `preferredLocale`: An optional preferred locale to use if available.
|
|
39
|
+
* - `fallback`: A fallback locale to use if no match is found.
|
|
40
|
+
* - Additional options for locale matching can be provided as well.
|
|
41
|
+
*
|
|
42
|
+
* @returns The matched locale string based on the provided options.
|
|
43
|
+
*/
|
|
44
|
+
const useI18nState = (opts) => useMemo(() => {
|
|
45
|
+
const { locales, availableLocales, preferredLocale, fallback: defaultLocale, ...options } = opts;
|
|
46
|
+
if (preferredLocale && _.includes(availableLocales, preferredLocale)) {
|
|
47
|
+
return preferredLocale;
|
|
48
|
+
}
|
|
49
|
+
return match(locales, availableLocales, defaultLocale, {
|
|
50
|
+
algorithm: 'best fit',
|
|
51
|
+
...options,
|
|
52
|
+
});
|
|
53
|
+
}, [opts]);
|
|
54
|
+
/**
|
|
55
|
+
* A hook that provides a localization function based on the current i18n state.
|
|
56
|
+
*
|
|
57
|
+
* @param opts - An object containing the following properties:
|
|
58
|
+
* - `locales`: An array of preferred locales.
|
|
59
|
+
* - `availableLocales`: An array of available locales.
|
|
60
|
+
* - `preferredLocale`: An optional preferred locale to use if available.
|
|
61
|
+
* - `fallback`: A fallback locale to use if no match is found.
|
|
62
|
+
* - Additional options for locale matching can be provided as well.
|
|
63
|
+
*
|
|
64
|
+
* @returns A function that takes a record of localized strings and an optional selector, returning the localized string based on the current i18n state.
|
|
65
|
+
*/
|
|
66
|
+
const useLocalize = (opts) => {
|
|
67
|
+
const i18nState = useI18nState(opts);
|
|
68
|
+
return useCallback((strings, selector) => selector ? _.get(strings[i18nState], selector) : strings[i18nState]);
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
export { useI18nState, useLocalize };
|
|
72
|
+
//# sourceMappingURL=i18n.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"i18n.mjs","sources":["../../src/i18n/index.ts"],"sourcesContent":["//\n// index.ts\n//\n// The MIT License\n// Copyright (c) 2021 - 2026 O2ter Limited. All rights reserved.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n// THE SOFTWARE.\n//\n\nimport _ from 'lodash';\nimport { match, Opts } from '@formatjs/intl-localematcher';\nimport { useMemo } from '../core/hooks/memo';\nimport { useCallback } from '../core/hooks/callback';\n\ntype I18nStateOPts = Partial<Opts> & {\n locales: string[];\n availableLocales: string[];\n preferredLocale?: string;\n fallback: string;\n};\n\n/**\n * A hook that provides the current i18n state based on the provided options.\n *\n * @param opts - An object containing the following properties:\n * - `locales`: An array of preferred locales.\n * - `availableLocales`: An array of available locales.\n * - `preferredLocale`: An optional preferred locale to use if available.\n * - `fallback`: A fallback locale to use if no match is found.\n * - Additional options for locale matching can be provided as well.\n *\n * @returns The matched locale string based on the provided options.\n */\nexport const useI18nState = (opts: I18nStateOPts) => useMemo(() => {\n const { locales, availableLocales, preferredLocale, fallback: defaultLocale, ...options } = opts;\n if (preferredLocale && _.includes(availableLocales, preferredLocale)) {\n return preferredLocale;\n }\n return match(locales, availableLocales, defaultLocale, {\n algorithm: 'best fit',\n ...options,\n });\n}, [opts]);\n\n/**\n * A hook that provides a localization function based on the current i18n state.\n *\n * @param opts - An object containing the following properties:\n * - `locales`: An array of preferred locales.\n * - `availableLocales`: An array of available locales.\n * - `preferredLocale`: An optional preferred locale to use if available.\n * - `fallback`: A fallback locale to use if no match is found.\n * - Additional options for locale matching can be provided as well.\n * \n * @returns A function that takes a record of localized strings and an optional selector, returning the localized string based on the current i18n state.\n */\nexport const useLocalize = (opts: I18nStateOPts) => {\n const i18nState = useI18nState(opts);\n return useCallback(<TObject extends unknown>(\n strings: Record<string, TObject>,\n selector?: _.PropertyPath,\n ) => selector ? _.get(strings[i18nState], selector) : strings[i18nState]);\n};"],"names":[],"mappings":";;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAcA;;;;;;;;;;;AAWG;AACI,MAAM,YAAY,GAAG,CAAC,IAAmB,KAAK,OAAO,CAAC,MAAK;AAChE,IAAA,MAAM,EAAE,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,QAAQ,EAAE,aAAa,EAAE,GAAG,OAAO,EAAE,GAAG,IAAI;IAChG,IAAI,eAAe,IAAI,CAAC,CAAC,QAAQ,CAAC,gBAAgB,EAAE,eAAe,CAAC,EAAE;AACpE,QAAA,OAAO,eAAe;IACxB;AACA,IAAA,OAAO,KAAK,CAAC,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAAE;AACrD,QAAA,SAAS,EAAE,UAAU;AACrB,QAAA,GAAG,OAAO;AACX,KAAA,CAAC;AACJ,CAAC,EAAE,CAAC,IAAI,CAAC;AAET;;;;;;;;;;;AAWG;AACI,MAAM,WAAW,GAAG,CAAC,IAAmB,KAAI;AACjD,IAAA,MAAM,SAAS,GAAG,YAAY,CAAC,IAAI,CAAC;AACpC,IAAA,OAAO,WAAW,CAAC,CACjB,OAAgC,EAChC,QAAyB,KACtB,QAAQ,GAAG,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE,QAAQ,CAAC,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC;AAC3E;;;;"}
|