soma-core 1.0.2 → 1.0.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.
@@ -31,5 +31,11 @@ export declare class SomaDomRenderer {
31
31
  private appendListItem;
32
32
  private renderObj;
33
33
  private applyShowConfig;
34
+ private applyNestedShowConfig;
35
+ private appendNestedTemplateItem;
36
+ private applyExtendedShowConfig;
34
37
  private resolveShowValue;
38
+ private parseConditionalPath;
39
+ private isNestedShowMapping;
40
+ private isExtendedShowValue;
35
41
  }
@@ -0,0 +1,3 @@
1
+ /** Runtime fallback when host app does not provide config/app.config.yaml. */
2
+ declare const _default: {};
3
+ export default _default;
@@ -0,0 +1,3 @@
1
+ /** Runtime fallback when host app does not provide config/locale.yaml. */
2
+ declare const _default: {};
3
+ export default _default;
@@ -0,0 +1,8 @@
1
+ export interface SomaAssetSource {
2
+ type: 'host' | 'package';
3
+ name: string;
4
+ assetRoot: string;
5
+ codeRoot: string;
6
+ packageName?: string;
7
+ }
8
+ export declare function getSomaAssetSources(hostDir: string): SomaAssetSource[];
package/global.d.ts CHANGED
@@ -8,13 +8,13 @@ declare module '*.yaml' {
8
8
  export default content;
9
9
  }
10
10
 
11
- declare module '*.yml' {
12
- const content: string;
13
- export default content;
14
- }
15
-
16
- /** Dev console API (window.__SOMA__ in npm run dev) */
17
- interface SomaDevConsole {
11
+ declare module '*.yml' {
12
+ const content: string;
13
+ export default content;
14
+ }
15
+
16
+ /** Dev console API (window.__SOMA__ in npm run dev) */
17
+ interface SomaDevConsole {
18
18
  getDiagnosticsSnapshot: () => import('./core/diagnostics/SomaDiagnostics').SomaDiagnosticsSnapshot | null;
19
19
  getTelemetrySnapshot: () => Record<string, { count: number; avg: number; max: number; min: number }> | null;
20
20
  getAvailableThemes?: () => string[];
package/next.config.js CHANGED
@@ -1,4 +1,5 @@
1
1
  /** @type {import('next').NextConfig} */
2
+ const fs = require('fs');
2
3
  const path = require('path');
3
4
  const { SomaManifestWebpackPlugin } = require('./core/compiler/soma-manifest-webpack-plugin');
4
5
 
@@ -10,15 +11,78 @@ if (!rawHostDir || !String(rawHostDir).trim()) {
10
11
  }
11
12
  const hostDir = path.resolve(rawHostDir);
12
13
 
14
+ function resolveOptionalHostFile(relativePath, fallbackPath) {
15
+ const hostFile = path.resolve(hostDir, relativePath);
16
+ if (fs.existsSync(hostFile)) {
17
+ return hostFile;
18
+ }
19
+ return path.resolve(__dirname, fallbackPath);
20
+ }
21
+
22
+ function readHostFileDependencyEntries() {
23
+ const packageJsonPath = path.join(hostDir, 'package.json');
24
+ if (!fs.existsSync(packageJsonPath)) {
25
+ return [];
26
+ }
27
+
28
+ try {
29
+ const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));
30
+ const dependencies = {
31
+ ...(packageJson.dependencies ?? {}),
32
+ ...(packageJson.devDependencies ?? {}),
33
+ };
34
+ return Object.entries(dependencies)
35
+ .filter(([, version]) => typeof version === 'string' && version.startsWith('file:'))
36
+ .map(([name, version]) => ({
37
+ name,
38
+ root: path.resolve(hostDir, String(version).slice('file:'.length)),
39
+ }))
40
+ .filter((entry) => fs.existsSync(entry.root));
41
+ } catch {
42
+ return [];
43
+ }
44
+ }
45
+
46
+ function readEnvTranspilePackages() {
47
+ return String(process.env.SOMA_TRANSPILE_PACKAGES ?? '')
48
+ .split(',')
49
+ .map((item) => item.trim())
50
+ .filter(Boolean);
51
+ }
52
+
53
+ const hostFileDependencyEntries = readHostFileDependencyEntries();
54
+ const transpilePackages = [
55
+ ...new Set(['soma-core', ...hostFileDependencyEntries.map((entry) => entry.name), ...readEnvTranspilePackages()]),
56
+ ];
57
+
13
58
  const nextConfig = {
14
59
  experimental: {
15
60
  externalDir: true,
61
+ serverComponentsExternalPackages: ['jiti'],
16
62
  },
17
63
 
18
- serverExternalPackages: ['jiti'],
64
+ transpilePackages,
19
65
 
20
66
  webpack: (config) => {
67
+ config.resolve.alias['@'] = __dirname;
68
+ config.resolve.alias['soma-core$'] = path.resolve(__dirname, 'core/index.ts');
69
+ config.resolve.alias['soma-core/base$'] = path.resolve(__dirname, 'core/base/index.ts');
21
70
  config.resolve.alias['@core'] = path.resolve(__dirname, 'core');
71
+ for (const entry of hostFileDependencyEntries) {
72
+ config.resolve.alias[entry.name] = entry.root;
73
+ }
74
+ config.resolve.alias['@soma-host/bootstrap/soma-bootstrap'] = resolveOptionalHostFile(
75
+ 'bootstrap/soma-bootstrap.ts',
76
+ 'core/host/soma-bootstrap-host.stub.ts',
77
+ );
78
+ config.resolve.alias['@soma-host/config/locale.yaml'] = resolveOptionalHostFile(
79
+ 'config/locale.yaml',
80
+ 'core/host/locale.stub.ts',
81
+ );
82
+ config.resolve.alias['@soma-host/config/app.config.yaml'] = resolveOptionalHostFile(
83
+ 'config/app.config.yaml',
84
+ 'core/host/app-config.stub.ts',
85
+ );
22
86
  config.resolve.alias['@soma-host'] = hostDir;
23
87
 
24
88
  config.plugins.push(new SomaManifestWebpackPlugin({ hostDir }));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "soma-core",
3
- "version": "1.0.2",
3
+ "version": "1.0.3",
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",
@@ -17,7 +17,7 @@
17
17
  "directory": "soma-core"
18
18
  },
19
19
  "main": "./core/index.ts",
20
- "types": "./core/index.ts",
20
+ "types": "./dist/types/index.d.ts",
21
21
  "typesVersions": {
22
22
  "*": {
23
23
  "diagnostics": [
@@ -31,16 +31,20 @@
31
31
  },
32
32
  "exports": {
33
33
  ".": {
34
- "types": "./core/index.ts",
34
+ "types": "./dist/types/index.d.ts",
35
35
  "import": "./core/index.ts",
36
36
  "require": "./dist/core/index.cjs",
37
37
  "default": "./core/index.ts"
38
38
  },
39
- "./base": "./core/base/index.ts",
39
+ "./base": {
40
+ "types": "./dist/types/base/index.d.ts",
41
+ "import": "./core/base/index.ts",
42
+ "default": "./core/base/index.ts"
43
+ },
40
44
  "./compiler/vite": "./core/compiler/vite-plugin-soma.ts",
41
45
  "./compiler/webpack-loader": "./core/compiler/soma-webpack-loader.js",
42
46
  "./diagnostics": {
43
- "types": "./core/diagnostics/SomaTelemetry.ts",
47
+ "types": "./dist/types/diagnostics/SomaTelemetry.d.ts",
44
48
  "import": "./core/diagnostics/SomaTelemetry.ts",
45
49
  "require": "./dist/diagnostics/telemetry.cjs",
46
50
  "default": "./core/diagnostics/SomaTelemetry.ts"
@@ -1,12 +1,13 @@
1
1
  import type { Config } from 'tailwindcss';
2
2
  import fs from 'node:fs';
3
3
  import path from 'node:path';
4
- import { createRequire } from 'node:module';
5
- import { fileURLToPath } from 'node:url';
4
+ import { createRequire } from 'node:module';
5
+ import { fileURLToPath } from 'node:url';
6
+ import { getSomaAssetSources } from './core/host/source-packages';
6
7
 
7
8
  /**
8
9
  * Framework Tailwind config (loaded with soma-core / Next).
9
- * Host theme/plugins come from SOMA_HOST_DIR/tailwind.config.js via presets.
10
+ * Host theme/plugins come from SOMA_HOST_DIR/tailwind.config.cjs/js via presets.
10
11
  */
11
12
  if (!process.env.SOMA_HOST_DIR) {
12
13
  throw new Error('[soma-core] tailwind: SOMA_HOST_DIR is not set');
@@ -14,8 +15,8 @@ if (!process.env.SOMA_HOST_DIR) {
14
15
  const hostDir = path.resolve(process.env.SOMA_HOST_DIR);
15
16
  const require = createRequire(fileURLToPath(import.meta.url));
16
17
 
17
- function loadHostPreset(): Config | null {
18
- for (const name of ['tailwind.config.js', 'tailwind.config.cjs']) {
18
+ function loadHostPreset(): Config | null {
19
+ for (const name of ['tailwind.config.cjs', 'tailwind.config.js']) {
19
20
  const cfgPath = path.join(hostDir, name);
20
21
  if (!fs.existsSync(cfgPath)) continue;
21
22
  const mod = require(cfgPath) as Config | { default: Config };
@@ -24,17 +25,20 @@ function loadHostPreset(): Config | null {
24
25
  return null;
25
26
  }
26
27
 
27
- const hostPreset = loadHostPreset();
28
-
29
- const config: Config = {
30
- presets: hostPreset ? [hostPreset] : [],
31
- content: [
32
- './app/**/*.{js,ts,jsx,tsx,mdx}',
33
- './core/**/*.{js,ts,jsx,tsx}',
34
- path.join(hostDir, 'html/**/*.html'),
35
- path.join(hostDir, 'ui/**/*_style.yaml'),
36
- path.join(hostDir, 'styles/**/*.css'),
37
- ],
38
- };
28
+ const hostPreset = loadHostPreset();
29
+ const sourceContent = getSomaAssetSources(hostDir).flatMap((source) => [
30
+ path.join(source.assetRoot, 'html/**/*.html'),
31
+ path.join(source.assetRoot, 'ui/**/*_style.yaml'),
32
+ path.join(source.assetRoot, 'styles/**/*.css'),
33
+ ]);
34
+
35
+ const config: Config = {
36
+ ...(hostPreset ? { presets: [hostPreset] } : {}),
37
+ content: [
38
+ './app/**/*.{js,ts,jsx,tsx,mdx}',
39
+ './core/**/*.{js,ts,jsx,tsx}',
40
+ ...sourceContent,
41
+ ],
42
+ };
39
43
 
40
44
  export default config;