@inglorious/web 4.1.1 → 4.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +208 -19
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -712,6 +712,195 @@ See the plugin documentation for full details on control flow, attributes, and e
|
|
|
712
712
|
|
|
713
713
|
---
|
|
714
714
|
|
|
715
|
+
## Vue Template Support
|
|
716
|
+
|
|
717
|
+
If you prefer **Vue Single-File Component–style templates**, you can use
|
|
718
|
+
**`@inglorious/vite-plugin-vue`** to write Vue-like `<template>` syntax and compile it into optimized `lit-html` render functions for **@inglorious/web**.
|
|
719
|
+
|
|
720
|
+
This plugin is **not Vue** and does **not implement Vue’s reactivity model**.
|
|
721
|
+
Instead, it provides a **template-only compatibility layer** that maps a well-defined subset of Vue template syntax onto Inglorious Web’s entity-based rendering model.
|
|
722
|
+
|
|
723
|
+
### What This Is (and Is Not)
|
|
724
|
+
|
|
725
|
+
✔ **Is:**
|
|
726
|
+
|
|
727
|
+
- A Vue-like _template syntax_ compiler
|
|
728
|
+
- Zero-runtime, compile-time transformation
|
|
729
|
+
- Direct output to `lit-html`
|
|
730
|
+
- Fully compatible with Inglorious entities and store-driven rendering
|
|
731
|
+
|
|
732
|
+
❌ **Is NOT:**
|
|
733
|
+
|
|
734
|
+
- Vue runtime
|
|
735
|
+
- Vue reactivity (no proxies, refs, watchers)
|
|
736
|
+
- Vue SFC compiler
|
|
737
|
+
- A drop-in replacement for Vue apps
|
|
738
|
+
|
|
739
|
+
Think of it as **“Vue templates as a syntax convenience”**, not Vue itself.
|
|
740
|
+
|
|
741
|
+
---
|
|
742
|
+
|
|
743
|
+
### Supported Syntax
|
|
744
|
+
|
|
745
|
+
The plugin supports the most common and useful Vue template features:
|
|
746
|
+
|
|
747
|
+
#### Templates
|
|
748
|
+
|
|
749
|
+
```vue
|
|
750
|
+
<template>
|
|
751
|
+
<div class="counter">
|
|
752
|
+
<span>{{ value }}</span>
|
|
753
|
+
<button @click="increment">+</button>
|
|
754
|
+
</div>
|
|
755
|
+
</template>
|
|
756
|
+
```
|
|
757
|
+
|
|
758
|
+
#### Interpolations
|
|
759
|
+
|
|
760
|
+
- `{{ value }}`
|
|
761
|
+
- Automatically prefixed with `entity.` when appropriate
|
|
762
|
+
|
|
763
|
+
#### Conditionals
|
|
764
|
+
|
|
765
|
+
- `v-if`
|
|
766
|
+
- `v-else-if`
|
|
767
|
+
- `v-else`
|
|
768
|
+
|
|
769
|
+
Compiled using `lit-html`’s `when()` directive.
|
|
770
|
+
|
|
771
|
+
#### Loops
|
|
772
|
+
|
|
773
|
+
- `v-for="item in items"`
|
|
774
|
+
- `v-for="(item, index) in items"`
|
|
775
|
+
- Optional `:key`
|
|
776
|
+
|
|
777
|
+
Compiled using `lit-html`’s `repeat()` directive.
|
|
778
|
+
|
|
779
|
+
#### Bindings
|
|
780
|
+
|
|
781
|
+
- `:prop="expr"`
|
|
782
|
+
- `v-bind:prop="expr"`
|
|
783
|
+
- Static attributes
|
|
784
|
+
- Correct handling of property vs attribute bindings
|
|
785
|
+
|
|
786
|
+
#### Events
|
|
787
|
+
|
|
788
|
+
- `@click="method"`
|
|
789
|
+
- `@click="() => method(entity, arg)"`
|
|
790
|
+
- `v-on:event="handler"`
|
|
791
|
+
|
|
792
|
+
Method references are automatically translated to `api.notify(...)` calls.
|
|
793
|
+
|
|
794
|
+
#### Components
|
|
795
|
+
|
|
796
|
+
- PascalCase components are treated as entity renders:
|
|
797
|
+
|
|
798
|
+
```vue
|
|
799
|
+
<Message />
|
|
800
|
+
```
|
|
801
|
+
|
|
802
|
+
```js
|
|
803
|
+
api.render("message")
|
|
804
|
+
```
|
|
805
|
+
|
|
806
|
+
---
|
|
807
|
+
|
|
808
|
+
### Script Sections
|
|
809
|
+
|
|
810
|
+
Both JavaScript and TypeScript are supported:
|
|
811
|
+
|
|
812
|
+
```vue
|
|
813
|
+
<script lang="ts">
|
|
814
|
+
const message: string = "Hello"
|
|
815
|
+
|
|
816
|
+
const greet = (entity: any): void => {
|
|
817
|
+
console.log(entity.message)
|
|
818
|
+
}
|
|
819
|
+
</script>
|
|
820
|
+
```
|
|
821
|
+
|
|
822
|
+
The plugin automatically:
|
|
823
|
+
|
|
824
|
+
- Separates **state variables** from **methods**
|
|
825
|
+
- Strips TypeScript annotations
|
|
826
|
+
- Emits clean JavaScript output
|
|
827
|
+
- Generates entity-compatible methods
|
|
828
|
+
|
|
829
|
+
---
|
|
830
|
+
|
|
831
|
+
### Example
|
|
832
|
+
|
|
833
|
+
**Vue-style input:**
|
|
834
|
+
|
|
835
|
+
```vue
|
|
836
|
+
<template>
|
|
837
|
+
<div>
|
|
838
|
+
<h1>{{ title }}</h1>
|
|
839
|
+
<TodoItem v-for="todo in todos" :key="todo.id" />
|
|
840
|
+
</div>
|
|
841
|
+
</template>
|
|
842
|
+
|
|
843
|
+
<script>
|
|
844
|
+
const title = "Todos"
|
|
845
|
+
</script>
|
|
846
|
+
```
|
|
847
|
+
|
|
848
|
+
**Generated output (simplified):**
|
|
849
|
+
|
|
850
|
+
```js
|
|
851
|
+
export const app = {
|
|
852
|
+
create(entity) {
|
|
853
|
+
entity.title = "Todos"
|
|
854
|
+
},
|
|
855
|
+
|
|
856
|
+
render(entity, api) {
|
|
857
|
+
return html`
|
|
858
|
+
<div>
|
|
859
|
+
<h1>${entity.title}</h1>
|
|
860
|
+
${repeat(entity.todos, (todo) => api.render("todoItem"))}
|
|
861
|
+
</div>
|
|
862
|
+
`
|
|
863
|
+
},
|
|
864
|
+
}
|
|
865
|
+
```
|
|
866
|
+
|
|
867
|
+
---
|
|
868
|
+
|
|
869
|
+
### Design Philosophy
|
|
870
|
+
|
|
871
|
+
This plugin exists to support developers who:
|
|
872
|
+
|
|
873
|
+
- Like Vue’s **template ergonomics**
|
|
874
|
+
- Want to migrate incrementally from Vue
|
|
875
|
+
- Prefer HTML-like syntax over JS mixed with tags
|
|
876
|
+
- Still want **Inglorious Web’s explicit, predictable architecture**
|
|
877
|
+
|
|
878
|
+
It deliberately avoids:
|
|
879
|
+
|
|
880
|
+
- Hidden reactivity
|
|
881
|
+
- Magic bindings
|
|
882
|
+
- Lifecycle hooks
|
|
883
|
+
- Framework-level state
|
|
884
|
+
|
|
885
|
+
Everything still flows through **entities, events, and full-tree renders**.
|
|
886
|
+
|
|
887
|
+
---
|
|
888
|
+
|
|
889
|
+
### When to Use Native lit-html vs Vue Templates vs JSX
|
|
890
|
+
|
|
891
|
+
| Choose this if you… | Use |
|
|
892
|
+
| ----------------------------- | --------------- |
|
|
893
|
+
| Like HTML templates | lit-html or Vue |
|
|
894
|
+
| Want JSX ergonomics | JSX |
|
|
895
|
+
| Prefer JavaScript-only syntax | lit-html |
|
|
896
|
+
| Prefer declarative templates | lit-html or Vue |
|
|
897
|
+
| Are migrating from Vue | Vue templates |
|
|
898
|
+
| Want maximal explicitness | lit-html or JSX |
|
|
899
|
+
|
|
900
|
+
Both plugins generate **the same runtime model**.
|
|
901
|
+
|
|
902
|
+
---
|
|
903
|
+
|
|
715
904
|
## Redux DevTools Integration
|
|
716
905
|
|
|
717
906
|
`@inglorious/web` ships with first-class support for the **Redux DevTools Extension**, allowing you to:
|
|
@@ -1411,25 +1600,25 @@ Inglorious Web works seamlessly with any Web Component library, such as Shoelace
|
|
|
1411
1600
|
|
|
1412
1601
|
**Use Inglorious Web's built-in components when:**
|
|
1413
1602
|
|
|
1414
|
-
✅ You want full architectural consistency
|
|
1415
|
-
✅ You need fine-grained control over behavior
|
|
1416
|
-
✅ You want to compose behaviors via type composition
|
|
1417
|
-
✅ You need time-travel debugging of component state
|
|
1418
|
-
✅ You want minimal bundle size
|
|
1419
|
-
✅ You're building a core pattern used throughout your app
|
|
1420
|
-
✅ You want the simplest possible tests
|
|
1421
|
-
✅ You need custom behavior that third-party components don't provide
|
|
1422
|
-
✅ You're using SSX for static site generation
|
|
1603
|
+
- ✅ You want full architectural consistency
|
|
1604
|
+
- ✅ You need fine-grained control over behavior
|
|
1605
|
+
- ✅ You want to compose behaviors via type composition
|
|
1606
|
+
- ✅ You need time-travel debugging of component state
|
|
1607
|
+
- ✅ You want minimal bundle size
|
|
1608
|
+
- ✅ You're building a core pattern used throughout your app
|
|
1609
|
+
- ✅ You want the simplest possible tests
|
|
1610
|
+
- ✅ You need custom behavior that third-party components don't provide
|
|
1611
|
+
- ✅ You're using SSX for static site generation
|
|
1423
1612
|
|
|
1424
1613
|
**Use Web Components (like Shoelace) when:**
|
|
1425
1614
|
|
|
1426
|
-
✅ You need complex, battle-tested UI (date pickers, rich text editors)
|
|
1427
|
-
✅ You want a comprehensive design system out of the box
|
|
1428
|
-
✅ Speed of development matters more than architectural purity
|
|
1429
|
-
✅ You need features you don't want to build yourself (color pickers, tree views)
|
|
1430
|
-
✅ The component is isolated or used infrequently
|
|
1431
|
-
✅ You're okay with some state living outside the store
|
|
1432
|
-
✅ You're building a client-only application (not using SSX)
|
|
1615
|
+
- ✅ You need complex, battle-tested UI (date pickers, rich text editors)
|
|
1616
|
+
- ✅ You want a comprehensive design system out of the box
|
|
1617
|
+
- ✅ Speed of development matters more than architectural purity
|
|
1618
|
+
- ✅ You need features you don't want to build yourself (color pickers, tree views)
|
|
1619
|
+
- ✅ The component is isolated or used infrequently
|
|
1620
|
+
- ✅ You're okay with some state living outside the store
|
|
1621
|
+
- ✅ You're building a client-only application (not using SSX)
|
|
1433
1622
|
|
|
1434
1623
|
### Example: Hybrid Approach
|
|
1435
1624
|
|
|
@@ -1516,11 +1705,11 @@ const store = createStore({
|
|
|
1516
1705
|
})
|
|
1517
1706
|
```
|
|
1518
1707
|
|
|
1519
|
-
If you want to initialize an entity with specific data, you can use the `
|
|
1708
|
+
If you want to initialize an entity with specific data, you can use the `create()` event handler:
|
|
1520
1709
|
|
|
1521
1710
|
```javascript
|
|
1522
1711
|
const header = {
|
|
1523
|
-
|
|
1712
|
+
create(entity) {
|
|
1524
1713
|
entity.title = "Welcome"
|
|
1525
1714
|
},
|
|
1526
1715
|
|
|
@@ -1530,7 +1719,7 @@ const header = {
|
|
|
1530
1719
|
}
|
|
1531
1720
|
```
|
|
1532
1721
|
|
|
1533
|
-
The `
|
|
1722
|
+
The `create()` handler runs for each entity of that type is first created, making it perfect for setting up default values. This pattern works great for web apps where most entities are singletons that behave more like components than game objects.
|
|
1534
1723
|
|
|
1535
1724
|
**When to use `autoCreateEntities` in web apps:**
|
|
1536
1725
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inglorious/web",
|
|
3
|
-
"version": "4.1.
|
|
3
|
+
"version": "4.1.3",
|
|
4
4
|
"description": "A new web framework that leverages the power of the Inglorious Store combined with the performance and simplicity of lit-html.",
|
|
5
5
|
"author": "IceOnFire <antony.mistretta@gmail.com> (https://ingloriouscoderz.it)",
|
|
6
6
|
"license": "MIT",
|
|
@@ -68,7 +68,7 @@
|
|
|
68
68
|
"dependencies": {
|
|
69
69
|
"@lit-labs/ssr-client": "^1.1.8",
|
|
70
70
|
"lit-html": "^3.3.1",
|
|
71
|
-
"@inglorious/store": "9.
|
|
71
|
+
"@inglorious/store": "9.3.0",
|
|
72
72
|
"@inglorious/utils": "3.7.2"
|
|
73
73
|
},
|
|
74
74
|
"devDependencies": {
|