@nexia/sdk 0.8.25 → 0.9.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.
package/README.md CHANGED
@@ -2,6 +2,13 @@
2
2
 
3
3
  Public frontend contracts for Nexia App Packages. Import supported contracts from the package root, `/host` or `/testing`. This package does not contain the Nexia Core workspace runtime.
4
4
 
5
+ Development Fast Refresh requires the standard `nexiaAppConfig(import.meta.url)`
6
+ configuration, Vite 7.3.x, a compatible Nexia CLI and sandbox Core development
7
+ assets. Custom Vite configurations retain compiled development. Backend changes
8
+ are admitted before their matching frontend snapshot is exposed; an unsupported
9
+ hot update, disconnected session, or added/removed resource module requires an explicit workspace refresh after
10
+ saving drafts. SDK publication and Core/CLI adoption are separate release steps.
11
+
5
12
  ## Developer support / 개발자 지원
6
13
 
7
14
  Report SDK, setup, CLI, Docker, AI-tool and sandbox problems in the [central developer support tracker](https://github.com/nexia-cloud-os/developer-support/issues). Search existing issues first and include package versions and minimal reproduction steps. Never attach credentials, private Core source or customer data.
@@ -0,0 +1,11 @@
1
+ ---
2
+ status: published
3
+ version: 0.8.26
4
+ date: 2026-11-16
5
+ title: React Fast Refresh for App development
6
+ description: Preserve local state for compatible sandbox App updates.
7
+ ---
8
+
9
+ ### React Fast Refresh for App development
10
+
11
+ Compatible App component and style edits can preserve local state. Adopt the matching CLI and sandbox Core assets and retain the standard Vite configuration. [CLI guide](https://developers.nexia.to/docs/getting-started-cli) · [SDK source](https://github.com/nexia-cloud-os/app-sdk/blob/develop/packages/react/src/vite.mjs)
@@ -0,0 +1,11 @@
1
+ ---
2
+ status: published
3
+ version: 0.8.26
4
+ date: 2026-11-16
5
+ title: App 개발용 React Fast Refresh
6
+ description: 호환되는 샌드박스 App 변경에서 로컬 상태를 유지합니다.
7
+ ---
8
+
9
+ ### App 개발용 React Fast Refresh
10
+
11
+ 호환되는 App 컴포넌트와 스타일 변경에서 로컬 상태를 유지할 수 있습니다. 대응하는 CLI와 샌드박스 Core 자산을 적용하고 기본 Vite 설정을 유지하세요. [CLI 안내](https://developers.nexia.to/ko/docs/getting-started-cli) · [SDK 소스](https://github.com/nexia-cloud-os/app-sdk/blob/develop/packages/react/src/vite.mjs)
@@ -0,0 +1,9 @@
1
+ ---
2
+ status: published
3
+ version: 0.9.0
4
+ date: 2026-11-17
5
+ title: Stopped data migration status
6
+ description: Adds a distinct status for user-stopped imports.
7
+ ---
8
+
9
+ `DataMigrationRunStatus` includes `cancelled` for an import stopped by its user. Apps that exhaustively handle run states must handle the new value. A compatible Core host is required to produce it. See [Import and export](https://developers.nexia.to/docs/building-apps-import-and-export).
@@ -0,0 +1,9 @@
1
+ ---
2
+ status: published
3
+ version: 0.9.0
4
+ date: 2026-11-17
5
+ title: 중단된 데이터 마이그레이션 상태
6
+ description: 사용자가 중단한 가져오기에 별도 상태를 추가합니다.
7
+ ---
8
+
9
+ 사용자가 가져오기를 중단하면 `DataMigrationRunStatus`의 `cancelled` 상태로 기록할 수 있습니다. 실행 상태를 빠짐없이 분기하는 앱은 이 값을 처리해야 합니다. 실제 상태 기록에는 호환 Core 호스트가 필요합니다. [가져오기 및 내보내기](https://developers.nexia.to/ko/docs/building-apps-import-and-export)를 참고하세요.
@@ -2,6 +2,7 @@
2
2
  status: draft
3
3
  ---
4
4
 
5
+
5
6
  The `organization.workforce` v1 slot lets Apps supply workforce views for an authorized Legal Entity. The detailed guide covers props, registration, scoped permissions, and verification.
6
7
 
7
8
  [Implement the workforce slot](https://developers.nexia.to/docs/platform-extensions-add-slot-widget)
@@ -2,6 +2,7 @@
2
2
  status: draft
3
3
  ---
4
4
 
5
+
5
6
  `organization.workforce` v1 슬롯으로 App이 권한 있는 법인의 직원 배치 보기를 제공할 수 있습니다. 상세 문서에서 props, 등록, 범위별 권한과 확인 방법을 설명합니다.
6
7
 
7
8
  [직원 배치 슬롯 구현하기](https://developers.nexia.to/ko/docs/platform-extensions-add-slot-widget)
@@ -1,5 +1,5 @@
1
1
  import type { ComponentType, LazyExoticComponent } from 'react';
2
- export type DataMigrationRunStatus = 'processing' | 'completed' | 'completed_with_errors' | 'failed';
2
+ export type DataMigrationRunStatus = 'processing' | 'completed' | 'completed_with_errors' | 'failed' | 'cancelled';
3
3
  /** Host-owned asynchronous operation returned by migration analysis/apply APIs. */
4
4
  export interface DataMigrationBackgroundOperation<TResult = Readonly<Record<string, unknown>>> {
5
5
  ticket: string;
@@ -0,0 +1,142 @@
1
+ // HMR context semantics follow Vite 7.3.6 (MIT); transport and reload handling are Nexia-owned.
2
+ const modules = new Map(), data = new Map(), disposers = new Map(), pruners = new Map();
3
+ const listeners = new Map(), owners = new Map(), styles = new Map();
4
+ const failedPaths = new Set();
5
+ const serverErrors = new Set();
6
+ const moduleKey = (value, update = false) => {
7
+ const path = String(value ?? '').replaceAll('\\', '/').split('?')[0];
8
+ // Worker roots are private temporary directories with this fixed prefix.
9
+ // Preserve the full App-relative path even when it contains nested resources.
10
+ const workerPath = path.match(/\/nexia-hmr-[^/]+(\/resources\/.*)$/);
11
+ if (workerPath) return workerPath[1];
12
+ if (path.startsWith('/resources/')) return path;
13
+ if (update && path.includes('/resources/')) return path.slice(path.indexOf('/resources/'));
14
+ const offset = path.lastIndexOf('/resources/');
15
+ return offset < 0 || path.indexOf('/resources/') !== offset ? null : path.slice(offset);
16
+ };
17
+ const socketUrl = new URL('./__nexia_hmr', import.meta.url);
18
+ socketUrl.protocol = socketUrl.protocol === 'https:' ? 'wss:' : 'ws:';
19
+ let socket, retry, stopped = false, connected = false, frozen = false, queue = Promise.resolve();
20
+ const notify = (event, detail) => {
21
+ for (const callback of listeners.get(event) ?? []) callback(detail);
22
+ window.dispatchEvent(new CustomEvent('nexia:hmr', { detail: { ...detail, event, owner: import.meta.url } }));
23
+ };
24
+ const send = (event, payload) => {
25
+ if (socket?.readyState === WebSocket.OPEN) socket.send(JSON.stringify({ type: 'custom', event, data: payload }));
26
+ };
27
+ function connect() {
28
+ socket = new WebSocket(socketUrl, 'vite-hmr');
29
+ socket.addEventListener('open', () => { if (connected) frozen = true; notify(connected ? 'reload-required' : 'connected', {}); connected = true; });
30
+ socket.addEventListener('close', () => { if (!stopped) { notify('disconnected', {}); retry = setTimeout(connect, 1000); } });
31
+ socket.addEventListener('message', ({ data: message }) => {
32
+ let payload;
33
+ try { payload = JSON.parse(message); } catch { return; }
34
+ queue = queue.then(() => handle(payload)).catch(error => { if (!stopped) notify('error', { message: String(error) }); });
35
+ });
36
+ }
37
+ async function handle(payload) {
38
+ if (stopped) return;
39
+ if (payload.type === 'update') {
40
+ if (frozen) return;
41
+ const updates = (payload.updates ?? []).map(update => ({ update, callbacks: [...(modules.get(update.path) ?? [])].filter(item => item.deps.includes(update.acceptedPath)) }));
42
+ const prepared = [];
43
+ for (const { update, callbacks } of updates) {
44
+ if (update.type !== 'js-update') { frozen = true; notify('reload-required', {}); return; }
45
+ if (!callbacks.length) continue;
46
+ const base = new URL('../', import.meta.url);
47
+ if (typeof update.acceptedPath !== 'string' || !update.acceptedPath.startsWith('/') || update.acceptedPath.startsWith('//')) { frozen = true; notify('reload-required', {}); return; }
48
+ const url = new URL(update.acceptedPath.slice(1), base);
49
+ if (url.origin !== base.origin || !url.pathname.startsWith(base.pathname)) { frozen = true; notify('reload-required', {}); return; }
50
+ if (update.explicitImportRequired) url.searchParams.set('import', '');
51
+ url.searchParams.set('t', String(update.timestamp));
52
+ prepared.push({ update, callbacks, url });
53
+ }
54
+ const fetched = await Promise.all(prepared.map(async item => {
55
+ try {
56
+ await disposers.get(item.update.acceptedPath)?.(data.get(item.update.acceptedPath));
57
+ if (stopped || frozen) return null;
58
+ return { ...item, module: await import(/* @vite-ignore */ item.url.href) };
59
+ } catch (error) {
60
+ if (!stopped) { failedPaths.add(item.update.acceptedPath); notify('error', { message: String(error) }); }
61
+ return null;
62
+ }
63
+ }));
64
+ if (stopped || frozen) return;
65
+ for (const item of fetched) {
66
+ if (!item || stopped || frozen) continue;
67
+ try {
68
+ for (const { deps, callback } of item.callbacks) {
69
+ if (stopped || frozen) return;
70
+ await callback(deps.map(dep => dep === item.update.acceptedPath ? item.module : undefined));
71
+ }
72
+ } catch (error) {
73
+ if (!stopped) { failedPaths.add(item.update.acceptedPath); notify('error', { message: String(error) }); }
74
+ continue;
75
+ }
76
+ if (stopped || frozen) return;
77
+ failedPaths.delete(item.update.acceptedPath);
78
+ const key = moduleKey(item.update.acceptedPath, true);
79
+ if (key) serverErrors.delete(key);
80
+ }
81
+ if (fetched.some(Boolean) && !stopped && !frozen && serverErrors.size === 0 && failedPaths.size === 0) notify('updated', {});
82
+ } else if (payload.type === 'prune') {
83
+ for (const path of payload.paths ?? []) { await disposers.get(path)?.(data.get(path)); await pruners.get(path)?.(data.get(path)); }
84
+ } else if (payload.type === 'full-reload') { frozen = true; notify('reload-required', {}); }
85
+ else if (payload.type === 'error') { serverErrors.add(moduleKey(payload.err?.id) ?? '*'); notify('error', { message: payload.err?.message ?? 'Update failed.' }); }
86
+ else if (payload.type === 'custom' && payload.event === 'nexia:utilities-update' && !frozen) {
87
+ const url = new URL(payload.data?.path, import.meta.url), base = new URL('../', import.meta.url);
88
+ if (url.origin !== base.origin || url.pathname !== `${base.pathname}@id/__x00__nexia-app-utilities.css`) { frozen = true; notify('reload-required', {}); return; }
89
+ url.searchParams.set('t', String(payload.data.timestamp));
90
+ try {
91
+ await import(/* @vite-ignore */ url.href);
92
+ if (stopped || frozen) return;
93
+ failedPaths.delete(url.pathname);
94
+ if (serverErrors.size === 0 && failedPaths.size === 0) notify('updated', {});
95
+ } catch (error) { if (!stopped) { failedPaths.add(url.pathname); notify('error', { message: String(error) }); } }
96
+ } else if (payload.type === 'custom') notify(payload.event, payload.data ?? {});
97
+ }
98
+ export function createHotContext(owner) {
99
+ if (!data.has(owner)) data.set(owner, {});
100
+ modules.set(owner, []);
101
+ for (const [event, callback] of owners.get(owner) ?? []) listeners.get(event)?.delete(callback);
102
+ owners.set(owner, []);
103
+ const add = (deps, callback = () => {}) => modules.get(owner).push({ deps, callback });
104
+ return {
105
+ get data() { return data.get(owner); },
106
+ accept(deps, callback) {
107
+ if (typeof deps === 'function' || deps === undefined) add([owner], ([module]) => deps?.(module));
108
+ else if (typeof deps === 'string') add([deps], ([module]) => callback?.(module));
109
+ else if (Array.isArray(deps)) add(deps, callback);
110
+ else throw new Error('Invalid hot.accept() usage.');
111
+ },
112
+ acceptExports(_exports, callback) { add([owner], ([module]) => callback?.(module)); },
113
+ dispose(callback) { disposers.set(owner, callback); },
114
+ prune(callback) { pruners.set(owner, callback); },
115
+ decline() {},
116
+ invalidate(message) { send('vite:invalidate', { path: owner, message, firstInvalidatedBy: owner }); },
117
+ on(event, callback) { if (!listeners.has(event)) listeners.set(event, new Set()); listeners.get(event).add(callback); owners.get(owner).push([event, callback]); },
118
+ off(event, callback) { listeners.get(event)?.delete(callback); },
119
+ send,
120
+ };
121
+ }
122
+ export function updateStyle(id, css) {
123
+ if (stopped || frozen) return;
124
+ const apply = window.__NEXIA_HMR_STYLE__;
125
+ if (typeof apply !== 'function') throw new Error('App style isolation is unavailable.');
126
+ styles.set(id, true);
127
+ apply(import.meta.url, id, css);
128
+ }
129
+ export function removeStyle(id) { if (styles.has(id)) window.__NEXIA_HMR_STYLE__?.(import.meta.url, id, null); styles.delete(id); }
130
+ export function injectQuery(url, query) {
131
+ if (url[0] !== '.' && url[0] !== '/') return url;
132
+ const pathname = url.replace(/[?#].*$/, '');
133
+ const { search, hash } = new URL(url, 'http://vite.dev');
134
+ return `${pathname}?${query}${search ? `&${search.slice(1)}` : ''}${hash}`;
135
+ }
136
+ export class ErrorOverlay extends HTMLElement {}
137
+ if (typeof window !== 'undefined') {
138
+ connect();
139
+ const close = () => { stopped = true; clearTimeout(retry); socket?.close(); for (const id of styles.keys()) removeStyle(id); };
140
+ window.addEventListener('nexia:hmr-stop', event => { if (event.detail?.owner === import.meta.url) close(); });
141
+ window.addEventListener('pagehide', close);
142
+ }
package/dist/vite.d.mts CHANGED
@@ -1,5 +1,6 @@
1
1
  export const nexiaHostPeers: readonly string[];
2
- export function nexiaAppConfig(configUrl: string | URL): Record<string, unknown>;
2
+ export function nexiaHmrPlugins(peers: Record<string, string>, refreshRuntime: string): unknown[];
3
+ export function nexiaAppConfig(configUrl: string | URL, options?: { sourceRoot?: string }): Record<string, unknown>;
3
4
  export function nexiaAppFrontend(apps: { appKey: string; root: string } | Array<{ appKey: string; root: string }>): {
4
5
  name: string;
5
6
  enforce: 'pre';
package/dist/vite.mjs CHANGED
@@ -1,6 +1,7 @@
1
1
  import path from 'node:path';
2
2
  import { createRequire } from 'node:module';
3
3
  import tailwindcss from '@tailwindcss/vite';
4
+ import react from '@vitejs/plugin-react';
4
5
  import { readFileSync, realpathSync } from 'node:fs';
5
6
  import { fileURLToPath } from 'node:url';
6
7
 
@@ -9,10 +10,45 @@ import { fileURLToPath } from 'node:url';
9
10
  export const nexiaHostPeers = ['react', 'react/jsx-runtime', 'react/jsx-dev-runtime',
10
11
  '@tanstack/react-query', 'react-router-dom', 'react-i18next', '@nexia/sdk', '@nexia/sdk/host'];
11
12
 
13
+ /** Development graphs use the host's exact peer URLs and a non-reloading HMR client. */
14
+ export function nexiaHmrPlugins(peers, refreshRuntime) {
15
+ const host = new URL(refreshRuntime);
16
+ for (const name of nexiaHostPeers) {
17
+ const url = new URL(peers[name]);
18
+ if (!['http:', 'https:'].includes(url.protocol) || url.username || url.password || url.search || url.hash) throw new Error('Invalid host peer URL.');
19
+ if (url.origin !== host.origin) throw new Error('Host peer origins differ.');
20
+ }
21
+ if (!['http:', 'https:'].includes(host.protocol) || host.username || host.password || host.search || host.hash) throw new Error('Invalid refresh runtime URL.');
22
+ const client = readFileSync(new URL('./hmr-client.mjs', import.meta.url), 'utf8');
23
+ return [{
24
+ name: 'nexia:hmr-host', enforce: 'pre',
25
+ resolveId(id) { if (nexiaHostPeers.includes(id)) return { id: peers[id], external: true }; },
26
+ configResolved(config) {
27
+ const keep = id => id !== 'react-dom' && !nexiaHostPeers.includes(id);
28
+ config.optimizeDeps.include = (config.optimizeDeps.include ?? []).filter(keep);
29
+ for (const environment of Object.values(config.environments ?? {})) {
30
+ if (environment.optimizeDeps) environment.optimizeDeps.include = (environment.optimizeDeps.include ?? []).filter(keep);
31
+ }
32
+ },
33
+ configureServer(server) {
34
+ server.middlewares.use((req, res, next) => {
35
+ const url = new URL(req.url, 'http://localhost').pathname;
36
+ if (url === `${server.config.base}@vite/client`) {
37
+ res.setHeader('Content-Type', 'text/javascript'); res.end(client); return;
38
+ }
39
+ if (url === `${server.config.base}@react-refresh`) {
40
+ res.setHeader('Content-Type', 'text/javascript'); res.end(`export * from ${JSON.stringify(host.href)}; export { default } from ${JSON.stringify(host.href)};`); return;
41
+ }
42
+ next();
43
+ });
44
+ },
45
+ }, react()];
46
+ }
47
+
12
48
  /** The same standalone build contract for generated and existing Apps. */
13
- export function nexiaAppConfig(configUrl) {
14
- const root = realpathSync(fileURLToPath(new URL('.', configUrl)));
15
- const manifest = JSON.parse(readFileSync(new URL('./nexia.json', configUrl), 'utf8'));
49
+ export function nexiaAppConfig(configUrl, options = {}) {
50
+ const root = realpathSync(options.sourceRoot ?? fileURLToPath(new URL('.', configUrl)));
51
+ const manifest = JSON.parse(readFileSync(path.join(root, 'nexia.json'), 'utf8'));
16
52
  const utilities = '\0nexia-app-utilities.css';
17
53
  const theme = createRequire(import.meta.url).resolve('tailwindcss/theme.css').replaceAll('\\', '/');
18
54
  const aliases = fileURLToPath(new URL('./theme.css', import.meta.url)).replaceAll('\\', '/');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nexia/sdk",
3
- "version": "0.8.25",
3
+ "version": "0.9.0",
4
4
  "description": "Frontend contracts for Nexia App Packages",
5
5
  "license": "UNLICENSED",
6
6
  "type": "module",
@@ -34,7 +34,7 @@
34
34
  "scripts": {
35
35
  "build": "node scripts/build.mjs",
36
36
  "prepack": "npm run build",
37
- "test": "npm run build && node tests/WireValuesTest.mjs && node tests/ResourceCompositionFrontendContractsTest.mjs && node scripts/organization-target-contract.mjs && node tests/ResourceInspectorRegistrationTest.mjs && node tests/SettingsPrimitivesTest.mjs && node tests/AppServicesTest.mjs && node tests/AppStylesTest.mjs && node --test tests/ApprovalRequestTest.mjs",
37
+ "test": "npm run build && node tests/WireValuesTest.mjs && node tests/ResourceCompositionFrontendContractsTest.mjs && node scripts/organization-target-contract.mjs && node tests/ResourceInspectorRegistrationTest.mjs && node tests/SettingsPrimitivesTest.mjs && node tests/AppServicesTest.mjs && node tests/AppStylesTest.mjs && node --test tests/ApprovalRequestTest.mjs tests/HmrClientTest.mjs",
38
38
  "test:wire-values": "node tests/WireValuesTest.mjs",
39
39
  "typecheck": "tsc -p tsconfig.json --noEmit",
40
40
  "test:resource-composition": "pnpm run build && node tests/ResourceCompositionFrontendContractsTest.mjs",
@@ -69,6 +69,7 @@
69
69
  },
70
70
  "dependencies": {
71
71
  "@tailwindcss/vite": "4.2.1",
72
+ "@vitejs/plugin-react": "4.7.0",
72
73
  "tailwindcss": "4.2.1"
73
74
  }
74
75
  }