soma-core 1.2.0 → 1.3.2
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/app/SomaPageClient.tsx +13 -0
- package/core/client/engine/render-engine.ts +4 -0
- package/core/client/engine/soma-bootstrap.ts +30 -1
- package/core/client/infra/http/SomaHttpService.ts +5 -0
- package/core/client/scheduler/SomaScheduler.ts +29 -1
- package/core/server/mock/node/cli.mjs +4 -2
- package/dist/cli/soma.js +15 -0
- package/dist/core/index.cjs +55 -2
- package/dist/types/client/engine/render-engine.d.ts +1 -0
- package/dist/types/client/engine/soma-bootstrap.d.ts +6 -0
- package/dist/types/client/infra/http/SomaHttpService.d.ts +2 -0
- package/dist/types/client/scheduler/SomaScheduler.d.ts +8 -0
- package/global.d.ts +8 -0
- package/next.config.js +22 -1
- package/package.json +5 -2
package/app/SomaPageClient.tsx
CHANGED
|
@@ -179,6 +179,17 @@ function SomaPageRenderer({
|
|
|
179
179
|
...assets,
|
|
180
180
|
});
|
|
181
181
|
|
|
182
|
+
await bs.whenSettled();
|
|
183
|
+
if (cancelled) return;
|
|
184
|
+
if (typeof window !== 'undefined') {
|
|
185
|
+
window.__SOMA_DIAGNOSTICS__ = {
|
|
186
|
+
isSettled: () => bs.isSettled(),
|
|
187
|
+
getDomainValue: (path: string) => bs.getDomainValue(path),
|
|
188
|
+
getRegisteredSomaIds: () => bs.getRegisteredSomaIds(),
|
|
189
|
+
};
|
|
190
|
+
window.__SOMA_READY__ = bs.isInitialized();
|
|
191
|
+
}
|
|
192
|
+
|
|
182
193
|
routerBridgeRef.current?.();
|
|
183
194
|
const domain = bs.getDomainInstance() as {
|
|
184
195
|
_services?: {
|
|
@@ -303,6 +314,8 @@ function SomaPageRenderer({
|
|
|
303
314
|
routerBridgeRef.current = null;
|
|
304
315
|
if (typeof window !== 'undefined') {
|
|
305
316
|
delete window.__SOMA__;
|
|
317
|
+
delete window.__SOMA_READY__;
|
|
318
|
+
delete window.__SOMA_DIAGNOSTICS__;
|
|
306
319
|
}
|
|
307
320
|
void bootstrapRef.current?.unmount();
|
|
308
321
|
bootstrapRef.current = null;
|
|
@@ -79,6 +79,10 @@ export class SomaRenderEngine {
|
|
|
79
79
|
return this.scopeTracker;
|
|
80
80
|
}
|
|
81
81
|
|
|
82
|
+
getRegisteredSomaIds(): string[] {
|
|
83
|
+
return [...new Set(this.bindingTable.map((entry) => entry.somaId).filter(Boolean) as string[])];
|
|
84
|
+
}
|
|
85
|
+
|
|
82
86
|
/** 注册属性监听器(文档 §10.2 watch API) */
|
|
83
87
|
watch(
|
|
84
88
|
path: string,
|
|
@@ -104,6 +104,7 @@ export class SomaBootstrap {
|
|
|
104
104
|
private triggerEngine: SomaTriggerEngine | null = null;
|
|
105
105
|
private timerEngine: SomaTimerEngine | null = null;
|
|
106
106
|
private parsedTimers: ParsedTimer[] = [];
|
|
107
|
+
private runtimeResolver: SomaScopeResolver | null = null;
|
|
107
108
|
private proxy: SomaReactiveProxy | null = null;
|
|
108
109
|
private domainInstance: SomaPageRoot | null = null;
|
|
109
110
|
private mounted = false;
|
|
@@ -150,11 +151,11 @@ export class SomaBootstrap {
|
|
|
150
151
|
// 5. 构建运行时(委托给 RuntimeBuilder)
|
|
151
152
|
await this.buildRuntime(parsed);
|
|
152
153
|
|
|
153
|
-
this.mounted = true;
|
|
154
154
|
if (typeof this.domainInstance.onMount === 'function') {
|
|
155
155
|
await this.domainInstance.onMount();
|
|
156
156
|
}
|
|
157
157
|
this.startDeclarativeTimers();
|
|
158
|
+
this.mounted = true;
|
|
158
159
|
recordMetric('bootstrap.mount', (globalThis.performance?.now?.() ?? Date.now()) - mountStarted);
|
|
159
160
|
} catch (error) {
|
|
160
161
|
console.error('[SomaBootstrap] Mount failed:', error);
|
|
@@ -297,6 +298,32 @@ export class SomaBootstrap {
|
|
|
297
298
|
return this.domainInstance;
|
|
298
299
|
}
|
|
299
300
|
|
|
301
|
+
isInitialized(): boolean {
|
|
302
|
+
return this.mounted && this.domainInstance !== null && this.renderEngine !== null;
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
isSettled(): boolean {
|
|
306
|
+
return this.isInitialized()
|
|
307
|
+
&& this.scheduler.isSettled()
|
|
308
|
+
&& (this.domainInstance?._services?.http.pendingCount() ?? 0) === 0;
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
async whenSettled(): Promise<void> {
|
|
312
|
+
await this.scheduler.whenSettled();
|
|
313
|
+
while (this.isInitialized() && (this.domainInstance?._services?.http.pendingCount() ?? 0) > 0) {
|
|
314
|
+
await new Promise<void>((resolve) => setTimeout(resolve, 0));
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
getDomainValue(path: string): unknown {
|
|
319
|
+
if (!this.domainInstance || !this.runtimeResolver) return undefined;
|
|
320
|
+
return this.runtimeResolver.readFromRoot(this.runtimeResolver.resolvePath(path));
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
getRegisteredSomaIds(): string[] {
|
|
324
|
+
return this.renderEngine?.getRegisteredSomaIds() ?? [];
|
|
325
|
+
}
|
|
326
|
+
|
|
300
327
|
/** 获取渲染引擎(测试 / 调试) */
|
|
301
328
|
getRenderEngine(): SomaRenderEngine | null {
|
|
302
329
|
return this.renderEngine;
|
|
@@ -371,6 +398,7 @@ export class SomaBootstrap {
|
|
|
371
398
|
|
|
372
399
|
this.parsedTimers = parsed.timers;
|
|
373
400
|
this.renderEngine = runtime.renderEngine;
|
|
401
|
+
this.runtimeResolver = runtime.resolver;
|
|
374
402
|
this.eventEngine = runtime.eventEngine;
|
|
375
403
|
this.styleBinder = runtime.styleBinder;
|
|
376
404
|
this.propertyWatcher = runtime.propertyWatcher;
|
|
@@ -439,6 +467,7 @@ export class SomaBootstrap {
|
|
|
439
467
|
this.parsedTimers = [];
|
|
440
468
|
this.propertyWatcher = null;
|
|
441
469
|
this.proxy = null;
|
|
470
|
+
this.runtimeResolver = null;
|
|
442
471
|
this.domainInstance = null;
|
|
443
472
|
this.mounted = false;
|
|
444
473
|
this.container = null;
|
|
@@ -26,6 +26,11 @@ export class SomaHttpService implements IHttpClient {
|
|
|
26
26
|
this.onHttpError = handler;
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
+
/** Number of requests currently owned by this runtime service. */
|
|
30
|
+
pendingCount(): number {
|
|
31
|
+
return this.abortControllers.size;
|
|
32
|
+
}
|
|
33
|
+
|
|
29
34
|
async get<T>(url: string, config?: HttpRequestConfig): Promise<T> {
|
|
30
35
|
return this.requestWithConfig<T>('GET', url, undefined, config);
|
|
31
36
|
}
|
|
@@ -25,6 +25,7 @@ export class SomaScheduler {
|
|
|
25
25
|
private diagnostics: SomaDiagnostics | null = null;
|
|
26
26
|
private flushQueued = false;
|
|
27
27
|
private flushing = false;
|
|
28
|
+
private settledWaiters: Array<() => void> = [];
|
|
28
29
|
|
|
29
30
|
constructor(
|
|
30
31
|
options: SomaSchedulerOptions & {
|
|
@@ -114,12 +115,39 @@ export class SomaScheduler {
|
|
|
114
115
|
this.flushing = false;
|
|
115
116
|
if (this.autoFlush && this.hasPendingTasks()) {
|
|
116
117
|
this.queueFlush();
|
|
118
|
+
} else {
|
|
119
|
+
this.resolveSettledWaiters();
|
|
117
120
|
}
|
|
118
121
|
}
|
|
119
122
|
}
|
|
120
123
|
|
|
124
|
+
/** Number of tasks waiting to be executed (excluding the currently running task). */
|
|
125
|
+
pendingCount(): number {
|
|
126
|
+
return PRIORITY_ORDER.reduce(
|
|
127
|
+
(count, priority) => count + (this.queues.get(priority)?.length ?? 0),
|
|
128
|
+
0,
|
|
129
|
+
);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/** True only when no task is queued or currently being flushed. */
|
|
133
|
+
isSettled(): boolean {
|
|
134
|
+
return !this.flushing && !this.flushQueued && this.pendingCount() === 0;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/** Wait until the scheduler has finished its current batch. */
|
|
138
|
+
whenSettled(): Promise<void> {
|
|
139
|
+
if (this.isSettled()) return Promise.resolve();
|
|
140
|
+
return new Promise((resolve) => this.settledWaiters.push(resolve));
|
|
141
|
+
}
|
|
142
|
+
|
|
121
143
|
private hasPendingTasks(): boolean {
|
|
122
|
-
return
|
|
144
|
+
return this.pendingCount() > 0;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
private resolveSettledWaiters(): void {
|
|
148
|
+
if (!this.isSettled()) return;
|
|
149
|
+
const waiters = this.settledWaiters.splice(0);
|
|
150
|
+
for (const resolve of waiters) resolve();
|
|
123
151
|
}
|
|
124
152
|
|
|
125
153
|
private queueFlush(): void {
|
|
@@ -10,8 +10,10 @@ import {
|
|
|
10
10
|
import { filterMockEnvironment } from './environment-policy.mjs';
|
|
11
11
|
|
|
12
12
|
const MOCK_COMMANDS = new Set(['dev', 'build', 'start']);
|
|
13
|
-
const PACKAGE_ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '
|
|
14
|
-
const DEFAULT_PRELOAD_URL = pathToFileURL(
|
|
13
|
+
const PACKAGE_ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '../../../..');
|
|
14
|
+
const DEFAULT_PRELOAD_URL = pathToFileURL(
|
|
15
|
+
path.join(path.dirname(fileURLToPath(import.meta.url)), 'preload.mjs'),
|
|
16
|
+
).href;
|
|
15
17
|
|
|
16
18
|
export { SomaMockCliError, terminateMockChild };
|
|
17
19
|
|
package/dist/cli/soma.js
CHANGED
|
@@ -375,6 +375,20 @@ function resolveNextWorkspaceDir(hostDir) {
|
|
|
375
375
|
assertReusableWorkspaceDir(workspaceDir);
|
|
376
376
|
return workspaceDir;
|
|
377
377
|
}
|
|
378
|
+
/** Mount Host `public/` into the Next workspace so files are served at `/…`. */
|
|
379
|
+
function ensureHostPublicAssets(hostDir, workspaceDir) {
|
|
380
|
+
const hostPublic = node_path_1.default.join(hostDir, 'public');
|
|
381
|
+
const workspacePublic = node_path_1.default.join(workspaceDir, 'public');
|
|
382
|
+
const hostPublicStat = lstatIfPresent(hostPublic);
|
|
383
|
+
if (hostPublicStat?.isDirectory()) {
|
|
384
|
+
linkOrCopy(hostPublic, workspacePublic, 'dir');
|
|
385
|
+
return;
|
|
386
|
+
}
|
|
387
|
+
const existing = lstatIfPresent(workspacePublic);
|
|
388
|
+
if (existing) {
|
|
389
|
+
node_fs_1.default.rmSync(workspacePublic, { recursive: true, force: true });
|
|
390
|
+
}
|
|
391
|
+
}
|
|
378
392
|
function ensureNextWorkspace(hostDir) {
|
|
379
393
|
const workspaceDir = resolveNextWorkspaceDir(hostDir);
|
|
380
394
|
node_fs_1.default.mkdirSync(workspaceDir, { recursive: true });
|
|
@@ -385,6 +399,7 @@ function ensureNextWorkspace(hostDir) {
|
|
|
385
399
|
linkOrCopy(node_path_1.default.join(packageRoot, 'postcss.config.js'), node_path_1.default.join(workspaceDir, 'postcss.config.js'), 'file');
|
|
386
400
|
linkOrCopy(node_path_1.default.join(packageRoot, 'tailwind.config.ts'), node_path_1.default.join(workspaceDir, 'tailwind.config.ts'), 'file');
|
|
387
401
|
linkOrCopy(node_path_1.default.join(packageRoot, 'global.d.ts'), node_path_1.default.join(workspaceDir, 'global.d.ts'), 'file');
|
|
402
|
+
ensureHostPublicAssets(hostDir, workspaceDir);
|
|
388
403
|
const hasWorkspaceNodeModules = ensureWorkspaceNodeModules(workspaceDir);
|
|
389
404
|
writeFileIfChanged(node_path_1.default.join(workspaceDir, 'next.config.js'), `module.exports = require(${JSON.stringify(node_path_1.default.join(packageRoot, 'next.config.js'))});\n`);
|
|
390
405
|
writeFileIfChanged(node_path_1.default.join(workspaceDir, 'tsconfig.json'), buildNextWorkspaceTsconfig(workspaceDir, hasWorkspaceNodeModules));
|
package/dist/core/index.cjs
CHANGED
|
@@ -920,6 +920,7 @@ var SomaScheduler = class {
|
|
|
920
920
|
this.diagnostics = null;
|
|
921
921
|
this.flushQueued = false;
|
|
922
922
|
this.flushing = false;
|
|
923
|
+
this.settledWaiters = [];
|
|
923
924
|
this.autoFlush = options.autoFlush ?? true;
|
|
924
925
|
this.diagnostics = options.diagnostics ?? null;
|
|
925
926
|
}
|
|
@@ -992,11 +993,34 @@ var SomaScheduler = class {
|
|
|
992
993
|
this.flushing = false;
|
|
993
994
|
if (this.autoFlush && this.hasPendingTasks()) {
|
|
994
995
|
this.queueFlush();
|
|
996
|
+
} else {
|
|
997
|
+
this.resolveSettledWaiters();
|
|
995
998
|
}
|
|
996
999
|
}
|
|
997
1000
|
}
|
|
1001
|
+
/** Number of tasks waiting to be executed (excluding the currently running task). */
|
|
1002
|
+
pendingCount() {
|
|
1003
|
+
return PRIORITY_ORDER.reduce(
|
|
1004
|
+
(count, priority) => count + (this.queues.get(priority)?.length ?? 0),
|
|
1005
|
+
0
|
|
1006
|
+
);
|
|
1007
|
+
}
|
|
1008
|
+
/** True only when no task is queued or currently being flushed. */
|
|
1009
|
+
isSettled() {
|
|
1010
|
+
return !this.flushing && !this.flushQueued && this.pendingCount() === 0;
|
|
1011
|
+
}
|
|
1012
|
+
/** Wait until the scheduler has finished its current batch. */
|
|
1013
|
+
whenSettled() {
|
|
1014
|
+
if (this.isSettled()) return Promise.resolve();
|
|
1015
|
+
return new Promise((resolve) => this.settledWaiters.push(resolve));
|
|
1016
|
+
}
|
|
998
1017
|
hasPendingTasks() {
|
|
999
|
-
return
|
|
1018
|
+
return this.pendingCount() > 0;
|
|
1019
|
+
}
|
|
1020
|
+
resolveSettledWaiters() {
|
|
1021
|
+
if (!this.isSettled()) return;
|
|
1022
|
+
const waiters = this.settledWaiters.splice(0);
|
|
1023
|
+
for (const resolve of waiters) resolve();
|
|
1000
1024
|
}
|
|
1001
1025
|
queueFlush() {
|
|
1002
1026
|
if (this.flushQueued || this.flushing) {
|
|
@@ -6722,6 +6746,9 @@ var SomaRenderEngine = class {
|
|
|
6722
6746
|
getScopeTracker() {
|
|
6723
6747
|
return this.scopeTracker;
|
|
6724
6748
|
}
|
|
6749
|
+
getRegisteredSomaIds() {
|
|
6750
|
+
return [...new Set(this.bindingTable.map((entry) => entry.somaId).filter(Boolean))];
|
|
6751
|
+
}
|
|
6725
6752
|
/** 注册属性监听器(文档 §10.2 watch API) */
|
|
6726
6753
|
watch(path, callback, options) {
|
|
6727
6754
|
return this.propertyWatcher.watch(path, callback, options);
|
|
@@ -7916,6 +7943,10 @@ var SomaHttpService = class {
|
|
|
7916
7943
|
setErrorHandler(handler) {
|
|
7917
7944
|
this.onHttpError = handler;
|
|
7918
7945
|
}
|
|
7946
|
+
/** Number of requests currently owned by this runtime service. */
|
|
7947
|
+
pendingCount() {
|
|
7948
|
+
return this.abortControllers.size;
|
|
7949
|
+
}
|
|
7919
7950
|
async get(url, config) {
|
|
7920
7951
|
return this.requestWithConfig("GET", url, void 0, config);
|
|
7921
7952
|
}
|
|
@@ -8766,6 +8797,7 @@ var SomaBootstrap = class {
|
|
|
8766
8797
|
this.triggerEngine = null;
|
|
8767
8798
|
this.timerEngine = null;
|
|
8768
8799
|
this.parsedTimers = [];
|
|
8800
|
+
this.runtimeResolver = null;
|
|
8769
8801
|
this.proxy = null;
|
|
8770
8802
|
this.domainInstance = null;
|
|
8771
8803
|
this.mounted = false;
|
|
@@ -8794,11 +8826,11 @@ var SomaBootstrap = class {
|
|
|
8794
8826
|
this.proxy = new SomaReactiveProxy(void 0, this.diagnostics);
|
|
8795
8827
|
this.domainInstance = this.proxy.wrap(this.domainInstance);
|
|
8796
8828
|
await this.buildRuntime(parsed);
|
|
8797
|
-
this.mounted = true;
|
|
8798
8829
|
if (typeof this.domainInstance.onMount === "function") {
|
|
8799
8830
|
await this.domainInstance.onMount();
|
|
8800
8831
|
}
|
|
8801
8832
|
this.startDeclarativeTimers();
|
|
8833
|
+
this.mounted = true;
|
|
8802
8834
|
recordMetric("bootstrap.mount", (globalThis.performance?.now?.() ?? Date.now()) - mountStarted);
|
|
8803
8835
|
} catch (error) {
|
|
8804
8836
|
console.error("[SomaBootstrap] Mount failed:", error);
|
|
@@ -8910,6 +8942,25 @@ var SomaBootstrap = class {
|
|
|
8910
8942
|
getDomainInstance() {
|
|
8911
8943
|
return this.domainInstance;
|
|
8912
8944
|
}
|
|
8945
|
+
isInitialized() {
|
|
8946
|
+
return this.mounted && this.domainInstance !== null && this.renderEngine !== null;
|
|
8947
|
+
}
|
|
8948
|
+
isSettled() {
|
|
8949
|
+
return this.isInitialized() && this.scheduler.isSettled() && (this.domainInstance?._services?.http.pendingCount() ?? 0) === 0;
|
|
8950
|
+
}
|
|
8951
|
+
async whenSettled() {
|
|
8952
|
+
await this.scheduler.whenSettled();
|
|
8953
|
+
while (this.isInitialized() && (this.domainInstance?._services?.http.pendingCount() ?? 0) > 0) {
|
|
8954
|
+
await new Promise((resolve) => setTimeout(resolve, 0));
|
|
8955
|
+
}
|
|
8956
|
+
}
|
|
8957
|
+
getDomainValue(path) {
|
|
8958
|
+
if (!this.domainInstance || !this.runtimeResolver) return void 0;
|
|
8959
|
+
return this.runtimeResolver.readFromRoot(this.runtimeResolver.resolvePath(path));
|
|
8960
|
+
}
|
|
8961
|
+
getRegisteredSomaIds() {
|
|
8962
|
+
return this.renderEngine?.getRegisteredSomaIds() ?? [];
|
|
8963
|
+
}
|
|
8913
8964
|
/** 获取渲染引擎(测试 / 调试) */
|
|
8914
8965
|
getRenderEngine() {
|
|
8915
8966
|
return this.renderEngine;
|
|
@@ -8969,6 +9020,7 @@ var SomaBootstrap = class {
|
|
|
8969
9020
|
});
|
|
8970
9021
|
this.parsedTimers = parsed.timers;
|
|
8971
9022
|
this.renderEngine = runtime.renderEngine;
|
|
9023
|
+
this.runtimeResolver = runtime.resolver;
|
|
8972
9024
|
this.eventEngine = runtime.eventEngine;
|
|
8973
9025
|
this.styleBinder = runtime.styleBinder;
|
|
8974
9026
|
this.propertyWatcher = runtime.propertyWatcher;
|
|
@@ -9029,6 +9081,7 @@ var SomaBootstrap = class {
|
|
|
9029
9081
|
this.parsedTimers = [];
|
|
9030
9082
|
this.propertyWatcher = null;
|
|
9031
9083
|
this.proxy = null;
|
|
9084
|
+
this.runtimeResolver = null;
|
|
9032
9085
|
this.domainInstance = null;
|
|
9033
9086
|
this.mounted = false;
|
|
9034
9087
|
this.container = null;
|
|
@@ -44,6 +44,7 @@ export declare class SomaRenderEngine {
|
|
|
44
44
|
private initProps;
|
|
45
45
|
constructor(options: SomaRenderEngineOptions);
|
|
46
46
|
getScopeTracker(): WeakMap<HTMLElement, any>;
|
|
47
|
+
getRegisteredSomaIds(): string[];
|
|
47
48
|
/** 注册属性监听器(文档 §10.2 watch API) */
|
|
48
49
|
watch(path: string, callback: WatchCallback, options?: WatcherOptions): () => void;
|
|
49
50
|
getPropertyWatcher(): SomaPropertyWatcher;
|
|
@@ -73,6 +73,7 @@ export declare class SomaBootstrap {
|
|
|
73
73
|
private triggerEngine;
|
|
74
74
|
private timerEngine;
|
|
75
75
|
private parsedTimers;
|
|
76
|
+
private runtimeResolver;
|
|
76
77
|
private proxy;
|
|
77
78
|
private domainInstance;
|
|
78
79
|
private mounted;
|
|
@@ -99,6 +100,11 @@ export declare class SomaBootstrap {
|
|
|
99
100
|
switchTheme(themeName: string | null): void;
|
|
100
101
|
/** 获取当前挂载的业务实例(测试 / 调试) */
|
|
101
102
|
getDomainInstance(): SomaPageRoot | null;
|
|
103
|
+
isInitialized(): boolean;
|
|
104
|
+
isSettled(): boolean;
|
|
105
|
+
whenSettled(): Promise<void>;
|
|
106
|
+
getDomainValue(path: string): unknown;
|
|
107
|
+
getRegisteredSomaIds(): string[];
|
|
102
108
|
/** 获取渲染引擎(测试 / 调试) */
|
|
103
109
|
getRenderEngine(): SomaRenderEngine | null;
|
|
104
110
|
/** 监听属性变更(委托 RenderEngine.watch) */
|
|
@@ -16,6 +16,8 @@ export declare class SomaHttpService implements IHttpClient {
|
|
|
16
16
|
constructor(config: SomaHttpClientConfig);
|
|
17
17
|
/** 注册 HTTP 错误回调(401/403/422 等统一处理) */
|
|
18
18
|
setErrorHandler(handler: (status: number, message: string) => void): void;
|
|
19
|
+
/** Number of requests currently owned by this runtime service. */
|
|
20
|
+
pendingCount(): number;
|
|
19
21
|
get<T>(url: string, config?: HttpRequestConfig): Promise<T>;
|
|
20
22
|
post<T>(url: string, data?: any, config?: HttpRequestConfig): Promise<T>;
|
|
21
23
|
put<T>(url: string, data?: any, config?: HttpRequestConfig): Promise<T>;
|
|
@@ -6,6 +6,7 @@ export declare class SomaScheduler {
|
|
|
6
6
|
private diagnostics;
|
|
7
7
|
private flushQueued;
|
|
8
8
|
private flushing;
|
|
9
|
+
private settledWaiters;
|
|
9
10
|
constructor(options?: SomaSchedulerOptions & {
|
|
10
11
|
diagnostics?: SomaDiagnostics;
|
|
11
12
|
});
|
|
@@ -13,7 +14,14 @@ export declare class SomaScheduler {
|
|
|
13
14
|
schedule<T>(run: () => T | Promise<T>, options?: SomaSchedulerTaskOptions): Promise<T>;
|
|
14
15
|
cancelAll(reason?: string): void;
|
|
15
16
|
flush(): Promise<void>;
|
|
17
|
+
/** Number of tasks waiting to be executed (excluding the currently running task). */
|
|
18
|
+
pendingCount(): number;
|
|
19
|
+
/** True only when no task is queued or currently being flushed. */
|
|
20
|
+
isSettled(): boolean;
|
|
21
|
+
/** Wait until the scheduler has finished its current batch. */
|
|
22
|
+
whenSettled(): Promise<void>;
|
|
16
23
|
private hasPendingTasks;
|
|
24
|
+
private resolveSettledWaiters;
|
|
17
25
|
private queueFlush;
|
|
18
26
|
private getHighestPendingPriority;
|
|
19
27
|
/**
|
package/global.d.ts
CHANGED
|
@@ -71,4 +71,12 @@ interface SomaDevConsole {
|
|
|
71
71
|
|
|
72
72
|
interface Window {
|
|
73
73
|
__SOMA__?: SomaDevConsole;
|
|
74
|
+
__SOMA_READY__?: boolean;
|
|
75
|
+
__SOMA_DIAGNOSTICS__?: SomaReadinessDiagnostics;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
interface SomaReadinessDiagnostics {
|
|
79
|
+
isSettled: () => boolean;
|
|
80
|
+
getDomainValue: (path: string) => unknown;
|
|
81
|
+
getRegisteredSomaIds: () => string[];
|
|
74
82
|
}
|
package/next.config.js
CHANGED
|
@@ -125,9 +125,30 @@ function readEnvTranspilePackages() {
|
|
|
125
125
|
.filter(Boolean);
|
|
126
126
|
}
|
|
127
127
|
|
|
128
|
+
function readHostSourcePackageNames() {
|
|
129
|
+
const packageJson = readJson(path.join(hostDir, 'package.json'));
|
|
130
|
+
const dependencies = {
|
|
131
|
+
...(packageJson?.dependencies ?? {}),
|
|
132
|
+
...(packageJson?.devDependencies ?? {}),
|
|
133
|
+
};
|
|
134
|
+
return Object.entries(dependencies)
|
|
135
|
+
.filter(([name]) => {
|
|
136
|
+
const packageRoot = path.join(hostDir, 'node_modules', ...name.split('/'));
|
|
137
|
+
const sourcePackage = readJson(path.join(packageRoot, 'package.json'));
|
|
138
|
+
return sourcePackage?.soma?.source === true
|
|
139
|
+
|| fs.existsSync(path.join(packageRoot, 'shell', 'html'));
|
|
140
|
+
})
|
|
141
|
+
.map(([name]) => name);
|
|
142
|
+
}
|
|
143
|
+
|
|
128
144
|
const hostFileDependencyEntries = readHostFileDependencyEntries();
|
|
129
145
|
const transpilePackages = [
|
|
130
|
-
...new Set([
|
|
146
|
+
...new Set([
|
|
147
|
+
'soma-core',
|
|
148
|
+
...hostFileDependencyEntries.map((entry) => entry.name),
|
|
149
|
+
...readHostSourcePackageNames(),
|
|
150
|
+
...readEnvTranspilePackages(),
|
|
151
|
+
]),
|
|
131
152
|
];
|
|
132
153
|
|
|
133
154
|
const nextConfig = {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "soma-core",
|
|
3
|
-
"version": "1.2
|
|
3
|
+
"version": "1.3.2",
|
|
4
4
|
"description": "SOMA — Semantic Oriented Modular Architecture. A declarative frontend framework runtime built on Next.js 14+ App Router.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"soma",
|
|
@@ -108,7 +108,6 @@
|
|
|
108
108
|
"dev": "next dev",
|
|
109
109
|
"build": "next build",
|
|
110
110
|
"start": "next start",
|
|
111
|
-
"lint": "next lint",
|
|
112
111
|
"test": "vitest run && npm run test:mock",
|
|
113
112
|
"test:mock": "node --test tests/mock/*.test.mjs",
|
|
114
113
|
"verify:mock-pack": "node scripts/verify-mock-pack.mjs",
|
|
@@ -152,5 +151,9 @@
|
|
|
152
151
|
"vite": "6.4.3",
|
|
153
152
|
"vitest": "^3.2.7",
|
|
154
153
|
"ws": "^8.21.0"
|
|
154
|
+
},
|
|
155
|
+
"publishConfig": {
|
|
156
|
+
"access": "public",
|
|
157
|
+
"registry": "https://registry.npmjs.org/"
|
|
155
158
|
}
|
|
156
159
|
}
|