This commit is contained in:
Tutur33
2023-11-24 22:35:41 +01:00
parent 3c0b507a93
commit 7644b2a0f7
45165 changed files with 4803356 additions and 3 deletions
+7
View File
@@ -0,0 +1,7 @@
/// <reference types="@adonisjs/core" />
import { ViewContract } from '@ioc:Adonis/Core/View';
import { AssetsManagerContract } from '@ioc:Adonis/Core/AssetsManager';
/**
* Registers the asset manager tags and globals with the template engine
*/
export declare function defineAssetsManagerBindings(View: ViewContract, AssetsManager: AssetsManagerContract): void;
+60
View File
@@ -0,0 +1,60 @@
"use strict";
/*
* @adonisjs/view
*
* (c) Harminder Virk <virk@adonisjs.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.defineAssetsManagerBindings = void 0;
const edge_error_1 = require("edge-error");
/**
* Registers the asset manager tags and globals with the template engine
*/
function defineAssetsManagerBindings(View, AssetsManager) {
View.global('assetsManager', AssetsManager);
View.global('asset', (filename) => AssetsManager.assetPath(filename));
View.registerTag({
tagName: 'entryPointStyles',
seekable: true,
block: false,
compile(parser, buffer, token) {
/**
* Ensure an argument is defined
*/
if (!token.properties.jsArg.trim()) {
throw new edge_error_1.EdgeError('Missing entrypoint name', 'E_RUNTIME_EXCEPTION', {
filename: token.filename,
line: token.loc.start.line,
col: token.loc.start.col,
});
}
const parsed = parser.utils.transformAst(parser.utils.generateAST(token.properties.jsArg, token.loc, token.filename), token.filename, parser);
const entrypointName = parser.utils.stringify(parsed);
buffer.outputExpression(`state.assetsManager.entryPointStyleTags(${entrypointName})`, token.filename, token.loc.start.line, false);
},
});
View.registerTag({
tagName: 'entryPointScripts',
seekable: true,
block: false,
compile(parser, buffer, token) {
/**
* Ensure an argument is defined
*/
if (!token.properties.jsArg.trim()) {
throw new edge_error_1.EdgeError('Missing entrypoint name', 'E_RUNTIME_EXCEPTION', {
filename: token.filename,
line: token.loc.start.line,
col: token.loc.start.col,
});
}
const parsed = parser.utils.transformAst(parser.utils.generateAST(token.properties.jsArg, token.loc, token.filename), token.filename, parser);
const entrypointName = parser.utils.stringify(parsed);
buffer.outputExpression(`state.assetsManager.entryPointScriptTags(${entrypointName})`, token.filename, token.loc.start.line, false);
},
});
}
exports.defineAssetsManagerBindings = defineAssetsManagerBindings;
+9
View File
@@ -0,0 +1,9 @@
/// <reference types="@adonisjs/application/build/adonis-typings" />
/// <reference types="@adonisjs/repl" />
import { ReplContract } from '@ioc:Adonis/Addons/Repl';
import { ApplicationContract } from '@ioc:Adonis/Core/Application';
/**
* Define repl bindings. The method must be invoked when application environment
* is set to repl.
*/
export declare function defineReplBindings(app: ApplicationContract, Repl: ReplContract): void;
+24
View File
@@ -0,0 +1,24 @@
"use strict";
/*
* @adonisjs/view
*
* (c) Harminder Virk <virk@adonisjs.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.defineReplBindings = void 0;
/**
* Define repl bindings. The method must be invoked when application environment
* is set to repl.
*/
function defineReplBindings(app, Repl) {
Repl.addMethod('loadView', (repl) => {
repl.server.context.View = app.container.use('Adonis/Core/View');
repl.notify(`Loaded View module. You can access it using the "${repl.colors.underline('View')}" variable`);
}, {
description: 'Load view provider and save reference to the "View" variable',
});
}
exports.defineReplBindings = defineReplBindings;