@vyckr/tachyon 1.1.10 → 1.1.11

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vyckr/tachyon",
3
- "version": "1.1.10",
3
+ "version": "1.1.11",
4
4
  "author": "Chidelma",
5
5
  "repository": {
6
6
  "type": "git",
package/routes/HTML CHANGED
@@ -28,6 +28,10 @@
28
28
  function removeTodo(index) {
29
29
  todos = todos.filter((_, i) => i !== index)
30
30
  }
31
+
32
+ function propEvent() {
33
+ console.log('prop event')
34
+ }
31
35
  </script>
32
36
 
33
37
  <h1>Yon Framework Test</h1>
@@ -66,7 +70,7 @@
66
70
  </div>
67
71
  </ty-logic>
68
72
 
69
- <ty-clicker :clicks="count"/>
73
+ <ty-clicker :clicks="count" @click="propEvent()"/>
70
74
 
71
75
  <style>
72
76
  body {
package/src/client/yon.ts CHANGED
@@ -186,21 +186,25 @@ export default class Yon {
186
186
  .replaceAll(/`<\/ty-(\w+)\s*>`/g, '')
187
187
  .replaceAll(/`<ty-([a-zA-Z0-9-]+)(?:\s+([^>]*))>`/g, (match, component, atrributes) => {
188
188
 
189
- const matches = atrributes.matchAll(/([a-zA-Z0-9-]+)="([^"]*)"/g)
189
+ const matches = atrributes.matchAll(/([a-zA-Z0-9-@]+)="([^"]*)"/g)
190
190
 
191
- const exports: string[] = []
191
+ const props: string[] = []
192
+ const events: string[] = []
193
+
194
+ const hash = Bun.randomUUIDv7().split('-')[3]
192
195
 
193
196
  for(const [_, key, value] of matches) {
194
- exports.push(`${key}=${value}`)
197
+ if(key.startsWith('@')) events.push(`${key}="${value.replace(/(ty_invokeEvent\(')([^"]+)(',[^)]+\))/g, `$1${hash}$3`)}"`)
198
+ else props.push(`${key}=${value}`)
195
199
  }
196
-
197
- const hash = Bun.randomUUIDv7().split('-')[3]
200
+
201
+ const genId = "${ty_generateId('" + hash + "', 'id')}"
198
202
 
199
203
  return `
200
- elements += '<div>'
204
+ elements += \`<div id="${genId}" ${events.join(' ')}>\`
201
205
 
202
206
  if(!compRenders.has('${hash}')) {
203
- render = await ${component}(\`${exports.join(';')}\`)
207
+ render = await ${component}(\`${props.join(';')}\`)
204
208
  elements += await render(elemId, event, '${hash}')
205
209
  compRenders.set('${hash}', render)
206
210
  } else {