herb 0.9.7-x86-linux-gnu → 0.10.0-x86-linux-gnu
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +1 -0
- data/ext/herb/extconf.rb +1 -0
- data/ext/herb/extension.c +108 -0
- data/herb.gemspec +1 -1
- data/lib/herb/3.2/herb.so +0 -0
- data/lib/herb/3.3/herb.so +0 -0
- data/lib/herb/3.4/herb.so +0 -0
- data/lib/herb/4.0/herb.so +0 -0
- data/lib/herb/action_view/render_analyzer.rb +1057 -0
- data/lib/herb/ast/erb_render_node.rb +155 -0
- data/lib/herb/bootstrap.rb +0 -1
- data/lib/herb/cli.rb +253 -19
- data/lib/herb/colors.rb +18 -0
- data/lib/herb/configuration.rb +49 -13
- data/lib/herb/defaults.yml +3 -0
- data/lib/herb/dev/runner.rb +445 -0
- data/lib/herb/dev/server.rb +207 -0
- data/lib/herb/dev/server_entry.rb +128 -0
- data/lib/herb/diff_operation.rb +34 -0
- data/lib/herb/diff_result.rb +59 -0
- data/lib/herb/engine/compiler.rb +56 -3
- data/lib/herb/engine/validators/render_validator.rb +92 -0
- data/lib/herb/engine.rb +58 -4
- data/lib/herb/html/util.rb +16 -0
- data/lib/herb/project.rb +1 -6
- data/lib/herb/version.rb +1 -1
- data/lib/herb.rb +41 -5
- data/sig/herb/action_view/render_analyzer.rbs +122 -0
- data/sig/herb/ast/erb_render_node.rbs +29 -0
- data/sig/herb/colors.rbs +12 -0
- data/sig/herb/configuration.rbs +20 -1
- data/sig/herb/dev/runner.rbs +59 -0
- data/sig/herb/dev/server.rbs +50 -0
- data/sig/herb/dev/server_entry.rbs +51 -0
- data/sig/herb/diff_operation.rbs +34 -0
- data/sig/herb/diff_result.rbs +34 -0
- data/sig/herb/engine/compiler.rbs +6 -0
- data/sig/herb/engine/validators/render_validator.rbs +21 -0
- data/sig/herb/engine.rbs +15 -0
- data/sig/herb/html/util.rbs +13 -0
- data/sig/herb.rbs +12 -2
- data/sig/herb_c_extension.rbs +1 -1
- data/sig/vendor/did_you_mean.rbs +6 -0
- data/sig/vendor/parallel.rbs +4 -0
- data/src/analyze/action_view/attribute_extraction_helpers.c +3 -2
- data/src/diff/herb_diff.c +137 -0
- data/src/diff/herb_diff_attributes.c +207 -0
- data/src/diff/herb_diff_children.c +518 -0
- data/src/diff/herb_diff_helpers.c +114 -0
- data/src/diff/herb_diff_nodes.c +707 -0
- data/src/diff/herb_hash.c +42 -0
- data/src/diff/herb_hash_index_map.c +47 -0
- data/src/diff/herb_hash_map.c +104 -0
- data/src/diff/herb_hash_tree.c +680 -0
- data/src/include/diff/herb_diff.h +118 -0
- data/src/include/diff/herb_hash.h +25 -0
- data/src/include/diff/herb_hash_index_map.h +32 -0
- data/src/include/diff/herb_hash_map.h +30 -0
- data/src/include/herb.h +1 -0
- data/src/include/version.h +1 -1
- data/templates/javascript/packages/core/src/config.ts.erb +43 -0
- data/templates/rust/src/ast/nodes.rs.erb +1 -1
- data/templates/rust/src/config.rs.erb +50 -0
- data/templates/src/diff/herb_diff_helpers.c.erb +38 -0
- data/templates/src/diff/herb_diff_nodes.c.erb +224 -0
- data/templates/src/diff/herb_hash_tree.c.erb +147 -0
- data/templates/template.rb +4 -4
- metadata +40 -4
- data/lib/herb/3.0/herb.so +0 -0
- data/lib/herb/3.1/herb.so +0 -0
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: c1a995c36f01e7382d4280f7e7f76eb796f2d155eac5c7712ab060e26005c4a0
|
|
4
|
+
data.tar.gz: 59e99da8f1b4430075cf24816fa756ecc5ae394c52e771f78eae8ea9da17ece3
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 28e958aeb7400c82ca07140a7bf505e5bb5d612724dfba73b1ac02c6d847587041379661544b164c2ba2a461e108d885f0e5964fa483212c04f517b92080e139
|
|
7
|
+
data.tar.gz: 45f6e97a8716f7d025b94d0ddda713ce303341deaec75f65237ade8728837db152c000d8e376fdf77542130123101e33c72000e9debf872ca02b12c87a725c35
|
data/README.md
CHANGED
|
@@ -59,6 +59,7 @@ The Herb ecosystem offers multiple tools that integrate seamlessly into editors,
|
|
|
59
59
|
| [Herb Language Service](https://herb-tools.dev/projects/language-service) | HTML+ERB language service with ActionView tag helper support. |
|
|
60
60
|
| [Herb Language Server](https://herb-tools.dev/projects/language-server) | Rich editor integration for VS Code, Zed, Neovim, and more. |
|
|
61
61
|
| [Herb Engine](https://herb-tools.dev/projects/engine) | HTML-aware ERB rendering engine, API-compatible with Erubi. |
|
|
62
|
+
| [Herb Dev Server](https://herb-tools.dev/projects/dev-server) | File-watching dev server with live DOM patching for templates. *(experimental)* |
|
|
62
63
|
| [Herb Dev Tools](https://herb-tools.dev/projects/dev-tools) | In-browser dev tools for inspecting and debugging templates, shipped with ReActionView. |
|
|
63
64
|
| [ReActionView](https://reactionview.dev) | ActionView-compatible ERB engine with modern DX for Rails. |
|
|
64
65
|
|
data/ext/herb/extconf.rb
CHANGED
|
@@ -47,6 +47,7 @@ $VPATH << "$(srcdir)/../../src"
|
|
|
47
47
|
$VPATH << "$(srcdir)/../../src/analyze"
|
|
48
48
|
$VPATH << "$(srcdir)/../../src/analyze/action_view"
|
|
49
49
|
$VPATH << "$(srcdir)/../../src/ast"
|
|
50
|
+
$VPATH << "$(srcdir)/../../src/diff"
|
|
50
51
|
$VPATH << "$(srcdir)/../../src/lexer"
|
|
51
52
|
$VPATH << "$(srcdir)/../../src/location"
|
|
52
53
|
$VPATH << "$(srcdir)/../../src/parser"
|
data/ext/herb/extension.c
CHANGED
|
@@ -412,6 +412,113 @@ static VALUE Herb_version(VALUE self) {
|
|
|
412
412
|
#endif
|
|
413
413
|
}
|
|
414
414
|
|
|
415
|
+
typedef struct {
|
|
416
|
+
AST_DOCUMENT_NODE_T* old_root;
|
|
417
|
+
AST_DOCUMENT_NODE_T* new_root;
|
|
418
|
+
herb_diff_result_T* diff_result;
|
|
419
|
+
hb_allocator_T old_allocator;
|
|
420
|
+
hb_allocator_T new_allocator;
|
|
421
|
+
hb_allocator_T diff_allocator;
|
|
422
|
+
} diff_args_T;
|
|
423
|
+
|
|
424
|
+
static VALUE rb_create_diff_operation(const herb_diff_operation_T* operation) {
|
|
425
|
+
VALUE cDiffOperation = rb_const_get(mHerb, rb_intern("DiffOperation"));
|
|
426
|
+
|
|
427
|
+
VALUE type = ID2SYM(rb_intern(herb_diff_operation_type_to_string(operation->type)));
|
|
428
|
+
|
|
429
|
+
VALUE path_array = rb_ary_new_capa(operation->path.depth);
|
|
430
|
+
for (uint16_t index = 0; index < operation->path.depth; index++) {
|
|
431
|
+
rb_ary_push(path_array, UINT2NUM(operation->path.indices[index]));
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
VALUE old_node = operation->old_node != NULL ? rb_node_from_c_struct((AST_NODE_T*) operation->old_node) : Qnil;
|
|
435
|
+
VALUE new_node = operation->new_node != NULL ? rb_node_from_c_struct((AST_NODE_T*) operation->new_node) : Qnil;
|
|
436
|
+
|
|
437
|
+
return rb_funcall(
|
|
438
|
+
cDiffOperation,
|
|
439
|
+
rb_intern("new"),
|
|
440
|
+
6,
|
|
441
|
+
type,
|
|
442
|
+
path_array,
|
|
443
|
+
old_node,
|
|
444
|
+
new_node,
|
|
445
|
+
UINT2NUM(operation->old_index),
|
|
446
|
+
UINT2NUM(operation->new_index)
|
|
447
|
+
);
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
static VALUE diff_convert_body(VALUE arg) {
|
|
451
|
+
diff_args_T* args = (diff_args_T*) arg;
|
|
452
|
+
herb_diff_result_T* diff_result = args->diff_result;
|
|
453
|
+
|
|
454
|
+
VALUE cDiffResult = rb_const_get(mHerb, rb_intern("DiffResult"));
|
|
455
|
+
|
|
456
|
+
size_t operation_count = herb_diff_operation_count(diff_result);
|
|
457
|
+
VALUE operations_array = rb_ary_new_capa((long) operation_count);
|
|
458
|
+
|
|
459
|
+
for (size_t index = 0; index < operation_count; index++) {
|
|
460
|
+
const herb_diff_operation_T* operation = herb_diff_operation_at(diff_result, index);
|
|
461
|
+
rb_ary_push(operations_array, rb_create_diff_operation(operation));
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
VALUE result_args[] = { diff_result->trees_identical ? Qtrue : Qfalse, operations_array };
|
|
465
|
+
|
|
466
|
+
return rb_class_new_instance(2, result_args, cDiffResult);
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
static VALUE diff_cleanup(VALUE arg) {
|
|
470
|
+
diff_args_T* args = (diff_args_T*) arg;
|
|
471
|
+
|
|
472
|
+
if (args->old_root != NULL) { ast_node_free((AST_NODE_T*) args->old_root, &args->old_allocator); }
|
|
473
|
+
if (args->new_root != NULL) { ast_node_free((AST_NODE_T*) args->new_root, &args->new_allocator); }
|
|
474
|
+
|
|
475
|
+
hb_allocator_destroy(&args->diff_allocator);
|
|
476
|
+
hb_allocator_destroy(&args->old_allocator);
|
|
477
|
+
hb_allocator_destroy(&args->new_allocator);
|
|
478
|
+
|
|
479
|
+
return Qnil;
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
static VALUE Herb_diff(int argc, VALUE* argv, VALUE self) {
|
|
483
|
+
VALUE old_source, new_source;
|
|
484
|
+
rb_scan_args(argc, argv, "2", &old_source, &new_source);
|
|
485
|
+
|
|
486
|
+
char* old_string = (char*) check_string(old_source);
|
|
487
|
+
char* new_string = (char*) check_string(new_source);
|
|
488
|
+
|
|
489
|
+
diff_args_T args = { 0 };
|
|
490
|
+
|
|
491
|
+
parser_options_T parser_options = HERB_DEFAULT_PARSER_OPTIONS;
|
|
492
|
+
|
|
493
|
+
if (!hb_allocator_init(&args.old_allocator, HB_ALLOCATOR_ARENA)) { return Qnil; }
|
|
494
|
+
|
|
495
|
+
if (!hb_allocator_init(&args.new_allocator, HB_ALLOCATOR_ARENA)) {
|
|
496
|
+
hb_allocator_destroy(&args.old_allocator);
|
|
497
|
+
|
|
498
|
+
return Qnil;
|
|
499
|
+
}
|
|
500
|
+
|
|
501
|
+
if (!hb_allocator_init(&args.diff_allocator, HB_ALLOCATOR_ARENA)) {
|
|
502
|
+
hb_allocator_destroy(&args.old_allocator);
|
|
503
|
+
hb_allocator_destroy(&args.new_allocator);
|
|
504
|
+
|
|
505
|
+
return Qnil;
|
|
506
|
+
}
|
|
507
|
+
|
|
508
|
+
args.old_root = herb_parse(old_string, &parser_options, &args.old_allocator);
|
|
509
|
+
args.new_root = herb_parse(new_string, &parser_options, &args.new_allocator);
|
|
510
|
+
|
|
511
|
+
if (args.old_root == NULL || args.new_root == NULL) {
|
|
512
|
+
diff_cleanup((VALUE) &args);
|
|
513
|
+
|
|
514
|
+
return Qnil;
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
args.diff_result = herb_diff(args.old_root, args.new_root, &args.diff_allocator);
|
|
518
|
+
|
|
519
|
+
return rb_ensure(diff_convert_body, (VALUE) &args, diff_cleanup, (VALUE) &args);
|
|
520
|
+
}
|
|
521
|
+
|
|
415
522
|
__attribute__((__visibility__("default"))) void Init_herb(void) {
|
|
416
523
|
mHerb = rb_define_module("Herb");
|
|
417
524
|
cPosition = rb_define_class_under(mHerb, "Position", rb_cObject);
|
|
@@ -433,4 +540,5 @@ __attribute__((__visibility__("default"))) void Init_herb(void) {
|
|
|
433
540
|
rb_define_singleton_method(mHerb, "arena_stats", Herb_arena_stats, -1);
|
|
434
541
|
rb_define_singleton_method(mHerb, "leak_check", Herb_leak_check, 1);
|
|
435
542
|
rb_define_singleton_method(mHerb, "version", Herb_version, 0);
|
|
543
|
+
rb_define_singleton_method(mHerb, "diff", Herb_diff, -1);
|
|
436
544
|
}
|
data/herb.gemspec
CHANGED
data/lib/herb/3.2/herb.so
CHANGED
|
Binary file
|
data/lib/herb/3.3/herb.so
CHANGED
|
Binary file
|
data/lib/herb/3.4/herb.so
CHANGED
|
Binary file
|
data/lib/herb/4.0/herb.so
CHANGED
|
Binary file
|