mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-03-18 15:34:09 +01:00
Run oxfmt across repo, add format script and docs
Add .oxfmtignore to skip generated bindings and wasm-pack output. Add npm format script, update DEVELOPMENT.md for Vite+ toolchain, and format all non-generated files with oxfmt. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
{
|
||||
"name": "@yaak/template-function-encode",
|
||||
"displayName": "Encoding Template Functions",
|
||||
"description": "Template functions for encoding and decoding data",
|
||||
"private": true,
|
||||
"version": "0.1.0",
|
||||
"private": true,
|
||||
"description": "Template functions for encoding and decoding data",
|
||||
"scripts": {
|
||||
"build": "yaakcli build",
|
||||
"dev": "yaakcli dev"
|
||||
|
||||
@@ -1,60 +1,60 @@
|
||||
import type { CallTemplateFunctionArgs, Context, PluginDefinition } from '@yaakapp/api';
|
||||
import type { CallTemplateFunctionArgs, Context, PluginDefinition } from "@yaakapp/api";
|
||||
|
||||
export const plugin: PluginDefinition = {
|
||||
templateFunctions: [
|
||||
{
|
||||
name: 'base64.encode',
|
||||
description: 'Encode a value to base64',
|
||||
name: "base64.encode",
|
||||
description: "Encode a value to base64",
|
||||
args: [
|
||||
{
|
||||
label: 'Encoding',
|
||||
type: 'select',
|
||||
name: 'encoding',
|
||||
defaultValue: 'base64',
|
||||
label: "Encoding",
|
||||
type: "select",
|
||||
name: "encoding",
|
||||
defaultValue: "base64",
|
||||
options: [
|
||||
{
|
||||
label: 'Base64',
|
||||
value: 'base64',
|
||||
label: "Base64",
|
||||
value: "base64",
|
||||
},
|
||||
{
|
||||
label: 'Base64 URL-safe',
|
||||
value: 'base64url',
|
||||
label: "Base64 URL-safe",
|
||||
value: "base64url",
|
||||
},
|
||||
],
|
||||
},
|
||||
{ label: 'Plain Text', type: 'text', name: 'value', multiLine: true },
|
||||
{ label: "Plain Text", type: "text", name: "value", multiLine: true },
|
||||
],
|
||||
async onRender(_ctx: Context, args: CallTemplateFunctionArgs): Promise<string | null> {
|
||||
return Buffer.from(String(args.values.value ?? '')).toString(
|
||||
args.values.encoding === 'base64url' ? 'base64url' : 'base64',
|
||||
return Buffer.from(String(args.values.value ?? "")).toString(
|
||||
args.values.encoding === "base64url" ? "base64url" : "base64",
|
||||
);
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'base64.decode',
|
||||
description: 'Decode a value from base64',
|
||||
args: [{ label: 'Encoded Value', type: 'text', name: 'value', multiLine: true }],
|
||||
name: "base64.decode",
|
||||
description: "Decode a value from base64",
|
||||
args: [{ label: "Encoded Value", type: "text", name: "value", multiLine: true }],
|
||||
async onRender(_ctx: Context, args: CallTemplateFunctionArgs): Promise<string | null> {
|
||||
return Buffer.from(String(args.values.value ?? ''), 'base64').toString('utf-8');
|
||||
return Buffer.from(String(args.values.value ?? ""), "base64").toString("utf-8");
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'url.encode',
|
||||
description: 'Encode a value for use in a URL (percent-encoding)',
|
||||
args: [{ label: 'Plain Text', type: 'text', name: 'value', multiLine: true }],
|
||||
name: "url.encode",
|
||||
description: "Encode a value for use in a URL (percent-encoding)",
|
||||
args: [{ label: "Plain Text", type: "text", name: "value", multiLine: true }],
|
||||
async onRender(_ctx: Context, args: CallTemplateFunctionArgs): Promise<string | null> {
|
||||
return encodeURIComponent(String(args.values.value ?? ''));
|
||||
return encodeURIComponent(String(args.values.value ?? ""));
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'url.decode',
|
||||
description: 'Decode a percent-encoded URL value',
|
||||
args: [{ label: 'Encoded Value', type: 'text', name: 'value', multiLine: true }],
|
||||
name: "url.decode",
|
||||
description: "Decode a percent-encoded URL value",
|
||||
args: [{ label: "Encoded Value", type: "text", name: "value", multiLine: true }],
|
||||
async onRender(_ctx: Context, args: CallTemplateFunctionArgs): Promise<string | null> {
|
||||
try {
|
||||
return decodeURIComponent(String(args.values.value ?? ''));
|
||||
return decodeURIComponent(String(args.values.value ?? ""));
|
||||
} catch {
|
||||
return '';
|
||||
return "";
|
||||
}
|
||||
},
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user