@unisphere/nx 1.1.2 → 1.1.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.
package/README.md CHANGED
@@ -2,13 +2,16 @@
2
2
 
3
3
  > This is a temporary documentation to the @unisphere/nx plugin until the official documentation is available.
4
4
 
5
+ > ⚠️ **This generator is currently available only to Kaltura developers.**
6
+ > It depends on internal resources such as CI/CD templates, design systems, and private NPM packages. External support for Kaltura customers is on our roadmap.
7
+
5
8
  Unisphere is Kaltura’s frontend framework for building dynamic, composable experiences. A **Unisphere project** is a structured repository that allows developers to create and organize **applications**, **runtimes**, and **packages** under a single cohesive experience. This setup encourages healthy module separation, runtime decoupling, reusability, and clean ownership boundaries — all key ingredients for scaling product development in a multi-team environment.
6
9
 
7
10
  Whether you're building a full application like _Content Lab_ or a lightweight widget like _Chat_, Unisphere gives you the tooling and conventions to do it the right way from the start.
8
11
 
9
- ---
12
+ ## Step 1 - Create a New Unisphere Project
10
13
 
11
- ## Create a New Unisphere Project
14
+ Before creating a new Unisphere project, make sure you have a valid `GITHUB_TOKEN` exported in your environment. This is required for GitHub operations during setup.
12
15
 
13
16
  To scaffold a new project you can use [create-unisphere-project](https://www.npmjs.com/package/create-unisphere-project) npm package with all necessary tooling and structure, run:
14
17
 
@@ -16,13 +19,6 @@ To scaffold a new project you can use [create-unisphere-project](https://www.npm
16
19
  npm create unisphere-project@latest
17
20
  ```
18
21
 
19
- > ⚠️ **This generator is currently available only to Kaltura developers.**
20
- > It depends on internal resources such as CI/CD templates, design systems, and private NPM packages. External support for Kaltura customers is on our roadmap.
21
-
22
- **Before running the command**, make sure you have a valid `GITHUB_TOKEN` exported in your environment. This is required for GitHub operations during setup.
23
-
24
- ---
25
-
26
22
  ### Set Up the GitHub Repository
27
23
 
28
24
  Once the project is generated locally, you’ll need to create a new GitHub repository so that CI/CD can operate correctly and your team has proper access.
@@ -36,7 +32,7 @@ Please contact **Eran Sakal** or **Omri Ceisler** to provision the repository. T
36
32
  unisphere-{friendly-experience-name}
37
33
  ```
38
34
 
39
- > The friendly name is derived from your declared experience name (e.g., `unisphere.widget.reactions` → `reactions` → `unisphere-reactions` as the repository name).
35
+ The friendly name is derived from your declared experience name (e.g., `unisphere.widget.reactions` → `reactions` → `unisphere-reactions` as the repository name).
40
36
 
41
37
  2. **Team Access Configuration**
42
38
  The appropriate GitHub teams will be granted access to the repository to match the experience's ownership and collaboration needs.
@@ -48,7 +44,7 @@ Once created, you can push your local project into the new repository and begin
48
44
 
49
45
  ---
50
46
 
51
- ## Use the `@unisphere/nx` Plugin
47
+ ## Step 2 - Use the `@unisphere/nx` Plugin
52
48
 
53
49
  After your project is set up, you’ll use the `@unisphere/nx` plugin to generate and manage your project’s core elements. All generators are interactive and designed to enforce Unisphere best practices and conventions.
54
50
 
@@ -91,8 +87,6 @@ npx nx g @unisphere/nx:add-runtime
91
87
 
92
88
  - Assume it is developed using a playground expo application of another runtime in the project
93
89
 
94
- ---
95
-
96
90
  ### 🎨 `add-visual`
97
91
 
98
92
  Creates a **visual component** within a runtime — the building blocks of your UI.
@@ -108,8 +102,6 @@ npx nx g @unisphere/nx:add-visual
108
102
  - **Is this visual limited to a single occurrence?**
109
103
  Choose `Yes` for singleton visuals (e.g., when the visual represent a container that can only have one instance), otherwise `No`.
110
104
 
111
- ---
112
-
113
105
  ### 📱 `add-application`
114
106
 
115
107
  Creates an **application** that acts as a host for your runtime(s). These apps can be used for development, standalone deployments, or iframe integrations. The application can be used as a playground for developing and simulating a host environment without the need to deploy the experience to a customer, or it can be an additional entry point for the experience and use the Unisphere ci/cd to be publically available in multi region environments.
@@ -133,8 +125,6 @@ npx nx g @unisphere/nx:add-application
133
125
 
134
126
  - **HTML page title** (if not using Playground)
135
127
 
136
- ---
137
-
138
128
  ### 📦 `add-package`
139
129
 
140
130
  Creates a shared **package** for separating concerns within an experience. Most of the actual code in a Unisphere project lives in packages — not in runtimes — making it easier to reuse components, services, and logic across multiple entry points. These packages are usually not distributed externally but serve as internal modules consumed by runtimes.
@@ -161,8 +151,6 @@ npx nx g @unisphere/nx:add-package
161
151
  - **Internal** - Published to GitHub packages (`@kaltura/unisphere-<experience-name>-<package-name>`)
162
152
  - **Public** - Published to npm (`@unisphere/<experience-name>-<package-name>`)
163
153
 
164
- ---
165
-
166
154
  ## Best Practices
167
155
 
168
156
  🧠 Use descriptive names that reflect the purpose of the runtime or visual. For example, use `player-plugin` for a runtime that integrates into a video player, or `container` for visual that represent a container that can only have one instance, or `drawer` if it is a drawer runtime.
@@ -173,8 +161,6 @@ npx nx g @unisphere/nx:add-package
173
161
 
174
162
  🔍 Use the interactive CLI mode to generate all project elements. This ensures naming consistency, correct scaffolding, and alignment with Unisphere conventions.
175
163
 
176
- ---
177
-
178
164
  ## What’s Next?
179
165
 
180
166
  Stay tuned for full documentation on each concept and tool at
@@ -5,11 +5,103 @@ import { ConfigurationContext } from './configuration-provider';
5
5
  import { isConfigurationValid } from './definitions';
6
6
  import { Header } from './components/header';
7
7
  import { ConfigurationProvider } from './configuration-provider';
8
- import { UnisphereProvider } from '@unisphere/runtime-react';
8
+ import { UnisphereProvider, UnisphereRuntimeVisual } from '@unisphere/runtime-react';
9
9
  import { UnisphereWorkspaceConfig } from '@unisphere/runtime';
10
10
  import { UnisphereWorkspaceType } from '@unisphere/runtime';
11
11
  import { <%= runtimeName__pascalCase %>Runtime } from '<%= coreAlias %>';
12
12
 
13
+
14
+ const Hihi: React.FC = () => {
15
+ return (
16
+ <div
17
+ style={{
18
+ display: 'flex',
19
+ flexDirection: 'column',
20
+ alignItems: 'center',
21
+ justifyContent: 'center',
22
+ height: '100vh',
23
+ padding: '2rem',
24
+ backgroundColor: '#f9f9f9',
25
+ color: '#333',
26
+ fontFamily: 'sans-serif',
27
+ textAlign: 'center',
28
+ }}
29
+ >
30
+ <h1
31
+ style={{
32
+ fontSize: '1.5rem',
33
+ }}
34
+ >
35
+ Hihi :)
36
+ </h1>
37
+
38
+ <h2
39
+ style={{
40
+ fontSize: '1.0rem',
41
+ marginBottom: '1rem',
42
+ }}
43
+ >
44
+ No visuals are mounted yet
45
+ </h2>
46
+
47
+ <p
48
+ style={{
49
+ fontSize: '1rem',
50
+ maxWidth: '400px',
51
+ lineHeight: 1.4,
52
+ marginBottom: '2rem',
53
+ }}
54
+ >
55
+ You haven’t created a runtime visual or just didn't mount it in the Expo
56
+ application. Once you add one, open{' '}
57
+ <span
58
+ style={{
59
+ backgroundColor: '#eaeaea',
60
+ padding: '0.2rem 0.4rem',
61
+ borderRadius: '4px',
62
+ fontFamily: 'monospace',
63
+ }}
64
+ >
65
+ app.tsx
66
+ </span>{' '}
67
+ and uncomment the{' '}
68
+ <span
69
+ style={{
70
+ backgroundColor: '#eaeaea',
71
+ padding: '0.2rem 0.4rem',
72
+ borderRadius: '4px',
73
+ fontFamily: 'monospace',
74
+ }}
75
+ >
76
+ &lt;UnisphereRuntimeVisual /&gt;
77
+ </span>{' '}
78
+ component to see it render here.
79
+ </p>
80
+
81
+ <pre
82
+ style={{
83
+ backgroundColor: '#fff',
84
+ padding: '1rem',
85
+ border: '1px solid #ddd',
86
+ borderRadius: '4px',
87
+ overflowX: 'auto',
88
+ fontFamily: 'monospace',
89
+ textAlign: 'left',
90
+ }}
91
+ >
92
+ {`<UnisphereRuntimeVisual
93
+ widgetName="unisphere.widget.<%= widgetName__lowerDashCase %>"
94
+ runtimeName="<%= runtimeName__lowerDashCase %>"
95
+ visualType="-- provide here the visual name --"
96
+ visualSettings={{
97
+ -- provide here the visual settings --
98
+ }}
99
+ />`}
100
+ </pre>
101
+ </div>
102
+ );
103
+ };
104
+
13
105
  export function AppContent() {
14
106
  const { configuration } = useContext(ConfigurationContext);
15
107
 
@@ -22,18 +114,18 @@ export function AppContent() {
22
114
  () => {
23
115
  /*
24
116
  Developer Note:
25
- You don’t need to touch the code to enable runtime configuration.
117
+ The Expo app lets you provide runtime configuration as a JSON object that matches the same schema used in your production or staging environments.
26
118
 
27
- If this runtime is already active in an app:
28
- 1. Open Unisphere, press Cmd + K, then choose Manage Workspace Runtimes.
29
- 2. Find the runtime you want, click (Action), and select Copy Settings.
30
- 3. Paste into NVQ2 with a valid host—settings will be ready to go.
119
+ If the runtime is already active in production or staging:
120
+ 1. Open Unisphere (Cmd + K) and choose Manage Workspace Runtimes.
121
+ 2. Locate your runtime, click the ••• (Actions) menu, and select Copy Settings.
122
+ 3. Open the Expo app in the browser, in the header click on the settings icon and paste the JSON into the settings field.
123
+ 4. Use the Save button to persist your settings. They’ll be stored in local storage and automatically loaded the next time the app runs.
31
124
 
32
- If the runtime isn’t yet in use:
33
- 1. Manually create the JSON payload matching the runtime’s schema.
34
-
35
- Once you run the application you will have a button where you can save the configurations.
36
- The application will save it in the local storage and will load it on the next run.
125
+ If the runtime isn’t yet in use:
126
+ 1. Manually create a JSON payload that conforms to your runtime’s schema.
127
+ 2. Open the Expo app in the browser, in the header click on the settings icon and paste the JSON into the settings field.
128
+ 3. Use the Save button to persist your settings. They’ll be stored in local storage and automatically loaded the next time the app runs.
37
129
  */
38
130
 
39
131
  try {
@@ -95,6 +187,8 @@ export function AppContent() {
95
187
  onWorkspaceLoaded={onWorkspaceLoaded}
96
188
  initialConfiguration={initialConfiguration}
97
189
  >
190
+ <Hihi />
191
+
98
192
  {/* <UnisphereRuntimeVisual
99
193
  widgetName="unisphere.widget.<%= widgetName__lowerDashCase %>"
100
194
  runtimeName="<%= runtimeName__lowerDashCase %>"
@@ -92,11 +92,15 @@ export const SettingsForm: React.FC = () => {
92
92
  name={'settings'}
93
93
  fullWidth
94
94
  inputProps={{
95
- ...register('settings', { required: true }),
95
+ ...register('settings', {
96
+ required: `To pass empty settings, type "{}". Otherwise: (1) manually type valid JSON. (2) `,
97
+ }),
96
98
  }}
97
99
  label={'Unisphere Settings'}
98
- helperText={`Easily copy settings from Unisphere by entering a workable host in NVQ2 and then do: Unisphere cmd+k > Manage Workspace Runtimes > show ... (actions) of desired runtime > copy settings`}
99
- error={!!errors?.settings}
100
+ helperText={`${
101
+ errors?.settings?.message || ''
102
+ }Easily copy settings from Unisphere by entering a workable host in NVQ2 and then do: Unisphere cmd+k > Manage Workspace Runtimes > show ... (actions) of desired runtime > copy settings`}
103
+ error={!!errors?.settings?.message}
100
104
  />
101
105
  </FormCard>
102
106
  </Stack>
@@ -1 +1 @@
1
- {"version":3,"file":"add-package.d.ts","sourceRoot":"","sources":["../../../src/generators/add-package/add-package.ts"],"names":[],"mappings":"AAAA,OAAO,EAA8B,IAAI,EAAiB,MAAM,YAAY,CAAC;AAE7E,OAAO,EAAE,yBAAyB,EAAE,MAAM,UAAU,CAAC;AAkBrD,wBAAsB,mBAAmB,CACvC,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,yBAAyB,uBAwGnC;AAED,eAAe,mBAAmB,CAAC"}
1
+ {"version":3,"file":"add-package.d.ts","sourceRoot":"","sources":["../../../src/generators/add-package/add-package.ts"],"names":[],"mappings":"AAAA,OAAO,EAA8B,IAAI,EAAiB,MAAM,YAAY,CAAC;AAE7E,OAAO,EAAE,yBAAyB,EAAE,MAAM,UAAU,CAAC;AAuGrD,wBAAsB,mBAAmB,CACvC,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,yBAAyB,uBAyGnC;AAED,eAAe,mBAAmB,CAAC"}
@@ -5,6 +5,82 @@ const tslib_1 = require("tslib");
5
5
  const devkit_1 = require("@nx/devkit");
6
6
  const path = tslib_1.__importStar(require("path"));
7
7
  const utils_1 = require("../utils");
8
+ function generateDemoComponent(tree, projectRoot, vars) {
9
+ // path: packages/<pkg>/src/lib/panel-demo.tsx
10
+ const targetPath = `${projectRoot}/src/lib/${vars['packageName__lowerDashCase']}-demo.tsx`;
11
+ // component and logger names
12
+ const loggerName = `${vars['packageName__lowerDashCase']}-demo`;
13
+ const demoName = `${vars['packageName__pascalCase']}Demo`;
14
+ const content = `import { useContext, useEffect } from 'react';
15
+ import {
16
+ ScopedUnisphereWorkspaceContext,
17
+ useGetScopedWorkspaceLogger,
18
+ } from '@unisphere/runtime-react';
19
+
20
+ const Hihi = () => {
21
+ return (
22
+ <div
23
+ style={{
24
+ border: '2px dashed #888',
25
+ borderRadius: '8px',
26
+ padding: '2rem',
27
+ margin: '2rem auto',
28
+ maxWidth: '500px',
29
+ textAlign: 'center',
30
+ fontFamily: 'sans-serif',
31
+ color: '#444',
32
+ backgroundColor: '#fcfcfc',
33
+ }}
34
+ >
35
+ <h2
36
+ style={{
37
+ marginBottom: '1rem',
38
+ fontSize: '1.25rem',
39
+ fontWeight: 500,
40
+ }}
41
+ >
42
+ Hihi :)
43
+ </h2>
44
+ <p
45
+ style={{
46
+ lineHeight: 1.5,
47
+ marginBottom: '1.5rem',
48
+ fontSize: '1rem',
49
+ }}
50
+ >
51
+ This '${demoName}' component shows you how to connect with the Unisphere workspace and set up a scoped logger.
52
+ </p>
53
+ </div>
54
+ );
55
+ };
56
+
57
+ export const ${demoName} = () => {
58
+ const { unisphereWorkspace } = useContext(ScopedUnisphereWorkspaceContext);
59
+ const logger = useGetScopedWorkspaceLogger({
60
+ type: 'react',
61
+ name: '${loggerName}',
62
+ });
63
+
64
+ useEffect(() => {
65
+ // example only - feel free to remove
66
+ logger.log('${loggerName} mounted');
67
+ return () => {
68
+ logger.log('${loggerName} unmounted');
69
+ };
70
+ }, []);
71
+
72
+ useEffect(() => {
73
+ if (!unisphereWorkspace) return;
74
+
75
+ // you can access the unisphere workspace that renders the runtime this component is mounted in
76
+ }, [unisphereWorkspace]);
77
+
78
+ // render your visual
79
+ return <Hihi />;
80
+ };
81
+ `;
82
+ tree.write(targetPath, content);
83
+ }
8
84
  async function addPackageGenerator(tree, options) {
9
85
  // Validate and read .unisphere configuration
10
86
  const unisphereConfig = (0, utils_1.validateUnisphereConfig)(tree);
@@ -68,6 +144,7 @@ async function addPackageGenerator(tree, options) {
68
144
  });
69
145
  // Update tsconfig.base.json with path mapping
70
146
  (0, utils_1.updateTsConfigPaths)(tree, packageJsonName, `unisphere/packages/${userInputPackageName}/src/index.ts`);
147
+ generateDemoComponent(tree, projectRoot, templateVariables);
71
148
  await (0, devkit_1.formatFiles)(tree);
72
149
  // Return a function that will be executed after all file operations are complete
73
150
  return () => {
@@ -15,23 +15,23 @@
15
15
  "description": "The distribution scope of the package",
16
16
  "default": "none",
17
17
  "x-prompt": {
18
- "message": "What scope should this package have? If you are not sure what to choose, choose None.",
19
- "type": "list",
20
- "items": [
21
- {
22
- "value": "none",
23
- "label": "None (no scope) - Used only internally by the experience runtimes."
24
- },
25
- {
26
- "value": "internal",
27
- "label": "Internal - Published to GitHub packages (@kaltura/unisphere-<experience-name>-<package-name>)"
28
- },
29
- {
30
- "value": "public",
31
- "label": "Public - Published to npm (@unisphere/<experience-name>-<package-name>)"
32
- }
33
- ]
18
+ "message": "What scope should this package have? If you’re unsure, choose Private.",
19
+ "type": "list",
20
+ "items": [
21
+ {
22
+ "value": "none",
23
+ "label": "Private only for this Unisphere experience (not published externally)"
24
+ },
25
+ {
26
+ "value": "internal",
27
+ "label": "Kaltura published as a GitHub package (@kaltura/unisphere-… for Kaltura teams)"
28
+ },
29
+ {
30
+ "value": "public",
31
+ "label": "Public published to npm (@unisphere/… available to everyone)"
34
32
  }
33
+ ]
34
+ }
35
35
  }
36
36
  },
37
37
  "required": [
@@ -0,0 +1 @@
1
+ export * from './lib/<%= packageName__lowerDashCase %>-demo';
@@ -19,5 +19,5 @@
19
19
  "**/*.spec.jsx",
20
20
  "**/*.test.jsx"
21
21
  ],
22
- "include": ["src/**/*.js", "src/**/*.jsx", "src/**/*.ts", "src/**/*.tsx"]
22
+ "include": ["src/**/*.js", "src/**/*.jsx", "src/**/*.ts", "src/**/*.tsx", "src/index.ts.template"]
23
23
  }
@@ -31,6 +31,9 @@ export class Runtime
31
31
  }
32
32
 
33
33
  constructor(options: CreateElementOptions<<%= runtimeName__pascalCase %>RuntimeSettings>) {
34
+ /*
35
+ Developer Note: to generate a visual run `npx nx g @unisphere/nx:add-visual`
36
+ */
34
37
  super({
35
38
  ...options,
36
39
  settingsSchema: <%= runtimeName__camelCase %>RuntimeSettingsSchema,
@@ -9,7 +9,7 @@
9
9
  this._logger.log('rendering <%= visualName__humanReadable %>');
10
10
 
11
11
  visual.htmlContainer?.render(
12
- <ScopedUnisphereWorkspaceProvider unisphereWorkspace={this._workspace}>
12
+ <ScopedUnisphereWorkspaceProvider unisphereWorkspace={this._workspace} runtimeLogger={this._logger}>
13
13
  <ThemeProvider
14
14
  cssPrefix={'<%= widgetName__lowerDashCase %>-<%= runtimeName__lowerDashCase %>-<%= visualName__lowerDashCase %>'}
15
15
  mode={typeof this._theme === 'string' ? this._theme : this._theme.mode}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unisphere/nx",
3
- "version": "1.1.2",
3
+ "version": "1.1.4",
4
4
  "private": false,
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",