onelaraveljs 1.1.1 → 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.
package/index.js
CHANGED
|
@@ -3,13 +3,15 @@ import { App } from './src/app.js';
|
|
|
3
3
|
import { viewLoader } from './src/core/ViewLoader.js';
|
|
4
4
|
import { EventService } from './src/core/services/EventService.js';
|
|
5
5
|
import initApp from './src/init.js';
|
|
6
|
+
import { View } from './src/core/View.js';
|
|
6
7
|
|
|
7
8
|
// Export Core Components
|
|
8
9
|
export {
|
|
9
10
|
App,
|
|
10
11
|
viewLoader,
|
|
11
12
|
EventService,
|
|
12
|
-
initApp
|
|
13
|
+
initApp,
|
|
14
|
+
View
|
|
13
15
|
};
|
|
14
16
|
|
|
15
17
|
// Default export
|
package/package.json
CHANGED
package/scripts/build.py
CHANGED
|
@@ -221,7 +221,7 @@ def build_view_template_importer(created_files, output_path, context='all'):
|
|
|
221
221
|
|
|
222
222
|
if build_config and context != 'all' and context in build_config['contexts']:
|
|
223
223
|
# Use context-specific registry file
|
|
224
|
-
output_path = os.path.join(
|
|
224
|
+
output_path = os.path.join(config.project_root, build_config['contexts'][context]['output']['register'])
|
|
225
225
|
|
|
226
226
|
# Create output directory if it doesn't exist
|
|
227
227
|
os.makedirs(os.path.dirname(output_path), exist_ok=True)
|
|
@@ -385,8 +385,9 @@ def build_main_spa_file():
|
|
|
385
385
|
|
|
386
386
|
def load_build_config():
|
|
387
387
|
"""Load build.config.json"""
|
|
388
|
-
|
|
389
|
-
|
|
388
|
+
# Use the config object to find the project root
|
|
389
|
+
config_path = os.path.join(config.project_root, 'build.config.json')
|
|
390
|
+
if not os.path.exists(config_path):
|
|
390
391
|
return None
|
|
391
392
|
|
|
392
393
|
with open(config_path, 'r', encoding='utf-8') as f:
|
|
@@ -417,15 +418,15 @@ def get_source_directories(context_name=None):
|
|
|
417
418
|
# Return sources for specific context
|
|
418
419
|
sources = build_config['contexts'][context_name]['sources']
|
|
419
420
|
# Convert relative paths to absolute
|
|
420
|
-
base_path =
|
|
421
|
-
return [
|
|
421
|
+
base_path = config.project_root
|
|
422
|
+
return [os.path.join(base_path, src) for src in sources]
|
|
422
423
|
elif build_config and context_name == 'all':
|
|
423
424
|
# Return all sources from all contexts
|
|
424
|
-
base_path =
|
|
425
|
+
base_path = config.project_root
|
|
425
426
|
all_sources = set()
|
|
426
427
|
for ctx in build_config['contexts'].values():
|
|
427
428
|
for src in ctx['sources']:
|
|
428
|
-
all_sources.add(
|
|
429
|
+
all_sources.add(os.path.join(base_path, src))
|
|
429
430
|
return list(all_sources)
|
|
430
431
|
else:
|
|
431
432
|
# Fallback to config.get_build_directories()
|
|
@@ -537,7 +538,7 @@ def main():
|
|
|
537
538
|
# Create a proxy ViewTemplate.js in core/ that re-exports from context registry
|
|
538
539
|
core_template_path = os.path.join(config.js_input_path, 'core', 'ViewTemplate.js')
|
|
539
540
|
relative_to_registry = os.path.relpath(
|
|
540
|
-
os.path.join(
|
|
541
|
+
os.path.join(config.project_root, registry_path),
|
|
541
542
|
os.path.dirname(core_template_path)
|
|
542
543
|
).replace('\\', '/')
|
|
543
544
|
|
|
@@ -1005,7 +1005,7 @@ class BladeCompiler:
|
|
|
1005
1005
|
# Add View import if scripts are registered
|
|
1006
1006
|
view_import = ""
|
|
1007
1007
|
if script_registrations:
|
|
1008
|
-
view_import = "import { View } from '
|
|
1008
|
+
view_import = "import { View } from 'onelaraveljs';\n\n"
|
|
1009
1009
|
|
|
1010
1010
|
return_template = setup_script_line + view_import + script_registrations_line + """export function """ + function_name + """($$$DATA$$$ = {}, systemData = {}) {
|
|
1011
1011
|
const {App, View, __base__, __layout__, __page__, __component__, __template__, __context__, __partial__, __system__, __env = {}, __helper = {}} = systemData;
|
|
@@ -13,23 +13,31 @@ import { fileURLToPath } from 'url';
|
|
|
13
13
|
const __filename = fileURLToPath(import.meta.url);
|
|
14
14
|
const __dirname = path.dirname(__filename);
|
|
15
15
|
|
|
16
|
-
// Load build.config.json
|
|
17
|
-
const
|
|
16
|
+
// Load build.config.json from project root
|
|
17
|
+
const projectRoot = process.env.ONEJS_PROJECT_ROOT || process.cwd();
|
|
18
|
+
const configPath = path.join(projectRoot, 'build.config.json');
|
|
19
|
+
|
|
20
|
+
try {
|
|
21
|
+
var buildConfig = JSON.parse(fs.readFileSync(configPath, 'utf-8'));
|
|
22
|
+
} catch (e) {
|
|
23
|
+
console.error(`Error loading build.config.json from ${configPath}:`, e.message);
|
|
24
|
+
process.exit(1);
|
|
25
|
+
}
|
|
18
26
|
|
|
19
27
|
// Get context from environment variable
|
|
20
28
|
const buildContext = process.env.BUILD_CONTEXT || 'web';
|
|
21
29
|
|
|
22
30
|
// Determine static path based on context
|
|
23
31
|
const STATIC_PATH = buildConfig.contexts[buildContext]
|
|
24
|
-
? path.join(
|
|
25
|
-
: path.join(
|
|
32
|
+
? path.join(projectRoot, path.dirname(buildConfig.contexts[buildContext].dist.bundle))
|
|
33
|
+
: path.join(projectRoot, 'public/static/app');
|
|
26
34
|
|
|
27
35
|
// Determine base URL path for assets
|
|
28
36
|
const BASE_URL = buildConfig.contexts[buildContext]
|
|
29
37
|
? `/static/${buildContext}/js/`
|
|
30
38
|
: '/static/app/';
|
|
31
39
|
|
|
32
|
-
const OUTPUT_FILE = path.join(
|
|
40
|
+
const OUTPUT_FILE = path.join(projectRoot, 'resources/views/partials/assets-scripts.blade.php');
|
|
33
41
|
|
|
34
42
|
function getAssetsByCategory() {
|
|
35
43
|
const assets = {
|
package/src/core/ViewManager.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { SEOTagConfig } from './SEOConfig.js';
|
|
2
|
-
|
|
2
|
+
// ViewTemplates import removed
|
|
3
3
|
import { hasData, uniqId } from '../helpers/utils.js';
|
|
4
4
|
import { View, ViewEngine } from './View.js';
|
|
5
5
|
import { ViewState } from './ViewState.js';
|
|
@@ -126,7 +126,7 @@ export class ViewManager {
|
|
|
126
126
|
/**
|
|
127
127
|
* @type {Object<string, ViewEngine>}
|
|
128
128
|
*/
|
|
129
|
-
this.templates =
|
|
129
|
+
this.templates = viewLoader.registry || {};
|
|
130
130
|
/**
|
|
131
131
|
* @type {Object<string, string>}
|
|
132
132
|
*/
|
|
@@ -295,8 +295,8 @@ export class ViewManager {
|
|
|
295
295
|
this._changedSections = [];
|
|
296
296
|
|
|
297
297
|
// Initialize views if not already done
|
|
298
|
-
if (!this.templates) {
|
|
299
|
-
this.templates =
|
|
298
|
+
if (!this.templates || Object.keys(this.templates).length === 0) {
|
|
299
|
+
this.templates = viewLoader.registry || {};
|
|
300
300
|
}
|
|
301
301
|
|
|
302
302
|
// Initialize current scope
|