@unisphere/nx 1.1.2 → 1.1.3

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.
@@ -10,6 +10,98 @@ 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 %>"
@@ -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.3",
4
4
  "private": false,
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",