From d11cc7ff5c00c9a731cfe1bb7830752c31d793d2 Mon Sep 17 00:00:00 2001 From: Claycuy Date: Sat, 19 Sep 2026 06:50:19 +0800 Subject: [PATCH 01/13] docs: Added documentation for the initialization section --- .../lang/en/sidebarAPIReferences.ts | 2 + .../lang/en/sidebarConfigurationReference.ts | 14 +++++ .../lang/id/sidebarAPIReferences.ts | 2 + .../lang/id/sidebarConfigurationReference.ts | 14 +++++ docs/.vitepress/theme/style.css | 12 +++- .../typescript-configuration.md | 35 ++++++++++++ docs/en/get-started/quick-usage.md | 55 ------------------- docs/en/index.md | 14 +++-- .../configuration-reference/builderPattern.ts | 20 +++++++ .../builder_pattern.rs | 26 +++++++++ .../configuration-reference/objectPattern.ts | 28 ++++++++++ .../configuration-reference/object_pattern.rs | 38 +++++++++++++ docs/examples/getStarted/builderPattern.ts | 17 +----- docs/examples/getStarted/builder_pattern.rs | 17 +----- docs/examples/getStarted/objectPattern.ts | 21 +------ docs/examples/getStarted/object_pattern.rs | 27 ++------- .../typescript-configuration.md | 32 +++++++++++ docs/id/get-started/quick-usage.md | 55 ------------------- docs/id/index.md | 2 +- docs/public/assets/dark/box.svg | 1 + docs/public/assets/dark/lock.svg | 1 + docs/public/assets/dark/wand-magic.svg | 1 + docs/public/assets/light/box.svg | 1 + docs/public/assets/light/lock.svg | 1 + docs/public/assets/light/wand-magic.svg | 2 + 25 files changed, 251 insertions(+), 187 deletions(-) create mode 100644 docs/.vitepress/lang/en/sidebarConfigurationReference.ts create mode 100644 docs/.vitepress/lang/id/sidebarConfigurationReference.ts create mode 100644 docs/en/api-reference/configuration-reference/typescript-configuration.md create mode 100644 docs/examples/configuration-reference/builderPattern.ts create mode 100644 docs/examples/configuration-reference/builder_pattern.rs create mode 100644 docs/examples/configuration-reference/objectPattern.ts create mode 100644 docs/examples/configuration-reference/object_pattern.rs create mode 100644 docs/id/api-reference/configuration-reference/typescript-configuration.md create mode 100644 docs/public/assets/dark/box.svg create mode 100644 docs/public/assets/dark/lock.svg create mode 100644 docs/public/assets/dark/wand-magic.svg create mode 100644 docs/public/assets/light/box.svg create mode 100644 docs/public/assets/light/lock.svg create mode 100644 docs/public/assets/light/wand-magic.svg diff --git a/docs/.vitepress/lang/en/sidebarAPIReferences.ts b/docs/.vitepress/lang/en/sidebarAPIReferences.ts index f07829ff..d9b4ed0a 100644 --- a/docs/.vitepress/lang/en/sidebarAPIReferences.ts +++ b/docs/.vitepress/lang/en/sidebarAPIReferences.ts @@ -1,8 +1,10 @@ +import { sidebarConfigurationReference } from './sidebarConfigurationReference.js'; import { sidebarMethodFunctions } from './sidebarMethodFunctions.js'; import { sidebarInstructionSet } from './sidebarInstructionSet.js'; import { sidebarErrorCodes } from './sidebarErrorCodes.js'; export const sidebarAPIReferences = [ + sidebarConfigurationReference, sidebarMethodFunctions, { text: 'Primitive Types', link: '/api-reference/primitive-types' }, { text: 'Capabilities', link: '/api-reference/capabilities' }, diff --git a/docs/.vitepress/lang/en/sidebarConfigurationReference.ts b/docs/.vitepress/lang/en/sidebarConfigurationReference.ts new file mode 100644 index 00000000..3e55735f --- /dev/null +++ b/docs/.vitepress/lang/en/sidebarConfigurationReference.ts @@ -0,0 +1,14 @@ +export const sidebarConfigurationReference = { + text: 'Configuration Reference', + collapsed: false, + items: [ + { + text: 'TypeScript Configuration', + link: '/api-reference/configuration-reference/typescript-configuration', + }, + { + text: 'Embedded Method', + link: '/api-reference/method-functions/embedded-method', + } + ], +}; diff --git a/docs/.vitepress/lang/id/sidebarAPIReferences.ts b/docs/.vitepress/lang/id/sidebarAPIReferences.ts index 4fd10785..5b0da717 100644 --- a/docs/.vitepress/lang/id/sidebarAPIReferences.ts +++ b/docs/.vitepress/lang/id/sidebarAPIReferences.ts @@ -1,8 +1,10 @@ +import { sidebarConfigurationReference } from './sidebarConfigurationReference.js'; import { sidebarMethodFunctions } from './sidebarMethodFunctions.js'; import { sidebarInstructionSet } from './sidebarInstructionSet.js'; import { sidebarErrorCodes } from './sidebarErrorCodes.js'; export const sidebarAPIReferences = [ + sidebarConfigurationReference, sidebarMethodFunctions, { text: 'Tipe Primitif', link: '/id/api-reference/primitive-types' }, { text: 'Kapabilitas', link: '/id/api-reference/capabilities' }, diff --git a/docs/.vitepress/lang/id/sidebarConfigurationReference.ts b/docs/.vitepress/lang/id/sidebarConfigurationReference.ts new file mode 100644 index 00000000..f1b6dc0d --- /dev/null +++ b/docs/.vitepress/lang/id/sidebarConfigurationReference.ts @@ -0,0 +1,14 @@ +export const sidebarConfigurationReference = { + text: 'Referensi Konfigurasi', + collapsed: false, + items: [ + { + text: 'Konfigurasi TypeScript', + link: '/id/api-reference/configuration-reference/typescript-configuration', + }, + { + text: 'Embedded Method', + link: '/api-reference/method-functions/embedded-method', + } + ], +}; diff --git a/docs/.vitepress/theme/style.css b/docs/.vitepress/theme/style.css index 3bf70c4d..3e68cb9e 100644 --- a/docs/.vitepress/theme/style.css +++ b/docs/.vitepress/theme/style.css @@ -133,4 +133,14 @@ div[class*="language-"] > pre { .fade-enter-from, .fade-leave-to { opacity: 0; -} \ No newline at end of file +} +/* Light mode (default) */ +.VPImage { + filter: none; +} + +/* Dark mode */ +.dark .VPImage { + /* Atur filter sesuai kebutuhan, misal di-invert atau diubah brightness-nya */ + filter: invert(1) hue-rotate(180deg); +} diff --git a/docs/en/api-reference/configuration-reference/typescript-configuration.md b/docs/en/api-reference/configuration-reference/typescript-configuration.md new file mode 100644 index 00000000..71ce8be4 --- /dev/null +++ b/docs/en/api-reference/configuration-reference/typescript-configuration.md @@ -0,0 +1,35 @@ +# TypeScript Configuration +This page provides a comprehensive reference for all available configuration options, limits, and security controls when initializing a `LightVM` instance. + +## Full Configuration Example +The following example demonstrates how to configure all available limits, safety flags, and error options using both the builder and object patterns. + +::: code-group +<<< @/examples/configuration-reference/builderPattern.ts{ts:line-numbers}[Builder Pattern] +<<< @/examples/configuration-reference/objectPattern.ts{ts:line-numbers}[Object Pattern] +::: + +## Configuration Options Breakdown + +| Method / Property | Type | Default | Description | +| :--- | :--- | :--- | :--- | +| `caps` | `Capability[]` | `[]` | Specifies the active capabilities granted to the virtual machine. | +| `setMaxIo` / `maxIo` | `number` | `100` | Maximum number of I/O operations allowed during execution. | +| `setMaxImport` / `maxImport` | `number` | `3` | Maximum number of allowed module imports. | +| `setMaxAlloc` / `maxAlloc` | `number` | `50` | Maximum number of memory allocations allowed. | +| `setMaxCall` / `maxCall` | `number` | `200` | Maximum number of nested function calls allowed. | +| `setMaxJump` / `maxJump` | `number` | `100` | Maximum number of control flow jumps allowed. | +| `setMaxTicks` / `maxTicks` | `number` | `1_000_000` | Maximum number of execution ticks before stopping to prevent infinite loops. | +| `setMaxStackSize` / `maxStackSize` | `number` | `128` | Maximum number of items the evaluation stack can hold. | +| `setAllowedImports` / `allowedImports` | `string[]` | `[]` | Whitelist of module names that are permitted to be imported. | +| `setTimeBudget` / `timeBudget` | `TimeBudget` | `TimeBudget.Cheap` | Sets the execution time budget tier limit. | +| `withUnsafeMode` / `unsafeMode` | `boolean` | `false` | Enables or disables system-level unsafe operations. | +| `withNightly` / `nightly` | `boolean` | `false` | Allows the usage of experimental nightly features. | +| `withBacktrace` / `backtrace` | `boolean` | `false` | Displays internal backtrace details in error messages. | +| `withExplain` / `explain` | `boolean` | `false` | Displays a more detailed explanatory hint in error messages. | +| `withHint` / `hint` | `boolean` | `true` | Displays general usage hints on error messages. | +| `withDiagnosticLinks` / `diagnosticLinks` | `boolean` | `true` | Includes metadata links pointing to error-code documentation. | + +::: info Related Documentation +Need to check individual error codes mentioned in error messages? Visit the [Error Code Reference](/api-reference/error-codes/lvm001-code). +::: \ No newline at end of file diff --git a/docs/en/get-started/quick-usage.md b/docs/en/get-started/quick-usage.md index 8e60cbd9..c5453452 100644 --- a/docs/en/get-started/quick-usage.md +++ b/docs/en/get-started/quick-usage.md @@ -23,58 +23,3 @@ For Rust projects, configure `VmConfig` before creating the VM. <<< @/examples/getStarted/object_pattern.rs{rust:line-numbers}[Object Pattern] ::: - -## Diagnostic links - -Formatted VM errors include a `documentation:` metadata row by default. Its URL is derived from the error's `LVM` code and points to the matching page in the [error-code reference](/api-reference/error-codes/lvm001-code). - -Disable the row through the constructor configuration or the fluent API: - -::: code-group - -```rust [Native configuration] -let vm = LightVM::new(VmConfig { - error_options: Some(ErrorOptions { - diagnostic_links: false, - ..Default::default() - }), - ..Default::default() -}); - -let vm = LightVM::new(VmConfig::default()) - .with_diagnostic_links(false); -``` - -```ts [Node.js] -const vm = new LightVM({ - errorOptions: { - backtrace: false, - explain: false, - hint: true, - diagnosticLinks: false, - }, -}); - -vm.withDiagnosticLinks(false); -``` - -```ts [WASM] -const vm = new LightVM({ - caps: [], - errorOptions: { diagnosticLinks: false }, -}); - -vm.withDiagnosticLinks(false); -``` - -::: - -The same setting is retained by `tools()` and applies to errors from tool operations, including bytecode optimization. - -## Expected result - -You have a configured VM instance ready to load bytecode. Continue with the [Run Method](/api-reference/method-functions/run-method), or review [Capabilities](/api-reference/capabilities) before granting access. - -::: info Related API Reference -`TimeBudget` limits bytecode optimization time. Use `SecurityConfig.maxTicks` to limit execution work. -::: diff --git a/docs/en/index.md b/docs/en/index.md index 9c7fa875..1314411f 100644 --- a/docs/en/index.md +++ b/docs/en/index.md @@ -33,14 +33,20 @@ hero: link: /get-started/installation - theme: alt text: API Reference - link: /api-reference/method-functions/run-method + link: /api-reference/configuration-reference/typescript-configuration features: - - title: Zero Magic (Deterministic) + - icon: + src: /public/assets/light/wand-magic.svg + title: Zero Magic details: Instruction execution is linear and completely predictable. The VM operates explicitly, executing instructions exactly as they are defined. - - title: Resource Conscious + - icon: + src: /public/assets/light/box.svg + title: Resource Conscious details: Designed with a minimal memory footprint through the use of optimized data structures such as SmolStr and ahash for fast metadata management. - - title: Explicit Security + - icon: + src: /public/assets/light/lock.svg + title: Explicit Security details: Security is managed through a strict Capability system. Every VM access and operation must have permissions explicitly defined by the host from the outset. --- diff --git a/docs/examples/configuration-reference/builderPattern.ts b/docs/examples/configuration-reference/builderPattern.ts new file mode 100644 index 00000000..c21e4bb8 --- /dev/null +++ b/docs/examples/configuration-reference/builderPattern.ts @@ -0,0 +1,20 @@ +import { LightVM, Capability, TimeBudget } from 'lightvm'; + +const vm = new LightVM({ caps: [Capability.Observe, Capability.Control] }) + .setMaxIo(100) // Maximum number of I/O operations allowed (default: 100) + .setMaxImport(3) // Maximum number of allowed module imports (default: 3) + .setMaxAlloc(50) // Maximum number of memory allocations allowed (default: 50) + .setMaxCall(200) // Maximum number of nested function calls allowed (default: 200) + .setMaxJump(100) // Maximum number of control flow jumps allowed (default: 100) + .setMaxTicks(1_000_000) // Maximum number of execution ticks before stopping (default: 1,000,000) + .setMaxStackSize(128) // Maximum number of items the stack can hold (default: 128) + .setAllowedImports(['math', 'time', 'utils']) // Whitelist of modules that can be imported + .setTimeBudget(TimeBudget.Cheap) // Sets the execution time budget limit to prevent infinite loops (Default: Cheap) + .withUnsafeMode(false) // Enable or disable system-level unsafe operations (default: false) + .withNightly(false) // Allow nightly features (default: false) + .withBacktrace(false) // Display backtrace details in error messages (default: false) + .withExplain(false) // Display a more detailed hint in the error message (default: false) + .withHint(true) // Display a hint on error messages (default: true) + .withDiagnosticLinks(false); // Hide links to error-code documentation (default: true) + +const tools = vm.tools(); diff --git a/docs/examples/configuration-reference/builder_pattern.rs b/docs/examples/configuration-reference/builder_pattern.rs new file mode 100644 index 00000000..9ef97d0b --- /dev/null +++ b/docs/examples/configuration-reference/builder_pattern.rs @@ -0,0 +1,26 @@ +use lightvm::LightVM; +use lightvm::types::{vmconfig::VmConfig, capability::Capability, time_budget::TimeBudget}; + +fn main() { + let mut vm = LightVM::new(VmConfig { + caps: vec![Capability::Control, Capability::Observe], + ..Default::default() + }) + .set_max_io(100) // Maximum number of I/O operations allowed (default: 100) + .set_max_import(3) // Maximum number of allowed module imports (default: 3) + .set_max_alloc(50) // Maximum number of memory allocations allowed (default: 50) + .set_max_call(200) // Maximum number of nested function calls allowed (default: 200) + .set_max_jump(100) // Maximum number of control flow jumps allowed (default: 100) + .set_max_ticks(1_000_000) // Maximum number of execution ticks before stopping (default: 1,000,000) + .set_max_stack_size(128) // Maximum number of items the stack can hold (default: 128) + .set_allowed_imports(vec!["math".into(), "time".into(), "utils".into()]) // Whitelist of modules that can be imported + .set_time_budget(TimeBudget::Cheap) // Sets the execution time budget limit to prevent infinite loops (Default: Cheap) + .with_unsafe_mode(false) // Enable or disable system-level unsafe operations (default: false) + .with_nightly(false) // Allow nightly features (default: false) + .with_backtrace(false) // Display backtrace details in error messages (default: false) + .with_explain(false) // Display a more detailed hint in the error message (default: false) + .with_hint(true) // Display a hint on error messages (default: true) + .with_diagnostic_links(false); // Hide links to error-code documentation (default: true) + + let tools = vm.tools(); +} diff --git a/docs/examples/configuration-reference/objectPattern.ts b/docs/examples/configuration-reference/objectPattern.ts new file mode 100644 index 00000000..b7a3464a --- /dev/null +++ b/docs/examples/configuration-reference/objectPattern.ts @@ -0,0 +1,28 @@ +import { LightVM, Capability, TimeBudget } from 'lightvm'; + +const vm = new LightVM({ + caps: [Capability.Observe, Capability.Control], + runtimeConfig: { + nightly: false, // Allow nightly features (default: false) + }, + errorOptions: { + backtrace: false, // Display backtrace details in error messages (default: false) + explain: false, // Display a more detailed hint in the error message (default: false) + hint: true, // Display a hint on error messages (default: true) + diagnosticLinks: false, // Hide links to error-code documentation (default: true) + }, + securityConfig: { + maxIo: 100, // Maximum number of I/O operations allowed (default: 100) + maxImport: 3, // Maximum number of allowed module imports (default: 3) + maxAlloc: 50, // Maximum number of memory allocations allowed (default: 50) + maxCall: 200, // Maximum number of nested function calls allowed (default: 200) + maxJump: 100, // Maximum number of control flow jumps allowed (default: 100) + maxTicks: 1_000_000, // Maximum number of execution ticks before stopping (default: 1,000,000) + maxStackSize: 128, // Maximum number of items the stack can hold (default: 128) + allowedImports: ['math', 'time', 'utils'], // Whitelist of modules that can be imported + timeBudget: TimeBudget.Cheap, // Sets the execution time budget limit to prevent infinite loops (Default: Cheap) + unsafeMode: false, // Enable or disable system-level unsafe operations (default: false) + }, +}); + +const tools = vm.tools(); diff --git a/docs/examples/configuration-reference/object_pattern.rs b/docs/examples/configuration-reference/object_pattern.rs new file mode 100644 index 00000000..523bf2e8 --- /dev/null +++ b/docs/examples/configuration-reference/object_pattern.rs @@ -0,0 +1,38 @@ +use lightvm::LightVM; +use lightvm::types::{ + vmconfig::VmConfig, + runtime_config::RuntimeConfig, + error_options::ErrorOptions, + security_config::SecurityConfig, + capability::Capability, + time_budget::TimeBudget +}; + +fn main() { + let mut vm = LightVM::new(VmConfig { + caps: vec![Capability::Control, Capability::Observe], + runtime_config: Some(RuntimeConfig { + nightly: false // Allow nightly features (default: false) + }), + error_options: Some(ErrorOptions { + backtrace: false, // Display backtrace details in error messages (default: false) + explain: false, // Display a more detailed hint in the error message (default: false) + hint: true, // Display a hint on error messages (default: true) + diagnostic_links: false // Hide links to error-code documentation (default: true) + }), + security_config: Some(SecurityConfig { + max_io: 100, // Maximum number of I/O operations allowed (default: 100) + max_import: 3, // Maximum number of allowed module imports (default: 3) + max_alloc: 50, // Maximum number of memory allocations allowed (default: 50) + max_call: 200, // Maximum number of nested function calls allowed (default: 200) + max_jump: 100, // Maximum number of control flow jumps allowed (default: 100) + max_ticks: 1_000_000, // Maximum number of execution ticks before stopping (default: 1,000,000) + max_stack_size: 128, // Maximum number of items the stack can hold (default: 128) + allowed_imports: vec!["math".into(), "time".into(), "utils".into()], // Whitelist of modules that can be imported + time_budget: TimeBudget::Cheap, // Sets the execution time budget limit to prevent infinite loops (Default: Cheap) + unsafe_mode: false // Enable or disable system-level unsafe operations (default: false) + }) + }); + + let tools = vm.tools(); +} diff --git a/docs/examples/getStarted/builderPattern.ts b/docs/examples/getStarted/builderPattern.ts index c21e4bb8..6afd5b1d 100644 --- a/docs/examples/getStarted/builderPattern.ts +++ b/docs/examples/getStarted/builderPattern.ts @@ -1,20 +1,7 @@ import { LightVM, Capability, TimeBudget } from 'lightvm'; const vm = new LightVM({ caps: [Capability.Observe, Capability.Control] }) - .setMaxIo(100) // Maximum number of I/O operations allowed (default: 100) - .setMaxImport(3) // Maximum number of allowed module imports (default: 3) - .setMaxAlloc(50) // Maximum number of memory allocations allowed (default: 50) - .setMaxCall(200) // Maximum number of nested function calls allowed (default: 200) - .setMaxJump(100) // Maximum number of control flow jumps allowed (default: 100) - .setMaxTicks(1_000_000) // Maximum number of execution ticks before stopping (default: 1,000,000) - .setMaxStackSize(128) // Maximum number of items the stack can hold (default: 128) - .setAllowedImports(['math', 'time', 'utils']) // Whitelist of modules that can be imported - .setTimeBudget(TimeBudget.Cheap) // Sets the execution time budget limit to prevent infinite loops (Default: Cheap) - .withUnsafeMode(false) // Enable or disable system-level unsafe operations (default: false) - .withNightly(false) // Allow nightly features (default: false) - .withBacktrace(false) // Display backtrace details in error messages (default: false) - .withExplain(false) // Display a more detailed hint in the error message (default: false) - .withHint(true) // Display a hint on error messages (default: true) - .withDiagnosticLinks(false); // Hide links to error-code documentation (default: true) + .setMaxTicks(1_000_000) + .setTimeBudget(TimeBudget.Cheap); const tools = vm.tools(); diff --git a/docs/examples/getStarted/builder_pattern.rs b/docs/examples/getStarted/builder_pattern.rs index 9ef97d0b..f98637e2 100644 --- a/docs/examples/getStarted/builder_pattern.rs +++ b/docs/examples/getStarted/builder_pattern.rs @@ -6,21 +6,8 @@ fn main() { caps: vec![Capability::Control, Capability::Observe], ..Default::default() }) - .set_max_io(100) // Maximum number of I/O operations allowed (default: 100) - .set_max_import(3) // Maximum number of allowed module imports (default: 3) - .set_max_alloc(50) // Maximum number of memory allocations allowed (default: 50) - .set_max_call(200) // Maximum number of nested function calls allowed (default: 200) - .set_max_jump(100) // Maximum number of control flow jumps allowed (default: 100) - .set_max_ticks(1_000_000) // Maximum number of execution ticks before stopping (default: 1,000,000) - .set_max_stack_size(128) // Maximum number of items the stack can hold (default: 128) - .set_allowed_imports(vec!["math".into(), "time".into(), "utils".into()]) // Whitelist of modules that can be imported - .set_time_budget(TimeBudget::Cheap) // Sets the execution time budget limit to prevent infinite loops (Default: Cheap) - .with_unsafe_mode(false) // Enable or disable system-level unsafe operations (default: false) - .with_nightly(false) // Allow nightly features (default: false) - .with_backtrace(false) // Display backtrace details in error messages (default: false) - .with_explain(false) // Display a more detailed hint in the error message (default: false) - .with_hint(true) // Display a hint on error messages (default: true) - .with_diagnostic_links(false); // Hide links to error-code documentation (default: true) + .set_max_ticks(1_000_000) + .set_time_budget(TimeBudget::Cheap); let tools = vm.tools(); } diff --git a/docs/examples/getStarted/objectPattern.ts b/docs/examples/getStarted/objectPattern.ts index b7a3464a..7f5de38e 100644 --- a/docs/examples/getStarted/objectPattern.ts +++ b/docs/examples/getStarted/objectPattern.ts @@ -2,26 +2,9 @@ import { LightVM, Capability, TimeBudget } from 'lightvm'; const vm = new LightVM({ caps: [Capability.Observe, Capability.Control], - runtimeConfig: { - nightly: false, // Allow nightly features (default: false) - }, - errorOptions: { - backtrace: false, // Display backtrace details in error messages (default: false) - explain: false, // Display a more detailed hint in the error message (default: false) - hint: true, // Display a hint on error messages (default: true) - diagnosticLinks: false, // Hide links to error-code documentation (default: true) - }, securityConfig: { - maxIo: 100, // Maximum number of I/O operations allowed (default: 100) - maxImport: 3, // Maximum number of allowed module imports (default: 3) - maxAlloc: 50, // Maximum number of memory allocations allowed (default: 50) - maxCall: 200, // Maximum number of nested function calls allowed (default: 200) - maxJump: 100, // Maximum number of control flow jumps allowed (default: 100) - maxTicks: 1_000_000, // Maximum number of execution ticks before stopping (default: 1,000,000) - maxStackSize: 128, // Maximum number of items the stack can hold (default: 128) - allowedImports: ['math', 'time', 'utils'], // Whitelist of modules that can be imported - timeBudget: TimeBudget.Cheap, // Sets the execution time budget limit to prevent infinite loops (Default: Cheap) - unsafeMode: false, // Enable or disable system-level unsafe operations (default: false) + maxTicks: 1_000_000, + timeBudget: TimeBudget.Cheap, }, }); diff --git a/docs/examples/getStarted/object_pattern.rs b/docs/examples/getStarted/object_pattern.rs index 523bf2e8..96c540fd 100644 --- a/docs/examples/getStarted/object_pattern.rs +++ b/docs/examples/getStarted/object_pattern.rs @@ -1,8 +1,6 @@ use lightvm::LightVM; use lightvm::types::{ vmconfig::VmConfig, - runtime_config::RuntimeConfig, - error_options::ErrorOptions, security_config::SecurityConfig, capability::Capability, time_budget::TimeBudget @@ -11,27 +9,12 @@ use lightvm::types::{ fn main() { let mut vm = LightVM::new(VmConfig { caps: vec![Capability::Control, Capability::Observe], - runtime_config: Some(RuntimeConfig { - nightly: false // Allow nightly features (default: false) - }), - error_options: Some(ErrorOptions { - backtrace: false, // Display backtrace details in error messages (default: false) - explain: false, // Display a more detailed hint in the error message (default: false) - hint: true, // Display a hint on error messages (default: true) - diagnostic_links: false // Hide links to error-code documentation (default: true) - }), security_config: Some(SecurityConfig { - max_io: 100, // Maximum number of I/O operations allowed (default: 100) - max_import: 3, // Maximum number of allowed module imports (default: 3) - max_alloc: 50, // Maximum number of memory allocations allowed (default: 50) - max_call: 200, // Maximum number of nested function calls allowed (default: 200) - max_jump: 100, // Maximum number of control flow jumps allowed (default: 100) - max_ticks: 1_000_000, // Maximum number of execution ticks before stopping (default: 1,000,000) - max_stack_size: 128, // Maximum number of items the stack can hold (default: 128) - allowed_imports: vec!["math".into(), "time".into(), "utils".into()], // Whitelist of modules that can be imported - time_budget: TimeBudget::Cheap, // Sets the execution time budget limit to prevent infinite loops (Default: Cheap) - unsafe_mode: false // Enable or disable system-level unsafe operations (default: false) - }) + max_ticks: 1_000_000, + time_budget: TimeBudget::Cheap, + ..Defualt::default(), + }), + ..Defualt::defualt(), }); let tools = vm.tools(); diff --git a/docs/id/api-reference/configuration-reference/typescript-configuration.md b/docs/id/api-reference/configuration-reference/typescript-configuration.md new file mode 100644 index 00000000..897efb87 --- /dev/null +++ b/docs/id/api-reference/configuration-reference/typescript-configuration.md @@ -0,0 +1,32 @@ +# Konfigurasi TypeScript +Halaman ini menyediakan referensi komprehensif untuk semua opsi konfigurasi, batasan, dan kontrol keamanan yang tersedia saat menginisialisasi instance `LightVM`. +## Contoh Konfigurasi Lengkap +Contoh berikut mendemonstrasikan cara mengonfigurasi semua batas, bendera keamanan, dan opsi error yang tersedia menggunakan pola builder maupun object. +::: code-group +<<< @/examples/configuration-reference/builderPattern.ts{ts:line-numbers}[Builder Pattern] +<<< @/examples/configuration-reference/objectPattern.ts{ts:line-numbers}[Object Pattern] +::: +## Rincian Opsi Konfigurasi + +| Method / Properti | Tipe | Default | Deskripsi | +| :--- | :--- | :--- | :--- | +| `caps` | `Capability[]` | `[]` | Menentukan kapabilitas aktif yang diberikan ke virtual machine. | +| `setMaxIo` / `maxIo` | `number` | `100` | Jumlah maksimum operasi I/O yang diizinkan selama eksekusi. | +| `setMaxImport` / `maxImport` | `number` | `3` | Jumlah maksimum impor modul yang diizinkan. | +| `setMaxAlloc` / `maxAlloc` | `number` | `50` | Jumlah maksimum alokasi memori yang diizinkan. | +| `setMaxCall` / `maxCall` | `number` | `200` | Jumlah maksimum pemanggilan fungsi bersarang yang diizinkan. | +| `setMaxJump` / `maxJump` | `number` | `100` | Jumlah maksimum lompatan control flow yang diizinkan. | +| `setMaxTicks` / `maxTicks` | `number` | `1_000_000` | Jumlah maksimum tick eksekusi sebelum berhenti untuk mencegah infinite loop. | +| `setMaxStackSize` / `maxStackSize` | `number` | `128` | Jumlah maksimum item yang dapat ditampung oleh evaluation stack. | +| `setAllowedImports` / `allowedImports` | `string[]` | `[]` | Daftar putih nama modul yang diizinkan untuk diimpor. | +| `setTimeBudget` / `timeBudget` | `TimeBudget` | `TimeBudget.Cheap` | Menetapkan batas tingkatan anggaran waktu eksekusi. | +| `withUnsafeMode` / `unsafeMode` | `boolean` | `false` | Mengaktifkan atau menonaktifkan operasi tingkat sistem yang tidak aman (unsafe). | +| `withNightly` / `nightly` | `boolean` | `false` | Mengizinkan penggunaan fitur nightly eksperimental. | +| `withBacktrace` / `backtrace` | `boolean` | `false` | Menampilkan detail backtrace internal dalam pesan error. | +| `withExplain` / `explain` | `boolean` | `false` | Menampilkan petunjuk penjelasan yang lebih rinci dalam pesan error. | +| `withHint` / `hint` | `boolean` | `true` | Menampilkan petunjuk penggunaan umum pada pesan error. | +| `withDiagnosticLinks` / `diagnosticLinks` | `boolean` | `true` | Menyertakan tautan metadata yang mengarah ke dokumentasi kode error. | + +::: info Dokumentasi Terkait +Perlu memeriksa kode error individual yang disebutkan dalam pesan error? Kunjungi [Referensi Kode Error](/api-reference/error-codes/lvm001-code). +::: \ No newline at end of file diff --git a/docs/id/get-started/quick-usage.md b/docs/id/get-started/quick-usage.md index 8c6de527..47e84df2 100644 --- a/docs/id/get-started/quick-usage.md +++ b/docs/id/get-started/quick-usage.md @@ -23,58 +23,3 @@ Untuk proyek Rust, konfigurasikan `VmConfig` sebelum membuat VM. <<< @/examples/getStarted/object_pattern.rs{rust:line-numbers}[Object Pattern] ::: - -## Tautan diagnostik - -Error VM yang diformat menyertakan baris metadata `documentation:` secara default. URL-nya berasal dari kode `LVM` error dan mengarah ke halaman yang sesuai dalam [referensi kode error](/id/api-reference/error-codes/lvm001-code). - -Nonaktifkan baris tersebut melalui konfigurasi konstruktor atau API fluent: - -::: code-group - -```rust [Native configuration] -let vm = LightVM::new(VmConfig { - error_options: Some(ErrorOptions { - diagnostic_links: false, - ..Default::default() - }), - ..Default::default() -}); - -let vm = LightVM::new(VmConfig::default()) - .with_diagnostic_links(false); -``` - -```ts [Node.js] -const vm = new LightVM({ - errorOptions: { - backtrace: false, - explain: false, - hint: true, - diagnosticLinks: false, - }, -}); - -vm.withDiagnosticLinks(false); -``` - -```ts [WASM] -const vm = new LightVM({ - caps: [], - errorOptions: { diagnosticLinks: false }, -}); - -vm.withDiagnosticLinks(false); -``` - -::: - -Pengaturan yang sama dipertahankan oleh `tools()` dan berlaku untuk error dari operasi alat, termasuk optimasi bytecode. - -## Hasil yang diharapkan - -Anda memiliki instance VM terkonfigurasi yang siap memuat bytecode. Lanjutkan ke [Metode Run](/id/api-reference/method-functions/run-method), atau tinjau [Kapabilitas](/id/api-reference/capabilities) sebelum memberikan akses. - -::: info Referensi API Terkait -`TimeBudget` membatasi waktu optimasi bytecode. Gunakan `SecurityConfig.maxTicks` untuk membatasi pekerjaan eksekusi. -::: diff --git a/docs/id/index.md b/docs/id/index.md index 9c61cf5a..f7ab4e6b 100644 --- a/docs/id/index.md +++ b/docs/id/index.md @@ -33,7 +33,7 @@ hero: link: /id/get-started/installation - theme: alt text: Referensi API - link: /id/api-reference/method-functions/run-method + link: /id/api-reference/configuration-reference/typescript-configuration features: - title: Zero Magic (Deterministik) diff --git a/docs/public/assets/dark/box.svg b/docs/public/assets/dark/box.svg new file mode 100644 index 00000000..525ad167 --- /dev/null +++ b/docs/public/assets/dark/box.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/docs/public/assets/dark/lock.svg b/docs/public/assets/dark/lock.svg new file mode 100644 index 00000000..d7286c0f --- /dev/null +++ b/docs/public/assets/dark/lock.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/docs/public/assets/dark/wand-magic.svg b/docs/public/assets/dark/wand-magic.svg new file mode 100644 index 00000000..a196714d --- /dev/null +++ b/docs/public/assets/dark/wand-magic.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/docs/public/assets/light/box.svg b/docs/public/assets/light/box.svg new file mode 100644 index 00000000..525ad167 --- /dev/null +++ b/docs/public/assets/light/box.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/docs/public/assets/light/lock.svg b/docs/public/assets/light/lock.svg new file mode 100644 index 00000000..d7286c0f --- /dev/null +++ b/docs/public/assets/light/lock.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/docs/public/assets/light/wand-magic.svg b/docs/public/assets/light/wand-magic.svg new file mode 100644 index 00000000..e604c509 --- /dev/null +++ b/docs/public/assets/light/wand-magic.svg @@ -0,0 +1,2 @@ + \ No newline at end of file From 8b7faa8d6420883e9d2da5caa35139f40bc68123 Mon Sep 17 00:00:00 2001 From: Claycuy Date: Sat, 19 Sep 2026 07:28:59 +0800 Subject: [PATCH 02/13] docs: Update docs --- .../lang/en/sidebarConfigurationReference.ts | 4 +-- .../lang/id/sidebarConfigurationReference.ts | 4 +-- .../rust-configuration.md | 35 +++++++++++++++++++ .../configuration-reference/builderPattern.ts | 32 ++++++++--------- .../builder_pattern.rs | 32 ++++++++--------- .../configuration-reference/objectPattern.ts | 32 ++++++++--------- .../configuration-reference/object_pattern.rs | 32 ++++++++--------- docs/examples/getStarted/builderPattern.ts | 2 -- docs/examples/getStarted/builder_pattern.rs | 2 -- docs/examples/getStarted/objectPattern.ts | 2 -- docs/examples/getStarted/object_pattern.rs | 2 -- .../rust-configuration.md | 32 +++++++++++++++++ 12 files changed, 131 insertions(+), 80 deletions(-) create mode 100644 docs/en/api-reference/configuration-reference/rust-configuration.md create mode 100644 docs/id/api-reference/configuration-reference/rust-configuration.md diff --git a/docs/.vitepress/lang/en/sidebarConfigurationReference.ts b/docs/.vitepress/lang/en/sidebarConfigurationReference.ts index 3e55735f..023e9765 100644 --- a/docs/.vitepress/lang/en/sidebarConfigurationReference.ts +++ b/docs/.vitepress/lang/en/sidebarConfigurationReference.ts @@ -7,8 +7,8 @@ export const sidebarConfigurationReference = { link: '/api-reference/configuration-reference/typescript-configuration', }, { - text: 'Embedded Method', - link: '/api-reference/method-functions/embedded-method', + text: 'Rust Configuration', + link: '/api-reference/configuration-reference/rust-configuration', } ], }; diff --git a/docs/.vitepress/lang/id/sidebarConfigurationReference.ts b/docs/.vitepress/lang/id/sidebarConfigurationReference.ts index f1b6dc0d..6ed30f54 100644 --- a/docs/.vitepress/lang/id/sidebarConfigurationReference.ts +++ b/docs/.vitepress/lang/id/sidebarConfigurationReference.ts @@ -7,8 +7,8 @@ export const sidebarConfigurationReference = { link: '/id/api-reference/configuration-reference/typescript-configuration', }, { - text: 'Embedded Method', - link: '/api-reference/method-functions/embedded-method', + text: 'Konfigurasi Rust', + link: '/id/api-reference/configuration-reference/typescript-configuration', } ], }; diff --git a/docs/en/api-reference/configuration-reference/rust-configuration.md b/docs/en/api-reference/configuration-reference/rust-configuration.md new file mode 100644 index 00000000..86d2c7fb --- /dev/null +++ b/docs/en/api-reference/configuration-reference/rust-configuration.md @@ -0,0 +1,35 @@ +# Rust Configuration +This page provides a comprehensive reference for all available configuration options, limits, and security controls when initializing a `LightVM` instance. + +## Full Configuration Example +The following example demonstrates how to configure all available limits, safety flags, and error options using both the builder and object patterns. + +::: code-group +<<< @/examples/configuration-reference/builder_pattern.rs{rs:line-numbers}[Builder Pattern] +<<< @/examples/configuration-reference/object_pattern.rs{rs:line-numbers}[Object Pattern] +::: + +## Configuration Options Breakdown + +| Method / Property | Type | Default | Description | +| :--- | :--- | :--- | :--- | +| `caps` | `Capability[]` | `[]` | Specifies the active capabilities granted to the virtual machine. | +| `set_max_io` / `max_io` | `number` | `100` | Maximum number of I/O operations allowed during execution. | +| `set_max_import` / `max_import` | `number` | `3` | Maximum number of allowed module imports. | +| `set_max_alloc` / `max_alloc` | `number` | `50` | Maximum number of memory allocations allowed. | +| `set_max_call` / `max_call` | `number` | `200` | Maximum number of nested function calls allowed. | +| `set_max_jump` / `max_jump` | `number` | `100` | Maximum number of control flow jumps allowed. | +| `set_max_ticks` / `max_ticks` | `number` | `1_000_000` | Maximum number of execution ticks before stopping to prevent infinite loops. | +| `set_max_stack_size` / `max_stack_size` | `number` | `128` | Maximum number of items the evaluation stack can hold. | +| `set_allowed_imports` / `allowed_imports` | `string[]` | `[]` | Whitelist of module names that are permitted to be imported. | +| `set_time_budget` / `time_budget` | `TimeBudget` | `TimeBudget.Cheap` | Sets the execution time budget tier limit. | +| `with_unsafe_mode` / `unsafe_mode` | `boolean` | `false` | Enables or disables system-level unsafe operations. | +| `with_nightly` / `nightly` | `boolean` | `false` | Allows the usage of experimental nightly features. | +| `with_backtrace` / `backtrace` | `boolean` | `false` | Displays internal backtrace details in error messages. | +| `with_explain` / `explain` | `boolean` | `false` | Displays a more detailed explanatory hint in error messages. | +| `withHint` / `hint` | `boolean` | `true` | Displays general usage hints on error messages. | +| `with_diagnostic_links` / `diagnostic_links` | `boolean` | `true` | Includes metadata links pointing to error-code documentation. | + +::: info Related Documentation +Need to check individual error codes mentioned in error messages? Visit the [Error Code Reference](/api-reference/error-codes/lvm001-code). +::: \ No newline at end of file diff --git a/docs/examples/configuration-reference/builderPattern.ts b/docs/examples/configuration-reference/builderPattern.ts index c21e4bb8..d0e3d47b 100644 --- a/docs/examples/configuration-reference/builderPattern.ts +++ b/docs/examples/configuration-reference/builderPattern.ts @@ -1,20 +1,18 @@ import { LightVM, Capability, TimeBudget } from 'lightvm'; const vm = new LightVM({ caps: [Capability.Observe, Capability.Control] }) - .setMaxIo(100) // Maximum number of I/O operations allowed (default: 100) - .setMaxImport(3) // Maximum number of allowed module imports (default: 3) - .setMaxAlloc(50) // Maximum number of memory allocations allowed (default: 50) - .setMaxCall(200) // Maximum number of nested function calls allowed (default: 200) - .setMaxJump(100) // Maximum number of control flow jumps allowed (default: 100) - .setMaxTicks(1_000_000) // Maximum number of execution ticks before stopping (default: 1,000,000) - .setMaxStackSize(128) // Maximum number of items the stack can hold (default: 128) - .setAllowedImports(['math', 'time', 'utils']) // Whitelist of modules that can be imported - .setTimeBudget(TimeBudget.Cheap) // Sets the execution time budget limit to prevent infinite loops (Default: Cheap) - .withUnsafeMode(false) // Enable or disable system-level unsafe operations (default: false) - .withNightly(false) // Allow nightly features (default: false) - .withBacktrace(false) // Display backtrace details in error messages (default: false) - .withExplain(false) // Display a more detailed hint in the error message (default: false) - .withHint(true) // Display a hint on error messages (default: true) - .withDiagnosticLinks(false); // Hide links to error-code documentation (default: true) - -const tools = vm.tools(); + .setMaxIo(100) + .setMaxImport(3) + .setMaxAlloc(50) + .setMaxCall(200) + .setMaxJump(100) + .setMaxTicks(1_000_000) + .setMaxStackSize(128) + .setAllowedImports(['math', 'time', 'utils']) + .setTimeBudget(TimeBudget.Cheap) + .withUnsafeMode(false) + .withNightly(false) + .withBacktrace(false) + .withExplain(false) + .withHint(true) + .withDiagnosticLinks(false); diff --git a/docs/examples/configuration-reference/builder_pattern.rs b/docs/examples/configuration-reference/builder_pattern.rs index 9ef97d0b..d49aa32e 100644 --- a/docs/examples/configuration-reference/builder_pattern.rs +++ b/docs/examples/configuration-reference/builder_pattern.rs @@ -6,21 +6,19 @@ fn main() { caps: vec![Capability::Control, Capability::Observe], ..Default::default() }) - .set_max_io(100) // Maximum number of I/O operations allowed (default: 100) - .set_max_import(3) // Maximum number of allowed module imports (default: 3) - .set_max_alloc(50) // Maximum number of memory allocations allowed (default: 50) - .set_max_call(200) // Maximum number of nested function calls allowed (default: 200) - .set_max_jump(100) // Maximum number of control flow jumps allowed (default: 100) - .set_max_ticks(1_000_000) // Maximum number of execution ticks before stopping (default: 1,000,000) - .set_max_stack_size(128) // Maximum number of items the stack can hold (default: 128) - .set_allowed_imports(vec!["math".into(), "time".into(), "utils".into()]) // Whitelist of modules that can be imported - .set_time_budget(TimeBudget::Cheap) // Sets the execution time budget limit to prevent infinite loops (Default: Cheap) - .with_unsafe_mode(false) // Enable or disable system-level unsafe operations (default: false) - .with_nightly(false) // Allow nightly features (default: false) - .with_backtrace(false) // Display backtrace details in error messages (default: false) - .with_explain(false) // Display a more detailed hint in the error message (default: false) - .with_hint(true) // Display a hint on error messages (default: true) - .with_diagnostic_links(false); // Hide links to error-code documentation (default: true) - - let tools = vm.tools(); + .set_max_io(100) + .set_max_import(3) + .set_max_alloc(50) + .set_max_call(200) + .set_max_jump(100) + .set_max_ticks(1_000_000) + .set_max_stack_size(128) + .set_allowed_imports(vec!["math".into(), "time".into(), "utils".into()]) + .set_time_budget(TimeBudget::Cheap) + .with_unsafe_mode(false) + .with_nightly(false) + .with_backtrace(false) + .with_explain(false) + .with_hint(true) + .with_diagnostic_links(false); } diff --git a/docs/examples/configuration-reference/objectPattern.ts b/docs/examples/configuration-reference/objectPattern.ts index b7a3464a..02122d8a 100644 --- a/docs/examples/configuration-reference/objectPattern.ts +++ b/docs/examples/configuration-reference/objectPattern.ts @@ -3,26 +3,24 @@ import { LightVM, Capability, TimeBudget } from 'lightvm'; const vm = new LightVM({ caps: [Capability.Observe, Capability.Control], runtimeConfig: { - nightly: false, // Allow nightly features (default: false) + nightly: false, }, errorOptions: { - backtrace: false, // Display backtrace details in error messages (default: false) - explain: false, // Display a more detailed hint in the error message (default: false) - hint: true, // Display a hint on error messages (default: true) - diagnosticLinks: false, // Hide links to error-code documentation (default: true) + backtrace: false, + explain: false, + hint: true, + diagnosticLinks: false, }, securityConfig: { - maxIo: 100, // Maximum number of I/O operations allowed (default: 100) - maxImport: 3, // Maximum number of allowed module imports (default: 3) - maxAlloc: 50, // Maximum number of memory allocations allowed (default: 50) - maxCall: 200, // Maximum number of nested function calls allowed (default: 200) - maxJump: 100, // Maximum number of control flow jumps allowed (default: 100) - maxTicks: 1_000_000, // Maximum number of execution ticks before stopping (default: 1,000,000) - maxStackSize: 128, // Maximum number of items the stack can hold (default: 128) - allowedImports: ['math', 'time', 'utils'], // Whitelist of modules that can be imported - timeBudget: TimeBudget.Cheap, // Sets the execution time budget limit to prevent infinite loops (Default: Cheap) - unsafeMode: false, // Enable or disable system-level unsafe operations (default: false) + maxIo: 100, + maxImport: 3, + maxAlloc: 50, + maxCall: 200, + maxJump: 100, + maxTicks: 1_000_000, + maxStackSize: 128, + allowedImports: ['math', 'time', 'utils'], + timeBudget: TimeBudget.Cheap, + unsafeMode: false, }, }); - -const tools = vm.tools(); diff --git a/docs/examples/configuration-reference/object_pattern.rs b/docs/examples/configuration-reference/object_pattern.rs index 523bf2e8..ae5fe937 100644 --- a/docs/examples/configuration-reference/object_pattern.rs +++ b/docs/examples/configuration-reference/object_pattern.rs @@ -12,27 +12,25 @@ fn main() { let mut vm = LightVM::new(VmConfig { caps: vec![Capability::Control, Capability::Observe], runtime_config: Some(RuntimeConfig { - nightly: false // Allow nightly features (default: false) + nightly: false }), error_options: Some(ErrorOptions { - backtrace: false, // Display backtrace details in error messages (default: false) - explain: false, // Display a more detailed hint in the error message (default: false) - hint: true, // Display a hint on error messages (default: true) - diagnostic_links: false // Hide links to error-code documentation (default: true) + backtrace: false, + explain: false, + hint: true, + diagnostic_links: false }), security_config: Some(SecurityConfig { - max_io: 100, // Maximum number of I/O operations allowed (default: 100) - max_import: 3, // Maximum number of allowed module imports (default: 3) - max_alloc: 50, // Maximum number of memory allocations allowed (default: 50) - max_call: 200, // Maximum number of nested function calls allowed (default: 200) - max_jump: 100, // Maximum number of control flow jumps allowed (default: 100) - max_ticks: 1_000_000, // Maximum number of execution ticks before stopping (default: 1,000,000) - max_stack_size: 128, // Maximum number of items the stack can hold (default: 128) - allowed_imports: vec!["math".into(), "time".into(), "utils".into()], // Whitelist of modules that can be imported - time_budget: TimeBudget::Cheap, // Sets the execution time budget limit to prevent infinite loops (Default: Cheap) - unsafe_mode: false // Enable or disable system-level unsafe operations (default: false) + max_io: 100, + max_import: 3, + max_alloc: 50, + max_call: 200, + max_jump: 100, + max_ticks: 1_000_000, + max_stack_size: 128, + allowed_imports: vec!["math".into(), "time".into(), "utils".into()], + time_budget: TimeBudget::Cheap, + unsafe_mode: false }) }); - - let tools = vm.tools(); } diff --git a/docs/examples/getStarted/builderPattern.ts b/docs/examples/getStarted/builderPattern.ts index 6afd5b1d..c6ca0306 100644 --- a/docs/examples/getStarted/builderPattern.ts +++ b/docs/examples/getStarted/builderPattern.ts @@ -3,5 +3,3 @@ import { LightVM, Capability, TimeBudget } from 'lightvm'; const vm = new LightVM({ caps: [Capability.Observe, Capability.Control] }) .setMaxTicks(1_000_000) .setTimeBudget(TimeBudget.Cheap); - -const tools = vm.tools(); diff --git a/docs/examples/getStarted/builder_pattern.rs b/docs/examples/getStarted/builder_pattern.rs index f98637e2..7113df9e 100644 --- a/docs/examples/getStarted/builder_pattern.rs +++ b/docs/examples/getStarted/builder_pattern.rs @@ -8,6 +8,4 @@ fn main() { }) .set_max_ticks(1_000_000) .set_time_budget(TimeBudget::Cheap); - - let tools = vm.tools(); } diff --git a/docs/examples/getStarted/objectPattern.ts b/docs/examples/getStarted/objectPattern.ts index 7f5de38e..c1115c79 100644 --- a/docs/examples/getStarted/objectPattern.ts +++ b/docs/examples/getStarted/objectPattern.ts @@ -7,5 +7,3 @@ const vm = new LightVM({ timeBudget: TimeBudget.Cheap, }, }); - -const tools = vm.tools(); diff --git a/docs/examples/getStarted/object_pattern.rs b/docs/examples/getStarted/object_pattern.rs index 96c540fd..48ac168c 100644 --- a/docs/examples/getStarted/object_pattern.rs +++ b/docs/examples/getStarted/object_pattern.rs @@ -16,6 +16,4 @@ fn main() { }), ..Defualt::defualt(), }); - - let tools = vm.tools(); } diff --git a/docs/id/api-reference/configuration-reference/rust-configuration.md b/docs/id/api-reference/configuration-reference/rust-configuration.md new file mode 100644 index 00000000..f8ad6e89 --- /dev/null +++ b/docs/id/api-reference/configuration-reference/rust-configuration.md @@ -0,0 +1,32 @@ +# Konfigurasi Rust +Halaman ini menyediakan referensi komprehensif untuk semua opsi konfigurasi, batasan, dan kontrol keamanan yang tersedia saat menginisialisasi instance `LightVM`. +## Contoh Konfigurasi Lengkap +Contoh berikut mendemonstrasikan cara mengonfigurasi semua batas, bendera keamanan, dan opsi error yang tersedia menggunakan pola builder maupun object. +::: code-group +<<< @/examples/configuration-reference/builder_pattern.rs{rs:line-numbers}[Builder Pattern] +<<< @/examples/configuration-reference/object_pattern.rs{rs:line-numbers}[Object Pattern] +::: +## Rincian Opsi Konfigurasi + +| Method / Properti | Tipe | Default | Deskripsi | +| :--- | :--- | :--- | :--- | +| `caps` | `Capability[]` | `[]` | Menentukan kapabilitas aktif yang diberikan ke virtual machine. | +| `set_max_io` / `max_io` | `number` | `100` | Jumlah maksimum operasi I/O yang diizinkan selama eksekusi. | +| `set_max_import` / `max_import` | `number` | `3` | Jumlah maksimum impor modul yang diizinkan. | +| `set_max_alloc` / `max_alloc` | `number` | `50` | Jumlah maksimum alokasi memori yang diizinkan. | +| `set_max_call` / `max_call` | `number` | `200` | Jumlah maksimum pemanggilan fungsi bersarang yang diizinkan. | +| `set_maxJump` / `max_jump` | `number` | `100` | Jumlah maksimum lompatan control flow yang diizinkan. | +| `set_max_ticks` / `max_ticks` | `number` | `1_000_000` | Jumlah maksimum tick eksekusi sebelum berhenti untuk mencegah infinite loop. | +| `set_max_stack_size` / `max_stack_size` | `number` | `128` | Jumlah maksimum item yang dapat ditampung oleh evaluation stack. | +| `set_allowed_imports` / `allowed_imports` | `string[]` | `[]` | Daftar putih nama modul yang diizinkan untuk diimpor. | +| `set_time_budget` / `time_budget` | `TimeBudget` | `TimeBudget.Cheap` | Menetapkan batas tingkatan anggaran waktu eksekusi. | +| `with_unsafe_mode` / `unsafe_mode` | `boolean` | `false` | Mengaktifkan atau menonaktifkan operasi tingkat sistem yang tidak aman (unsafe). | +| `with_nightly` / `nightly` | `boolean` | `false` | Mengizinkan penggunaan fitur nightly eksperimental. | +| `with_backtrace` / `backtrace` | `boolean` | `false` | Menampilkan detail backtrace internal dalam pesan error. | +| `with_explain` / `explain` | `boolean` | `false` | Menampilkan petunjuk penjelasan yang lebih rinci dalam pesan error. | +| `with_hint` / `hint` | `boolean` | `true` | Menampilkan petunjuk penggunaan umum pada pesan error. | +| `with_diagnostic_links` / `diagnostic_links` | `boolean` | `true` | Menyertakan tautan metadata yang mengarah ke dokumentasi kode error. | + +::: info Dokumentasi Terkait +Perlu memeriksa kode error individual yang disebutkan dalam pesan error? Kunjungi [Referensi Kode Error](/api-reference/error-codes/lvm001-code). +::: \ No newline at end of file From b59cbe660a3b29c4618a5b15584519ccc441a5ab Mon Sep 17 00:00:00 2001 From: Claycuy Date: Mon, 21 Sep 2026 09:02:16 +0800 Subject: [PATCH 03/13] docs: Update docs --- docs/.vitepress/en.ts | 2 +- docs/.vitepress/id.ts | 2 +- docs/.vitepress/theme/style.css | 61 ++++++++++++++++++- docs/data/stats.json | 6 +- .../rust-configuration.md | 2 +- docs/en/get-started/installation.md | 4 -- docs/en/get-started/quick-usage.md | 4 ++ .../rust-configuration.md | 2 +- docs/id/get-started/installation.md | 4 -- docs/id/get-started/quick-usage.md | 4 ++ 10 files changed, 73 insertions(+), 18 deletions(-) diff --git a/docs/.vitepress/en.ts b/docs/.vitepress/en.ts index 9b249578..fb801d43 100644 --- a/docs/.vitepress/en.ts +++ b/docs/.vitepress/en.ts @@ -19,7 +19,7 @@ export const enUs = defineConfig({ { text: 'Get Started', link: '/get-started/installation' }, { text: 'API Reference', - link: '/api-reference/method-functions/run-method', + link: '/api-reference/configuration-reference/typescript-configuration', }, { text: 'Concepts', link: '/concepts/what-is' }, navAbout, diff --git a/docs/.vitepress/id.ts b/docs/.vitepress/id.ts index 8f1ec787..bd26a688 100644 --- a/docs/.vitepress/id.ts +++ b/docs/.vitepress/id.ts @@ -19,7 +19,7 @@ export const idId = defineConfig({ { text: 'Memulai', link: '/id/get-started/installation' }, { text: 'Referensi API', - link: '/id/api-reference/method-functions/run-method', + link: '/id/api-reference/configuration-reference/typescript-configuration', }, { text: 'Konsep', link: '/id/concepts/what-is' }, navAbout, diff --git a/docs/.vitepress/theme/style.css b/docs/.vitepress/theme/style.css index 3e68cb9e..ef3422b1 100644 --- a/docs/.vitepress/theme/style.css +++ b/docs/.vitepress/theme/style.css @@ -134,13 +134,68 @@ div[class*="language-"] > pre { .fade-leave-to { opacity: 0; } +@keyframes floatAndGlow { + 0%, 100% { + transform: translateY(0); + filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.05)); + } + 50% { + transform: translateY(-6px); + filter: drop-shadow(0 12px 16px rgba(0, 0, 0, 0.12)); + } +} + /* Light mode (default) */ .VPImage { - filter: none; + animation: floatAndGlow 4s ease-in-out infinite; } /* Dark mode */ .dark .VPImage { - /* Atur filter sesuai kebutuhan, misal di-invert atau diubah brightness-nya */ - filter: invert(1) hue-rotate(180deg); + filter: invert(1) hue-rotate(180deg); + /* Di dark mode, shadow-nya dibikin sedikit lebih terang/glow tipis biar kontras */ + animation: floatAndGlowDark 4s ease-in-out infinite; +} + +@keyframes floatAndGlowDark { + 0%, 100% { + transform: translateY(0); + filter: invert(1) hue-rotate(180deg) drop-shadow(0 4px 6px rgba(255, 255, 255, 0.05)); + } + 50% { + transform: translateY(-6px); + filter: invert(1) hue-rotate(180deg) drop-shadow(0 12px 16px rgba(255, 255, 255, 0.15)); + } +} + +/* Keyframes buat animasi muncul dari bawah ke atas dengan halus */ +@keyframes fadeInUp { + from { + opacity: 0; + transform: translateY(20px); + } + to { + opacity: 1; + transform: translateY(0); + } +} + +/* Terapkan ke elemen teks utama di beranda VitePress (Hero section) */ +.VPHero .name { + animation: fadeInUp 0.8s ease-out forwards; +} + +.VPHero .text { + animation: fadeInUp 0.8s ease-out 0.2s forwards; + opacity: 0; /* Mencegah kedip sebelum animasi mulai */ +} + +.VPHero .tagline { + animation: fadeInUp 0.8s ease-out 0.4s forwards; + opacity: 0; +} + +.VPHero .actions { + animation: fadeInUp 0.8s ease-out 0.6s forwards; + opacity: 0; } diff --git a/docs/data/stats.json b/docs/data/stats.json index 57eb23a4..d9dff8dc 100644 --- a/docs/data/stats.json +++ b/docs/data/stats.json @@ -1,5 +1,5 @@ { - "weekly": "3.5", - "allTime": "42.8", - "updatedAt": "2026-07-28T12:35:48.172Z" + "weekly": "4.0", + "allTime": "96.3", + "updatedAt": "2026-09-21T00:42:01.698Z" } \ No newline at end of file diff --git a/docs/en/api-reference/configuration-reference/rust-configuration.md b/docs/en/api-reference/configuration-reference/rust-configuration.md index 86d2c7fb..d599a0eb 100644 --- a/docs/en/api-reference/configuration-reference/rust-configuration.md +++ b/docs/en/api-reference/configuration-reference/rust-configuration.md @@ -27,7 +27,7 @@ The following example demonstrates how to configure all available limits, safety | `with_nightly` / `nightly` | `boolean` | `false` | Allows the usage of experimental nightly features. | | `with_backtrace` / `backtrace` | `boolean` | `false` | Displays internal backtrace details in error messages. | | `with_explain` / `explain` | `boolean` | `false` | Displays a more detailed explanatory hint in error messages. | -| `withHint` / `hint` | `boolean` | `true` | Displays general usage hints on error messages. | +| `with_hint` / `hint` | `boolean` | `true` | Displays general usage hints on error messages. | | `with_diagnostic_links` / `diagnostic_links` | `boolean` | `true` | Includes metadata links pointing to error-code documentation. | ::: info Related Documentation diff --git a/docs/en/get-started/installation.md b/docs/en/get-started/installation.md index 3c73eaca..39c6abbd 100644 --- a/docs/en/get-started/installation.md +++ b/docs/en/get-started/installation.md @@ -38,7 +38,3 @@ If you're using **Rust**, use **Cargo** to integrate **LightVM** natively. <<< @/examples/installation/cargo-specific.sh{sh:line-numbers}[Specific Version] ::: - -## Expected result - -The package is added to your project manifest and is available to import. Continue with [Quick Usage](/get-started/quick-usage) to create a `LightVM` instance. diff --git a/docs/en/get-started/quick-usage.md b/docs/en/get-started/quick-usage.md index c5453452..89715955 100644 --- a/docs/en/get-started/quick-usage.md +++ b/docs/en/get-started/quick-usage.md @@ -23,3 +23,7 @@ For Rust projects, configure `VmConfig` before creating the VM. <<< @/examples/getStarted/object_pattern.rs{rust:line-numbers}[Object Pattern] ::: + +::: tip Detailed Configuration Reference +For a comprehensive breakdown of each configuration option, parameters, and type details in TypeScript, check out the [TypeScript Configuration Reference](/api-reference/configuration-reference/typescript-configuration) or [Rust Configuration Reference](/api-reference/configuration-reference/rust-configuration). +::: diff --git a/docs/id/api-reference/configuration-reference/rust-configuration.md b/docs/id/api-reference/configuration-reference/rust-configuration.md index f8ad6e89..e2e48204 100644 --- a/docs/id/api-reference/configuration-reference/rust-configuration.md +++ b/docs/id/api-reference/configuration-reference/rust-configuration.md @@ -15,7 +15,7 @@ Contoh berikut mendemonstrasikan cara mengonfigurasi semua batas, bendera keaman | `set_max_import` / `max_import` | `number` | `3` | Jumlah maksimum impor modul yang diizinkan. | | `set_max_alloc` / `max_alloc` | `number` | `50` | Jumlah maksimum alokasi memori yang diizinkan. | | `set_max_call` / `max_call` | `number` | `200` | Jumlah maksimum pemanggilan fungsi bersarang yang diizinkan. | -| `set_maxJump` / `max_jump` | `number` | `100` | Jumlah maksimum lompatan control flow yang diizinkan. | +| `set_max_jump` / `max_jump` | `number` | `100` | Jumlah maksimum lompatan control flow yang diizinkan. | | `set_max_ticks` / `max_ticks` | `number` | `1_000_000` | Jumlah maksimum tick eksekusi sebelum berhenti untuk mencegah infinite loop. | | `set_max_stack_size` / `max_stack_size` | `number` | `128` | Jumlah maksimum item yang dapat ditampung oleh evaluation stack. | | `set_allowed_imports` / `allowed_imports` | `string[]` | `[]` | Daftar putih nama modul yang diizinkan untuk diimpor. | diff --git a/docs/id/get-started/installation.md b/docs/id/get-started/installation.md index 045f6f9d..d4c3356b 100644 --- a/docs/id/get-started/installation.md +++ b/docs/id/get-started/installation.md @@ -38,7 +38,3 @@ Jika Anda menggunakan **Rust**, gunakan **Cargo** untuk mengintegrasikan **Light <<< @/examples/installation/cargo-specific.sh{sh:line-numbers}[Versi Spesifik] ::: - -## Hasil yang diharapkan - -Paket ditambahkan ke manifest proyek dan siap diimpor. Lanjutkan ke [Penggunaan Cepat](/id/get-started/quick-usage) untuk membuat instance `LightVM`. diff --git a/docs/id/get-started/quick-usage.md b/docs/id/get-started/quick-usage.md index 47e84df2..c263e9a0 100644 --- a/docs/id/get-started/quick-usage.md +++ b/docs/id/get-started/quick-usage.md @@ -23,3 +23,7 @@ Untuk proyek Rust, konfigurasikan `VmConfig` sebelum membuat VM. <<< @/examples/getStarted/object_pattern.rs{rust:line-numbers}[Object Pattern] ::: + +::: tip Detail Referensi Konfigurasi +Untuk rincian komprehensif mengenai setiap opsi konfigurasi, parameter, dan detail tipe dalam TypeScript, cek [Referensi Konfigurasi TypeScript](/id/api-reference/configuration-reference/typescript-configuration) atau [Referensi Konfigurasi Rust](/id/api-reference/configuration-reference/rust-configuration). +::: From 31d8d0633f79c0b590a64db81423b2ce6f4769e5 Mon Sep 17 00:00:00 2001 From: claycuy Date: Thu, 24 Sep 2026 18:47:09 +0800 Subject: [PATCH 04/13] docs: Update docs --- docs/.vitepress/lang/en/sidebarAPIReferences.ts | 5 ++--- docs/.vitepress/lang/en/sidebarDataTypes.ts | 9 +++++++++ docs/.vitepress/lang/en/sidebarGetStarted.ts | 2 +- docs/.vitepress/lang/id/sidebarAPIReferences.ts | 5 ++--- docs/.vitepress/lang/id/sidebarDataTypes.ts | 9 +++++++++ docs/.vitepress/lang/id/sidebarGetStarted.ts | 2 +- 6 files changed, 24 insertions(+), 8 deletions(-) create mode 100644 docs/.vitepress/lang/en/sidebarDataTypes.ts create mode 100644 docs/.vitepress/lang/id/sidebarDataTypes.ts diff --git a/docs/.vitepress/lang/en/sidebarAPIReferences.ts b/docs/.vitepress/lang/en/sidebarAPIReferences.ts index d9b4ed0a..19c7f8ae 100644 --- a/docs/.vitepress/lang/en/sidebarAPIReferences.ts +++ b/docs/.vitepress/lang/en/sidebarAPIReferences.ts @@ -1,14 +1,13 @@ import { sidebarConfigurationReference } from './sidebarConfigurationReference.js'; +import { sidebarDataTypes } from './sidebarDataTypes.js'; import { sidebarMethodFunctions } from './sidebarMethodFunctions.js'; import { sidebarInstructionSet } from './sidebarInstructionSet.js'; import { sidebarErrorCodes } from './sidebarErrorCodes.js'; export const sidebarAPIReferences = [ sidebarConfigurationReference, + sidebarDataTypes, sidebarMethodFunctions, - { text: 'Primitive Types', link: '/api-reference/primitive-types' }, - { text: 'Capabilities', link: '/api-reference/capabilities' }, - { text: 'Time Budget', link: '/api-reference/time-budget' }, sidebarInstructionSet, sidebarErrorCodes, ]; diff --git a/docs/.vitepress/lang/en/sidebarDataTypes.ts b/docs/.vitepress/lang/en/sidebarDataTypes.ts new file mode 100644 index 00000000..137660a9 --- /dev/null +++ b/docs/.vitepress/lang/en/sidebarDataTypes.ts @@ -0,0 +1,9 @@ +export const sidebarDataTypes = { + text: 'Data Types', + collapsed: false, + items: [ + { text: 'Primitive Types', link: '/api-reference/primitive-types' }, + { text: 'Capabilities', link: '/api-reference/capabilities' }, + { text: 'Time Budget', link: '/api-reference/time-budget' }, + ], +}; diff --git a/docs/.vitepress/lang/en/sidebarGetStarted.ts b/docs/.vitepress/lang/en/sidebarGetStarted.ts index f9a85ccc..50c4ebc9 100644 --- a/docs/.vitepress/lang/en/sidebarGetStarted.ts +++ b/docs/.vitepress/lang/en/sidebarGetStarted.ts @@ -13,7 +13,7 @@ export const sidebarGetStarted = [ }, { text: 'API References', - link: '/api-reference/method-functions/run-method', + link: '/api-reference/configuration-reference/typescript-configuration', }, { text: 'Concepts', diff --git a/docs/.vitepress/lang/id/sidebarAPIReferences.ts b/docs/.vitepress/lang/id/sidebarAPIReferences.ts index 5b0da717..19c7f8ae 100644 --- a/docs/.vitepress/lang/id/sidebarAPIReferences.ts +++ b/docs/.vitepress/lang/id/sidebarAPIReferences.ts @@ -1,14 +1,13 @@ import { sidebarConfigurationReference } from './sidebarConfigurationReference.js'; +import { sidebarDataTypes } from './sidebarDataTypes.js'; import { sidebarMethodFunctions } from './sidebarMethodFunctions.js'; import { sidebarInstructionSet } from './sidebarInstructionSet.js'; import { sidebarErrorCodes } from './sidebarErrorCodes.js'; export const sidebarAPIReferences = [ sidebarConfigurationReference, + sidebarDataTypes, sidebarMethodFunctions, - { text: 'Tipe Primitif', link: '/id/api-reference/primitive-types' }, - { text: 'Kapabilitas', link: '/id/api-reference/capabilities' }, - { text: 'Batas Waktu Eksekusi', link: '/id/api-reference/time-budget' }, sidebarInstructionSet, sidebarErrorCodes, ]; diff --git a/docs/.vitepress/lang/id/sidebarDataTypes.ts b/docs/.vitepress/lang/id/sidebarDataTypes.ts new file mode 100644 index 00000000..860c7919 --- /dev/null +++ b/docs/.vitepress/lang/id/sidebarDataTypes.ts @@ -0,0 +1,9 @@ +export const sidebarDataTypes = { + text: 'Tipe Data', + collapsed: false, + items: [ + { text: 'Tipe Primitif', link: '/id/api-reference/primitive-types' }, + { text: 'Kapabilitas', link: '/id/api-reference/capabilities' }, + { text: 'Batas Waktu Eksekusi', link: '/id/api-reference/time-budget' }, + ], +}; diff --git a/docs/.vitepress/lang/id/sidebarGetStarted.ts b/docs/.vitepress/lang/id/sidebarGetStarted.ts index 5397a791..16e6ba59 100644 --- a/docs/.vitepress/lang/id/sidebarGetStarted.ts +++ b/docs/.vitepress/lang/id/sidebarGetStarted.ts @@ -13,7 +13,7 @@ export const sidebarGetStarted = [ }, { text: 'Referensi API', - link: '/id/api-reference/method-functions/run-method', + link: '/id/api-reference/configuration-reference/typescript-configuration', }, { text: 'Konsep', From 72e628bc43bf35be059c3f8ee5e79897cb3936b5 Mon Sep 17 00:00:00 2001 From: claycuy Date: Thu, 24 Sep 2026 19:13:58 +0800 Subject: [PATCH 05/13] docs: Update docs --- docs/en/api-reference/method-functions/info-method.md | 4 ++++ docs/examples/methodFunctions/compileWithArray.ts | 2 +- docs/examples/methodFunctions/compile_with_raw_string.rs | 2 +- docs/examples/methodFunctions/compile_with_serde.rs | 2 +- docs/examples/methodFunctions/embeddedCode.ts | 2 +- docs/examples/methodFunctions/embedded_with_raw_string.rs | 2 +- docs/examples/methodFunctions/embedded_with_serde.rs | 2 +- docs/examples/methodFunctions/exportFunction.ts | 2 +- docs/examples/methodFunctions/exportVariable.ts | 2 +- docs/examples/methodFunctions/export_function.rs | 2 +- docs/examples/methodFunctions/export_variable.rs | 4 ++-- docs/examples/methodFunctions/haltCode.ts | 2 +- docs/examples/methodFunctions/halt_code.rs | 4 ++-- docs/examples/methodFunctions/infoCode.ts | 4 ++-- docs/examples/methodFunctions/info_code.rs | 4 ++-- docs/examples/methodFunctions/inspectCode.ts | 2 +- docs/examples/methodFunctions/inspect_code.rs | 2 +- docs/examples/methodFunctions/onEventFinish.ts | 5 +++-- docs/examples/methodFunctions/onEventHalt.ts | 5 +++-- docs/examples/methodFunctions/onEventStart.ts | 5 +++-- docs/examples/methodFunctions/onEventTick.ts | 5 +++-- docs/examples/methodFunctions/on_event_finish.rs | 4 ++-- docs/examples/methodFunctions/on_event_halt.rs | 4 ++-- docs/examples/methodFunctions/on_event_start.rs | 4 ++-- docs/examples/methodFunctions/on_event_tick.rs | 4 ++-- docs/examples/methodFunctions/provideWithArray.ts | 2 +- docs/examples/methodFunctions/provide_with_raw_string.rs | 2 +- docs/examples/methodFunctions/provide_with_serde.rs | 2 +- docs/examples/methodFunctions/runWithArray.ts | 2 +- docs/examples/methodFunctions/run_with_raw_string.rs | 2 +- docs/examples/methodFunctions/run_with_serde.rs | 2 +- .../methodFunctions/toolsMethod/optimizeBytecodeWithArray.ts | 2 +- .../toolsMethod/optimize_bytecode_with_raw_string.rs | 2 +- .../toolsMethod/optimize_bytecode_with_serde.rs | 2 +- docs/examples/methodFunctions/toolsMethod/parseArrayCode.ts | 4 ++-- docs/examples/methodFunctions/toolsMethod/parseCode.ts | 4 ++-- .../examples/methodFunctions/toolsMethod/parse_array_code.rs | 4 ++-- docs/examples/methodFunctions/toolsMethod/parse_code.rs | 4 ++-- .../methodFunctions/toolsMethod/stringifyWithArray.ts | 4 ++-- .../methodFunctions/toolsMethod/stringify_with_raw_string.rs | 4 ++-- .../methodFunctions/toolsMethod/stringify_with_serde.rs | 4 ++-- docs/id/api-reference/method-functions/info-method.md | 4 ++++ 42 files changed, 71 insertions(+), 59 deletions(-) diff --git a/docs/en/api-reference/method-functions/info-method.md b/docs/en/api-reference/method-functions/info-method.md index c80af2ad..4703e21c 100644 --- a/docs/en/api-reference/method-functions/info-method.md +++ b/docs/en/api-reference/method-functions/info-method.md @@ -18,3 +18,7 @@ In **Rust**, you can query the initialized VM instance to inspect current runtim <<< @/examples/methodFunctions/info_code.rs{rust:line-numbers}[Code] ::: + +::: info +**Capability Required**: no specific capability +::: diff --git a/docs/examples/methodFunctions/compileWithArray.ts b/docs/examples/methodFunctions/compileWithArray.ts index 242cf7e1..2c20b1c5 100644 --- a/docs/examples/methodFunctions/compileWithArray.ts +++ b/docs/examples/methodFunctions/compileWithArray.ts @@ -1,6 +1,6 @@ import { Capability, FileType, LightVM, TargetArch } from 'lightvm'; -const vm = new LightVM({ caps: [Capability.Debug] }); +const vm = new LightVM({ caps: [Capability.Control] }); const tools = vm.tools(); const raw = [ diff --git a/docs/examples/methodFunctions/compile_with_raw_string.rs b/docs/examples/methodFunctions/compile_with_raw_string.rs index fd75f38b..7eddc10d 100644 --- a/docs/examples/methodFunctions/compile_with_raw_string.rs +++ b/docs/examples/methodFunctions/compile_with_raw_string.rs @@ -9,7 +9,7 @@ use lightvm::types::{ fn main() { let vm = LightVM::new(VmConfig { - caps: vec![Capability::Debug], + caps: vec![Capability::Control], ..Default::default() }); let tools = vm.tools(); diff --git a/docs/examples/methodFunctions/compile_with_serde.rs b/docs/examples/methodFunctions/compile_with_serde.rs index 85bb893c..0800a69b 100644 --- a/docs/examples/methodFunctions/compile_with_serde.rs +++ b/docs/examples/methodFunctions/compile_with_serde.rs @@ -9,7 +9,7 @@ use lightvm::types::{ fn main() { let vm = LightVM::new(VmConfig { - caps: vec![Capability::Debug], + caps: vec![Capability::Control], ..Default::default() }); let tools = vm.tools(); diff --git a/docs/examples/methodFunctions/embeddedCode.ts b/docs/examples/methodFunctions/embeddedCode.ts index bc871f6f..7d0dbbba 100644 --- a/docs/examples/methodFunctions/embeddedCode.ts +++ b/docs/examples/methodFunctions/embeddedCode.ts @@ -1,6 +1,6 @@ import { Capability, LightVM } from 'lightvm'; -const vm = new LightVM({ caps: [Capability.Debug] }); +const vm = new LightVM({ caps: [Capability.Control, Capability.Observe] }); const tools = vm.tools(); const raw = [['push', 42], ['stop']]; diff --git a/docs/examples/methodFunctions/embedded_with_raw_string.rs b/docs/examples/methodFunctions/embedded_with_raw_string.rs index 40401a1a..676baf7f 100644 --- a/docs/examples/methodFunctions/embedded_with_raw_string.rs +++ b/docs/examples/methodFunctions/embedded_with_raw_string.rs @@ -3,7 +3,7 @@ use lightvm::{vmconfig::VmConfig, capability::Capability}; fn main() { let vm = LightVM::new(VmConfig { - caps: vec![Capability::Debug], + caps: vec![Capability::Control, Capability::Observe], ..Default::default() }); let tools = vm.tools(); diff --git a/docs/examples/methodFunctions/embedded_with_serde.rs b/docs/examples/methodFunctions/embedded_with_serde.rs index ff9e6f06..b14b8b2c 100644 --- a/docs/examples/methodFunctions/embedded_with_serde.rs +++ b/docs/examples/methodFunctions/embedded_with_serde.rs @@ -3,7 +3,7 @@ use lightvm::types::{capability::Capability, vmconfig::VmConfig}; fn main() { let mut vm = LightVM::new(VmConfig { - caps: vec![Capability::Debug], + caps: vec![Capability::Control, Capability::Observe], ..Default::default() }); let tools = vm.tools(); diff --git a/docs/examples/methodFunctions/exportFunction.ts b/docs/examples/methodFunctions/exportFunction.ts index 827ef016..1d2c89f3 100644 --- a/docs/examples/methodFunctions/exportFunction.ts +++ b/docs/examples/methodFunctions/exportFunction.ts @@ -1,6 +1,6 @@ import { Capability, LightVM } from 'lightvm'; -const vm = new LightVM({ caps: [Capability.Debug] }); +const vm = new LightVM({ caps: [Capability.Control] }); const tools = vm.tools(); const raw = [ diff --git a/docs/examples/methodFunctions/exportVariable.ts b/docs/examples/methodFunctions/exportVariable.ts index 06127598..acdb6ff4 100644 --- a/docs/examples/methodFunctions/exportVariable.ts +++ b/docs/examples/methodFunctions/exportVariable.ts @@ -1,6 +1,6 @@ import { Capability, LightVM } from 'lightvm'; -const vm = new LightVM({ caps: [Capability.Debug] }); +const vm = new LightVM({ caps: [Capability.Control] }); const tools = vm.tools(); const raw = [ diff --git a/docs/examples/methodFunctions/export_function.rs b/docs/examples/methodFunctions/export_function.rs index 27b98734..8409ba59 100644 --- a/docs/examples/methodFunctions/export_function.rs +++ b/docs/examples/methodFunctions/export_function.rs @@ -3,7 +3,7 @@ use lightvm::types::{capability::Capability, vmconfig::VmConfig}; fn main() { let mut vm = LightVM::new(VmConfig { - caps: vec![Capability::Debug], + caps: vec![Capability::Control], ..Default::default() }); let tools = vm.tools(); diff --git a/docs/examples/methodFunctions/export_variable.rs b/docs/examples/methodFunctions/export_variable.rs index cd9040bc..71cad2d6 100644 --- a/docs/examples/methodFunctions/export_variable.rs +++ b/docs/examples/methodFunctions/export_variable.rs @@ -3,7 +3,7 @@ use lightvm::types::{capability::Capability, vmconfig::VmConfig}; fn main() { let mut vm = LightVM::new(VmConfig { - caps: vec![Capability::Debug], + caps: vec![Capability::Control], ..Default::default() }); let tools = vm.tools(); @@ -19,6 +19,6 @@ fn main() { vm.load(optimized); let score_variable = vm.export("score".to_string()); - + println!("{:?}", score_variable.call(&mut vm, vec![])); } diff --git a/docs/examples/methodFunctions/haltCode.ts b/docs/examples/methodFunctions/haltCode.ts index 1325c298..3d85d8e6 100644 --- a/docs/examples/methodFunctions/haltCode.ts +++ b/docs/examples/methodFunctions/haltCode.ts @@ -1,6 +1,6 @@ import { Capability, LightVM } from 'lightvm'; -const vm = new LightVM({ caps: [Capability.Debug] }); +const vm = new LightVM({ caps: [Capability.Unsafe] }); vm.halt(); vm.run(); // will not be executed diff --git a/docs/examples/methodFunctions/halt_code.rs b/docs/examples/methodFunctions/halt_code.rs index 54b3b716..8a4f2935 100644 --- a/docs/examples/methodFunctions/halt_code.rs +++ b/docs/examples/methodFunctions/halt_code.rs @@ -3,12 +3,12 @@ use lightvm::types::{capability::Capability, vmconfig::VmConfig}; fn main() { let mut vm = LightVM::new(VmConfig { - caps: vec![Capability::Debug], + caps: vec![Capability::Unsafe], ..Default::default() }); vm.halt(); vm.run(None); // will not be executed - + println!("The VM has been terminated."); } diff --git a/docs/examples/methodFunctions/infoCode.ts b/docs/examples/methodFunctions/infoCode.ts index 8d32f8b6..c0a54a64 100644 --- a/docs/examples/methodFunctions/infoCode.ts +++ b/docs/examples/methodFunctions/infoCode.ts @@ -1,5 +1,5 @@ -import { Capability, LightVM } from 'lightvm'; +import { LightVM } from 'lightvm'; -const vm = new LightVM({ caps: [Capability.Debug] }); +const vm = new LightVM({ caps: [] }); console.log(vm.info()); diff --git a/docs/examples/methodFunctions/info_code.rs b/docs/examples/methodFunctions/info_code.rs index 9e3c30b0..f669dcf1 100644 --- a/docs/examples/methodFunctions/info_code.rs +++ b/docs/examples/methodFunctions/info_code.rs @@ -1,9 +1,9 @@ use lightvm::LightVM; -use lightvm::types::{capability::Capability, vmconfig::VmConfig}; +use lightvm::types::{vmconfig::VmConfig}; fn main() { let mut vm = LightVM::new(VmConfig { - caps: vec![Capability::Debug], + caps: vec![], ..Default::default() }); diff --git a/docs/examples/methodFunctions/inspectCode.ts b/docs/examples/methodFunctions/inspectCode.ts index dfc33ff8..72e40362 100644 --- a/docs/examples/methodFunctions/inspectCode.ts +++ b/docs/examples/methodFunctions/inspectCode.ts @@ -1,5 +1,5 @@ import { Capability, LightVM } from 'lightvm'; -const vm = new LightVM({ caps: [Capability.Debug] }); +const vm = new LightVM({ caps: [Capability.Control] }); const report = vm.inspect(); console.log(report); diff --git a/docs/examples/methodFunctions/inspect_code.rs b/docs/examples/methodFunctions/inspect_code.rs index 2b18a155..60f29b54 100644 --- a/docs/examples/methodFunctions/inspect_code.rs +++ b/docs/examples/methodFunctions/inspect_code.rs @@ -3,7 +3,7 @@ use lightvm::types::{capability::Capability, vmconfig::VmConfig}; fn main() { let vm = LightVM::new(VmConfig { - caps: vec![Capability::Debug], + caps: vec![Capability::Control], ..Default::default() }); diff --git a/docs/examples/methodFunctions/onEventFinish.ts b/docs/examples/methodFunctions/onEventFinish.ts index 4cccf168..8140e05b 100644 --- a/docs/examples/methodFunctions/onEventFinish.ts +++ b/docs/examples/methodFunctions/onEventFinish.ts @@ -1,6 +1,7 @@ -import { Capability, LightVM, VMEvent } from 'lightvm'; +import { LightVM, VMEvent } from 'lightvm'; + +const vm = new LightVM({ caps: [] }); -const vm = new LightVM({ caps: [Capability.Debug] }); vm.on(VMEvent.Finish, (data) => { console.log('Event: ', data.event); console.log('Payload: ', data.payload); diff --git a/docs/examples/methodFunctions/onEventHalt.ts b/docs/examples/methodFunctions/onEventHalt.ts index 7046d7a7..367a134c 100644 --- a/docs/examples/methodFunctions/onEventHalt.ts +++ b/docs/examples/methodFunctions/onEventHalt.ts @@ -1,6 +1,7 @@ -import { Capability, LightVM, VMEvent } from 'lightvm'; +import { LightVM, VMEvent } from 'lightvm'; + +const vm = new LightVM({ caps: [] }); -const vm = new LightVM({ caps: [Capability.Debug] }); vm.on(VMEvent.Halt, (data) => { console.log('Event: ', data.event); console.log('Payload: ', data.payload); diff --git a/docs/examples/methodFunctions/onEventStart.ts b/docs/examples/methodFunctions/onEventStart.ts index 3edea97f..524b8c5a 100644 --- a/docs/examples/methodFunctions/onEventStart.ts +++ b/docs/examples/methodFunctions/onEventStart.ts @@ -1,6 +1,7 @@ -import { Capability, LightVM, VMEvent } from 'lightvm'; +import { LightVM, VMEvent } from 'lightvm'; + +const vm = new LightVM({ caps: [] }); -const vm = new LightVM({ caps: [Capability.Debug] }); vm.on(VMEvent.Start, (data) => { console.log('Event: ', data.event); console.log('Payload: ', data.payload); diff --git a/docs/examples/methodFunctions/onEventTick.ts b/docs/examples/methodFunctions/onEventTick.ts index eb1d357f..612d7722 100644 --- a/docs/examples/methodFunctions/onEventTick.ts +++ b/docs/examples/methodFunctions/onEventTick.ts @@ -1,6 +1,7 @@ -import { Capability, LightVM, VMEvent } from 'lightvm'; +import { LightVM, VMEvent } from 'lightvm'; + +const vm = new LightVM({ caps: [] }); -const vm = new LightVM({ caps: [Capability.Debug] }); vm.on(VMEvent.Tick, (data) => { console.log('Event: ', data.event); console.log('Payload: ', data.payload); diff --git a/docs/examples/methodFunctions/on_event_finish.rs b/docs/examples/methodFunctions/on_event_finish.rs index c7993902..f291d1e1 100644 --- a/docs/examples/methodFunctions/on_event_finish.rs +++ b/docs/examples/methodFunctions/on_event_finish.rs @@ -1,9 +1,9 @@ use lightvm::LightVM; -use lightvm::types::{capability::Capability, vmconfig::VmConfig, vmevent::VmEvent}; +use lightvm::types::{vmconfig::VmConfig, vmevent::VmEvent}; fn main() { let mut vm = LightVM::new(VmConfig { - caps: vec![Capability::Debug, Capability::Control], + caps: vec![], ..Default::default() }); diff --git a/docs/examples/methodFunctions/on_event_halt.rs b/docs/examples/methodFunctions/on_event_halt.rs index 3bf14a6e..872789af 100644 --- a/docs/examples/methodFunctions/on_event_halt.rs +++ b/docs/examples/methodFunctions/on_event_halt.rs @@ -1,9 +1,9 @@ use lightvm::LightVM; -use lightvm::types::{capability::Capability, vmconfig::VmConfig, vmevent::VmEvent}; +use lightvm::types::{vmconfig::VmConfig, vmevent::VmEvent}; fn main() { let mut vm = LightVM::new(VmConfig { - caps: vec![Capability::Debug, Capability::Unsafe], + caps: vec![], ..Default::default() }); diff --git a/docs/examples/methodFunctions/on_event_start.rs b/docs/examples/methodFunctions/on_event_start.rs index 9407bf41..57da984b 100644 --- a/docs/examples/methodFunctions/on_event_start.rs +++ b/docs/examples/methodFunctions/on_event_start.rs @@ -1,9 +1,9 @@ use lightvm::LightVM; -use lightvm::types::{capability::Capability, vmconfig::VmConfig, vmevent::VmEvent}; +use lightvm::types::{vmconfig::VmConfig, vmevent::VmEvent}; fn main() { let mut vm = LightVM::new(VmConfig { - caps: vec![Capability::Debug, Capability::Control], + caps: vec![], ..Default::default() }); diff --git a/docs/examples/methodFunctions/on_event_tick.rs b/docs/examples/methodFunctions/on_event_tick.rs index 6c2e0dbb..8a9e1073 100644 --- a/docs/examples/methodFunctions/on_event_tick.rs +++ b/docs/examples/methodFunctions/on_event_tick.rs @@ -1,9 +1,9 @@ use lightvm::LightVM; -use lightvm::types::{capability::Capability, vmconfig::VmConfig, vmevent::VmEvent}; +use lightvm::types::{vmconfig::VmConfig, vmevent::VmEvent}; fn main() { let mut vm = LightVM::new(VmConfig { - caps: vec![Capability::Debug], + caps: vec![], ..Default::default() }); diff --git a/docs/examples/methodFunctions/provideWithArray.ts b/docs/examples/methodFunctions/provideWithArray.ts index c9a3b94a..f7a71105 100644 --- a/docs/examples/methodFunctions/provideWithArray.ts +++ b/docs/examples/methodFunctions/provideWithArray.ts @@ -1,6 +1,6 @@ import { Capability, LightVM } from 'lightvm'; -const vm = new LightVM({ caps: [Capability.Debug] }); +const vm = new LightVM({ caps: [Capability.Control] }); vm.provide({ name: 'John Doe', force: 2021, diff --git a/docs/examples/methodFunctions/provide_with_raw_string.rs b/docs/examples/methodFunctions/provide_with_raw_string.rs index 7dafec99..a6e19465 100644 --- a/docs/examples/methodFunctions/provide_with_raw_string.rs +++ b/docs/examples/methodFunctions/provide_with_raw_string.rs @@ -3,7 +3,7 @@ use lightvm::types::{capability::Capability, vmconfig::VmConfig}; fn main() { let mut vm = LightVM::new(VmConfig { - caps: vec![Capability::Debug, Capability::Control], + caps: vec![Capability::Control], ..Default::default() }); diff --git a/docs/examples/methodFunctions/provide_with_serde.rs b/docs/examples/methodFunctions/provide_with_serde.rs index 5f81a19c..d9a0340b 100644 --- a/docs/examples/methodFunctions/provide_with_serde.rs +++ b/docs/examples/methodFunctions/provide_with_serde.rs @@ -3,7 +3,7 @@ use lightvm::types::{capability::Capability, vmconfig::VmConfig}; fn main() { let mut vm = LightVM::new(VmConfig { - caps: vec![Capability::Debug, Capability::Control], + caps: vec![Capability::Control], ..Default::default() }); diff --git a/docs/examples/methodFunctions/runWithArray.ts b/docs/examples/methodFunctions/runWithArray.ts index fb5192c1..cecad385 100644 --- a/docs/examples/methodFunctions/runWithArray.ts +++ b/docs/examples/methodFunctions/runWithArray.ts @@ -1,6 +1,6 @@ import { Capability, LightVM } from 'lightvm'; -const vm = new LightVM({ caps: [Capability.Debug] }); +const vm = new LightVM({ caps: [Capability.Control] }); const tools = vm.tools(); const raw = [ diff --git a/docs/examples/methodFunctions/run_with_raw_string.rs b/docs/examples/methodFunctions/run_with_raw_string.rs index ebdbe966..13b38f95 100644 --- a/docs/examples/methodFunctions/run_with_raw_string.rs +++ b/docs/examples/methodFunctions/run_with_raw_string.rs @@ -3,7 +3,7 @@ use lightvm::types::{capability::Capability, vmconfig::VmConfig}; fn main() { let mut vm = LightVM::new(VmConfig { - caps: vec![Capability::Debug], + caps: vec![Capability::Control], ..Default::default() }); let tools = vm.tools(); diff --git a/docs/examples/methodFunctions/run_with_serde.rs b/docs/examples/methodFunctions/run_with_serde.rs index d4fce344..90de4a92 100644 --- a/docs/examples/methodFunctions/run_with_serde.rs +++ b/docs/examples/methodFunctions/run_with_serde.rs @@ -3,7 +3,7 @@ use lightvm::types::{capability::Capability, vmconfig::VmConfig}; fn main() { let mut vm = LightVM::new(VmConfig { - caps: vec![Capability::Debug], + caps: vec![Capability::Control], ..Default::default() }); let tools = vm.tools(); diff --git a/docs/examples/methodFunctions/toolsMethod/optimizeBytecodeWithArray.ts b/docs/examples/methodFunctions/toolsMethod/optimizeBytecodeWithArray.ts index 7adf4ed7..d63cdfa6 100644 --- a/docs/examples/methodFunctions/toolsMethod/optimizeBytecodeWithArray.ts +++ b/docs/examples/methodFunctions/toolsMethod/optimizeBytecodeWithArray.ts @@ -1,6 +1,6 @@ import { Capability, LightVM } from 'lightvm'; -const vm = new LightVM({ caps: [Capability.Debug] }); +const vm = new LightVM({ caps: [Capability.Control] }); const tools = vm.tools(); const raw = [ diff --git a/docs/examples/methodFunctions/toolsMethod/optimize_bytecode_with_raw_string.rs b/docs/examples/methodFunctions/toolsMethod/optimize_bytecode_with_raw_string.rs index 64aa120b..ee488331 100644 --- a/docs/examples/methodFunctions/toolsMethod/optimize_bytecode_with_raw_string.rs +++ b/docs/examples/methodFunctions/toolsMethod/optimize_bytecode_with_raw_string.rs @@ -3,7 +3,7 @@ use lightvm::types::{capability::Capability, vmconfig::VmConfig}; fn main() { let mut vm = LightVM::new(VmConfig { - caps: vec![Capability::Debug], + caps: vec![Capability::Control], ..Default::default() }); let tools = vm.tools(); diff --git a/docs/examples/methodFunctions/toolsMethod/optimize_bytecode_with_serde.rs b/docs/examples/methodFunctions/toolsMethod/optimize_bytecode_with_serde.rs index d005392d..11075d9b 100644 --- a/docs/examples/methodFunctions/toolsMethod/optimize_bytecode_with_serde.rs +++ b/docs/examples/methodFunctions/toolsMethod/optimize_bytecode_with_serde.rs @@ -3,7 +3,7 @@ use lightvm::types::{capability::Capability, vmconfig::VmConfig}; fn main() { let mut vm = LightVM::new(VmConfig { - caps: vec![Capability::Debug], + caps: vec![Capability::Control], ..Default::default() }); let tools = vm.tools(); diff --git a/docs/examples/methodFunctions/toolsMethod/parseArrayCode.ts b/docs/examples/methodFunctions/toolsMethod/parseArrayCode.ts index 37a91689..293e1e99 100644 --- a/docs/examples/methodFunctions/toolsMethod/parseArrayCode.ts +++ b/docs/examples/methodFunctions/toolsMethod/parseArrayCode.ts @@ -1,6 +1,6 @@ -import { Capability, LightVM } from 'lightvm'; +import { LightVM } from 'lightvm'; -const vm = new LightVM({ caps: [Capability.Debug] }); +const vm = new LightVM({ caps: [] }); const tools = vm.tools(); const strVal = ` diff --git a/docs/examples/methodFunctions/toolsMethod/parseCode.ts b/docs/examples/methodFunctions/toolsMethod/parseCode.ts index 9a2ece9a..6aa9b399 100644 --- a/docs/examples/methodFunctions/toolsMethod/parseCode.ts +++ b/docs/examples/methodFunctions/toolsMethod/parseCode.ts @@ -1,6 +1,6 @@ -import { Capability, LightVM } from 'lightvm'; +import { LightVM } from 'lightvm'; -const vm = new LightVM({ caps: [Capability.Debug] }); +const vm = new LightVM({ caps: [] }); const tools = vm.tools(); const strVal = ` diff --git a/docs/examples/methodFunctions/toolsMethod/parse_array_code.rs b/docs/examples/methodFunctions/toolsMethod/parse_array_code.rs index 79452396..3f24ab6f 100644 --- a/docs/examples/methodFunctions/toolsMethod/parse_array_code.rs +++ b/docs/examples/methodFunctions/toolsMethod/parse_array_code.rs @@ -1,9 +1,9 @@ use lightvm::LightVM; -use lightvm::types::{capability::Capability, vmconfig::VmConfig}; +use lightvm::types::{vmconfig::VmConfig}; fn main() { let mut vm = LightVM::new(VmConfig { - caps: vec![Capability::Debug], + caps: vec![], ..Default::default() }); let tools = vm.tools(); diff --git a/docs/examples/methodFunctions/toolsMethod/parse_code.rs b/docs/examples/methodFunctions/toolsMethod/parse_code.rs index bcd10772..aaa742b5 100644 --- a/docs/examples/methodFunctions/toolsMethod/parse_code.rs +++ b/docs/examples/methodFunctions/toolsMethod/parse_code.rs @@ -1,9 +1,9 @@ use lightvm::LightVM; -use lightvm::types::{capability::Capability, vmconfig::VmConfig}; +use lightvm::types::{vmconfig::VmConfig}; fn main() { let mut vm = LightVM::new(VmConfig { - caps: vec![Capability::Debug], + caps: vec![], ..Default::default() }); let tools = vm.tools(); diff --git a/docs/examples/methodFunctions/toolsMethod/stringifyWithArray.ts b/docs/examples/methodFunctions/toolsMethod/stringifyWithArray.ts index dc6220dc..488fc42b 100644 --- a/docs/examples/methodFunctions/toolsMethod/stringifyWithArray.ts +++ b/docs/examples/methodFunctions/toolsMethod/stringifyWithArray.ts @@ -1,6 +1,6 @@ -import { Capability, LightVM } from 'lightvm'; +import { LightVM } from 'lightvm'; -const vm = new LightVM({ caps: [Capability.Debug] }); +const vm = new LightVM({ caps: [] }); const tools = vm.tools(); const raw = [ diff --git a/docs/examples/methodFunctions/toolsMethod/stringify_with_raw_string.rs b/docs/examples/methodFunctions/toolsMethod/stringify_with_raw_string.rs index 6faad88d..b98ecfb6 100644 --- a/docs/examples/methodFunctions/toolsMethod/stringify_with_raw_string.rs +++ b/docs/examples/methodFunctions/toolsMethod/stringify_with_raw_string.rs @@ -1,9 +1,9 @@ use lightvm::LightVM; -use lightvm::types::{capability::Capability, vmconfig::VmConfig}; +use lightvm::types::{vmconfig::VmConfig}; fn main() { let mut vm = LightVM::new(VmConfig { - caps: vec![Capability::Debug], + caps: vec![], ..Default::default() }); let tools = vm.tools(); diff --git a/docs/examples/methodFunctions/toolsMethod/stringify_with_serde.rs b/docs/examples/methodFunctions/toolsMethod/stringify_with_serde.rs index 6be8c642..84fb54bd 100644 --- a/docs/examples/methodFunctions/toolsMethod/stringify_with_serde.rs +++ b/docs/examples/methodFunctions/toolsMethod/stringify_with_serde.rs @@ -1,9 +1,9 @@ use lightvm::LightVM; -use lightvm::types::{capability::Capability, vmconfig::VmConfig}; +use lightvm::types::{vmconfig::VmConfig}; fn main() { let mut vm = LightVM::new(VmConfig { - caps: vec![Capability::Debug], + caps: vec![], ..Default::default() }); let tools = vm.tools(); diff --git a/docs/id/api-reference/method-functions/info-method.md b/docs/id/api-reference/method-functions/info-method.md index e47f39fe..aff0d108 100644 --- a/docs/id/api-reference/method-functions/info-method.md +++ b/docs/id/api-reference/method-functions/info-method.md @@ -18,3 +18,7 @@ Dalam **Rust**, Anda dapat menquery instance VM yang telah diinisialisasi untuk <<< @/examples/methodFunctions/info_code.rs{rust:line-numbers}[Kode] ::: + +::: info +**Kapabilitas yang Dibutuhkan**: tidak ada kapabilitas khusus +::: From 8afc9c967ad5dacbbfce54b93584c344245a1d5d Mon Sep 17 00:00:00 2001 From: claycuy Date: Thu, 24 Sep 2026 19:28:02 +0800 Subject: [PATCH 06/13] docs: Update docs --- docs/examples/methodFunctions/compileWithArray.ts | 2 ++ .../methodFunctions/compile_with_raw_string.rs | 4 +++- docs/examples/methodFunctions/compile_with_serde.rs | 4 +++- docs/examples/methodFunctions/provideWithArray.ts | 13 ++++++++++++- .../methodFunctions/provide_with_raw_string.rs | 3 ++- docs/examples/methodFunctions/provide_with_serde.rs | 3 ++- docs/examples/methodFunctions/runWithArray.ts | 2 ++ .../examples/methodFunctions/run_with_raw_string.rs | 4 +++- docs/examples/methodFunctions/run_with_serde.rs | 4 +++- 9 files changed, 32 insertions(+), 7 deletions(-) diff --git a/docs/examples/methodFunctions/compileWithArray.ts b/docs/examples/methodFunctions/compileWithArray.ts index 2c20b1c5..c20a424b 100644 --- a/docs/examples/methodFunctions/compileWithArray.ts +++ b/docs/examples/methodFunctions/compileWithArray.ts @@ -7,6 +7,8 @@ const raw = [ ['push', 5], ['val', 'x'], ['set', 'x'], + ['get', 'x'], + ['println'] ]; const optimized = tools.optimizeBytecode(raw); vm.load(optimized).compile({ diff --git a/docs/examples/methodFunctions/compile_with_raw_string.rs b/docs/examples/methodFunctions/compile_with_raw_string.rs index 7eddc10d..cddf80d1 100644 --- a/docs/examples/methodFunctions/compile_with_raw_string.rs +++ b/docs/examples/methodFunctions/compile_with_raw_string.rs @@ -17,7 +17,9 @@ fn main() { let raw = r#"[ ["push", 5], ["val", "x"], - ["set", "x"] + ["set", "x"], + ["get", "x"], + ["println"] ]"#; let optimized = tools.optimize_bytecode(raw); diff --git a/docs/examples/methodFunctions/compile_with_serde.rs b/docs/examples/methodFunctions/compile_with_serde.rs index 0800a69b..de8e3550 100644 --- a/docs/examples/methodFunctions/compile_with_serde.rs +++ b/docs/examples/methodFunctions/compile_with_serde.rs @@ -17,7 +17,9 @@ fn main() { let raw = serde_json::json!([ ["push", 5], ["val", "x"], - ["set", "x"] + ["set", "x"], + ["get", "x"], + ["println"] ]); let optimized = tools.optimize_bytecode(raw); diff --git a/docs/examples/methodFunctions/provideWithArray.ts b/docs/examples/methodFunctions/provideWithArray.ts index f7a71105..53a92d38 100644 --- a/docs/examples/methodFunctions/provideWithArray.ts +++ b/docs/examples/methodFunctions/provideWithArray.ts @@ -1,8 +1,19 @@ import { Capability, LightVM } from 'lightvm'; const vm = new LightVM({ caps: [Capability.Control] }); +const tools = vm.tools(); + vm.provide({ name: 'John Doe', force: 2021, }); -const raw = [['get', 'name'], ['println'], ['get', 'force'], ['println']]; + +const raw = [ + ['get', 'name'], + ['println'], + ['get', 'force'], + ['println'] +]; + +const optimized = tools.optimizeBytecode(raw); +vm.load(optimized).run(); diff --git a/docs/examples/methodFunctions/provide_with_raw_string.rs b/docs/examples/methodFunctions/provide_with_raw_string.rs index a6e19465..03ca1a43 100644 --- a/docs/examples/methodFunctions/provide_with_raw_string.rs +++ b/docs/examples/methodFunctions/provide_with_raw_string.rs @@ -6,6 +6,7 @@ fn main() { caps: vec![Capability::Control], ..Default::default() }); + let tools = vm.tools(); vm.provide(serde_json::json!({ "name": "John Doe", @@ -19,7 +20,7 @@ fn main() { ["println"] ]"#; - let optimized = vm.tools().optimize_bytecode(raw); + let optimized = tools.optimize_bytecode(raw); vm.load(optimized) .run(None); } diff --git a/docs/examples/methodFunctions/provide_with_serde.rs b/docs/examples/methodFunctions/provide_with_serde.rs index d9a0340b..6580603a 100644 --- a/docs/examples/methodFunctions/provide_with_serde.rs +++ b/docs/examples/methodFunctions/provide_with_serde.rs @@ -6,6 +6,7 @@ fn main() { caps: vec![Capability::Control], ..Default::default() }); + let tools = vm.tools(); vm.provide(serde_json::json!({ "name": "John Doe", @@ -19,7 +20,7 @@ fn main() { ["println"] ]); - let optimized = vm.tools().optimize_bytecode(raw); + let optimized = tools.optimize_bytecode(raw); vm.load(optimized) .run(None); } diff --git a/docs/examples/methodFunctions/runWithArray.ts b/docs/examples/methodFunctions/runWithArray.ts index cecad385..bc432fc4 100644 --- a/docs/examples/methodFunctions/runWithArray.ts +++ b/docs/examples/methodFunctions/runWithArray.ts @@ -7,6 +7,8 @@ const raw = [ ['push', 5], ['val', 'x'], ['set', 'x'], + ['get', 'x'], + ['println'] ]; const optimized = tools.optimizeBytecode(raw); vm.load(optimized).run(); diff --git a/docs/examples/methodFunctions/run_with_raw_string.rs b/docs/examples/methodFunctions/run_with_raw_string.rs index 13b38f95..f2bfb81e 100644 --- a/docs/examples/methodFunctions/run_with_raw_string.rs +++ b/docs/examples/methodFunctions/run_with_raw_string.rs @@ -11,7 +11,9 @@ fn main() { let raw = r#"[ ["push", 5], ["val", "x"], - ["set", "x"] + ["set", "x"], + ["get", "x"], + ["println"] ]"#; let optimized = tools.optimize_bytecode(raw); diff --git a/docs/examples/methodFunctions/run_with_serde.rs b/docs/examples/methodFunctions/run_with_serde.rs index 90de4a92..2eb3d7fa 100644 --- a/docs/examples/methodFunctions/run_with_serde.rs +++ b/docs/examples/methodFunctions/run_with_serde.rs @@ -11,7 +11,9 @@ fn main() { let raw = serde_json::json!([ ["push", 5], ["val", "x"], - ["set", "x"] + ["set", "x"], + ["get", "x"], + ["println"] ]); let optimized = tools.optimize_bytecode(raw); From 128d04c4db84467a9ea5c2698813f89979dda967 Mon Sep 17 00:00:00 2001 From: claycuy Date: Thu, 24 Sep 2026 19:38:44 +0800 Subject: [PATCH 07/13] docs: Update docs --- docs/examples/methodFunctions/compileWithArray.ts | 5 ++++- docs/examples/methodFunctions/embeddedCode.ts | 8 +++++++- docs/examples/methodFunctions/exportFunction.ts | 3 +++ docs/examples/methodFunctions/exportVariable.ts | 3 +++ docs/examples/methodFunctions/haltCode.ts | 1 + docs/examples/methodFunctions/inspectCode.ts | 2 ++ docs/examples/methodFunctions/provideWithArray.ts | 3 ++- docs/examples/methodFunctions/runWithArray.ts | 4 +++- .../toolsMethod/optimizeBytecodeWithArray.ts | 2 ++ .../methodFunctions/toolsMethod/parseArrayCode.ts | 2 ++ docs/examples/methodFunctions/toolsMethod/parseCode.ts | 2 ++ .../methodFunctions/toolsMethod/stringifyWithArray.ts | 2 ++ 12 files changed, 33 insertions(+), 4 deletions(-) diff --git a/docs/examples/methodFunctions/compileWithArray.ts b/docs/examples/methodFunctions/compileWithArray.ts index c20a424b..4d6674d0 100644 --- a/docs/examples/methodFunctions/compileWithArray.ts +++ b/docs/examples/methodFunctions/compileWithArray.ts @@ -10,8 +10,11 @@ const raw = [ ['get', 'x'], ['println'] ]; + const optimized = tools.optimizeBytecode(raw); -vm.load(optimized).compile({ +vm.load(optimized); + +vm.compile({ targetArch: TargetArch.AArch64, fileType: FileType.Binary, path: './bin/output', diff --git a/docs/examples/methodFunctions/embeddedCode.ts b/docs/examples/methodFunctions/embeddedCode.ts index 7d0dbbba..634129af 100644 --- a/docs/examples/methodFunctions/embeddedCode.ts +++ b/docs/examples/methodFunctions/embeddedCode.ts @@ -3,8 +3,14 @@ import { Capability, LightVM } from 'lightvm'; const vm = new LightVM({ caps: [Capability.Control, Capability.Observe] }); const tools = vm.tools(); -const raw = [['push', 42], ['stop']]; +const raw = [ + ['push', 42], + ['stop'] +]; + const optimized = tools.optimizeBytecode(raw); vm.load(optimized); + const result = vm.embedded(); + console.log(result); diff --git a/docs/examples/methodFunctions/exportFunction.ts b/docs/examples/methodFunctions/exportFunction.ts index 1d2c89f3..71552b18 100644 --- a/docs/examples/methodFunctions/exportFunction.ts +++ b/docs/examples/methodFunctions/exportFunction.ts @@ -13,7 +13,10 @@ const raw = [ ['stop'], ['export', 'add'], ]; + const optimized = tools.optimizeBytecode(raw); vm.load(optimized); + const addFunc = vm.export('add'); + console.log(addFunc.call(5, 6)); diff --git a/docs/examples/methodFunctions/exportVariable.ts b/docs/examples/methodFunctions/exportVariable.ts index acdb6ff4..3dac88e3 100644 --- a/docs/examples/methodFunctions/exportVariable.ts +++ b/docs/examples/methodFunctions/exportVariable.ts @@ -9,7 +9,10 @@ const raw = [ ['set', 'score'], ['export', 'score'], ]; + const optimized = tools.optimizeBytecode(raw); vm.load(optimized); + const scoreVar = vm.export('score'); + console.log(scoreVar.call()); diff --git a/docs/examples/methodFunctions/haltCode.ts b/docs/examples/methodFunctions/haltCode.ts index 3d85d8e6..06d041ff 100644 --- a/docs/examples/methodFunctions/haltCode.ts +++ b/docs/examples/methodFunctions/haltCode.ts @@ -4,4 +4,5 @@ const vm = new LightVM({ caps: [Capability.Unsafe] }); vm.halt(); vm.run(); // will not be executed + console.log('The VM has been terminated.'); diff --git a/docs/examples/methodFunctions/inspectCode.ts b/docs/examples/methodFunctions/inspectCode.ts index 72e40362..b2d325ac 100644 --- a/docs/examples/methodFunctions/inspectCode.ts +++ b/docs/examples/methodFunctions/inspectCode.ts @@ -1,5 +1,7 @@ import { Capability, LightVM } from 'lightvm'; const vm = new LightVM({ caps: [Capability.Control] }); + const report = vm.inspect(); + console.log(report); diff --git a/docs/examples/methodFunctions/provideWithArray.ts b/docs/examples/methodFunctions/provideWithArray.ts index 53a92d38..78192891 100644 --- a/docs/examples/methodFunctions/provideWithArray.ts +++ b/docs/examples/methodFunctions/provideWithArray.ts @@ -16,4 +16,5 @@ const raw = [ ]; const optimized = tools.optimizeBytecode(raw); -vm.load(optimized).run(); +vm.load(optimized) + .run(); diff --git a/docs/examples/methodFunctions/runWithArray.ts b/docs/examples/methodFunctions/runWithArray.ts index bc432fc4..0fa7cedc 100644 --- a/docs/examples/methodFunctions/runWithArray.ts +++ b/docs/examples/methodFunctions/runWithArray.ts @@ -10,5 +10,7 @@ const raw = [ ['get', 'x'], ['println'] ]; + const optimized = tools.optimizeBytecode(raw); -vm.load(optimized).run(); +vm.load(optimized) + .run(); diff --git a/docs/examples/methodFunctions/toolsMethod/optimizeBytecodeWithArray.ts b/docs/examples/methodFunctions/toolsMethod/optimizeBytecodeWithArray.ts index d63cdfa6..3ec914d1 100644 --- a/docs/examples/methodFunctions/toolsMethod/optimizeBytecodeWithArray.ts +++ b/docs/examples/methodFunctions/toolsMethod/optimizeBytecodeWithArray.ts @@ -8,5 +8,7 @@ const raw = [ ['val', 'x'], ['set', 'x'], ]; + const optimized = tools.optimizeBytecode(raw); + console.log(optimized); diff --git a/docs/examples/methodFunctions/toolsMethod/parseArrayCode.ts b/docs/examples/methodFunctions/toolsMethod/parseArrayCode.ts index 293e1e99..3e973388 100644 --- a/docs/examples/methodFunctions/toolsMethod/parseArrayCode.ts +++ b/docs/examples/methodFunctions/toolsMethod/parseArrayCode.ts @@ -8,5 +8,7 @@ const strVal = ` val x; ;; IP=1 set x; ;; IP=2 `; + const parsed = tools.parseLTCArray(strVal); + console.log(parsed); diff --git a/docs/examples/methodFunctions/toolsMethod/parseCode.ts b/docs/examples/methodFunctions/toolsMethod/parseCode.ts index 6aa9b399..afe453bb 100644 --- a/docs/examples/methodFunctions/toolsMethod/parseCode.ts +++ b/docs/examples/methodFunctions/toolsMethod/parseCode.ts @@ -8,5 +8,7 @@ const strVal = ` val x; ;; IP=1 set x; ;; IP=2 `; + const parsed = tools.parseLTC(strVal); + console.log(parsed); diff --git a/docs/examples/methodFunctions/toolsMethod/stringifyWithArray.ts b/docs/examples/methodFunctions/toolsMethod/stringifyWithArray.ts index 488fc42b..3a2ae716 100644 --- a/docs/examples/methodFunctions/toolsMethod/stringifyWithArray.ts +++ b/docs/examples/methodFunctions/toolsMethod/stringifyWithArray.ts @@ -8,5 +8,7 @@ const raw = [ ['val', 'x'], ['set', 'x'], ]; + const stringify = tools.stringifyLTC(raw); + console.log(stringify); From 0e0df4b6a2b99dddb8c898237141d81139cf176f Mon Sep 17 00:00:00 2001 From: "coderabbitai[bot]" <136622811+coderabbitai[bot]@users.noreply.github.com> Date: Thu, 24 Sep 2026 12:29:16 +0000 Subject: [PATCH 08/13] fix: Forward security config and correct documentation Correct configuration types, defaults, and example capabilities; fix asset and sidebar links and respect reduced motion. --- .../lang/id/sidebarConfigurationReference.ts | 4 +-- docs/.vitepress/theme/style.css | 17 ++++++++++ .../rust-configuration.md | 34 +++++++++---------- .../typescript-configuration.md | 4 +-- docs/en/index.md | 8 ++--- docs/examples/getStarted/object_pattern.rs | 4 +-- .../methodFunctions/exportVariable.ts | 5 ++- .../methodFunctions/export_variable.rs | 7 ++-- docs/examples/methodFunctions/inspectCode.ts | 2 +- docs/examples/methodFunctions/inspect_code.rs | 2 +- .../methodFunctions/on_event_finish.rs | 4 +-- .../examples/methodFunctions/on_event_halt.rs | 4 +-- .../methodFunctions/on_event_start.rs | 4 +-- .../rust-configuration.md | 34 +++++++++---------- .../typescript-configuration.md | 4 +-- ts/src/index.ts | 1 + 16 files changed, 81 insertions(+), 57 deletions(-) diff --git a/docs/.vitepress/lang/id/sidebarConfigurationReference.ts b/docs/.vitepress/lang/id/sidebarConfigurationReference.ts index 6ed30f54..e5980256 100644 --- a/docs/.vitepress/lang/id/sidebarConfigurationReference.ts +++ b/docs/.vitepress/lang/id/sidebarConfigurationReference.ts @@ -8,7 +8,7 @@ export const sidebarConfigurationReference = { }, { text: 'Konfigurasi Rust', - link: '/id/api-reference/configuration-reference/typescript-configuration', - } + link: '/id/api-reference/configuration-reference/rust-configuration', + }, ], }; diff --git a/docs/.vitepress/theme/style.css b/docs/.vitepress/theme/style.css index ef3422b1..faf152e2 100644 --- a/docs/.vitepress/theme/style.css +++ b/docs/.vitepress/theme/style.css @@ -199,3 +199,20 @@ div[class*="language-"] > pre { animation: fadeInUp 0.8s ease-out 0.6s forwards; opacity: 0; } + +@media (prefers-reduced-motion: reduce) { + .VPImage, + .dark .VPImage, + .VPHero .name, + .VPHero .text, + .VPHero .tagline, + .VPHero .actions { + animation: none; + } + + .VPHero .text, + .VPHero .tagline, + .VPHero .actions { + opacity: 1; + } +} diff --git a/docs/en/api-reference/configuration-reference/rust-configuration.md b/docs/en/api-reference/configuration-reference/rust-configuration.md index d599a0eb..be84c888 100644 --- a/docs/en/api-reference/configuration-reference/rust-configuration.md +++ b/docs/en/api-reference/configuration-reference/rust-configuration.md @@ -13,23 +13,23 @@ The following example demonstrates how to configure all available limits, safety | Method / Property | Type | Default | Description | | :--- | :--- | :--- | :--- | -| `caps` | `Capability[]` | `[]` | Specifies the active capabilities granted to the virtual machine. | -| `set_max_io` / `max_io` | `number` | `100` | Maximum number of I/O operations allowed during execution. | -| `set_max_import` / `max_import` | `number` | `3` | Maximum number of allowed module imports. | -| `set_max_alloc` / `max_alloc` | `number` | `50` | Maximum number of memory allocations allowed. | -| `set_max_call` / `max_call` | `number` | `200` | Maximum number of nested function calls allowed. | -| `set_max_jump` / `max_jump` | `number` | `100` | Maximum number of control flow jumps allowed. | -| `set_max_ticks` / `max_ticks` | `number` | `1_000_000` | Maximum number of execution ticks before stopping to prevent infinite loops. | -| `set_max_stack_size` / `max_stack_size` | `number` | `128` | Maximum number of items the evaluation stack can hold. | -| `set_allowed_imports` / `allowed_imports` | `string[]` | `[]` | Whitelist of module names that are permitted to be imported. | -| `set_time_budget` / `time_budget` | `TimeBudget` | `TimeBudget.Cheap` | Sets the execution time budget tier limit. | -| `with_unsafe_mode` / `unsafe_mode` | `boolean` | `false` | Enables or disables system-level unsafe operations. | -| `with_nightly` / `nightly` | `boolean` | `false` | Allows the usage of experimental nightly features. | -| `with_backtrace` / `backtrace` | `boolean` | `false` | Displays internal backtrace details in error messages. | -| `with_explain` / `explain` | `boolean` | `false` | Displays a more detailed explanatory hint in error messages. | -| `with_hint` / `hint` | `boolean` | `true` | Displays general usage hints on error messages. | -| `with_diagnostic_links` / `diagnostic_links` | `boolean` | `true` | Includes metadata links pointing to error-code documentation. | +| `caps` | `Vec` | `vec![]` (grants `Capability::Observe`) | Specifies the active capabilities granted to the virtual machine. | +| `set_max_io` / `max_io` | `usize` | `100` | Maximum number of I/O operations allowed during execution. | +| `set_max_import` / `max_import` | `usize` | `3` | Maximum number of allowed module imports. | +| `set_max_alloc` / `max_alloc` | `usize` | `50` | Maximum number of memory allocations allowed. | +| `set_max_call` / `max_call` | `usize` | `200` | Maximum number of nested function calls allowed. | +| `set_max_jump` / `max_jump` | `usize` | `100` | Maximum number of control flow jumps allowed. | +| `set_max_ticks` / `max_ticks` | `u64` | `1_000_000` | Maximum number of execution ticks before stopping to prevent infinite loops. | +| `set_max_stack_size` / `max_stack_size` | `usize` | `128` | Maximum number of items the evaluation stack can hold. | +| `set_allowed_imports` / `allowed_imports` | `Vec` | `vec!["math".into(), "time".into(), "utils".into()]` | Whitelist of module names that are permitted to be imported. | +| `set_time_budget` / `time_budget` | `TimeBudget` | `TimeBudget::Cheap` | Sets the execution time budget tier limit. | +| `with_unsafe_mode` / `unsafe_mode` | `bool` | `false` | Enables or disables system-level unsafe operations. | +| `with_nightly` / `nightly` | `bool` | `false` | Allows the usage of experimental nightly features. | +| `with_backtrace` / `backtrace` | `bool` | `false` | Displays internal backtrace details in error messages. | +| `with_explain` / `explain` | `bool` | `false` | Displays a more detailed explanatory hint in error messages. | +| `with_hint` / `hint` | `bool` | `true` | Displays general usage hints on error messages. | +| `with_diagnostic_links` / `diagnostic_links` | `bool` | `true` | Includes metadata links pointing to error-code documentation. | ::: info Related Documentation Need to check individual error codes mentioned in error messages? Visit the [Error Code Reference](/api-reference/error-codes/lvm001-code). -::: \ No newline at end of file +::: diff --git a/docs/en/api-reference/configuration-reference/typescript-configuration.md b/docs/en/api-reference/configuration-reference/typescript-configuration.md index 71ce8be4..5ae5902c 100644 --- a/docs/en/api-reference/configuration-reference/typescript-configuration.md +++ b/docs/en/api-reference/configuration-reference/typescript-configuration.md @@ -13,7 +13,7 @@ The following example demonstrates how to configure all available limits, safety | Method / Property | Type | Default | Description | | :--- | :--- | :--- | :--- | -| `caps` | `Capability[]` | `[]` | Specifies the active capabilities granted to the virtual machine. | +| `caps` | `Capability[]` | `[Capability.Observe]` | Specifies the active capabilities granted to the virtual machine. | | `setMaxIo` / `maxIo` | `number` | `100` | Maximum number of I/O operations allowed during execution. | | `setMaxImport` / `maxImport` | `number` | `3` | Maximum number of allowed module imports. | | `setMaxAlloc` / `maxAlloc` | `number` | `50` | Maximum number of memory allocations allowed. | @@ -32,4 +32,4 @@ The following example demonstrates how to configure all available limits, safety ::: info Related Documentation Need to check individual error codes mentioned in error messages? Visit the [Error Code Reference](/api-reference/error-codes/lvm001-code). -::: \ No newline at end of file +::: diff --git a/docs/en/index.md b/docs/en/index.md index 1314411f..2b9192ac 100644 --- a/docs/en/index.md +++ b/docs/en/index.md @@ -37,17 +37,17 @@ hero: features: - icon: - src: /public/assets/light/wand-magic.svg + src: /assets/light/wand-magic.svg title: Zero Magic details: Instruction execution is linear and completely predictable. The VM operates explicitly, executing instructions exactly as they are defined. - icon: - src: /public/assets/light/box.svg + src: /assets/light/box.svg title: Resource Conscious details: Designed with a minimal memory footprint through the use of optimized data structures such as SmolStr and ahash for fast metadata management. - icon: - src: /public/assets/light/lock.svg + src: /assets/light/lock.svg title: Explicit Security details: Security is managed through a strict Capability system. Every VM access and operation must have permissions explicitly defined by the host from the outset. --- - \ No newline at end of file + diff --git a/docs/examples/getStarted/object_pattern.rs b/docs/examples/getStarted/object_pattern.rs index 48ac168c..9d84cb46 100644 --- a/docs/examples/getStarted/object_pattern.rs +++ b/docs/examples/getStarted/object_pattern.rs @@ -12,8 +12,8 @@ fn main() { security_config: Some(SecurityConfig { max_ticks: 1_000_000, time_budget: TimeBudget::Cheap, - ..Defualt::default(), + ..Default::default() }), - ..Defualt::defualt(), + ..Default::default() }); } diff --git a/docs/examples/methodFunctions/exportVariable.ts b/docs/examples/methodFunctions/exportVariable.ts index 3dac88e3..2a6f08d2 100644 --- a/docs/examples/methodFunctions/exportVariable.ts +++ b/docs/examples/methodFunctions/exportVariable.ts @@ -1,6 +1,9 @@ import { Capability, LightVM } from 'lightvm'; -const vm = new LightVM({ caps: [Capability.Control] }); +const vm = new LightVM({ + caps: [Capability.Control, Capability.Observe], + runtimeConfig: { nightly: true }, +}); const tools = vm.tools(); const raw = [ diff --git a/docs/examples/methodFunctions/export_variable.rs b/docs/examples/methodFunctions/export_variable.rs index 71cad2d6..cb164104 100644 --- a/docs/examples/methodFunctions/export_variable.rs +++ b/docs/examples/methodFunctions/export_variable.rs @@ -1,9 +1,12 @@ use lightvm::LightVM; -use lightvm::types::{capability::Capability, vmconfig::VmConfig}; +use lightvm::types::{ + capability::Capability, runtime_config::RuntimeConfig, vmconfig::VmConfig, +}; fn main() { let mut vm = LightVM::new(VmConfig { - caps: vec![Capability::Control], + caps: vec![Capability::Control, Capability::Observe], + runtime_config: Some(RuntimeConfig { nightly: true }), ..Default::default() }); let tools = vm.tools(); diff --git a/docs/examples/methodFunctions/inspectCode.ts b/docs/examples/methodFunctions/inspectCode.ts index b2d325ac..08c064ed 100644 --- a/docs/examples/methodFunctions/inspectCode.ts +++ b/docs/examples/methodFunctions/inspectCode.ts @@ -1,6 +1,6 @@ import { Capability, LightVM } from 'lightvm'; -const vm = new LightVM({ caps: [Capability.Control] }); +const vm = new LightVM({ caps: [Capability.Observe] }); const report = vm.inspect(); diff --git a/docs/examples/methodFunctions/inspect_code.rs b/docs/examples/methodFunctions/inspect_code.rs index 60f29b54..eabe62ba 100644 --- a/docs/examples/methodFunctions/inspect_code.rs +++ b/docs/examples/methodFunctions/inspect_code.rs @@ -3,7 +3,7 @@ use lightvm::types::{capability::Capability, vmconfig::VmConfig}; fn main() { let vm = LightVM::new(VmConfig { - caps: vec![Capability::Control], + caps: vec![Capability::Observe], ..Default::default() }); diff --git a/docs/examples/methodFunctions/on_event_finish.rs b/docs/examples/methodFunctions/on_event_finish.rs index f291d1e1..22bd4c03 100644 --- a/docs/examples/methodFunctions/on_event_finish.rs +++ b/docs/examples/methodFunctions/on_event_finish.rs @@ -1,9 +1,9 @@ use lightvm::LightVM; -use lightvm::types::{vmconfig::VmConfig, vmevent::VmEvent}; +use lightvm::types::{capability::Capability, vmconfig::VmConfig, vmevent::VmEvent}; fn main() { let mut vm = LightVM::new(VmConfig { - caps: vec![], + caps: vec![Capability::Control], ..Default::default() }); diff --git a/docs/examples/methodFunctions/on_event_halt.rs b/docs/examples/methodFunctions/on_event_halt.rs index 872789af..7f2c0401 100644 --- a/docs/examples/methodFunctions/on_event_halt.rs +++ b/docs/examples/methodFunctions/on_event_halt.rs @@ -1,9 +1,9 @@ use lightvm::LightVM; -use lightvm::types::{vmconfig::VmConfig, vmevent::VmEvent}; +use lightvm::types::{capability::Capability, vmconfig::VmConfig, vmevent::VmEvent}; fn main() { let mut vm = LightVM::new(VmConfig { - caps: vec![], + caps: vec![Capability::Unsafe], ..Default::default() }); diff --git a/docs/examples/methodFunctions/on_event_start.rs b/docs/examples/methodFunctions/on_event_start.rs index 57da984b..7ccc0136 100644 --- a/docs/examples/methodFunctions/on_event_start.rs +++ b/docs/examples/methodFunctions/on_event_start.rs @@ -1,9 +1,9 @@ use lightvm::LightVM; -use lightvm::types::{vmconfig::VmConfig, vmevent::VmEvent}; +use lightvm::types::{capability::Capability, vmconfig::VmConfig, vmevent::VmEvent}; fn main() { let mut vm = LightVM::new(VmConfig { - caps: vec![], + caps: vec![Capability::Control], ..Default::default() }); diff --git a/docs/id/api-reference/configuration-reference/rust-configuration.md b/docs/id/api-reference/configuration-reference/rust-configuration.md index e2e48204..121af7ee 100644 --- a/docs/id/api-reference/configuration-reference/rust-configuration.md +++ b/docs/id/api-reference/configuration-reference/rust-configuration.md @@ -10,23 +10,23 @@ Contoh berikut mendemonstrasikan cara mengonfigurasi semua batas, bendera keaman | Method / Properti | Tipe | Default | Deskripsi | | :--- | :--- | :--- | :--- | -| `caps` | `Capability[]` | `[]` | Menentukan kapabilitas aktif yang diberikan ke virtual machine. | -| `set_max_io` / `max_io` | `number` | `100` | Jumlah maksimum operasi I/O yang diizinkan selama eksekusi. | -| `set_max_import` / `max_import` | `number` | `3` | Jumlah maksimum impor modul yang diizinkan. | -| `set_max_alloc` / `max_alloc` | `number` | `50` | Jumlah maksimum alokasi memori yang diizinkan. | -| `set_max_call` / `max_call` | `number` | `200` | Jumlah maksimum pemanggilan fungsi bersarang yang diizinkan. | -| `set_max_jump` / `max_jump` | `number` | `100` | Jumlah maksimum lompatan control flow yang diizinkan. | -| `set_max_ticks` / `max_ticks` | `number` | `1_000_000` | Jumlah maksimum tick eksekusi sebelum berhenti untuk mencegah infinite loop. | -| `set_max_stack_size` / `max_stack_size` | `number` | `128` | Jumlah maksimum item yang dapat ditampung oleh evaluation stack. | -| `set_allowed_imports` / `allowed_imports` | `string[]` | `[]` | Daftar putih nama modul yang diizinkan untuk diimpor. | -| `set_time_budget` / `time_budget` | `TimeBudget` | `TimeBudget.Cheap` | Menetapkan batas tingkatan anggaran waktu eksekusi. | -| `with_unsafe_mode` / `unsafe_mode` | `boolean` | `false` | Mengaktifkan atau menonaktifkan operasi tingkat sistem yang tidak aman (unsafe). | -| `with_nightly` / `nightly` | `boolean` | `false` | Mengizinkan penggunaan fitur nightly eksperimental. | -| `with_backtrace` / `backtrace` | `boolean` | `false` | Menampilkan detail backtrace internal dalam pesan error. | -| `with_explain` / `explain` | `boolean` | `false` | Menampilkan petunjuk penjelasan yang lebih rinci dalam pesan error. | -| `with_hint` / `hint` | `boolean` | `true` | Menampilkan petunjuk penggunaan umum pada pesan error. | -| `with_diagnostic_links` / `diagnostic_links` | `boolean` | `true` | Menyertakan tautan metadata yang mengarah ke dokumentasi kode error. | +| `caps` | `Vec` | `vec![]` (memberikan `Capability::Observe`) | Menentukan kapabilitas aktif yang diberikan ke virtual machine. | +| `set_max_io` / `max_io` | `usize` | `100` | Jumlah maksimum operasi I/O yang diizinkan selama eksekusi. | +| `set_max_import` / `max_import` | `usize` | `3` | Jumlah maksimum impor modul yang diizinkan. | +| `set_max_alloc` / `max_alloc` | `usize` | `50` | Jumlah maksimum alokasi memori yang diizinkan. | +| `set_max_call` / `max_call` | `usize` | `200` | Jumlah maksimum pemanggilan fungsi bersarang yang diizinkan. | +| `set_max_jump` / `max_jump` | `usize` | `100` | Jumlah maksimum lompatan control flow yang diizinkan. | +| `set_max_ticks` / `max_ticks` | `u64` | `1_000_000` | Jumlah maksimum tick eksekusi sebelum berhenti untuk mencegah infinite loop. | +| `set_max_stack_size` / `max_stack_size` | `usize` | `128` | Jumlah maksimum item yang dapat ditampung oleh evaluation stack. | +| `set_allowed_imports` / `allowed_imports` | `Vec` | `vec!["math".into(), "time".into(), "utils".into()]` | Daftar putih nama modul yang diizinkan untuk diimpor. | +| `set_time_budget` / `time_budget` | `TimeBudget` | `TimeBudget::Cheap` | Menetapkan batas tingkatan anggaran waktu eksekusi. | +| `with_unsafe_mode` / `unsafe_mode` | `bool` | `false` | Mengaktifkan atau menonaktifkan operasi tingkat sistem yang tidak aman (unsafe). | +| `with_nightly` / `nightly` | `bool` | `false` | Mengizinkan penggunaan fitur nightly eksperimental. | +| `with_backtrace` / `backtrace` | `bool` | `false` | Menampilkan detail backtrace internal dalam pesan error. | +| `with_explain` / `explain` | `bool` | `false` | Menampilkan petunjuk penjelasan yang lebih rinci dalam pesan error. | +| `with_hint` / `hint` | `bool` | `true` | Menampilkan petunjuk penggunaan umum pada pesan error. | +| `with_diagnostic_links` / `diagnostic_links` | `bool` | `true` | Menyertakan tautan metadata yang mengarah ke dokumentasi kode error. | ::: info Dokumentasi Terkait Perlu memeriksa kode error individual yang disebutkan dalam pesan error? Kunjungi [Referensi Kode Error](/api-reference/error-codes/lvm001-code). -::: \ No newline at end of file +::: diff --git a/docs/id/api-reference/configuration-reference/typescript-configuration.md b/docs/id/api-reference/configuration-reference/typescript-configuration.md index 897efb87..1d42a9a6 100644 --- a/docs/id/api-reference/configuration-reference/typescript-configuration.md +++ b/docs/id/api-reference/configuration-reference/typescript-configuration.md @@ -10,7 +10,7 @@ Contoh berikut mendemonstrasikan cara mengonfigurasi semua batas, bendera keaman | Method / Properti | Tipe | Default | Deskripsi | | :--- | :--- | :--- | :--- | -| `caps` | `Capability[]` | `[]` | Menentukan kapabilitas aktif yang diberikan ke virtual machine. | +| `caps` | `Capability[]` | `[Capability.Observe]` | Menentukan kapabilitas aktif yang diberikan ke virtual machine. | | `setMaxIo` / `maxIo` | `number` | `100` | Jumlah maksimum operasi I/O yang diizinkan selama eksekusi. | | `setMaxImport` / `maxImport` | `number` | `3` | Jumlah maksimum impor modul yang diizinkan. | | `setMaxAlloc` / `maxAlloc` | `number` | `50` | Jumlah maksimum alokasi memori yang diizinkan. | @@ -29,4 +29,4 @@ Contoh berikut mendemonstrasikan cara mengonfigurasi semua batas, bendera keaman ::: info Dokumentasi Terkait Perlu memeriksa kode error individual yang disebutkan dalam pesan error? Kunjungi [Referensi Kode Error](/api-reference/error-codes/lvm001-code). -::: \ No newline at end of file +::: diff --git a/ts/src/index.ts b/ts/src/index.ts index f8c2af27..e715ee31 100644 --- a/ts/src/index.ts +++ b/ts/src/index.ts @@ -103,6 +103,7 @@ export class LightVM { capsRaw: this.config.caps, runtimeConfig: this.config.runtimeConfig, errorOptions: this.config.errorOptions, + securityConfig: this.config.securityConfig, }), ); } From 4b413eba0a9cad18ccc10f0af5ad29f55b2eba6c Mon Sep 17 00:00:00 2001 From: Claycuy Date: Sat, 26 Sep 2026 07:00:10 +0800 Subject: [PATCH 09/13] docs: Update docs --- docs/.vitepress/lang/en/sidebarDataTypes.ts | 6 +++--- docs/.vitepress/lang/id/sidebarDataTypes.ts | 6 +++--- .../{ => data-types}/capabilities.md | 14 +------------- .../{ => data-types}/primitive-types.md | 0 docs/en/api-reference/data-types/time-budget.md | 9 +++++++++ docs/en/api-reference/time-budget.md | 17 ----------------- .../{ => data-types}/capabilities.md | 14 +------------- .../{ => data-types}/primitive-types.md | 0 docs/id/api-reference/data-types/time-budget.md | 9 +++++++++ docs/id/api-reference/time-budget.md | 17 ----------------- 10 files changed, 26 insertions(+), 66 deletions(-) rename docs/en/api-reference/{ => data-types}/capabilities.md (54%) rename docs/en/api-reference/{ => data-types}/primitive-types.md (100%) create mode 100644 docs/en/api-reference/data-types/time-budget.md delete mode 100644 docs/en/api-reference/time-budget.md rename docs/id/api-reference/{ => data-types}/capabilities.md (52%) rename docs/id/api-reference/{ => data-types}/primitive-types.md (100%) create mode 100644 docs/id/api-reference/data-types/time-budget.md delete mode 100644 docs/id/api-reference/time-budget.md diff --git a/docs/.vitepress/lang/en/sidebarDataTypes.ts b/docs/.vitepress/lang/en/sidebarDataTypes.ts index 137660a9..5e3fe35e 100644 --- a/docs/.vitepress/lang/en/sidebarDataTypes.ts +++ b/docs/.vitepress/lang/en/sidebarDataTypes.ts @@ -2,8 +2,8 @@ export const sidebarDataTypes = { text: 'Data Types', collapsed: false, items: [ - { text: 'Primitive Types', link: '/api-reference/primitive-types' }, - { text: 'Capabilities', link: '/api-reference/capabilities' }, - { text: 'Time Budget', link: '/api-reference/time-budget' }, + { text: 'Primitive Types', link: '/api-reference/data-types/primitive-types' }, + { text: 'Capabilities', link: '/api-reference/data-types/capabilities' }, + { text: 'Time Budget', link: '/api-reference/data-types/time-budget' }, ], }; diff --git a/docs/.vitepress/lang/id/sidebarDataTypes.ts b/docs/.vitepress/lang/id/sidebarDataTypes.ts index 860c7919..1bd051fa 100644 --- a/docs/.vitepress/lang/id/sidebarDataTypes.ts +++ b/docs/.vitepress/lang/id/sidebarDataTypes.ts @@ -2,8 +2,8 @@ export const sidebarDataTypes = { text: 'Tipe Data', collapsed: false, items: [ - { text: 'Tipe Primitif', link: '/id/api-reference/primitive-types' }, - { text: 'Kapabilitas', link: '/id/api-reference/capabilities' }, - { text: 'Batas Waktu Eksekusi', link: '/id/api-reference/time-budget' }, + { text: 'Tipe Primitif', link: '/id/api-reference/data-types/primitive-types' }, + { text: 'Kapabilitas', link: '/id/api-reference/data-types/capabilities' }, + { text: 'Batas Waktu Eksekusi', link: '/id/api-reference/data-types/time-budget' }, ], }; diff --git a/docs/en/api-reference/capabilities.md b/docs/en/api-reference/data-types/capabilities.md similarity index 54% rename from docs/en/api-reference/capabilities.md rename to docs/en/api-reference/data-types/capabilities.md index a717f048..47ffe92e 100644 --- a/docs/en/api-reference/capabilities.md +++ b/docs/en/api-reference/data-types/capabilities.md @@ -9,18 +9,6 @@ A `Capability` grants a host operation permission to access a protected `LightVM | `Debug` | `2` | Benchmarks | | `Unsafe` | `3` | `halt` | -## Configuration - -::: code-group - -<<< @/examples/capsConfig.ts{ts:line-numbers}[TypeScript] - -<<< @/examples/caps_config.rs{rs:line-numbers}[Rust] - -::: - -Missing capabilities cause the protected operation to fail. Capabilities do not replace resource limits in `SecurityConfig`; configure both for untrusted bytecode. - ::: warning -Grant only the capabilities the host application needs. `Unsafe` permits an external halt but does not enable `SecurityConfig.unsafeMode`. +Failing to provide the required capabilities will cause protected host operations to fail execution or trigger runtime errors. Always ensure you grant the minimum necessary capability permissions required by your application. ::: diff --git a/docs/en/api-reference/primitive-types.md b/docs/en/api-reference/data-types/primitive-types.md similarity index 100% rename from docs/en/api-reference/primitive-types.md rename to docs/en/api-reference/data-types/primitive-types.md diff --git a/docs/en/api-reference/data-types/time-budget.md b/docs/en/api-reference/data-types/time-budget.md new file mode 100644 index 00000000..c272d3c9 --- /dev/null +++ b/docs/en/api-reference/data-types/time-budget.md @@ -0,0 +1,9 @@ +# Time Budget + +`TimeBudget` sets how much time Gazle can spend optimizing bytecode. It does not limit VM execution time. + +| Value | Numeric value | Optimizer budget | +| :--- | :--- | :--- | +| `Cheap` (default) | `0` | 200 ms | +| `Normal` | `1` | 1,000 ms | +| `Expensive` | `2` | 5,000 ms | diff --git a/docs/en/api-reference/time-budget.md b/docs/en/api-reference/time-budget.md deleted file mode 100644 index 36ad345f..00000000 --- a/docs/en/api-reference/time-budget.md +++ /dev/null @@ -1,17 +0,0 @@ -# Time Budget - -`TimeBudget` sets how much time Gazle can spend optimizing bytecode. It does not limit VM execution time. - -| Value | Numeric value | Optimizer budget | -| :--- | :--- | :--- | -| `Cheap` (default) | `0` | 200 ms | -| `Normal` | `1` | 1,000 ms | -| `Expensive` | `2` | 5,000 ms | - -Set the budget before starting optimization. Use `setTimeBudget(TimeBudget.Cheap)` before `tools().optimizeBytecode(...)`, or `set_time_budget(TimeBudget::Cheap)` before `tools().optimize_bytecode(...)` in Rust. - -A larger budget allows optimization to continue for longer. It does not guarantee a particular result. - -::: info -`SecurityConfig.maxTicks` limits VM execution work independently of `TimeBudget`. -::: diff --git a/docs/id/api-reference/capabilities.md b/docs/id/api-reference/data-types/capabilities.md similarity index 52% rename from docs/id/api-reference/capabilities.md rename to docs/id/api-reference/data-types/capabilities.md index a7d3582e..2514104c 100644 --- a/docs/id/api-reference/capabilities.md +++ b/docs/id/api-reference/data-types/capabilities.md @@ -9,18 +9,6 @@ | `Debug` | `2` | Benchmark | | `Unsafe` | `3` | `halt` | -## Konfigurasi - -::: code-group - -<<< @/examples/capsConfig.ts{ts:line-numbers}[TypeScript] - -<<< @/examples/caps_config.rs{rs:line-numbers}[Rust] - -::: - -Kapabilitas yang tidak diberikan menyebabkan operasi terlindungi gagal. Kapabilitas tidak menggantikan batas sumber daya dalam `SecurityConfig`; konfigurasikan keduanya untuk bytecode yang tidak tepercaya. - ::: warning -Berikan hanya kapabilitas yang diperlukan aplikasi host. `Unsafe` mengizinkan penghentian eksternal, tetapi tidak mengaktifkan `SecurityConfig.unsafeMode`. +Kegagalan memberikan kapabilitas yang sesuai akan menyebabkan operasi host yang dilindungi gagal dijalankan atau memicu error saat runtime. Pastikan untuk selalu memberikan izin kapabilitas minimum yang dibutuhkan oleh aplikasi Anda. ::: diff --git a/docs/id/api-reference/primitive-types.md b/docs/id/api-reference/data-types/primitive-types.md similarity index 100% rename from docs/id/api-reference/primitive-types.md rename to docs/id/api-reference/data-types/primitive-types.md diff --git a/docs/id/api-reference/data-types/time-budget.md b/docs/id/api-reference/data-types/time-budget.md new file mode 100644 index 00000000..f9df8269 --- /dev/null +++ b/docs/id/api-reference/data-types/time-budget.md @@ -0,0 +1,9 @@ +# Anggaran Waktu + +`TimeBudget` menentukan waktu yang dapat digunakan Gazle untuk mengoptimalkan bytecode. Nilai ini tidak membatasi waktu eksekusi VM. + +| Nilai | Nilai numerik | Batas optimizer | +| :--- | :--- | :--- | +| `Cheap` (bawaan) | `0` | 200 ms | +| `Normal` | `1` | 1.000 ms | +| `Expensive` | `2` | 5.000 ms | diff --git a/docs/id/api-reference/time-budget.md b/docs/id/api-reference/time-budget.md deleted file mode 100644 index 80d43a0b..00000000 --- a/docs/id/api-reference/time-budget.md +++ /dev/null @@ -1,17 +0,0 @@ -# Anggaran Waktu - -`TimeBudget` menentukan waktu yang dapat digunakan Gazle untuk mengoptimalkan bytecode. Nilai ini tidak membatasi waktu eksekusi VM. - -| Nilai | Nilai numerik | Batas optimizer | -| :--- | :--- | :--- | -| `Cheap` (bawaan) | `0` | 200 ms | -| `Normal` | `1` | 1.000 ms | -| `Expensive` | `2` | 5.000 ms | - -Atur anggaran sebelum memulai optimasi. Gunakan `setTimeBudget(TimeBudget.Cheap)` sebelum `tools().optimizeBytecode(...)`, atau `set_time_budget(TimeBudget::Cheap)` sebelum `tools().optimize_bytecode(...)` untuk Rust. - -Anggaran yang lebih besar memungkinkan optimasi berlangsung lebih lama. Nilai ini tidak menjamin hasil tertentu. - -::: info -`SecurityConfig.maxTicks` membatasi pekerjaan eksekusi VM secara terpisah dari `TimeBudget`. -::: From a16fff89874e8e7997b70a482ed83060dd7c19bf Mon Sep 17 00:00:00 2001 From: "coderabbitai[bot]" <136622811+coderabbitai[bot]@users.noreply.github.com> Date: Sat, 26 Sep 2026 10:52:44 +0800 Subject: [PATCH 10/13] =?UTF-8?q?=F0=9F=93=9D=20CodeRabbit=20Chat:=20Clari?= =?UTF-8?q?fy=20Debug=20and=20Unsafe=20capability=20permissions=20in=20bil?= =?UTF-8?q?ingual=20docs=20(#659)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --- docs/en/api-reference/data-types/capabilities.md | 6 ++++-- docs/id/api-reference/data-types/capabilities.md | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/docs/en/api-reference/data-types/capabilities.md b/docs/en/api-reference/data-types/capabilities.md index 47ffe92e..633c5a1a 100644 --- a/docs/en/api-reference/data-types/capabilities.md +++ b/docs/en/api-reference/data-types/capabilities.md @@ -6,8 +6,10 @@ A `Capability` grants a host operation permission to access a protected `LightVM | --- | ---: | --- | | `Control` | `0` | `run`, `compile`, `embedded`, function exports, `provide`, clearing outputs, and bytecode optimization | | `Observe` | `1` | `inspect`, reading outputs, and variable exports | -| `Debug` | `2` | Benchmarks | -| `Unsafe` | `3` | `halt` | +| `Debug` | `2` | Benchmarks, reading panic records, and clearing panic records (outside WASM) | +| `Unsafe` | `3` | `halt`, which stops the VM | + +`Unsafe` and `unsafeMode` are separate. `unsafeMode` changes enforcement of some resource limits; it does not grant permission to call `halt`. ::: warning Failing to provide the required capabilities will cause protected host operations to fail execution or trigger runtime errors. Always ensure you grant the minimum necessary capability permissions required by your application. diff --git a/docs/id/api-reference/data-types/capabilities.md b/docs/id/api-reference/data-types/capabilities.md index 2514104c..f109708d 100644 --- a/docs/id/api-reference/data-types/capabilities.md +++ b/docs/id/api-reference/data-types/capabilities.md @@ -6,8 +6,10 @@ | --- | ---: | --- | | `Control` | `0` | `run`, `compile`, `embedded`, ekspor fungsi, `provide`, menghapus output, dan optimasi bytecode | | `Observe` | `1` | `inspect`, membaca output, dan ekspor variabel | -| `Debug` | `2` | Benchmark | -| `Unsafe` | `3` | `halt` | +| `Debug` | `2` | Benchmark, membaca catatan panic, dan menghapus catatan panic (di luar WASM) | +| `Unsafe` | `3` | `halt`, yang menghentikan VM | + +`Unsafe` dan `unsafeMode` adalah hal yang terpisah. `unsafeMode` mengubah penerapan beberapa batas sumber daya; pengaturan ini tidak memberikan izin untuk memanggil `halt`. ::: warning Kegagalan memberikan kapabilitas yang sesuai akan menyebabkan operasi host yang dilindungi gagal dijalankan atau memicu error saat runtime. Pastikan untuk selalu memberikan izin kapabilitas minimum yang dibutuhkan oleh aplikasi Anda. From b416fe062c7a17615406c78e16a61e08531972bf Mon Sep 17 00:00:00 2001 From: Claycuy Date: Sat, 26 Sep 2026 10:54:58 +0800 Subject: [PATCH 11/13] docs: Update docs --- docs/en/api-reference/data-types/capabilities.md | 4 +--- docs/id/api-reference/data-types/capabilities.md | 4 +--- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/docs/en/api-reference/data-types/capabilities.md b/docs/en/api-reference/data-types/capabilities.md index 633c5a1a..207c0559 100644 --- a/docs/en/api-reference/data-types/capabilities.md +++ b/docs/en/api-reference/data-types/capabilities.md @@ -6,11 +6,9 @@ A `Capability` grants a host operation permission to access a protected `LightVM | --- | ---: | --- | | `Control` | `0` | `run`, `compile`, `embedded`, function exports, `provide`, clearing outputs, and bytecode optimization | | `Observe` | `1` | `inspect`, reading outputs, and variable exports | -| `Debug` | `2` | Benchmarks, reading panic records, and clearing panic records (outside WASM) | +| `Debug` | `2` | Benchmarks, reading panic records, and clearing panic records | | `Unsafe` | `3` | `halt`, which stops the VM | -`Unsafe` and `unsafeMode` are separate. `unsafeMode` changes enforcement of some resource limits; it does not grant permission to call `halt`. - ::: warning Failing to provide the required capabilities will cause protected host operations to fail execution or trigger runtime errors. Always ensure you grant the minimum necessary capability permissions required by your application. ::: diff --git a/docs/id/api-reference/data-types/capabilities.md b/docs/id/api-reference/data-types/capabilities.md index f109708d..4359344f 100644 --- a/docs/id/api-reference/data-types/capabilities.md +++ b/docs/id/api-reference/data-types/capabilities.md @@ -6,11 +6,9 @@ | --- | ---: | --- | | `Control` | `0` | `run`, `compile`, `embedded`, ekspor fungsi, `provide`, menghapus output, dan optimasi bytecode | | `Observe` | `1` | `inspect`, membaca output, dan ekspor variabel | -| `Debug` | `2` | Benchmark, membaca catatan panic, dan menghapus catatan panic (di luar WASM) | +| `Debug` | `2` | Benchmark, membaca catatan panic, dan menghapus catatan panic | | `Unsafe` | `3` | `halt`, yang menghentikan VM | -`Unsafe` dan `unsafeMode` adalah hal yang terpisah. `unsafeMode` mengubah penerapan beberapa batas sumber daya; pengaturan ini tidak memberikan izin untuk memanggil `halt`. - ::: warning Kegagalan memberikan kapabilitas yang sesuai akan menyebabkan operasi host yang dilindungi gagal dijalankan atau memicu error saat runtime. Pastikan untuk selalu memberikan izin kapabilitas minimum yang dibutuhkan oleh aplikasi Anda. ::: From 62426d99873eb077b06a27ae4f56bba3e419201d Mon Sep 17 00:00:00 2001 From: "coderabbitai[bot]" <136622811+coderabbitai[bot]@users.noreply.github.com> Date: Sat, 26 Sep 2026 09:52:07 +0000 Subject: [PATCH 12/13] docs: Clarify unsafe mode limits and capability requirements in English and Indonesian --- docs/en/api-reference/data-types/capabilities.md | 2 ++ docs/id/api-reference/data-types/capabilities.md | 2 ++ 2 files changed, 4 insertions(+) diff --git a/docs/en/api-reference/data-types/capabilities.md b/docs/en/api-reference/data-types/capabilities.md index 207c0559..b3efc3d1 100644 --- a/docs/en/api-reference/data-types/capabilities.md +++ b/docs/en/api-reference/data-types/capabilities.md @@ -9,6 +9,8 @@ A `Capability` grants a host operation permission to access a protected `LightVM | `Debug` | `2` | Benchmarks, reading panic records, and clearing panic records | | `Unsafe` | `3` | `halt`, which stops the VM | +`unsafeMode` disables security checks such as import restrictions and resource quotas for I/O, imports, allocations, calls, and jumps, but does not grant capability permissions. Bounds verification remains enabled. Calling `halt` still requires the `Unsafe` capability in `VMConfig.caps`, even when `unsafeMode` is enabled. + ::: warning Failing to provide the required capabilities will cause protected host operations to fail execution or trigger runtime errors. Always ensure you grant the minimum necessary capability permissions required by your application. ::: diff --git a/docs/id/api-reference/data-types/capabilities.md b/docs/id/api-reference/data-types/capabilities.md index 4359344f..5d1c6a11 100644 --- a/docs/id/api-reference/data-types/capabilities.md +++ b/docs/id/api-reference/data-types/capabilities.md @@ -9,6 +9,8 @@ | `Debug` | `2` | Benchmark, membaca catatan panic, dan menghapus catatan panic | | `Unsafe` | `3` | `halt`, yang menghentikan VM | +`unsafeMode` menonaktifkan pemeriksaan keamanan seperti pembatasan impor dan kuota sumber daya untuk I/O, impor, alokasi, pemanggilan fungsi, dan lompatan, tetapi tidak memberikan izin kapabilitas. Verifikasi batas tetap aktif. Pemanggilan `halt` tetap memerlukan kapabilitas `Unsafe` dalam `VMConfig.caps`, meskipun `unsafeMode` diaktifkan. + ::: warning Kegagalan memberikan kapabilitas yang sesuai akan menyebabkan operasi host yang dilindungi gagal dijalankan atau memicu error saat runtime. Pastikan untuk selalu memberikan izin kapabilitas minimum yang dibutuhkan oleh aplikasi Anda. ::: From a962dbdb37a09b59342db91ed2202da05ac9cea0 Mon Sep 17 00:00:00 2001 From: claycuy Date: Sat, 26 Sep 2026 18:03:30 +0800 Subject: [PATCH 13/13] docs: Update docs --- docs/en/api-reference/data-types/capabilities.md | 2 +- docs/id/api-reference/data-types/capabilities.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/en/api-reference/data-types/capabilities.md b/docs/en/api-reference/data-types/capabilities.md index b3efc3d1..35f23839 100644 --- a/docs/en/api-reference/data-types/capabilities.md +++ b/docs/en/api-reference/data-types/capabilities.md @@ -9,7 +9,7 @@ A `Capability` grants a host operation permission to access a protected `LightVM | `Debug` | `2` | Benchmarks, reading panic records, and clearing panic records | | `Unsafe` | `3` | `halt`, which stops the VM | -`unsafeMode` disables security checks such as import restrictions and resource quotas for I/O, imports, allocations, calls, and jumps, but does not grant capability permissions. Bounds verification remains enabled. Calling `halt` still requires the `Unsafe` capability in `VMConfig.caps`, even when `unsafeMode` is enabled. +`unsafeMode` (or `unsafe_mode` in **Rust**) in disables security checks such as import restrictions and resource quotas for I/O, imports, allocations, calls, and jumps, but does not grant capability permissions. Bounds verification remains enabled. Calling `halt` still requires the `Unsafe` capability in `VMConfig.caps`, even with this mode enabled. ::: warning Failing to provide the required capabilities will cause protected host operations to fail execution or trigger runtime errors. Always ensure you grant the minimum necessary capability permissions required by your application. diff --git a/docs/id/api-reference/data-types/capabilities.md b/docs/id/api-reference/data-types/capabilities.md index 5d1c6a11..fa5e0894 100644 --- a/docs/id/api-reference/data-types/capabilities.md +++ b/docs/id/api-reference/data-types/capabilities.md @@ -9,7 +9,7 @@ | `Debug` | `2` | Benchmark, membaca catatan panic, dan menghapus catatan panic | | `Unsafe` | `3` | `halt`, yang menghentikan VM | -`unsafeMode` menonaktifkan pemeriksaan keamanan seperti pembatasan impor dan kuota sumber daya untuk I/O, impor, alokasi, pemanggilan fungsi, dan lompatan, tetapi tidak memberikan izin kapabilitas. Verifikasi batas tetap aktif. Pemanggilan `halt` tetap memerlukan kapabilitas `Unsafe` dalam `VMConfig.caps`, meskipun `unsafeMode` diaktifkan. +`unsafeMode` (atau `unsafe_mode` pada **Rust**) menonaktifkan pemeriksaan keamanan seperti pembatasan impor dan kuota sumber daya untuk I/O, impor, alokasi, pemanggilan fungsi, dan lompatan, tetapi tidak memberikan izin kapabilitas. Verifikasi batas tetap aktif. Pemanggilan `halt` tetap memerlukan kapabilitas `Unsafe` dalam `VMConfig.caps`, bahkan dengan mode ini diaktifkan. ::: warning Kegagalan memberikan kapabilitas yang sesuai akan menyebabkan operasi host yang dilindungi gagal dijalankan atau memicu error saat runtime. Pastikan untuk selalu memberikan izin kapabilitas minimum yang dibutuhkan oleh aplikasi Anda.