solid-intlayer 8.3.3 → 8.3.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. package/dist/cjs/client/index.cjs +1 -1
  2. package/dist/cjs/client/useDictionary.cjs +1 -1
  3. package/dist/cjs/client/useDictionaryAsync.cjs +1 -1
  4. package/dist/cjs/client/useDictionaryDynamic.cjs +1 -1
  5. package/dist/cjs/client/useIntlayer.cjs +1 -1
  6. package/dist/cjs/editor/ContentSelectorWrapper.cjs +1 -1
  7. package/dist/cjs/editor/IntlayerEditorProvider.cjs +1 -1
  8. package/dist/cjs/editor/contexts/CommunicatorContext.cjs +1 -1
  9. package/dist/cjs/editor/contexts/ConfigurationContext.cjs +1 -1
  10. package/dist/cjs/editor/contexts/DictionariesRecordContext.cjs +1 -1
  11. package/dist/cjs/editor/contexts/EditedContentContext.cjs +1 -1
  12. package/dist/cjs/editor/contexts/EditorEnabledContext.cjs +1 -1
  13. package/dist/cjs/editor/contexts/EditorProvider.cjs +1 -1
  14. package/dist/cjs/editor/contexts/FocusDictionaryContext.cjs +1 -1
  15. package/dist/cjs/editor/contexts/index.cjs +1 -1
  16. package/dist/cjs/editor/contexts/useCrossFrameMessageListener.cjs +1 -1
  17. package/dist/cjs/editor/contexts/useCrossFrameState.cjs +1 -1
  18. package/dist/cjs/editor/contexts/useCrossURLPathState.cjs +1 -1
  19. package/dist/cjs/editor/contexts/useIframeClickInterceptor.cjs +1 -1
  20. package/dist/cjs/editor/index.cjs +1 -1
  21. package/dist/cjs/editor/useEditedContentRenderer.cjs +1 -1
  22. package/dist/cjs/getDictionary.cjs +1 -1
  23. package/dist/cjs/getIntlayer.cjs +1 -1
  24. package/dist/cjs/index.cjs +1 -1
  25. package/dist/cjs/plugins.cjs +1 -1
  26. package/dist/esm/client/index.mjs +1 -1
  27. package/dist/esm/client/useDictionary.mjs +1 -1
  28. package/dist/esm/client/useDictionaryAsync.mjs +1 -1
  29. package/dist/esm/client/useDictionaryDynamic.mjs +1 -1
  30. package/dist/esm/client/useIntlayer.mjs +1 -1
  31. package/dist/esm/editor/ContentSelectorWrapper.mjs +1 -1
  32. package/dist/esm/editor/IntlayerEditorProvider.mjs +6 -34
  33. package/dist/esm/editor/contexts/CommunicatorContext.mjs +9 -27
  34. package/dist/esm/editor/contexts/ConfigurationContext.mjs +7 -16
  35. package/dist/esm/editor/contexts/DictionariesRecordContext.mjs +14 -35
  36. package/dist/esm/editor/contexts/EditedContentContext.mjs +26 -132
  37. package/dist/esm/editor/contexts/EditorEnabledContext.mjs +18 -18
  38. package/dist/esm/editor/contexts/EditorProvider.mjs +33 -63
  39. package/dist/esm/editor/contexts/FocusDictionaryContext.mjs +13 -36
  40. package/dist/esm/editor/contexts/index.mjs +12 -11
  41. package/dist/esm/editor/contexts/useCrossFrameMessageListener.mjs +6 -28
  42. package/dist/esm/editor/contexts/useCrossFrameState.mjs +16 -36
  43. package/dist/esm/editor/contexts/useCrossURLPathState.mjs +2 -22
  44. package/dist/esm/editor/contexts/useIframeClickInterceptor.mjs +7 -14
  45. package/dist/esm/editor/index.mjs +1 -1
  46. package/dist/esm/editor/useEditedContentRenderer.mjs +12 -9
  47. package/dist/esm/getDictionary.mjs +1 -1
  48. package/dist/esm/getIntlayer.mjs +1 -1
  49. package/dist/esm/index.mjs +1 -1
  50. package/dist/esm/plugins.mjs +1 -1
  51. package/dist/getDictionary-DdbGMGJZ.mjs +197 -0
  52. package/dist/getDictionary-PBgZNa_l.js +1 -0
  53. package/dist/types/editor/ContentSelectorWrapper.d.ts +10 -0
  54. package/dist/types/editor/contexts/CommunicatorContext.d.ts +6 -7
  55. package/dist/types/editor/contexts/ConfigurationContext.d.ts +1 -7
  56. package/dist/types/editor/contexts/DictionariesRecordContext.d.ts +8 -11
  57. package/dist/types/editor/contexts/EditedContentContext.d.ts +26 -30
  58. package/dist/types/editor/contexts/EditorEnabledContext.d.ts +5 -9
  59. package/dist/types/editor/contexts/EditorProvider.d.ts +13 -3
  60. package/dist/types/editor/contexts/FocusDictionaryContext.d.ts +7 -15
  61. package/dist/types/editor/contexts/index.d.ts +1 -0
  62. package/dist/types/editor/contexts/useCrossFrameMessageListener.d.ts +0 -16
  63. package/dist/types/editor/contexts/useCrossFrameState.d.ts +1 -22
  64. package/dist/types/editor/contexts/useCrossURLPathState.d.ts +2 -3
  65. package/dist/types/editor/contexts/useIframeClickInterceptor.d.ts +1 -7
  66. package/package.json +7 -8
  67. package/dist/getDictionary-DKdSGWHu.mjs +0 -188
  68. package/dist/getDictionary-DxYuk0_0.js +0 -1
@@ -1,9 +1,8 @@
1
- import { Component, ParentProps } from 'solid-js';
2
- export type UseCrossPlatformStateProps = {
3
- postMessage: typeof window.postMessage;
4
- allowedOrigins?: string[];
1
+ export declare const useCommunicator: () => {
2
+ postMessage: (data: any) => void;
5
3
  senderId: string;
6
4
  };
7
- export type CommunicatorProviderProps = ParentProps<Omit<UseCrossPlatformStateProps, 'senderId'>>;
8
- export declare const CommunicatorProvider: Component<CommunicatorProviderProps>;
9
- export declare const useCommunicator: () => UseCrossPlatformStateProps;
5
+ export type CommunicatorProviderProps = {
6
+ postMessage?: (data: any) => void;
7
+ allowedOrigins?: string[];
8
+ };
@@ -1,8 +1,2 @@
1
1
  import { IntlayerConfig } from '@intlayer/types/config';
2
- import { Component, ParentProps } from 'solid-js';
3
- export declare const useConfigurationState: () => [import('solid-js').Accessor<IntlayerConfig>, (value: IntlayerConfig | ((prev: IntlayerConfig) => IntlayerConfig)) => void, () => void];
4
- export type ConfigurationProviderProps = ParentProps<{
5
- configuration?: IntlayerConfig;
6
- }>;
7
- export declare const ConfigurationProvider: Component<ConfigurationProviderProps>;
8
- export declare const useConfiguration: () => IntlayerConfig | undefined;
2
+ export declare const useConfiguration: () => import('solid-js').Accessor<IntlayerConfig | undefined>;
@@ -1,15 +1,12 @@
1
+ import { DictionaryContent } from '@intlayer/editor';
1
2
  import { Dictionary } from '@intlayer/types/dictionary';
2
- import { Component, ParentProps, Setter } from 'solid-js';
3
- export type DictionaryContent = Record<Dictionary['key'], Dictionary>;
4
- type DictionariesRecordActionsContextType = {
5
- setLocaleDictionaries: Setter<DictionaryContent>;
3
+ export type { DictionaryContent };
4
+ export declare const useDictionariesRecord: () => {
5
+ localeDictionaries: import('solid-js').Accessor<DictionaryContent>;
6
+ setLocaleDictionaries: (value: DictionaryContent) => void;
6
7
  setLocaleDictionary: (dictionary: Dictionary) => void;
7
8
  };
8
- export declare const DictionariesRecordProvider: Component<ParentProps>;
9
- export declare const useDictionariesRecordActions: () => DictionariesRecordActionsContextType | undefined;
10
- export declare const useDictionariesRecord: () => {
11
- setLocaleDictionaries?: Setter<DictionaryContent> | undefined;
12
- setLocaleDictionary?: ((dictionary: Dictionary) => void) | undefined;
13
- localeDictionaries: DictionaryContent;
9
+ export declare const useDictionariesRecordActions: () => {
10
+ setLocaleDictionaries: (value: DictionaryContent) => void;
11
+ setLocaleDictionary: (dictionary: Dictionary) => void;
14
12
  };
15
- export {};
@@ -1,34 +1,30 @@
1
- import { LocalDictionaryId } from '@intlayer/types/dictionary';
1
+ import { DictionaryContent } from '@intlayer/editor';
2
+ import { ContentNode, Dictionary, LocalDictionaryId } from '@intlayer/types/dictionary';
2
3
  import { KeyPath } from '@intlayer/types/keyPath';
3
- import { ContentNode, Dictionary } from 'intlayer';
4
- import { Component, ParentProps } from 'solid-js';
5
- export declare const usePostEditedContentState: <S>(onEventTriggered?: (data: S) => void) => (data?: S | undefined) => void;
6
- export declare const useGetEditedContentState: <S>(onEventTriggered?: (data: S) => void) => (data?: S | undefined) => void;
7
- type EditedContentActionsContextType = {
8
- setEditedContentState: (editedContent: Record<Dictionary['key'], Dictionary>) => void;
9
- setEditedDictionary: (newValue: Dictionary | ((prev?: Dictionary) => Dictionary)) => void;
10
- setEditedContent: (dictionaryKey: Dictionary['key'], newValue: Dictionary['content']) => void;
11
- addEditedContent: (dictionaryKey: Dictionary['key'], newValue: ContentNode<any>, keyPath?: KeyPath[], overwrite?: boolean) => void;
12
- renameEditedContent: (dictionaryKey: Dictionary['key'], newKey: KeyPath['key'], keyPath?: KeyPath[]) => void;
13
- removeEditedContent: (dictionaryKey: Dictionary['key'], keyPath: KeyPath[]) => void;
14
- restoreEditedContent: (dictionaryKey: Dictionary['key']) => void;
15
- clearEditedDictionaryContent: (dictionaryKey: Dictionary['key']) => void;
4
+ export declare const useEditedContent: () => {
5
+ editedContent: import('solid-js').Accessor<DictionaryContent | undefined>;
6
+ setEditedContentState: (value: DictionaryContent) => void;
7
+ setEditedDictionary: (dict: Dictionary) => void;
8
+ setEditedContent: (localId: LocalDictionaryId, value: Dictionary["content"]) => void;
9
+ addEditedContent: (localId: LocalDictionaryId, value: ContentNode, keyPath?: KeyPath[], overwrite?: boolean) => void;
10
+ renameEditedContent: (localId: LocalDictionaryId, newKey: KeyPath["key"], keyPath?: KeyPath[]) => void;
11
+ removeEditedContent: (localId: LocalDictionaryId, keyPath: KeyPath[]) => void;
12
+ restoreEditedContent: (localId: LocalDictionaryId) => void;
13
+ clearEditedDictionaryContent: (localId: LocalDictionaryId) => void;
16
14
  clearEditedContent: () => void;
17
- getEditedContentValue: (localDictionaryIdOrKey: LocalDictionaryId | Dictionary['key'] | string, keyPath: KeyPath[]) => ContentNode | undefined;
15
+ getEditedContentValue: (localIdOrKey: LocalDictionaryId | string, keyPath: KeyPath[]) => ContentNode | undefined;
18
16
  };
19
- export declare const EditedContentProvider: Component<ParentProps>;
20
- export declare const useEditedContentActions: () => EditedContentActionsContextType | undefined;
21
- export declare const useEditedContent: () => {
22
- setEditedContentState?: ((editedContent: Record<Dictionary["key"], Dictionary>) => void) | undefined;
23
- setEditedDictionary?: ((newValue: Dictionary | ((prev?: Dictionary) => Dictionary)) => void) | undefined;
24
- setEditedContent?: ((dictionaryKey: Dictionary["key"], newValue: Dictionary["content"]) => void) | undefined;
25
- addEditedContent?: ((dictionaryKey: Dictionary["key"], newValue: ContentNode<any>, keyPath?: KeyPath[], overwrite?: boolean) => void) | undefined;
26
- renameEditedContent?: ((dictionaryKey: Dictionary["key"], newKey: KeyPath["key"], keyPath?: KeyPath[]) => void) | undefined;
27
- removeEditedContent?: ((dictionaryKey: Dictionary["key"], keyPath: KeyPath[]) => void) | undefined;
28
- restoreEditedContent?: ((dictionaryKey: Dictionary["key"]) => void) | undefined;
29
- clearEditedDictionaryContent?: ((dictionaryKey: Dictionary["key"]) => void) | undefined;
30
- clearEditedContent?: (() => void) | undefined;
31
- getEditedContentValue?: ((localDictionaryIdOrKey: LocalDictionaryId | Dictionary["key"] | string, keyPath: KeyPath[]) => ContentNode | undefined) | undefined;
32
- editedContent: Record<Dictionary["key"], Dictionary> | undefined;
17
+ export declare const useEditedContentActions: () => {
18
+ setEditedContentState: (value: DictionaryContent) => void;
19
+ setEditedDictionary: (dict: Dictionary) => void;
20
+ setEditedContent: (localId: LocalDictionaryId, value: Dictionary["content"]) => void;
21
+ addEditedContent: (localId: LocalDictionaryId, value: ContentNode, keyPath?: KeyPath[], overwrite?: boolean) => void;
22
+ renameEditedContent: (localId: LocalDictionaryId, newKey: KeyPath["key"], keyPath?: KeyPath[]) => void;
23
+ removeEditedContent: (localId: LocalDictionaryId, keyPath: KeyPath[]) => void;
24
+ restoreEditedContent: (localId: LocalDictionaryId) => void;
25
+ clearEditedDictionaryContent: (localId: LocalDictionaryId) => void;
26
+ clearEditedContent: () => void;
27
+ getEditedContentValue: (localIdOrKey: LocalDictionaryId | string, keyPath: KeyPath[]) => ContentNode | undefined;
33
28
  };
34
- export {};
29
+ export declare const useGetEditedContentState: () => () => void;
30
+ export declare const usePostEditedContentState: () => () => void;
@@ -1,10 +1,6 @@
1
- import { Component, ParentProps } from 'solid-js';
2
- import { CrossFrameStateOptions } from './useCrossFrameState';
3
- export type EditorEnabledStateProps = {
4
- enabled: () => boolean;
1
+ export declare const useEditorEnabled: () => {
2
+ enabled: import('solid-js').Accessor<boolean>;
5
3
  };
6
- export declare const useEditorEnabledState: (options?: CrossFrameStateOptions) => [import('solid-js').Accessor<boolean>, (value: boolean | ((prev: boolean) => boolean)) => void, () => void];
7
- export declare const usePostEditorEnabledState: <S>(onEventTriggered?: (data: S) => void) => (data?: S | undefined) => void;
8
- export declare const useGetEditorEnabledState: <S>(onEventTriggered?: (data: S) => void) => (data?: S | undefined) => void;
9
- export declare const EditorEnabledProvider: Component<ParentProps>;
10
- export declare const useEditorEnabled: () => EditorEnabledStateProps;
4
+ export declare const useEditorEnabledState: () => readonly [import('solid-js').Accessor<boolean>, (value: boolean) => void];
5
+ export declare const useGetEditorEnabledState: () => () => void;
6
+ export declare const usePostEditorEnabledState: () => () => void;
@@ -1,5 +1,15 @@
1
+ import { EditorStateManager } from '@intlayer/editor';
2
+ import { IntlayerConfig } from '@intlayer/types/config';
1
3
  import { Component, ParentProps } from 'solid-js';
2
- import { CommunicatorProviderProps } from './CommunicatorContext';
3
- import { ConfigurationProviderProps } from './ConfigurationContext';
4
- export type EditorProviderProps = CommunicatorProviderProps & ConfigurationProviderProps;
4
+ export type EditorProviderProps = {
5
+ mode?: 'editor' | 'client';
6
+ configuration?: IntlayerConfig;
7
+ postMessage?: (data: any) => void;
8
+ allowedOrigins?: string[];
9
+ };
10
+ export declare const useEditorStateManager: () => EditorStateManager;
5
11
  export declare const EditorProvider: Component<ParentProps<EditorProviderProps>>;
12
+ export type { EditorProviderProps as CommunicatorProviderProps };
13
+ export type ConfigurationProviderProps = {
14
+ configuration?: IntlayerConfig;
15
+ };
@@ -1,20 +1,12 @@
1
+ import { FileContent } from '@intlayer/editor';
1
2
  import { KeyPath } from '@intlayer/types/keyPath';
2
- import { Component, ParentProps, Setter } from 'solid-js';
3
- type DictionaryPath = string;
4
- export type FileContent = {
5
- dictionaryKey: string;
6
- keyPath?: KeyPath[];
7
- dictionaryPath?: DictionaryPath;
8
- };
9
- type FocusDictionaryActions = {
10
- setFocusedContent: Setter<FileContent | null>;
3
+ export type { FileContent };
4
+ export declare const useFocusDictionary: () => {
5
+ focusedContent: import('solid-js').Accessor<FileContent | null>;
6
+ setFocusedContent: (value: FileContent | null) => void;
11
7
  setFocusedContentKeyPath: (keyPath: KeyPath[]) => void;
12
8
  };
13
- export declare const FocusDictionaryProvider: Component<ParentProps>;
14
- export declare const useFocusDictionaryActions: () => FocusDictionaryActions;
15
- export declare const useFocusDictionary: () => {
16
- setFocusedContent: Setter<FileContent | null>;
9
+ export declare const useFocusDictionaryActions: () => {
10
+ setFocusedContent: (value: FileContent | null) => void;
17
11
  setFocusedContentKeyPath: (keyPath: KeyPath[]) => void;
18
- focusedContent: FileContent | null;
19
12
  };
20
- export {};
@@ -1,4 +1,5 @@
1
1
  export * from '@intlayer/editor';
2
+ export * from './CommunicatorContext';
2
3
  export * from './ConfigurationContext';
3
4
  export * from './DictionariesRecordContext';
4
5
  export * from './EditedContentContext';
@@ -1,18 +1,2 @@
1
1
  import { MessageKey } from '@intlayer/editor';
2
- /**
3
- * useCrossFrameMessageListener
4
- *
5
- * This Solid hook listens for messages sent via the `postMessage` API and triggers a callback
6
- * whenever a message of the specified type (`key`) is received. It is useful for synchronizing
7
- * state or events across different windows, iframes, or contexts.
8
- *
9
- * @template S - The type of the data payload in the message.
10
- * @param key - A unique identifier for the message type to listen for.
11
- * @param [onEventTriggered] - A callback function triggered when a message
12
- * @param [revalidator] - A function that re-subscribes the listener. Could be useful if onEventTriggered depend of some state
13
- * with the specified key is received. The callback receives the message data as its argument.
14
- *
15
- * @returns {{ postMessage: (data: S) => void }} An object containing a `postMessage` function
16
- * that allows broadcasting messages with the specified key and data.
17
- */
18
2
  export declare const useCrossFrameMessageListener: <S>(key: `${MessageKey}` | `${MessageKey}/post` | `${MessageKey}/get`, onEventTriggered?: (data: S) => void) => (data?: S) => void;
@@ -4,25 +4,4 @@ export type CrossFrameStateOptions = {
4
4
  emit?: boolean;
5
5
  receive?: boolean;
6
6
  };
7
- /**
8
- * Configuration options for `useCrossFrameState`.
9
- * @typedef {Object} CrossFrameStateOptions
10
- * @property {boolean} [emit=true] - Whether to broadcast state changes to other instances.
11
- * @property {boolean} [receive=true] - Whether to listen for state updates from other instances.
12
- */
13
- /**
14
- * useCrossFrameState
15
- *
16
- * This Solid.js hook synchronizes state across multiple instances (e.g., different iframes or windows).
17
- * It uses the `postMessage` API to communicate state changes and updates between instances.
18
- *
19
- * @template S - The type of the state.
20
- * @param key - A unique identifier for the state to synchronize.
21
- * @param initialState - The initial state value or a function to compute it lazily.
22
- * @param options - Configuration options to control emitting and receiving messages.
23
- * - `emit` (default: true): Whether to broadcast state changes to other instances.
24
- * - `receive` (default: true): Whether to listen for state updates from other instances.
25
- *
26
- * @returns {[Accessor<S>, (value: S | ((prev: S) => S)) => void, () => void]} An array containing the current state accessor, setter function, and post function.
27
- */
28
- export declare const useCrossFrameState: <S>(key: `${MessageKey}`, initialState?: S | (() => S), options?: CrossFrameStateOptions) => [Accessor<S>, (value: S | ((prev: S) => S)) => void, () => void];
7
+ export declare const useCrossFrameState: <S>(key: `${MessageKey}`, initialState?: S, options?: CrossFrameStateOptions) => [Accessor<S>, (value: S | ((prev: S) => S)) => void, () => void];
@@ -1,3 +1,2 @@
1
- import { CrossFrameStateOptions } from './useCrossFrameState';
2
- export declare const useCrossURLPathState: (initialState?: string, options?: CrossFrameStateOptions) => [import('solid-js').Accessor<string>, (value: string | ((prev: string) => string)) => void, () => void];
3
- export declare const useCrossURLPathSetter: (initialState?: string) => [import('solid-js').Accessor<string>, (value: string | ((prev: string) => string)) => void, () => void];
1
+ export declare const useCrossURLPathSetter: () => void;
2
+ export declare const useCrossURLPathState: () => void;
@@ -1,8 +1,2 @@
1
- /**
2
- * Custom hook that intercepts clicks on the page and sends them via `postMessage`.
3
- *
4
- * This is useful in iframe contexts where you want the parent frame to know
5
- * about click events happening within the iframe.
6
- */
7
1
  export declare const useIframeClickInterceptor: () => void;
8
- export declare const useIframeClickMerger: () => (data?: MessageEvent<any> | undefined) => void;
2
+ export declare const useIframeClickMerger: () => void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "solid-intlayer",
3
- "version": "8.3.3",
3
+ "version": "8.3.4",
4
4
  "private": false,
5
5
  "description": "Easily internationalize i18n your Solid applications with type-safe multilingual content management.",
6
6
  "keywords": [
@@ -73,14 +73,13 @@
73
73
  "typecheck": "tsc --noEmit --project tsconfig.types.json"
74
74
  },
75
75
  "dependencies": {
76
- "@intlayer/api": "8.3.3",
77
- "@intlayer/config": "8.3.3",
78
- "@intlayer/core": "8.3.3",
79
- "@intlayer/editor": "8.3.3",
80
- "@intlayer/types": "8.3.3"
76
+ "@intlayer/api": "8.3.4",
77
+ "@intlayer/config": "8.3.4",
78
+ "@intlayer/core": "8.3.4",
79
+ "@intlayer/editor": "8.3.4",
80
+ "@intlayer/types": "8.3.4"
81
81
  },
82
82
  "devDependencies": {
83
- "@intlayer/unmerged-dictionaries-entry": "8.3.3",
84
83
  "@solidjs/testing-library": "0.8.10",
85
84
  "@testing-library/jest-dom": "6.9.1",
86
85
  "@testing-library/user-event": "14.6.1",
@@ -90,7 +89,7 @@
90
89
  "@utils/tsdown-config": "1.0.4",
91
90
  "jsdom": "28.1.0",
92
91
  "rimraf": "6.1.3",
93
- "tsdown": "0.21.2",
92
+ "tsdown": "0.21.4",
94
93
  "typescript": "5.9.3",
95
94
  "vite": "8.0.0",
96
95
  "vite-plugin-dts": "4.5.4",
@@ -1,188 +0,0 @@
1
- import { renderIntlayerNode as e } from "./esm/IntlayerNode.mjs";
2
- import { useEditorEnabled as t } from "./esm/editor/contexts/EditorEnabledContext.mjs";
3
- import { useFocusDictionary as n } from "./esm/editor/contexts/FocusDictionaryContext.mjs";
4
- import { IntlayerClientContext as r, useIntlayerContext as i } from "./esm/client/IntlayerProvider.mjs";
5
- import { useLoadDynamic as a } from "./esm/client/useLoadDynamic.mjs";
6
- import { ContentSelector as o } from "./esm/UI/ContentSelector.mjs";
7
- import { EditedContentRenderer as s } from "./esm/editor/useEditedContentRenderer.mjs";
8
- import { MarkdownMetadataRenderer as c, MarkdownRenderer as l } from "./esm/markdown/MarkdownRenderer.mjs";
9
- import { renderSolidElement as u } from "./esm/solidElement/renderSolidElement.mjs";
10
- import { conditionPlugin as d, enumerationPlugin as f, filePlugin as p, genderPlugin as m, getDictionary as h, getHTML as g, getIntlayer as _, nestedPlugin as v, splitInsertionTemplate as y, translationPlugin as b } from "@intlayer/core/interpreter";
11
- import { Dynamic as x, createComponent as S, mergeProps as C } from "solid-js/web";
12
- import w from "@intlayer/config/built";
13
- import { getMarkdownMetadata as T } from "@intlayer/core/markdown";
14
- import { HTML_TAGS as E } from "@intlayer/core/transpiler";
15
- import { NodeType as D } from "@intlayer/types/nodeType";
16
- import { isSameKeyPath as O } from "@intlayer/core/utils";
17
- import { createMemo as k, useContext as A } from "solid-js";
18
- //#region src/client/useDictionary.ts
19
- var j = (e, t) => {
20
- let n = A(r);
21
- return k(() => q(e, t ?? n?.locale?.()));
22
- }, M = async (e, t) => {
23
- let { locale: n } = A(r), i = w?.internationalization.defaultLocale, a = t ?? n() ?? i;
24
- return j(await e[a]?.(), a);
25
- }, N = (e, t, n) => {
26
- let { locale: i } = A(r) ?? {}, o = w?.internationalization.defaultLocale, s = n ?? i?.() ?? o;
27
- return j(a(`${String(t)}.${s}`, e[s]?.()), s);
28
- }, P = (e, t) => _(e, t, K(t)), F = (e, t) => {
29
- let n = A(r);
30
- return k(() => {
31
- let r = n?.locale();
32
- return P(e, t ?? r);
33
- });
34
- }, I = (e) => {
35
- let { focusedContent: t, setFocusedContent: r } = n(), i = k(() => e.keyPath.filter((e) => e.type !== D.Translation)), a = () => r({
36
- dictionaryKey: e.dictionaryKey,
37
- keyPath: i()
38
- }), s = k(() => (t?.dictionaryKey === e.dictionaryKey && (t?.keyPath?.length ?? 0) > 0 && O(t?.keyPath ?? [], i())) ?? !1);
39
- return S(o, {
40
- onPress: a,
41
- get isSelecting() {
42
- return s();
43
- },
44
- get children() {
45
- return e.children;
46
- }
47
- });
48
- }, L = (e) => {
49
- let { enabled: n } = t(), { disableEditor: r } = i();
50
- return n() && !r ? S(I, C(e, { get children() {
51
- return e.children;
52
- } })) : e.children;
53
- }, R = {
54
- id: "intlayer-node-plugin",
55
- canHandle: (e) => typeof e == "bigint" || typeof e == "string" || typeof e == "number",
56
- transform: (t, { plugins: n, ...r }) => e({
57
- ...r,
58
- value: r.children,
59
- children: w?.editor.enabled ? S(L, C(r, { get children() {
60
- return S(s, C(r, { get children() {
61
- return r.children;
62
- } }));
63
- } })) : r.children
64
- })
65
- }, z = {
66
- id: "solid-node-plugin",
67
- canHandle: (e) => typeof e == "object" && e?.props !== void 0 || typeof Node < "u" && e instanceof Node,
68
- transform: (t, { plugins: n, ...r }) => e({
69
- ...r,
70
- value: "[[solid-element]]",
71
- children: w?.editor.enabled ? S(L, C(r, { get children() {
72
- return typeof Node < "u" && t instanceof Node ? t : u(t);
73
- } })) : typeof Node < "u" && t instanceof Node ? t : u(t)
74
- })
75
- }, B = (e, t) => {
76
- let n = y(e, t);
77
- return n.isSimple, n.parts;
78
- }, V = {
79
- id: "insertion-plugin",
80
- canHandle: (e) => typeof e == "object" && e?.nodeType === D.Insertion,
81
- transform: (e, t, n) => {
82
- let r = [...t.keyPath, { type: D.Insertion }], i = e[D.Insertion];
83
- return (e) => {
84
- let a = {
85
- id: "insertion-string-plugin",
86
- canHandle: (e) => typeof e == "string",
87
- transform: (n, r, i) => {
88
- let a = B(i(n, {
89
- ...r,
90
- children: n,
91
- plugins: [...(t.plugins ?? []).filter((e) => e.id !== "intlayer-node-plugin")]
92
- }), e);
93
- return i(a, {
94
- ...r,
95
- plugins: t.plugins,
96
- children: a
97
- });
98
- }
99
- };
100
- return n(i, {
101
- ...t,
102
- children: i,
103
- keyPath: r,
104
- plugins: [a, ...t.plugins ?? []]
105
- });
106
- };
107
- }
108
- }, H = {
109
- id: "markdown-string-plugin",
110
- canHandle: (e) => typeof e == "string",
111
- transform: (t, n, r) => {
112
- let { plugins: i, ...a } = n, o = r(T(t), {
113
- plugins: [{
114
- id: "markdown-metadata-plugin",
115
- canHandle: (e) => typeof e == "string" || typeof e == "number" || typeof e == "boolean" || !e,
116
- transform: (n, r) => e({
117
- ...r,
118
- value: n,
119
- children: S(L, C(a, { get children() {
120
- return S(c, C(a, {
121
- get metadataKeyPath() {
122
- return r.keyPath;
123
- },
124
- children: t
125
- }));
126
- } }))
127
- })
128
- }],
129
- dictionaryKey: a.dictionaryKey,
130
- keyPath: []
131
- }), s = (r) => e({
132
- ...n,
133
- value: t,
134
- children: S(L, C(a, { get children() {
135
- return S(l, C(a, {
136
- components: r,
137
- children: t
138
- }));
139
- } })),
140
- additionalProps: { metadata: o }
141
- }), u = s();
142
- return new Proxy(u, { get(e, n, r) {
143
- return n === "value" ? t : n === "metadata" ? o : n === "use" ? (e) => s(e) : Reflect.get(e, n, r);
144
- } });
145
- }
146
- }, U = {
147
- id: "markdown-plugin",
148
- canHandle: (e) => typeof e == "object" && e?.nodeType === D.Markdown,
149
- transform: (e, t, n) => {
150
- let r = [...t.keyPath, { type: D.Markdown }], i = e[D.Markdown];
151
- return n(i, {
152
- ...t,
153
- children: i,
154
- keyPath: r,
155
- plugins: [H, ...t.plugins ?? []]
156
- });
157
- }
158
- }, W = (() => {
159
- let e = {};
160
- for (let t of E) e[t] = ({ children: e, ...n }) => S(x, C({ component: t }, n, { children: e }));
161
- return e;
162
- })(), G = {
163
- id: "html-plugin",
164
- canHandle: (e) => typeof e == "object" && e?.nodeType === D.HTML,
165
- transform: (e) => {
166
- let t = e[D.HTML], n = (e) => g(t, {
167
- ...W,
168
- ...e
169
- }), r = [n()];
170
- return new Proxy(r, { get(e, r, i) {
171
- return r === "value" ? t : r === "use" ? (e) => n(e) : Reflect.get(e, r, i);
172
- } });
173
- }
174
- }, K = (e, t = !0) => [
175
- b(e ?? w.internationalization.defaultLocale, t ? w.internationalization.defaultLocale : void 0),
176
- f,
177
- d,
178
- v(e ?? w.internationalization.defaultLocale),
179
- p,
180
- m,
181
- R,
182
- z,
183
- V,
184
- U,
185
- G
186
- ], q = (e, t) => h(e, t, K(t));
187
- //#endregion
188
- export { R as a, z as c, P as d, N as f, V as i, L as l, j as m, K as n, U as o, M as p, G as r, H as s, q as t, F as u };
@@ -1 +0,0 @@
1
- const e=require(`./chunk-C91j1N6u.js`),t=require(`./cjs/IntlayerNode.cjs`),n=require(`./cjs/editor/contexts/EditorEnabledContext.cjs`),r=require(`./cjs/editor/contexts/FocusDictionaryContext.cjs`),i=require(`./cjs/client/IntlayerProvider.cjs`),a=require(`./cjs/client/useLoadDynamic.cjs`),o=require(`./cjs/UI/ContentSelector.cjs`),s=require(`./cjs/editor/useEditedContentRenderer.cjs`),c=require(`./cjs/markdown/MarkdownRenderer.cjs`),l=require(`./cjs/solidElement/renderSolidElement.cjs`);let u=require(`@intlayer/core/interpreter`),d=require(`solid-js/web`),f=require(`@intlayer/config/built`);f=e.t(f);let p=require(`@intlayer/core/markdown`),m=require(`@intlayer/core/transpiler`),h=require(`@intlayer/types/nodeType`),g=require(`@intlayer/core/utils`),_=require(`solid-js`);var v=(e,t)=>{let n=(0,_.useContext)(i.IntlayerClientContext);return(0,_.createMemo)(()=>P(e,t??n?.locale?.()))},y=async(e,t)=>{let{locale:n}=(0,_.useContext)(i.IntlayerClientContext),r=f.default?.internationalization.defaultLocale,a=t??n()??r;return v(await e[a]?.(),a)},b=(e,t,n)=>{let{locale:r}=(0,_.useContext)(i.IntlayerClientContext)??{},o=f.default?.internationalization.defaultLocale,s=n??r?.()??o;return v(a.useLoadDynamic(`${String(t)}.${s}`,e[s]?.()),s)},x=(e,t)=>(0,u.getIntlayer)(e,t,N(t)),S=(e,t)=>{let n=(0,_.useContext)(i.IntlayerClientContext);return(0,_.createMemo)(()=>{let r=n?.locale();return x(e,t??r)})},C=e=>{let{focusedContent:t,setFocusedContent:n}=r.useFocusDictionary(),i=(0,_.createMemo)(()=>e.keyPath.filter(e=>e.type!==h.NodeType.Translation)),a=()=>n({dictionaryKey:e.dictionaryKey,keyPath:i()}),s=(0,_.createMemo)(()=>(t?.dictionaryKey===e.dictionaryKey&&(t?.keyPath?.length??0)>0&&(0,g.isSameKeyPath)(t?.keyPath??[],i()))??!1);return(0,d.createComponent)(o.ContentSelector,{onPress:a,get isSelecting(){return s()},get children(){return e.children}})},w=e=>{let{enabled:t}=n.useEditorEnabled(),{disableEditor:r}=i.useIntlayerContext();return t()&&!r?(0,d.createComponent)(C,(0,d.mergeProps)(e,{get children(){return e.children}})):e.children},T={id:`intlayer-node-plugin`,canHandle:e=>typeof e==`bigint`||typeof e==`string`||typeof e==`number`,transform:(e,{plugins:n,...r})=>t.renderIntlayerNode({...r,value:r.children,children:f.default?.editor.enabled?(0,d.createComponent)(w,(0,d.mergeProps)(r,{get children(){return(0,d.createComponent)(s.EditedContentRenderer,(0,d.mergeProps)(r,{get children(){return r.children}}))}})):r.children})},E={id:`solid-node-plugin`,canHandle:e=>typeof e==`object`&&e?.props!==void 0||typeof Node<`u`&&e instanceof Node,transform:(e,{plugins:n,...r})=>t.renderIntlayerNode({...r,value:`[[solid-element]]`,children:f.default?.editor.enabled?(0,d.createComponent)(w,(0,d.mergeProps)(r,{get children(){return typeof Node<`u`&&e instanceof Node?e:l.renderSolidElement(e)}})):typeof Node<`u`&&e instanceof Node?e:l.renderSolidElement(e)})},D=(e,t)=>{let n=(0,u.splitInsertionTemplate)(e,t);return n.isSimple,n.parts},O={id:`insertion-plugin`,canHandle:e=>typeof e==`object`&&e?.nodeType===h.NodeType.Insertion,transform:(e,t,n)=>{let r=[...t.keyPath,{type:h.NodeType.Insertion}],i=e[h.NodeType.Insertion];return e=>{let a={id:`insertion-string-plugin`,canHandle:e=>typeof e==`string`,transform:(n,r,i)=>{let a=D(i(n,{...r,children:n,plugins:[...(t.plugins??[]).filter(e=>e.id!==`intlayer-node-plugin`)]}),e);return i(a,{...r,plugins:t.plugins,children:a})}};return n(i,{...t,children:i,keyPath:r,plugins:[a,...t.plugins??[]]})}}},k={id:`markdown-string-plugin`,canHandle:e=>typeof e==`string`,transform:(e,n,r)=>{let{plugins:i,...a}=n,o=r((0,p.getMarkdownMetadata)(e),{plugins:[{id:`markdown-metadata-plugin`,canHandle:e=>typeof e==`string`||typeof e==`number`||typeof e==`boolean`||!e,transform:(n,r)=>t.renderIntlayerNode({...r,value:n,children:(0,d.createComponent)(w,(0,d.mergeProps)(a,{get children(){return(0,d.createComponent)(c.MarkdownMetadataRenderer,(0,d.mergeProps)(a,{get metadataKeyPath(){return r.keyPath},children:e}))}}))})}],dictionaryKey:a.dictionaryKey,keyPath:[]}),s=r=>t.renderIntlayerNode({...n,value:e,children:(0,d.createComponent)(w,(0,d.mergeProps)(a,{get children(){return(0,d.createComponent)(c.MarkdownRenderer,(0,d.mergeProps)(a,{components:r,children:e}))}})),additionalProps:{metadata:o}}),l=s();return new Proxy(l,{get(t,n,r){return n===`value`?e:n===`metadata`?o:n===`use`?e=>s(e):Reflect.get(t,n,r)}})}},A={id:`markdown-plugin`,canHandle:e=>typeof e==`object`&&e?.nodeType===h.NodeType.Markdown,transform:(e,t,n)=>{let r=[...t.keyPath,{type:h.NodeType.Markdown}],i=e[h.NodeType.Markdown];return n(i,{...t,children:i,keyPath:r,plugins:[k,...t.plugins??[]]})}},j=(()=>{let e={};for(let t of m.HTML_TAGS)e[t]=({children:e,...n})=>(0,d.createComponent)(d.Dynamic,(0,d.mergeProps)({component:t},n,{children:e}));return e})(),M={id:`html-plugin`,canHandle:e=>typeof e==`object`&&e?.nodeType===h.NodeType.HTML,transform:e=>{let t=e[h.NodeType.HTML],n=e=>(0,u.getHTML)(t,{...j,...e}),r=[n()];return new Proxy(r,{get(e,r,i){return r===`value`?t:r===`use`?e=>n(e):Reflect.get(e,r,i)}})}},N=(e,t=!0)=>[(0,u.translationPlugin)(e??f.default.internationalization.defaultLocale,t?f.default.internationalization.defaultLocale:void 0),u.enumerationPlugin,u.conditionPlugin,(0,u.nestedPlugin)(e??f.default.internationalization.defaultLocale),u.filePlugin,u.genderPlugin,T,E,O,A,M],P=(e,t)=>(0,u.getDictionary)(e,t,N(t));Object.defineProperty(exports,`a`,{enumerable:!0,get:function(){return T}}),Object.defineProperty(exports,`c`,{enumerable:!0,get:function(){return E}}),Object.defineProperty(exports,`d`,{enumerable:!0,get:function(){return x}}),Object.defineProperty(exports,`f`,{enumerable:!0,get:function(){return b}}),Object.defineProperty(exports,`i`,{enumerable:!0,get:function(){return O}}),Object.defineProperty(exports,`l`,{enumerable:!0,get:function(){return w}}),Object.defineProperty(exports,`m`,{enumerable:!0,get:function(){return v}}),Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return N}}),Object.defineProperty(exports,`o`,{enumerable:!0,get:function(){return A}}),Object.defineProperty(exports,`p`,{enumerable:!0,get:function(){return y}}),Object.defineProperty(exports,`r`,{enumerable:!0,get:function(){return M}}),Object.defineProperty(exports,`s`,{enumerable:!0,get:function(){return k}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return P}}),Object.defineProperty(exports,`u`,{enumerable:!0,get:function(){return S}});