@jahia/javascript-modules-library 0.3.0 → 0.4.0

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 (44) hide show
  1. package/bin/jahia-deploy.mjs +14 -0
  2. package/core/server/components/AddResources.js +1 -1
  3. package/core/server/components/render/internal/InBrowser.js +1 -1
  4. package/core/server/framework/register.js +1 -1
  5. package/core/server/hooks/useJCRQuery.js +1 -1
  6. package/core/server/hooks/useUrlBuilder.js +1 -1
  7. package/index.js +1 -1
  8. package/package.json +5 -1
  9. package/types/bin/jahia-deploy.d.mts +1 -0
  10. package/types/core/server/components/AbsoluteArea.d.ts +22 -16
  11. package/types/core/server/components/AddContentButtons.d.ts +13 -7
  12. package/types/core/server/components/AddResources.d.ts +18 -18
  13. package/types/core/server/components/Area.d.ts +21 -15
  14. package/types/core/server/components/render/HydrateInBrowser.d.ts +12 -8
  15. package/types/core/server/components/render/Render.d.ts +24 -16
  16. package/types/core/server/components/render/RenderInBrowser.d.ts +12 -8
  17. package/types/core/server/components/render/internal/InBrowser.d.ts +7 -7
  18. package/types/core/server/framework/defineJahiaComponent.d.ts +15 -36
  19. package/types/core/server/framework/register.d.ts +7 -3
  20. package/types/index.d.ts +19 -2
  21. package/core/index.js +0 -1
  22. package/core/server/components/index.js +0 -1
  23. package/core/server/components/render/index.js +0 -1
  24. package/core/server/framework/index.js +0 -1
  25. package/core/server/hooks/index.js +0 -1
  26. package/core/server/index.js +0 -1
  27. package/core/server/utils/index.js +0 -1
  28. package/core/server/utils/jcr/index.js +0 -1
  29. package/core/server/utils/urlBuilder/index.js +0 -1
  30. package/nav/index.js +0 -1
  31. package/nav/server/index.js +0 -1
  32. package/nav/server/navBuilder/index.js +0 -1
  33. package/types/core/index.d.ts +0 -1
  34. package/types/core/server/components/index.d.ts +0 -5
  35. package/types/core/server/components/render/index.d.ts +0 -3
  36. package/types/core/server/framework/index.d.ts +0 -2
  37. package/types/core/server/hooks/index.d.ts +0 -4
  38. package/types/core/server/index.d.ts +0 -4
  39. package/types/core/server/utils/index.d.ts +0 -2
  40. package/types/core/server/utils/jcr/index.d.ts +0 -4
  41. package/types/core/server/utils/urlBuilder/index.d.ts +0 -1
  42. package/types/nav/index.d.ts +0 -1
  43. package/types/nav/server/index.d.ts +0 -1
  44. package/types/nav/server/navBuilder/index.d.ts +0 -1
@@ -0,0 +1,14 @@
1
+ import dotenv from 'dotenv';
2
+ import { execSync } from 'child_process';
3
+ import path from 'path';
4
+ dotenv.config();
5
+ const deployMethod = process.env.JAHIA_DEPLOY_METHOD;
6
+ const packageFilePath = path.resolve('dist/package.tgz');
7
+ if (deployMethod === 'curl') {
8
+ console.log('Deploying URL curl to Jahia bundles REST API...');
9
+ console.log(execSync(`curl -s --user ${process.env.JAHIA_USER} --form bundle=@${packageFilePath} --form start=true ${process.env.JAHIA_HOST}/modules/api/bundles`, { encoding: 'utf8' }));
10
+ }
11
+ else {
12
+ console.log('Deploying using Docker copy...');
13
+ console.log(execSync(`docker cp ${packageFilePath} ${process.env.JAHIA_DOCKER_NAME}:/var/jahia/modules`, { encoding: 'utf8' }));
14
+ }
@@ -1 +1 @@
1
- import React from"react";import{useServerContext}from"../hooks";import{server}from"@jahia/javascript-modules-library-private";export function AddResources({...e}){const{renderContext:r}=useServerContext();return React.createElement("unwanteddiv",{dangerouslySetInnerHTML:{__html:server.render.addResources(e,r)}})}
1
+ import React from"react";import{server}from"@jahia/javascript-modules-library-private";import{useServerContext}from"../hooks/useServerContext";export function AddResources(e){const{renderContext:r}=useServerContext();return React.createElement("unwanteddiv",{dangerouslySetInnerHTML:{__html:server.render.addResources(e,r)}})}
@@ -1 +1 @@
1
- import React from"react";import{useServerContext}from"../../../hooks/useServerContext";import{AddResources}from"../../AddResources";import{buildUrl}from"../../../utils/urlBuilder";import{I18nextProvider}from"react-i18next";import i18n from"i18next";const getClientI18nStoreScript=(e,t)=>{const r=i18n.getResourceBundle(e,t);if(r){const n={};return n[e]={},n[e][t]=r,`<script type="text/javascript">\n if(!window.__APPSHELL_INIT_DATA__) {\n window.__APPSHELL_INIT_DATA__ = {};\n }\n if(!window.__APPSHELL_INIT_DATA__.initialI18nStore) {\n window.__APPSHELL_INIT_DATA__.initialI18nStore = [];\n }\n window.__APPSHELL_INIT_DATA__.initialI18nStore.push(${JSON.stringify(n)});\n <\/script>`}},getAppShellInitData=e=>`<script type="text/javascript">\n if(!window.__APPSHELL_INIT_DATA__) {\n window.__APPSHELL_INIT_DATA__ = {};\n }\n window.__APPSHELL_INIT_DATA__.moduleBaseUrl = '${e}';\n <\/script>`;function InBrowser({child:e,props:t,dataKey:r,preRender:n}){const{bundleKey:i,currentResource:o,renderContext:a}=useServerContext(),s=o.getLocale().getLanguage(),c=getAppShellInitData(buildUrl({value:"/modules"},a,o)),l=getClientI18nStoreScript(s,i),_=buildUrl({value:"/modules/"+i+"/javascript/client/remote.js"},a,o),d=buildUrl({value:"/modules/javascript-modules-engine/javascript/apps/reactAppShell.js"},a,o),p={};return p[r]=encodeURIComponent(JSON.stringify({name:e.name,lang:s,bundle:i,props:t||{}})),React.createElement(React.Fragment,null,React.createElement("div",{...p},n&&React.createElement(I18nextProvider,{i18n:i18n},React.createElement(e,{...t}))),l&&React.createElement(AddResources,{key:`i18n_initialStore_${i}`,insert:!0,inlineResource:l}),React.createElement(AddResources,{key:"npm-engine-appShellInitData",insert:!0,inlineResource:c}),React.createElement(AddResources,{insert:!0,type:"javascript",targetTag:"body",resources:_}),React.createElement(AddResources,{type:"javascript",targetTag:"body",resources:d}))}export default InBrowser;
1
+ import React from"react";import{useServerContext}from"../../../hooks/useServerContext";import{AddResources}from"../../AddResources";import{I18nextProvider}from"react-i18next";import i18n from"i18next";import{buildUrl}from"../../../utils/urlBuilder/urlBuilder";const getClientI18nStoreScript=(e,t)=>{const r=i18n.getResourceBundle(e,t);if(r){const n={[e]:{[t]:r}};return`<script type="text/javascript">\n if(!window.__APPSHELL_INIT_DATA__) {\n window.__APPSHELL_INIT_DATA__ = {};\n }\n if(!window.__APPSHELL_INIT_DATA__.initialI18nStore) {\n window.__APPSHELL_INIT_DATA__.initialI18nStore = [];\n }\n window.__APPSHELL_INIT_DATA__.initialI18nStore.push(${JSON.stringify(n)});\n <\/script>`}},getAppShellInitData=e=>`<script type="text/javascript">\n if(!window.__APPSHELL_INIT_DATA__) {\n window.__APPSHELL_INIT_DATA__ = {};\n }\n window.__APPSHELL_INIT_DATA__.moduleBaseUrl = ${JSON.stringify(e)};\n <\/script>`;function InBrowser({child:e,props:t,dataKey:r,preRender:n}){const{bundleKey:i,currentResource:o,renderContext:a}=useServerContext(),s=o.getLocale().getLanguage(),c=getAppShellInitData(buildUrl({value:"/modules"},a,o)),l=getClientI18nStoreScript(s,i),_=buildUrl({value:"/modules/"+i+"/javascript/client/remote.js"},a,o),d=buildUrl({value:"/modules/javascript-modules-engine/javascript/apps/reactAppShell.js"},a,o),u={[r]:encodeURIComponent(JSON.stringify({name:e.name,lang:s,bundle:i,props:t||{}}))};return React.createElement(React.Fragment,null,React.createElement("div",{...u},n&&React.createElement(I18nextProvider,{i18n:i18n},React.createElement(e,{...t}))),l&&React.createElement(AddResources,{key:`i18n_initialStore_${i}`,insert:!0,inlineResource:l}),React.createElement(AddResources,{key:"npm-engine-appShellInitData",insert:!0,inlineResource:c}),React.createElement(AddResources,{insert:!0,type:"javascript",targetTag:"body",resources:_}),React.createElement(AddResources,{type:"javascript",targetTag:"body",resources:d}))}export default InBrowser;
@@ -1 +1 @@
1
- import{server}from"@jahia/javascript-modules-library-private";export function registerJahiaComponents(e){if(!bundle)return void console.error("registerJahiaComponents: bundle is not available, make sure you are using this function inside the initialization of the bundle");const n=bundle.getSymbolicName(),o=server.registry.get("view","react");Object.keys(e).forEach((t=>{let i;const r=e[t].jahiaComponent;if(!r||!r.nodeType||!r.componentType)return void console.warn(`registerJahiaComponents(bundle=${n}: Missing mandatory property nodeType and/or componentType, skipping component name=${r.name} nodeType=${r.nodeType} id=${r.id} registration`);i={name:"default",templateType:"html",component:null};let a=r.id;delete r.id,i.component=e[t];const p={...i,...r};a||(a=`${n}_${p.componentType}_${p.nodeType}_${p.name}`),server.registry.add("view",a,o,p)}))}
1
+ import{server}from"@jahia/javascript-modules-library-private";export function registerJahiaComponents(e){if(!bundle)return void console.error("registerJahiaComponents: bundle is not available, make sure you are using this function inside the initialization of the bundle");const n=bundle.getSymbolicName(),o=server.registry.get("view","react");for(const t of Object.values(e)){const{id:e,...i}=t.jahiaComponent;if(!i.nodeType||!i.componentType)return void console.warn(`registerJahiaComponents(bundle=${n}: Missing mandatory property nodeType and/or componentType, skipping component name=${i.name} nodeType=${i.nodeType} id=${e} registration`);const r={name:"default",templateType:"html",component:t,...i};server.registry.add("view",e??`${n}_${r.componentType}_${r.nodeType}_${r.name}`,o,r)}}
@@ -1 +1 @@
1
- import{useServerContext}from"./useServerContext";import{getNodesByJCRQuery}from"../utils/jcr";export const useJCRQuery=({query:e})=>{const{renderContext:r}=useServerContext();return getNodesByJCRQuery(r.getMainResource().getNode().getSession(),e,-1,0)};
1
+ import{useServerContext}from"./useServerContext";import{getNodesByJCRQuery}from"../utils/jcr/getNodesByJCRQuery";export const useJCRQuery=({query:e})=>{const{renderContext:r}=useServerContext();return getNodesByJCRQuery(r.getMainResource().getNode().getSession(),e,-1,0)};
@@ -1 +1 @@
1
- import{useServerContext}from"./useServerContext";import{buildUrl as originalBuildUrl}from"../utils/urlBuilder";export function useUrlBuilder(){const{renderContext:e,currentResource:r}=useServerContext(),t=({nodePath:t,extension:a,language:l,mode:n,parameters:o})=>originalBuildUrl({path:t,extension:a,language:l,mode:n,parameters:o},e,r);return{buildStaticUrl:({assetPath:t,moduleName:a=e?.getURLGenerator()?.getCurrentModule(),parameters:l})=>{let n=a+"/static"+(t?.startsWith("/")?"":"/")+t;return originalBuildUrl({value:n,parameters:l},e,r)},buildNodeUrl:t,buildHtmlFragmentUrl:({nodePath:e,language:r,mode:a,parameters:l})=>t({nodePath:e,extension:".html.ajax",language:r,mode:a,parameters:l})}}
1
+ import{useServerContext}from"./useServerContext";import{buildUrl as originalBuildUrl}from"../utils/urlBuilder/urlBuilder";export function useUrlBuilder(){const{renderContext:e,currentResource:r}=useServerContext(),t=({nodePath:t,extension:a,language:l,mode:n,parameters:u})=>originalBuildUrl({path:t,extension:a,language:l,mode:n,parameters:u},e,r);return{buildStaticUrl:({assetPath:t,moduleName:a=e?.getURLGenerator()?.getCurrentModule(),parameters:l})=>{let n=a+"/static"+(t?.startsWith("/")?"":"/")+t;return originalBuildUrl({value:n,parameters:l},e,r)},buildNodeUrl:t,buildHtmlFragmentUrl:({nodePath:e,language:r,mode:a,parameters:l})=>t({nodePath:e,extension:".html.ajax",language:r,mode:a,parameters:l})}}
package/index.js CHANGED
@@ -1 +1 @@
1
- export*from"./core";export*from"./nav";
1
+ export{RenderInBrowser}from"./core/server/components/render/RenderInBrowser";export{HydrateInBrowser}from"./core/server/components/render/HydrateInBrowser";export{Render}from"./core/server/components/render/Render";export{AbsoluteArea}from"./core/server/components/AbsoluteArea";export{AddContentButtons}from"./core/server/components/AddContentButtons";export{AddResources}from"./core/server/components/AddResources";export{Area}from"./core/server/components/Area";export{defineJahiaComponent}from"./core/server/framework/defineJahiaComponent";export{registerJahiaComponents}from"./core/server/framework/register";export{useGQLQuery}from"./core/server/hooks/useGQLQuery";export{useJCRQuery}from"./core/server/hooks/useJCRQuery";export{useServerContext,ServerContextProvider}from"./core/server/hooks/useServerContext";export{useUrlBuilder}from"./core/server/hooks/useUrlBuilder";export{getChildNodes}from"./core/server/utils/jcr/getChildNodes";export{getNodeFromPathOrId}from"./core/server/utils/jcr/getNodeFromPathOrId";export{getNodeProps}from"./core/server/utils/jcr/getNodeProps";export{getNodesByJCRQuery}from"./core/server/utils/jcr/getNodesByJCRQuery";export{buildUrl,initUrlBuilder}from"./core/server/utils/urlBuilder/urlBuilder";export{buildNavMenu}from"./nav/server/navBuilder/navBuilder";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jahia/javascript-modules-library",
3
- "version": "0.3.0",
3
+ "version": "0.4.0",
4
4
  "main": "index.js",
5
5
  "types": "types/index.d.ts",
6
6
  "repository": "git@github.com:Jahia/javascript-modules.git",
@@ -17,10 +17,14 @@
17
17
  "lint:fix": "eslint --ext js,jsx,json,ts --fix src/",
18
18
  "prepack": "echo 'Please run 'mvn package' to create the tgz so the Maven version can be injected in the package.json' && exit 1"
19
19
  },
20
+ "bin": {
21
+ "jahia-deploy": "bin/jahia-deploy.mjs"
22
+ },
20
23
  "files": [
21
24
  "dist"
22
25
  ],
23
26
  "dependencies": {
27
+ "dotenv": "^16.4.7",
24
28
  "graphql": "^16.0.1",
25
29
  "graphql-tag": "^2.12.6",
26
30
  "prop-types": "^15.8.1"
@@ -0,0 +1 @@
1
+ export {};
@@ -1,29 +1,35 @@
1
+ import React from 'react';
1
2
  /**
2
3
  * Generates an absolute area in which editors may insert content objects.
3
- * @param {object} props The React properties for the component.
4
- * @param {string} [props.name] The name of the area.
5
- * @param {string} [props.areaView] The view to use for the area.
6
- * @param {string[]} [props.allowedTypes] The allowed types for the area.
7
- * @param {number} [props.numberOfItems] The number of items to display in the area.
8
- * @param {string} [props.subNodesView] The view to use for the subnodes.
9
- * @param {string} [props.path] Relative (to the current node) or absolute path to the node to include
10
- * @param {boolean} [props.editable] Enables or disables edition of this content in edit mode. Mainly used for absolute or references.
11
- * @param {number} [props.level] Ancestor level for absolute area - 0 is Home page, 1 first sub-pages, ...
12
- * @param {string} [props.areaType] Content type to be used to create the area (by default jnt:contentList)
13
- * @param {boolean} [props.limitedAbsoluteAreaEdit] Is the absolute area editable everywhere or only on the page containing its node.
14
- * @param {object} [props.parameters] the parameters to pass to the absolute area
15
- * @returns {JSX.Element} The AbsoluteArea component
4
+ * @returns The AbsoluteArea component
16
5
  */
17
- export function AbsoluteArea({ name, areaView, allowedTypes, numberOfItems, subNodesView, path, editable, level, areaType, limitedAbsoluteAreaEdit, parameters }: {
6
+ export declare function AbsoluteArea({ name, areaView, allowedTypes, numberOfItems, subNodesView, path, editable, level, areaType, limitedAbsoluteAreaEdit, parameters }: Readonly<{
7
+ /** The name of the area. */
18
8
  name?: string;
9
+ /** The view to use for the area. */
19
10
  areaView?: string;
11
+ /** The allowed types for the area. */
20
12
  allowedTypes?: string[];
13
+ /** The number of items to display in the area. */
21
14
  numberOfItems?: number;
15
+ /** The view to use for the subnodes. */
22
16
  subNodesView?: string;
17
+ /** Relative (to the current node) or absolute path to the node to include. */
23
18
  path?: string;
19
+ /**
20
+ * Enables or disables edition of this content in edit mode. Mainly used for absolute or references.
21
+ * @default true
22
+ */
24
23
  editable?: boolean;
24
+ /** Ancestor level for absolute area - 0 is Home page, 1 first sub-pages, ... */
25
25
  level?: number;
26
+ /**
27
+ * Content type to be used to create the area
28
+ * @default jnt:contentList
29
+ */
26
30
  areaType?: string;
31
+ /** Is the absolute area editable everywhere or only on the page containing its node. */
27
32
  limitedAbsoluteAreaEdit?: boolean;
28
- parameters?: object;
29
- }): JSX.Element;
33
+ /** The parameters to pass to the absolute area */
34
+ parameters?: Record<string, unknown>;
35
+ }>): React.JSX.Element;
@@ -1,13 +1,19 @@
1
+ import React from 'react';
1
2
  /**
2
3
  * Generates add content buttons for a content object
3
- * @param {object} properties The React properties for the component.
4
- * @param {string} [properties.nodeTypes] The node types to add.
5
- * @param {string} [properties.childName='*'] The child name.
6
- * @param {boolean} [properties.editCheck=false] If true, the edit check will be performed.
7
- * @returns {JSX.Element} The add content buttons.
4
+ * @returns The add content buttons.
8
5
  */
9
- export function AddContentButtons({ nodeTypes, childName, editCheck }: {
6
+ export declare function AddContentButtons({ nodeTypes, childName, editCheck }: Readonly<{
7
+ /** The node types to add. */
10
8
  nodeTypes?: string;
9
+ /**
10
+ * The child name.
11
+ * @default *
12
+ */
11
13
  childName?: string;
14
+ /**
15
+ * If true, the edit check will be performed.
16
+ * @default false
17
+ */
12
18
  editCheck?: boolean;
13
- }): JSX.Element;
19
+ }>): React.JSX.Element;
@@ -1,31 +1,31 @@
1
+ import React from 'react';
1
2
  /**
2
3
  * Adds a resources to the head tag of the HTML page.
3
- * @param {object} props - The properties for the component.
4
- * @param {boolean} [props.insert] - If true, the resource will be inserted into the document. Typically used for on-demand loading of resources.
5
- * @param {boolean} [props.async] - If true, the resource will be loaded asynchronously. For scripts, this means the script will be executed as soon as it's available, without blocking the rest of the page.
6
- * @param {boolean} [props.defer] - If true, the resource will be deferred, i.e., loaded after the document has been parsed. For scripts, this means the script will not be executed until after the page has loaded.
7
- * @param {string} [props.type] - The type of the resource. This could be 'javascript' for .js files, 'css' for .css files, etc.
8
- * @param {string} [props.resources] - The path to the resource file, relative to the module.
9
- * @param {string} [props.inlineResource] - Inline HTML that markup will be considered as resource.
10
- * @param {string} [props.title] - The title of the resource. This is typically not used for scripts or stylesheets, but may be used for other types of resources.
11
- * @param {string} [props.key] - A unique key for the resource. This could be used to prevent duplicate resources from being added to the document.
12
- * @param {string} [props.targetTag] - The HTML tag where the resource should be added. This could be 'head' for resources that should be added to the <head> tag, 'body' for resources that should be added to the <body> tag, etc.
13
- * @param {string} [props.rel] - The relationship of the resource to the document. This is typically 'stylesheet' for CSS files.
14
- * @param {string} [props.media] - The media for which the resource is intended. This is typically used for CSS files, with values like 'screen', 'print', etc.
15
- * @param {string} [props.condition] - A condition that must be met for the resource to be loaded. This could be used for conditional comments in IE, for example.
16
- * @returns {JSX.Element} A React element that renders a script or link tag.
4
+ * @returns A React element that renders a script or link tag.
17
5
  */
18
- export function AddResources({ ...props }: {
6
+ export declare function AddResources(props: Readonly<{
7
+ /** If true, the resource will be inserted into the document. Typically used for on-demand loading of resources. */
19
8
  insert?: boolean;
9
+ /** If true, the resource will be loaded asynchronously. For scripts, this means the script will be executed as soon as it's available, without blocking the rest of the page. */
20
10
  async?: boolean;
11
+ /** If true, the resource will be deferred, i.e., loaded after the document has been parsed. For scripts, this means the script will not be executed until after the page has loaded. */
21
12
  defer?: boolean;
22
- type?: string;
13
+ /** The type of the resource. This could be 'javascript' for .js files, 'css' for .css files, etc. */
14
+ type?: 'javascript' | 'css';
15
+ /** The path to the resource file, relative to the module. */
23
16
  resources?: string;
17
+ /** Inline HTML that markup will be considered as resource. */
24
18
  inlineResource?: string;
19
+ /** The title of the resource. This is typically not used for scripts or stylesheets, but may be used for other types of resources. */
25
20
  title?: string;
21
+ /** A unique key for the resource. This could be used to prevent duplicate resources from being added to the document. */
26
22
  key?: string;
27
- targetTag?: string;
23
+ /** The HTML tag where the resource should be added. This could be 'head' for resources that should be added to the <head> tag, 'body' for resources that should be added to the <body> tag, etc. */
24
+ targetTag?: 'head' | 'body';
25
+ /** The relationship of the resource to the document. This is typically 'stylesheet' for CSS files. */
28
26
  rel?: string;
27
+ /** The media for which the resource is intended. This is typically used for CSS files, with values like 'screen', 'print', etc. */
29
28
  media?: string;
29
+ /** A condition that must be met for the resource to be loaded. This could be used for conditional comments in IE, for example. */
30
30
  condition?: string;
31
- }): JSX.Element;
31
+ }>): React.JSX.Element;
@@ -1,27 +1,33 @@
1
+ import React from 'react';
1
2
  /**
2
3
  * Generates an area in which editors may insert content objects.
3
- * @param {object} props The React properties for the component.
4
- * @param {string} [props.name] The name of the area.
5
- * @param {string} [props.areaView] The view to use for the area.
6
- * @param {string[]} [props.allowedTypes] The allowed types for the area.
7
- * @param {number} [props.numberOfItems] The number of items to display in the area.
8
- * @param {string} [props.subNodesView] The view to use for the subnodes.
9
- * @param {string} [props.path] Relative (to the current node) or absolute path to the node to include
10
- * @param {boolean} [props.editable] Enables or disables edition of this content in edit mode. Mainly used for absolute or references.
11
- * @param {boolean} [props.areaAsSubNode] Allows area to be stored as a subnode
12
- * @param {string} [props.areaType] Content type to be used to create the area (by default jnt:contentList)
13
- * @param {object} [props.parameters] the parameters to pass to the area
14
- * @returns {JSX.Element} The Area component
4
+ * @returns The Area component
15
5
  */
16
- export function Area({ name, areaView, allowedTypes, numberOfItems, subNodesView, path, editable, areaAsSubNode, areaType, parameters }: {
6
+ export declare function Area({ name, areaView, allowedTypes, numberOfItems, subNodesView, path, editable, areaAsSubNode, areaType, parameters }: Readonly<{
7
+ /** The name of the area. */
17
8
  name?: string;
9
+ /** The view to use for the area. */
18
10
  areaView?: string;
11
+ /** The allowed types for the area. */
19
12
  allowedTypes?: string[];
13
+ /** The number of items to display in the area. */
20
14
  numberOfItems?: number;
15
+ /** The view to use for the subnodes. */
21
16
  subNodesView?: string;
17
+ /** Relative (to the current node) or absolute path to the node to include. */
22
18
  path?: string;
19
+ /**
20
+ * Enables or disables edition of this content in edit mode. Mainly used for absolute or references.
21
+ * @default true
22
+ */
23
23
  editable?: boolean;
24
+ /** Allow area to be stored as a subnode */
24
25
  areaAsSubNode?: boolean;
26
+ /**
27
+ * Content type to be used to create the area
28
+ * @default jnt:contentList
29
+ */
25
30
  areaType?: string;
26
- parameters?: object;
27
- }): JSX.Element;
31
+ /** The parameters to pass to the area */
32
+ parameters?: Record<string, unknown>;
33
+ }>): React.JSX.Element;
@@ -1,13 +1,17 @@
1
+ import React from 'react';
1
2
  /**
2
3
  * Will render the given React component server side and hydrate it in the browser to make it dynamic.
3
4
  * Be careful, the component will not have access to the '@jahia/javascript-modules-library' library from the browser.
4
5
  *
5
- * @param {object} params The React component.
6
- * @param {object} params.child The React component.
7
- * @param {object} [params.props] The React component props, this props will be serialized/deserialized to be usable server and client side. The serialization and deserialization is done using JSON.stringify server side and JSON.parse in the browser. Please make sure that the props are serializable.
8
- * @returns {JSX.Element} The component to be hydrated in the browser
6
+ * @returns The component to be hydrated in the browser
9
7
  */
10
- export function HydrateInBrowser({ child: Child, props }: {
11
- child: object;
12
- props?: object;
13
- }): JSX.Element;
8
+ export declare function HydrateInBrowser<T>(props: Readonly<{
9
+ /** The React component. */
10
+ child: React.ComponentType<T>;
11
+ /** The React component props, these props will be serialized/deserialized to be usable server and client side. The serialization and deserialization is done using JSON.stringify server side and JSON.parse in the browser. Please make sure that the props are serializable. */
12
+ props: T & React.JSX.IntrinsicAttributes;
13
+ }>): React.JSX.Element;
14
+ export declare function HydrateInBrowser(props: Readonly<{
15
+ /** The React component. */
16
+ child: React.ComponentType;
17
+ }>): React.JSX.Element;
@@ -1,23 +1,31 @@
1
+ import React from 'react';
2
+ import type { JCRNodeWrapper } from 'org.jahia.services.content';
1
3
  /**
2
4
  * Render a content node
3
- * @param {object} props the properties for the render
4
- * @param {object} [props.content] the content node to render
5
- * @param {object} [props.node] the node to render
6
- * @param {string} [props.path] the path to render
7
- * @param {boolean} [props.editable] if the content should be editable
8
- * @param {string} [props.advanceRenderingConfig] specifies if we should render a node or simply include a view. Acceptable values are : none, INCLUDE or OPTION
9
- * @param {string} [props.templateType] the template type to use (html, json, ...)
10
- * @param {string} [props.view] the name of the view variant to use
11
- * @param {object} [props.parameters] the parameters to pass to the view
12
- * @returns {JSX.Element} the rendered output of the view for the specified content
5
+ *
6
+ * @returns the rendered output of the view for the specified content
13
7
  */
14
- export function Render({ content, node, path, editable, advanceRenderingConfig, templateType, view, parameters }: {
15
- content?: object;
16
- node?: object;
8
+ export declare function Render({ content, node, path, editable, advanceRenderingConfig, templateType, view, parameters }: Readonly<{
9
+ /** The content node to render */
10
+ content?: unknown;
11
+ /** The node to render */
12
+ node?: JCRNodeWrapper;
13
+ /** The path to render */
17
14
  path?: string;
15
+ /**
16
+ * If the content should be editable
17
+ * @default true
18
+ */
18
19
  editable?: boolean;
19
- advanceRenderingConfig?: string;
20
+ /**
21
+ * Specifies if we should render a node or simply include a view.
22
+ * Acceptable values are : none, INCLUDE or OPTION
23
+ */
24
+ advanceRenderingConfig?: 'INCLUDE' | 'OPTION';
25
+ /** The template type to use (html, json, ...) */
20
26
  templateType?: string;
27
+ /** The name of the view variant to use */
21
28
  view?: string;
22
- parameters?: object;
23
- }): JSX.Element;
29
+ /** The parameters to pass to the view */
30
+ parameters?: unknown;
31
+ }>): React.JSX.Element;
@@ -1,13 +1,17 @@
1
+ import React from 'react';
1
2
  /**
2
3
  * Will render the given React component in the browser.
3
4
  * Be careful, the component will not have access to the '@jahia/javascript-modules-library' library from the browser.
4
5
  *
5
- * @param {object} params The React component.
6
- * @param {object} params.child The React component.
7
- * @param {object} [params.props] The React component props, this props will be serialized/deserialized to be usable server and client side. The serialization and deserialization is done using JSON.stringify server side and JSON.parse in the browser. Please make sure that the props are serializable.
8
- * @returns {JSX.Element} The component to be rendered in the browser
6
+ * @returns The component to be rendered in the browser
9
7
  * */
10
- export function RenderInBrowser({ child: Child, props }: {
11
- child: object;
12
- props?: object;
13
- }): JSX.Element;
8
+ export declare function RenderInBrowser<T>(props: Readonly<{
9
+ /** The React component */
10
+ child: React.ComponentType<T>;
11
+ /** The React component props, this props will be serialized/deserialized to be usable server and client side. The serialization and deserialization is done using JSON.stringify server side and JSON.parse in the browser. Please make sure that the props are serializable. */
12
+ props: T & React.JSX.IntrinsicAttributes;
13
+ }>): React.JSX.Element;
14
+ export declare function RenderInBrowser(props: Readonly<{
15
+ /** The React component */
16
+ child: React.ComponentType;
17
+ }>): React.JSX.Element;
@@ -1,8 +1,8 @@
1
+ import React from 'react';
2
+ declare function InBrowser<T>({ child: Child, props, dataKey, preRender }: Readonly<{
3
+ child: React.ComponentType<T>;
4
+ props: T & React.JSX.IntrinsicAttributes;
5
+ dataKey: string;
6
+ preRender?: boolean;
7
+ }>): React.JSX.Element;
1
8
  export default InBrowser;
2
- declare function InBrowser({ child: Child, props, dataKey, preRender }: {
3
- child: any;
4
- props: any;
5
- dataKey: any;
6
- preRender: any;
7
- }): React.JSX.Element;
8
- import React from "react";
@@ -1,41 +1,20 @@
1
- /**
2
- * @typedef {Object} JahiaComponent
3
- * @property {string} [id] - The ID of the component (autogenerated but can be overridden)
4
- * @property {string} name - The name of the component.
5
- * @property {string} [displayName] - The display name of the component (in jahia's UI), optional.
6
- * @property {"template"|"view"} componentType - The type of the component.
7
- * @property {string} nodeType - The content node type the component applies to.
8
- * @property {Record<string, string>} [properties] - Properties to add on the component, optional.
9
- */
10
- /**
11
- * Using this function provides autocomplete on the jahiaComponent properties.
12
- * @param {JahiaComponent} jahiaComponent - An object containing the Jahia component to define.
13
- * @returns {JahiaComponent} The jahiaComponent object.
14
- */
15
- export function defineJahiaComponent(jahiaComponent: JahiaComponent): JahiaComponent;
16
- export type JahiaComponent = {
17
- /**
18
- * - The ID of the component (autogenerated but can be overridden)
19
- */
1
+ export interface JahiaComponent {
2
+ /** The ID of the component (autogenerated but can be overridden) */
20
3
  id?: string;
21
- /**
22
- * - The name of the component.
23
- */
4
+ /** The name of the component. */
24
5
  name: string;
25
- /**
26
- * - The display name of the component (in jahia's UI), optional.
27
- */
6
+ /** The display name of the component (in jahia's UI), optional. */
28
7
  displayName?: string;
29
- /**
30
- * - The type of the component.
31
- */
32
- componentType: "template" | "view";
33
- /**
34
- * - The content node type the component applies to.
35
- */
8
+ /** The type of the component. */
9
+ componentType: 'template' | 'view';
10
+ /** The content node type the component applies to. */
36
11
  nodeType: string;
37
- /**
38
- * - Properties to add on the component, optional.
39
- */
12
+ /** Properties to add on the component, optional. */
40
13
  properties?: Record<string, string>;
41
- };
14
+ }
15
+ /**
16
+ * Using this function provides autocomplete on the jahiaComponent properties.
17
+ * @param jahiaComponent - An object containing the Jahia component to define.
18
+ * @returns The jahiaComponent object.
19
+ */
20
+ export declare function defineJahiaComponent(jahiaComponent: JahiaComponent): JahiaComponent;
@@ -1,7 +1,11 @@
1
+ /// <reference types="react" />
2
+ import type { JahiaComponent } from './defineJahiaComponent';
1
3
  /**
2
4
  * Registers Jahia components into the global registry as views
3
- * @param {object} jahiaComponents an object containing the jahia components to register
4
- * @returns {void}
5
+ * @param jahiaComponents an object containing the jahia components to register
5
6
  * TODO We will probably want to revisit this function once we handle global component registration in ticket https://jira.jahia.org/browse/BACKLOG-22400
6
7
  */
7
- export function registerJahiaComponents(jahiaComponents: object): void;
8
+ export declare function registerJahiaComponents(jahiaComponents: Record<string | number | symbol, {
9
+ (): React.JSX.Element;
10
+ jahiaComponent: JahiaComponent;
11
+ }>): void;
package/types/index.d.ts CHANGED
@@ -1,5 +1,22 @@
1
- export * from "./core";
2
- export * from "./nav";
1
+ export { RenderInBrowser } from "./core/server/components/render/RenderInBrowser";
2
+ export { HydrateInBrowser } from "./core/server/components/render/HydrateInBrowser";
3
+ export { Render } from "./core/server/components/render/Render";
4
+ export { AbsoluteArea } from "./core/server/components/AbsoluteArea";
5
+ export { AddContentButtons } from "./core/server/components/AddContentButtons";
6
+ export { AddResources } from "./core/server/components/AddResources";
7
+ export { Area } from "./core/server/components/Area";
8
+ export { defineJahiaComponent } from "./core/server/framework/defineJahiaComponent";
9
+ export { registerJahiaComponents } from "./core/server/framework/register";
10
+ export { useGQLQuery } from "./core/server/hooks/useGQLQuery";
11
+ export { useJCRQuery } from "./core/server/hooks/useJCRQuery";
12
+ export { useUrlBuilder } from "./core/server/hooks/useUrlBuilder";
13
+ export { getChildNodes } from "./core/server/utils/jcr/getChildNodes";
14
+ export { getNodeFromPathOrId } from "./core/server/utils/jcr/getNodeFromPathOrId";
15
+ export { getNodeProps } from "./core/server/utils/jcr/getNodeProps";
16
+ export { getNodesByJCRQuery } from "./core/server/utils/jcr/getNodesByJCRQuery";
17
+ export { buildNavMenu } from "./nav/server/navBuilder/navBuilder";
18
+ export { useServerContext, ServerContextProvider } from "./core/server/hooks/useServerContext";
19
+ export { buildUrl, initUrlBuilder } from "./core/server/utils/urlBuilder/urlBuilder";
3
20
  export * from './globals';
4
21
  export * from './java.io';
5
22
  export * from './java.net';
package/core/index.js DELETED
@@ -1 +0,0 @@
1
- export*from"./server";
@@ -1 +0,0 @@
1
- export*from"./AddContentButtons";export*from"./AddResources";export*from"./Area";export*from"./AbsoluteArea";export*from"./render";
@@ -1 +0,0 @@
1
- export*from"./Render";export*from"./HydrateInBrowser";export*from"./RenderInBrowser";
@@ -1 +0,0 @@
1
- export*from"./register";export*from"./defineJahiaComponent";
@@ -1 +0,0 @@
1
- export*from"./useGQLQuery";export*from"./useJCRQuery";export*from"./useServerContext";export*from"./useUrlBuilder";
@@ -1 +0,0 @@
1
- export*from"./components";export*from"./framework";export*from"./hooks";export*from"./utils";
@@ -1 +0,0 @@
1
- export*from"./jcr";export*from"./urlBuilder";
@@ -1 +0,0 @@
1
- export*from"./getChildNodes";export*from"./getNodeFromPathOrId";export*from"./getNodeProps";export*from"./getNodesByJCRQuery";
@@ -1 +0,0 @@
1
- export*from"./urlBuilder";
package/nav/index.js DELETED
@@ -1 +0,0 @@
1
- export*from"./server";
@@ -1 +0,0 @@
1
- export*from"./navBuilder";
@@ -1 +0,0 @@
1
- export*from"./navBuilder";
@@ -1 +0,0 @@
1
- export * from "./server";
@@ -1,5 +0,0 @@
1
- export * from "./AddContentButtons";
2
- export * from "./AddResources";
3
- export * from "./Area";
4
- export * from "./AbsoluteArea";
5
- export * from "./render";
@@ -1,3 +0,0 @@
1
- export * from "./Render";
2
- export * from "./HydrateInBrowser";
3
- export * from "./RenderInBrowser";
@@ -1,2 +0,0 @@
1
- export * from "./register";
2
- export * from "./defineJahiaComponent";
@@ -1,4 +0,0 @@
1
- export * from "./useGQLQuery";
2
- export * from "./useJCRQuery";
3
- export * from "./useServerContext";
4
- export * from "./useUrlBuilder";
@@ -1,4 +0,0 @@
1
- export * from "./components";
2
- export * from "./framework";
3
- export * from "./hooks";
4
- export * from "./utils";
@@ -1,2 +0,0 @@
1
- export * from "./jcr";
2
- export * from "./urlBuilder";
@@ -1,4 +0,0 @@
1
- export * from "./getChildNodes";
2
- export * from "./getNodeFromPathOrId";
3
- export * from "./getNodeProps";
4
- export * from "./getNodesByJCRQuery";
@@ -1 +0,0 @@
1
- export * from "./urlBuilder";
@@ -1 +0,0 @@
1
- export * from "./server";
@@ -1 +0,0 @@
1
- export * from "./navBuilder";
@@ -1 +0,0 @@
1
- export * from "./navBuilder";