spikijs 1.1.20 → 1.1.21

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 CHANGED
@@ -1,11 +1,149 @@
1
1
  # Spikijs
2
2
 
3
- ~5 KB (Gzip): Reactive JavaScript micro-framework
3
+ Spikijs is a lightweight (~5KB), high-performance JavaScript framework for building interactive interfaces. It works directly with your HTML (no build step required) and uses ES6 Proxies for reactive state management.
4
+
5
+ It is designed to be simple, secure (CSP Compliant), and fast.
6
+
7
+ ## Key Features
8
+
9
+ * **Tiny Footprint:** Around 5KB gzip. No complex bundlers needed.
10
+ * **Zero Inline Logic:** You cannot write JavaScript logic in HTML attributes (e.g., `count++` is forbidden). This enforces clean separation of concerns and complies with strict Content Security Policies (CSP).
11
+ * **Deep Reactivity:** Automatically tracks changes in nested objects and arrays using Proxies.
12
+ * **Memory Safe:** Explicit `mount()` and `unmount()` methods prevent memory leaks in Single Page Applications.
4
13
 
5
14
  ---
6
15
 
7
- ## Documentation
8
- Read the full documentation on [GitHub](https://github.com/novver/spikijs)
16
+ ## Installation
17
+
18
+ ### CDN (Browser)
19
+ Simply add the script tag to your HTML. Spiki will automatically attach to `window.spiki`.
20
+
21
+ ```html
22
+ <script src="https://unpkg.com/spikijs"></script>
23
+
24
+ ```
25
+
26
+ ### NPM (Module)
27
+
28
+ Install via package manager.
29
+
30
+ ```bash
31
+ npm install spikijs
32
+
33
+ ```
34
+
35
+ ---
36
+
37
+ ## Usage Strategies
38
+
39
+ Choose the initialization method that fits your architecture.
40
+
41
+ ### Automatic
42
+
43
+ Best for simple websites. Spiki scans the entire document for `s-data` attributes.
44
+
45
+ **HTML:**
46
+
47
+ ```html
48
+ <div s-data="counterApp">
49
+ Count: <span s-text="count"></span>
50
+ <button s-click="increment">+</button>
51
+ </div>
52
+
53
+ ```
54
+
55
+ **JavaScript:**
56
+
57
+ ```javascript
58
+ import spiki from 'spikijs';
59
+
60
+ // 1. Register Component
61
+ spiki.data('counterApp', () => ({
62
+ count: 0,
63
+ increment() {
64
+ this.count++;
65
+ }
66
+ }));
67
+
68
+ // 2. Start Engine (Scans the whole body)
69
+ spiki.start();
70
+
71
+ ```
72
+
73
+ ### Manual Mount
74
+
75
+ You control exactly *when* and *where* Spiki starts, and crucially, when it stops to free memory.
76
+
77
+ **HTML:**
78
+
79
+ ```html
80
+ <div id="my-widget" s-data="counterApp">
81
+ Count: <span s-text="count"></span>
82
+ <button s-click="increment">+</button>
83
+ </div>
84
+
85
+ ```
86
+
87
+ **JavaScript:**
88
+
89
+ ```javascript
90
+ import spiki from 'spikijs';
91
+
92
+ // 1. Register Component logic
93
+ spiki.data('counterApp', () => ({
94
+ count: 0,
95
+ increment() {
96
+ this.count++;
97
+ }
98
+ }));
99
+
100
+ // 2. Select the DOM element
101
+ const myWidget = document.getElementById('my-widget');
102
+
103
+ // 3. Mount Spiki to this specific element
104
+ const counterApp = spiki.mount(myWidget);
105
+
106
+ // ... later when removing the element or changing pages ...
107
+ // 4. Unmount to free memory (Stop watchers and event listeners)
108
+ // counterApp.unmount();
109
+
110
+ ```
111
+
112
+ ---
113
+
114
+ ## Quick Start
115
+
116
+ 1. **Define HTML**: Add `s-data` to a container.
117
+ 2. **Define Logic**: Use `spiki.data()`.
118
+ 3. **Start Engine**: Call `spiki.start()`.
119
+
120
+ ```html
121
+ <div s-data="counterApp">
122
+ <h1>Count: <span s-text="count"></span></h1>
123
+ <button s-click="increment">Add +1</button>
124
+ <button s-click="decrement">Del -1</button>
125
+ </div>
126
+
127
+ <script src="https://unpkg.com/spikijs"></script>
128
+ <script>
129
+ // 1. Register Component
130
+ spiki.data('counterApp', () => ({
131
+ count: 0,
132
+ increment() {
133
+ this.count++;
134
+ },
135
+ decrement() {
136
+ this.count--;
137
+ }
138
+ }));
139
+
140
+ // 2. Start Spiki
141
+ document.addEventListener('DOMContentLoaded', () => {
142
+ spiki.start();
143
+ });
144
+ </script>
145
+
146
+ ```
9
147
 
10
148
  ---
11
149
 
@@ -36,70 +174,353 @@ Read the full documentation on [GitHub](https://github.com/novver/spikijs)
36
174
 
37
175
  ---
38
176
 
39
- ## Installation
177
+ ## Detailed Usage Examples
40
178
 
41
- ### via NPM
42
- ```bash
43
- npm install spikijs
179
+ ### 1. Displaying Data (`s-text`)
180
+
181
+ Updates the `textContent` of an element. This is safe and prevents XSS attacks.
182
+
183
+ ```html
184
+ <div s-data="textApp">
185
+ <p>Message: <span s-text="msg"></span></p>
186
+
187
+ <p>Formatted: <span s-text="formatMsg"></span></p>
188
+ </div>
189
+
190
+ <script>
191
+ spiki.data('textApp', () => ({
192
+ msg: 'hello world',
193
+
194
+ // Function receives the element as argument
195
+ formatMsg(el) {
196
+ // You can manipulate 'el' if needed, but return value is used for text
197
+ return this.msg.toUpperCase();
198
+ }
199
+ }));
200
+ </script>
44
201
 
45
202
  ```
46
203
 
47
- ### via CDN
48
- You can use the CDN directly in your HTML using a standard script tag:
204
+ > **Note:** If you bind a function to `s-text`, that function receives the DOM element (`el`) as its first argument.
205
+
206
+ ### 2. Inner HTML (`s-html`)
207
+
208
+ Updates the `innerHTML`. Only use this if you trust the content source.
49
209
 
50
210
  ```html
51
- <script src="//unpkg.com/spikijs"></script>
211
+ <div s-data="htmlApp">
212
+ <div s-html="rawHtml"></div>
213
+ </div>
214
+
215
+ <script>
216
+ spiki.data('htmlApp', () => ({
217
+ rawHtml: '<b>Bold Text</b> and <i>Italic</i>'
218
+ }));
219
+ </script>
52
220
 
53
221
  ```
54
222
 
55
- ---
223
+ > **Note:** Just like `s-text`, if you use a function here, it receives the DOM element (`el`) as an argument.
56
224
 
57
- ## Quick Start
225
+ ### 3. Dynamic Attributes (`:[attribute]`)
58
226
 
59
- Here is a simple "Counter" example to show how Spikijs works.
227
+ You can bind ANY HTML attribute to a variable by adding a colon `:` before the attribute name.
60
228
 
61
- ### 1. HTML Layout
229
+ ```html
230
+ <div s-data="attrApp">
231
+ <img :src="avatarUrl" :alt="avatarAlt">
232
+ <a :href="profileLink">View Profile</a>
233
+
234
+ <button :disabled="checkStatus">Submit</button>
235
+ </div>
236
+
237
+ <script>
238
+ spiki.data('attrApp', () => ({
239
+ avatarUrl: 'https://via.placeholder.com/150',
240
+ avatarAlt: 'User Avatar',
241
+ profileLink: '/profile/user1',
242
+ isLoading: true,
243
+
244
+ checkStatus(el) {
245
+ // 'el' is the button element
246
+ if (this.isLoading) {
247
+ el.style.opacity = '0.5'; // You can touch DOM directly
248
+ return true; // Return value sets the attribute
249
+ }
250
+ el.style.opacity = '1';
251
+ return false;
252
+ }
253
+ }));
254
+ </script>
255
+
256
+ ```
62
257
 
63
- Use special `s-` attributes to bind data and events to your HTML.
258
+ > **Note:** The function receives the DOM element (`el`) as an argument. You can use this to perform direct DOM manipulation alongside setting the attribute.
259
+
260
+ ### 4. Initialization (`s-init`)
261
+
262
+ Runs a function immediately when the component is mounted. This is the perfect place for API calls or setting up 3rd party libraries.
64
263
 
65
264
  ```html
66
- <div s-data="counter">
67
- <h1 s-text="title"></h1>
68
- <h2 s-text="count"></h2>
265
+ <div s-data="usersApp" s-init="loadUsers">
266
+ <p s-if="isLoading">Loading...</p>
267
+ <ul>
268
+ <template s-for="user in users" s-key="id">
269
+ <li><span s-text="user.name"></span></li>
270
+ </template>
271
+ </ul>
272
+ </div>
273
+
274
+ <script>
275
+ spiki.data('usersApp', () => ({
276
+ isLoading: true,
277
+ users: [],
69
278
 
70
- <button s-click="decrement">-</button>
71
- <button s-click="increment">+</button>
279
+ loadUsers(el) {
280
+ // 'el' is the div containing s-init
281
+ console.log("Component mounted on:", el);
282
+
283
+ var self = this;
284
+ fetch('https://jsonplaceholder.typicode.com/users')
285
+ .then(function(r) { return r.json() })
286
+ .then(function(data) {
287
+ self.users = data;
288
+ self.isLoading = false;
289
+ });
290
+ }
291
+ }));
292
+ </script>
293
+
294
+ ```
295
+
296
+ > **Note:** The function receives the element (`el`) where the directive is placed.
297
+
298
+ ### 5. Event Listeners (`s-[event]`)
299
+
300
+ Listen to any DOM event using the `s-` prefix.
301
+
302
+ ```html
303
+ <div s-data="eventApp">
304
+ <button s-click="handleClick">Click Me</button>
72
305
  </div>
73
306
 
307
+ <script>
308
+ spiki.data('eventApp', () => ({
309
+ handleClick(e) {
310
+ // 'e' is the standard Native Event Object
311
+ // 'e.target' gives you the element
312
+ e.preventDefault();
313
+ alert('Button Clicked!');
314
+ }
315
+ }));
316
+ </script>
317
+
74
318
  ```
75
319
 
76
- ### 2. JavaScript Logic
320
+ > **Note:** Events receive the native Event Object (`e`). You can access the element via `e.target` or `e.currentTarget`.
77
321
 
78
- Register your component logic and start the framework.
322
+ ### 6. Side Effects (`s-effect`)
79
323
 
80
- ```javascript
81
- import spiki from 'spikijs'; // required in script module
324
+ Use `s-effect` to run a function automatically whenever its dependencies change.
82
325
 
83
- // Register the 'counter' component
84
- spiki.data('counter', () => ({
85
- count: 0,
86
- title: 'Hello Spiki',
326
+ ```html
327
+ <div s-data="saveApp" s-effect="autoSave">
328
+ <textarea s-model="note"></textarea>
329
+ <span s-text="status"></span>
330
+ </div>
331
+
332
+ <script>
333
+ spiki.data('saveApp', () => ({
334
+ note: localStorage.getItem('note') || '',
335
+ status: '',
87
336
 
88
- increment() {
89
- this.count++;
90
- },
91
- decrement() {
92
- this.count--;
337
+ autoSave() {
338
+ localStorage.setItem('note', this.note);
339
+ this.status = 'Saved!';
93
340
  }
94
341
  }));
342
+ </script>
95
343
 
96
- // Initialize the framework
97
- spiki.start();
344
+ ```
345
+
346
+ > **Note:** The function receives the element (`el`) as an argument. Useful if you need to update something visual on the container when data changes.
347
+
348
+ ### 7. Form Inputs (`s-model` vs `s-value`)
349
+
350
+ * **`s-model` (Two-Way):** Updates data when user types, and updates input when data changes.
351
+ * **`s-value` (One-Way):** Only updates the input when data changes.
352
+
353
+ ```html
354
+ <div s-data="formApp">
355
+ <input type="text" s-model="username">
356
+
357
+ <input type="text" s-value="previewName" readonly>
358
+ </div>
359
+
360
+ <script>
361
+ spiki.data('formApp', () => ({
362
+ username: 'john_doe',
363
+
364
+ get previewName() {
365
+ return this.username.toUpperCase();
366
+ }
367
+ }));
368
+ </script>
369
+
370
+ ```
371
+
372
+ ---
373
+
374
+ ## Mastering Lists (`s-for`)
375
+
376
+ ### 1. Basic Loop Requirement
377
+
378
+ You **MUST** use the `<template>` tag. Spiki uses the template to stamp out copies of your HTML.
379
+
380
+ ```html
381
+ <ul>
382
+ <template s-for="user in users" s-key="id">
383
+ <li><span s-text="user.name"></span></li>
384
+ </template>
385
+ </ul>
386
+
387
+ ```
388
+
389
+ ### 2. Accessing Data Inside Loop (`this.item`)
390
+
391
+ When you trigger an event inside a loop, Spiki automatically injects the current item into `this`. The property name matches your loop alias.
392
+
393
+ ```html
394
+ <div s-data="shopApp">
395
+ <ul>
396
+ <template s-for="product in products" s-key="id">
397
+ <li>
398
+ <span s-text="product.name"></span>
399
+ <button s-click="selectProduct">Select</button>
400
+ </li>
401
+ </template>
402
+ </ul>
403
+ </div>
404
+
405
+ <script>
406
+ spiki.data('shopApp', () => ({
407
+ products: [
408
+ { id: 1, name: 'Laptop' },
409
+ { id: 2, name: 'Phone' }
410
+ ],
411
+ selectProduct() {
412
+ // 'this.product' is automatically available
413
+ console.log('You selected:', this.product.name);
414
+ }
415
+ }));
416
+ </script>
417
+
418
+ ```
419
+
420
+ ### 3. Accessing Index
421
+
422
+ You can get the current index by using parentheses: `(item, index) in array`.
423
+
424
+ ```html
425
+ <template s-for="(item, i) in list" s-key="id">
426
+ <button s-click="remove">
427
+ Remove Index <span s-text="i"></span>
428
+ </button>
429
+ </template>
430
+
431
+ <script>
432
+ spiki.data('listApp', () => ({
433
+ list: ['A', 'B', 'C'],
434
+ remove() {
435
+ // 'this.i' is automatically available
436
+ this.list.splice(this.i, 1);
437
+ }
438
+ }));
439
+ </script>
440
+
441
+ ```
442
+
443
+ ---
444
+
445
+ ## Advanced Features
446
+
447
+ ### DOM References (`s-ref`)
448
+
449
+ Sometimes you need to access the raw DOM element (e.g., to focus an input or play a video).
450
+
451
+ ```html
452
+ <div s-data="refApp">
453
+ <input s-ref="myInput" type="text">
454
+ <button s-click="focusMe">Focus Input</button>
455
+ </div>
456
+
457
+ <script>
458
+ spiki.data('refApp', () => ({
459
+ focusMe() {
460
+ // Access DOM element via this.$refs
461
+ this.$refs.myInput.focus();
462
+ }
463
+ }));
464
+ </script>
98
465
 
99
466
  ```
100
467
 
101
468
  ---
102
469
 
470
+ ## Core Concepts
471
+
472
+ ### Component Instance (`this`)
473
+
474
+ Inside your functions, `this` refers to your component state.
475
+
476
+ > **Warning:** Do not use arrow functions for methods (`func: () => {}`) if you need `this`. Use method shorthand (`func() {}`) instead.
477
+
478
+ Spiki injects helper properties:
479
+
480
+ * **`this.$root`**: The HTML element containing the component.
481
+ * **`this.$refs`**: Access elements marked with `s-ref`.
482
+ * **`this.$store`**: Access the global store.
483
+ * **`this.$parent`**: Access the parent component.
484
+
485
+ ### Global Store
486
+
487
+ Share state across multiple components.
488
+
489
+ ```javascript
490
+ // 1. Define Store
491
+ spiki.store('user', {
492
+ name: 'John Doe',
493
+ isLoggedIn: true
494
+ });
495
+
496
+ // 2. Use in Component
497
+ spiki.data('profile', () => ({
498
+ get userName() {
499
+ return this.$store.user.name; // Reactive!
500
+ }
501
+ }));
502
+
503
+ ```
504
+
505
+ ### `spiki.raw(proxy)`
506
+
507
+ Get the original object from a Spiki proxy. Useful for console logging or API calls.
508
+
509
+ ```javascript
510
+ const cleanData = spiki.raw(this.myData);
511
+ console.log(cleanData);
512
+
513
+ ```
514
+
515
+ ---
516
+
517
+ ## Browser Support
518
+
519
+ Spiki requires a browser that supports **ES6 Proxy**.
520
+
521
+ * **Supported:** Chrome, Firefox, Edge, Safari (Modern versions).
522
+ * **Not Supported:** Internet Explorer 11.
523
+
103
524
  ## License
104
525
 
105
- MIT
526
+ MIT License.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "spikijs",
3
3
  "license": "MIT",
4
- "version": "1.1.20",
4
+ "version": "1.1.21",
5
5
  "type": "module",
6
6
  "repository": {
7
7
  "type": "git",
package/spiki.esm.js CHANGED
@@ -547,11 +547,21 @@ var spiki = (() => {
547
547
  var i = els.length;
548
548
  while (i--) mount(els[i]);
549
549
  },
550
- store: (k, v) => v === undefined ? globalStore[k] : (globalStore[k] = v),
550
+ store: (name, value) => {
551
+ if (value === undefined) {
552
+ return globalStore[name];
553
+ }
554
+ globalStore[name] = value;
555
+ var store = globalStore[name];
556
+ if (store && typeof store.init === 'function') {
557
+ store.init.call(store);
558
+ }
559
+ return store;
560
+ },
551
561
  raw: (o) => (o && o._t) || o,
552
562
  mount: (el) => mount(el),
553
563
  unmount: (el) => { if (el && el._m) el._m.unmount(); }
554
564
  };
555
565
  })();
556
566
 
557
- export default spiki;
567
+ export default spiki;
package/spiki.esm.min.js CHANGED
@@ -1 +1 @@
1
- var spiki=(()=>{var e,r=Object,t=Array,a=Reflect,n=Promise,o=Node,i=document,l=console,v="length",f="value",s="push",u="forEach",p="indexOf",c="split",_="slice",d="call",y="keys",h="get",m="prototype",g="hasOwnProperty",b="getPrototypeOf",x="defineProperty",P="create",k="isArray",A="getAttribute",N="removeAttribute",w="hasAttribute",E="tagName",S="type",T="name",$="checked",O="parentNode",j="nextSibling",C="textContent",L="innerHTML",q="replaceWith",M="insertBefore",D="cloneNode",F="remove",K="createTextNode",B="addEventListener",H="input",R="checkbox",W="function",z="radio",G="class",I="model",J="object",Q="unshift",U="scope",V="trim",X="cleanups",Y="nodes",Z="deps",ee="className",re="destroy",te="init",ae="charCodeAt",ne="sched",oe="string",ie="unmount",le="attr",ve="s-data",fe="s-if",se=r[P](null),ue=[],pe=!1,ce=null,_e=!1,de=n.resolve(),ye={blur:1,focus:1,scroll:1,load:1,error:1,mouseenter:1,mouseleave:1,toggle:1},he=e=>{e._q||(e._q=!0,ue[s](e),pe||(pe=!0,de.then(()=>{var e=ue;ue=[],pe=!1;for(var r=e[v];r--;)e[r]._q=!1,e[r]()})))},me=(e,r)=>{var a,n=e;if(typeof r===oe)a=e?e[r]:void 0;else{for(var o=0,i=r[v];o<i-1&&n;)n=n[r[o++]];a=n?n[r[i-1]]:void 0}if(void 0===a){var f=t[k](r)?r.join("."):r;l.warn("[spikijs] Property undefined: "+f)}return{ctx:n,val:a}},ge={};[s,"pop","shift",Q,"splice","sort","reverse"][u](e=>{ge[e]=function(...r){_e=!0;try{return t[m][e].apply(this,r)}finally{_e=!1,xe(this,v)}}});var be=(e,t)=>{if(ce){var a=e._d||(r[x](e,"_d",{value:r[P](null),writable:!0}),e._d),n=a[t]||(a[t]=[]);-1===n[p](ce)&&(n[s](ce),ce[Z][s](n))}},xe=(e,r)=>{if(!_e&&e._d&&e._d[r])for(var t=e._d[r][_](),a=0,n=t[v];a<n;a++){var o=t[a];o[ne]?o[ne](o):o()}},Pe=e=>{for(var r=e[Z][v];r--;){var t=e[Z][r],a=t[p](e);-1!==a&&(t[a]=t[t[v]-1],t.pop())}e[Z]=[]},ke=(e,r)=>{var t=()=>{Pe(t);var r=ce;ce=t;try{e()}finally{ce=r}};return t[Z]=[],t[ne]=r,t(),()=>Pe(t)},Ae=e=>{if(!e||typeof e!==J||e._y||e instanceof o)return e;if(r[m][g][d](e,"_p"))return e._p;var n=new Proxy(e,{get:(e,n,i)=>{if("_y"===n)return i===e._p;if("_t"===n)return e;if("_d"===n)return e._d;if("_i"===n)return e._i;if(t[k](e)&&ge[g](n))return ge[n];var l=r.getOwnPropertyDescriptor(e,n);if(l&&l[h]){var v="_"+n;return v in e||ke(()=>i[v]=l[h][d](i)),i[v]}be(e,n);var f=a[h](e,n,i);return!f||typeof f!==J||f instanceof o?f:Ae(f)},set:(e,n,o,i)=>{var l=e[n],f=t[k](e),s=f?Number(n)<e[v]:r[m][g][d](e,n);if(e._i&&!s)for(var u=r[b](e);u&&u!==r[m];){if(r[m][g][d](u,n)){var p=a.set(u,n,o);return _e||o===l||xe(e,n),p}u=r[b](u)}return p=a.set(e,n,o,i),!_e&&p&&(s&&o===l||(xe(e,n),f?xe(e,v):s||xe(e,"_k"))),p},deleteProperty:(e,n)=>{var o=r[m][g][d](e,n),i=a.deleteProperty(e,n);return i&&o&&(xe(e,n),t[k](e)?xe(e,v):xe(e,"_k")),i},ownKeys:e=>(be(e,"_k"),a.ownKeys(e))});return r[x](e,"_p",{value:n}),n};e=Ae({});var Ne=r[P](null);Ne.text=(e,r)=>{r=null==r?"":r,e[C]!==String(r)&&(e[C]=r)},Ne.html=(e,r)=>{e[L]!=r&&(e[L]=null==r?"":r)},Ne[f]=(e,r)=>{e[S]===R?e[$]=!!r:e[S]===z?e[$]=e[f]==r:e[f]!=r&&(e[f]=null==r?"":r)},Ne[le]=(e,r,t)=>{if(null==r||!1===r)e[N](t);else{var a=!0===r?"":String(r);e[A](t)!==a&&e.setAttribute(t,a)}},Ne[G]=(e,t)=>{var a=e._n||"",n=r[P](null);if(a[c](/\s+/)[u](e=>e&&(n[e]=1)),typeof t===oe)t[c](/\s+/)[u](e=>e&&(n[e]=1));else if(t)for(var o in t)t[o]?n[o]=1:delete n[o];var i=r[y](n).join(" ");e[ee]!==i&&(e[ee]=i)};var we=(a,n)=>{if(a._m)return a._m;var o=a[A](ve);if(se[o]){var l=se[o]();n&&r.setPrototypeOf(l,n);var h=Ae(l);h.$refs={},h.$root=a,h.$store=e,h.$parent=n;var g=[],b=r[P](null),C=e=>{var t=e.target;if(e[S]!==H||!t._c)for(var n=a[O],o=e[S];t&&t!==n;){var i=t._h&&t._h[o];if(i){var l=t._s;if(!l||l.$root!==h.$root){t=t[O];continue}for(var s=i[v];s--;){var u=i[s],p=u.p;if(u[I]){var c=t[S]===R?t[$]:t[f];if(typeof c===oe){var _=c[V]();_&&isFinite(_)&&(48===_[ae](0)&&1!==_[v]&&46!==_[ae](1)||(c=Number(_)))}if(typeof p===oe)l&&(l[p]=c);else{for(var y=l,m=0,g=p[v]-1;m<g&&y;)y=y[p[m++]];y&&(y[p[g]]=c)}}else{var b=me(l,p);typeof b.val===W&&(r[x](e,"currentTarget",{configurable:!0,value:t}),b.val[d](b.ctx,e))}}}t=t[O]}},L=e=>{b[e]||(b[e]=!0,a[B](e,C,!!ye[e]))},Z=(e,n,o)=>{if(1===e.nodeType&&!e[w]("s-ignore"))if(e!==a&&e[w](ve)){var l=we(e,n);l&&o[s](l[ie])}else{var g=e[A](fe),b=!g&&"TEMPLATE"===e[E]&&e[A]("s-for"),$=[];if(e[w](G)&&!e._n&&(e._n=e[ee]),g){var ne=i[K](""),oe=null,se=[];e[q](ne);var ue="!"===g[0],pe=ue?g[_](1):g,ce=-1===pe[p](".")?pe:pe[c](".");return o[s](()=>{se[u](e=>e())}),o[s](ke(()=>{var r=me(n,ce).val;ue&&(r=!r),r?oe||((oe=e[D](!0))[N](fe),Z(oe,n,se),ne[O][M](oe,ne)):oe&&(se[u](e=>e()),se=[],oe[F](),oe=null)},he))}if(b){var _e=b[p](" in ");if(-1!==_e){var de,ye=b[_](0,_e)[V](),ge=b[_](_e+4)[V](),xe=ye.replace(/[()]/g,"")[c](","),Pe=xe[0][V](),Ee=xe[1]?xe[1][V]():null,Se=-1===ge[p](".")?ge:ge[c]("."),Te=e[A]("s-key"),$e=Te?-1===Te[p](".")?Te:Te[c]("."):null,Oe=(ne=i[K](""),r[P](null));return e[q](ne),o[s](()=>{for(var e in Oe)Oe[e][X][u](e=>e())}),o[s](ke(()=>{var a=me(n,Se).val||[];"number"==typeof a&&(a=t.from({length:Math.max(0,Math.floor(a))},(e,r)=>r+1)),t[k](a)&&be(a,v);var o=i.createDocumentFragment(),l=ne;de=r[P](null);for(var f=t[k](a),s=f?a:r[y](a),p=f?a[v]:s[v],c=0;c<p;c++){var h,g=f?c:s[c],b=f?a[c]:a[g];h=null==b||typeof b!==J?String(b):$e?me(b,$e).val:String(g)+"_o",de[h]&&(h+="_"+c);var A=Oe[h];if(A)A[U][Pe]=b,Ee&&(A[U][Ee]=g);else{var N=e.content[D](!0),w=r[P](n);r[x](w,"_i",{value:!0});var E=Ae(w);E[Pe]=b,Ee&&(E[Ee]=g);for(var S=t[m][_][d](N.childNodes),T=[],$=0;$<S[v];$++)Z(S[$],E,T);A={nodes:S,scope:E,cleanups:T},Oe[h]=A}if(A[Y][0]!==l[j]){for($=0;$<A[Y][v];$++)o.appendChild(A[Y][$]);l[O][M](o,l[j])}l=A[Y][A[Y][v]-1],de[h]=!0}for(var C in Oe)de[C]||(Oe[C][X][u](e=>e()),Oe[C][Y][u](e=>e[F]()),delete Oe[C])},he))}}if(e.hasAttributes())for(var je=e.attributes,Ce=je[v];Ce--;){var Le=je[Ce],qe=Le[T],Me=Le[f];if(58===qe[ae](0)){var De=qe[_](1),Fe=33===Me[ae](0),Ke=Fe?Me[_](1):Me;ce=-1===Ke[p](".")?Ke:Ke[c]("."),$[s]({type:le,name:De,path:ce,neg:Fe})}else if(115===qe[ae](0)&&45===qe[ae](1)){let r=qe[_](2),t=-1===Me[p](".")?Me:Me[c](".");if(r===te||r===re)((r,t)=>{var a=me(n,t);typeof a.val===W&&(r===te?he(()=>{var r=a.val[d](a.ctx,e);typeof r===W&&o[s](r)}):o[s](()=>a.val[d](a.ctx,e)))})(r,t);else if("effect"===r)o[s](ke(()=>{var r=me(n,t);typeof r.val===W&&r.val[d](r.ctx,e)},he));else if(r===I){$[s]({type:f,path:t}),e._s=n,e._h=e._h||{};var Be=e[S]===R||e[S]===z||"SELECT"===e[E]?"change":H;Be===H&&(e[B]("compositionstart",()=>e._c=!0),e[B]("compositionend",()=>{e._c=!1,C({target:e,type:H})})),(e._h[Be]=e._h[Be]||[])[Q]({model:!0,p:t}),L(Be)}else"ref"===r?h.$refs[Me]=e:Ne[r]?$[s]({type:r,path:t}):(e._s=n,e._h=e._h||{},(e._h[r]=e._h[r]||[])[s]({p:t}),L(r))}}$[v]&&o[s](ke(()=>{for(var r=$[v];r--;){var t=$[r],a=me(n,t.path),o=typeof a.val===W?a.val[d](a.ctx,e):a.val;t[S]===le?(t.neg&&(o=!o),t[T]===G?Ne[G](e,o):Ne[le](e,o,t[T])):Ne[t[S]](e,o)}},he));for(var He=e.firstChild;He;){var Re=He[j];Z(He,n,o),He=Re}}};Z(a,h,g),h[te]&&h[te]();var ne={unmount:()=>{for(var e in h[re]&&h[re][d](h),g[u](e=>e()),b)a.removeEventListener(e,C);a._m=null}};return a._m=ne,ne}};return{data:(e,r)=>{se[e]=r},start:()=>{for(var e=i.querySelectorAll("[s-data]"),r=e[v];r--;)we(e[r])},store:(r,t)=>void 0===t?e[r]:e[r]=t,raw:e=>e&&e._t||e,mount:e=>we(e),unmount:e=>{e&&e._m&&e._m[ie]()}}})();export default spiki;
1
+ var spiki=(()=>{var r,e=Object,t=Array,a=Reflect,n=Promise,o=Node,i=document,l=console,v="length",f="value",s="push",u="forEach",p="indexOf",c="split",_="slice",d="call",y="keys",h="get",m="prototype",g="hasOwnProperty",b="getPrototypeOf",x="defineProperty",P="create",k="isArray",A="getAttribute",N="removeAttribute",w="hasAttribute",E="tagName",S="type",T="name",$="checked",O="parentNode",j="nextSibling",C="textContent",L="innerHTML",q="replaceWith",M="insertBefore",D="cloneNode",F="remove",K="createTextNode",B="addEventListener",H="input",R="checkbox",W="function",z="radio",G="class",I="model",J="object",Q="unshift",U="scope",V="trim",X="cleanups",Y="nodes",Z="deps",rr="className",er="destroy",tr="init",ar="charCodeAt",nr="sched",or="string",ir="unmount",lr="attr",vr="s-data",fr="s-if",sr=e[P](null),ur=[],pr=!1,cr=null,_r=!1,dr=n.resolve(),yr={blur:1,focus:1,scroll:1,load:1,error:1,mouseenter:1,mouseleave:1,toggle:1},hr=r=>{r._q||(r._q=!0,ur[s](r),pr||(pr=!0,dr.then(()=>{var r=ur;ur=[],pr=!1;for(var e=r[v];e--;)r[e]._q=!1,r[e]()})))},mr=(r,e)=>{var a,n=r;if(typeof e===or)a=r?r[e]:void 0;else{for(var o=0,i=e[v];o<i-1&&n;)n=n[e[o++]];a=n?n[e[i-1]]:void 0}if(void 0===a){var f=t[k](e)?e.join("."):e;l.warn("[spikijs] Property undefined: "+f)}return{ctx:n,val:a}},gr={};[s,"pop","shift",Q,"splice","sort","reverse"][u](r=>{gr[r]=function(...e){_r=!0;try{return t[m][r].apply(this,e)}finally{_r=!1,xr(this,v)}}});var br=(r,t)=>{if(cr){var a=r._d||(e[x](r,"_d",{value:e[P](null),writable:!0}),r._d),n=a[t]||(a[t]=[]);-1===n[p](cr)&&(n[s](cr),cr[Z][s](n))}},xr=(r,e)=>{if(!_r&&r._d&&r._d[e])for(var t=r._d[e][_](),a=0,n=t[v];a<n;a++){var o=t[a];o[nr]?o[nr](o):o()}},Pr=r=>{for(var e=r[Z][v];e--;){var t=r[Z][e],a=t[p](r);-1!==a&&(t[a]=t[t[v]-1],t.pop())}r[Z]=[]},kr=(r,e)=>{var t=()=>{Pr(t);var e=cr;cr=t;try{r()}finally{cr=e}};return t[Z]=[],t[nr]=e,t(),()=>Pr(t)},Ar=r=>{if(!r||typeof r!==J||r._y||r instanceof o)return r;if(e[m][g][d](r,"_p"))return r._p;var n=new Proxy(r,{get:(r,n,i)=>{if("_y"===n)return i===r._p;if("_t"===n)return r;if("_d"===n)return r._d;if("_i"===n)return r._i;if(t[k](r)&&gr[g](n))return gr[n];var l=e.getOwnPropertyDescriptor(r,n);if(l&&l[h]){var v="_"+n;return v in r||kr(()=>i[v]=l[h][d](i)),i[v]}br(r,n);var f=a[h](r,n,i);return!f||typeof f!==J||f instanceof o?f:Ar(f)},set:(r,n,o,i)=>{var l=r[n],f=t[k](r),s=f?Number(n)<r[v]:e[m][g][d](r,n);if(r._i&&!s)for(var u=e[b](r);u&&u!==e[m];){if(e[m][g][d](u,n)){var p=a.set(u,n,o);return _r||o===l||xr(r,n),p}u=e[b](u)}return p=a.set(r,n,o,i),!_r&&p&&(s&&o===l||(xr(r,n),f?xr(r,v):s||xr(r,"_k"))),p},deleteProperty:(r,n)=>{var o=e[m][g][d](r,n),i=a.deleteProperty(r,n);return i&&o&&(xr(r,n),t[k](r)?xr(r,v):xr(r,"_k")),i},ownKeys:r=>(br(r,"_k"),a.ownKeys(r))});return e[x](r,"_p",{value:n}),n};r=Ar({});var Nr=e[P](null);Nr.text=(r,e)=>{e=null==e?"":e,r[C]!==String(e)&&(r[C]=e)},Nr.html=(r,e)=>{r[L]!=e&&(r[L]=null==e?"":e)},Nr[f]=(r,e)=>{r[S]===R?r[$]=!!e:r[S]===z?r[$]=r[f]==e:r[f]!=e&&(r[f]=null==e?"":e)},Nr[lr]=(r,e,t)=>{if(null==e||!1===e)r[N](t);else{var a=!0===e?"":String(e);r[A](t)!==a&&r.setAttribute(t,a)}},Nr[G]=(r,t)=>{var a=r._n||"",n=e[P](null);if(a[c](/\s+/)[u](r=>r&&(n[r]=1)),typeof t===or)t[c](/\s+/)[u](r=>r&&(n[r]=1));else if(t)for(var o in t)t[o]?n[o]=1:delete n[o];var i=e[y](n).join(" ");r[rr]!==i&&(r[rr]=i)};var wr=(a,n)=>{if(a._m)return a._m;var o=a[A](vr);if(sr[o]){var l=sr[o]();n&&e.setPrototypeOf(l,n);var h=Ar(l);h.$refs={},h.$root=a,h.$store=r,h.$parent=n;var g=[],b=e[P](null),C=r=>{var t=r.target;if(r[S]!==H||!t._c)for(var n=a[O],o=r[S];t&&t!==n;){var i=t._h&&t._h[o];if(i){var l=t._s;if(!l||l.$root!==h.$root){t=t[O];continue}for(var s=i[v];s--;){var u=i[s],p=u.p;if(u[I]){var c=t[S]===R?t[$]:t[f];if(typeof c===or){var _=c[V]();_&&isFinite(_)&&(48===_[ar](0)&&1!==_[v]&&46!==_[ar](1)||(c=Number(_)))}if(typeof p===or)l&&(l[p]=c);else{for(var y=l,m=0,g=p[v]-1;m<g&&y;)y=y[p[m++]];y&&(y[p[g]]=c)}}else{var b=mr(l,p);typeof b.val===W&&(e[x](r,"currentTarget",{configurable:!0,value:t}),b.val[d](b.ctx,r))}}}t=t[O]}},L=r=>{b[r]||(b[r]=!0,a[B](r,C,!!yr[r]))},Z=(r,n,o)=>{if(1===r.nodeType&&!r[w]("s-ignore"))if(r!==a&&r[w](vr)){var l=wr(r,n);l&&o[s](l[ir])}else{var g=r[A](fr),b=!g&&"TEMPLATE"===r[E]&&r[A]("s-for"),$=[];if(r[w](G)&&!r._n&&(r._n=r[rr]),g){var nr=i[K](""),or=null,sr=[];r[q](nr);var ur="!"===g[0],pr=ur?g[_](1):g,cr=-1===pr[p](".")?pr:pr[c](".");return o[s](()=>{sr[u](r=>r())}),o[s](kr(()=>{var e=mr(n,cr).val;ur&&(e=!e),e?or||((or=r[D](!0))[N](fr),Z(or,n,sr),nr[O][M](or,nr)):or&&(sr[u](r=>r()),sr=[],or[F](),or=null)},hr))}if(b){var _r=b[p](" in ");if(-1!==_r){var dr,yr=b[_](0,_r)[V](),gr=b[_](_r+4)[V](),xr=yr.replace(/[()]/g,"")[c](","),Pr=xr[0][V](),Er=xr[1]?xr[1][V]():null,Sr=-1===gr[p](".")?gr:gr[c]("."),Tr=r[A]("s-key"),$r=Tr?-1===Tr[p](".")?Tr:Tr[c]("."):null,Or=(nr=i[K](""),e[P](null));return r[q](nr),o[s](()=>{for(var r in Or)Or[r][X][u](r=>r())}),o[s](kr(()=>{var a=mr(n,Sr).val||[];"number"==typeof a&&(a=t.from({length:Math.max(0,Math.floor(a))},(r,e)=>e+1)),t[k](a)&&br(a,v);var o=i.createDocumentFragment(),l=nr;dr=e[P](null);for(var f=t[k](a),s=f?a:e[y](a),p=f?a[v]:s[v],c=0;c<p;c++){var h,g=f?c:s[c],b=f?a[c]:a[g];h=null==b||typeof b!==J?String(b):$r?mr(b,$r).val:String(g)+"_o",dr[h]&&(h+="_"+c);var A=Or[h];if(A)A[U][Pr]=b,Er&&(A[U][Er]=g);else{var N=r.content[D](!0),w=e[P](n);e[x](w,"_i",{value:!0});var E=Ar(w);E[Pr]=b,Er&&(E[Er]=g);for(var S=t[m][_][d](N.childNodes),T=[],$=0;$<S[v];$++)Z(S[$],E,T);A={nodes:S,scope:E,cleanups:T},Or[h]=A}if(A[Y][0]!==l[j]){for($=0;$<A[Y][v];$++)o.appendChild(A[Y][$]);l[O][M](o,l[j])}l=A[Y][A[Y][v]-1],dr[h]=!0}for(var C in Or)dr[C]||(Or[C][X][u](r=>r()),Or[C][Y][u](r=>r[F]()),delete Or[C])},hr))}}if(r.hasAttributes())for(var jr=r.attributes,Cr=jr[v];Cr--;){var Lr=jr[Cr],qr=Lr[T],Mr=Lr[f];if(58===qr[ar](0)){var Dr=qr[_](1),Fr=33===Mr[ar](0),Kr=Fr?Mr[_](1):Mr;cr=-1===Kr[p](".")?Kr:Kr[c]("."),$[s]({type:lr,name:Dr,path:cr,neg:Fr})}else if(115===qr[ar](0)&&45===qr[ar](1)){let e=qr[_](2),t=-1===Mr[p](".")?Mr:Mr[c](".");if(e===tr||e===er)((e,t)=>{var a=mr(n,t);typeof a.val===W&&(e===tr?hr(()=>{var e=a.val[d](a.ctx,r);typeof e===W&&o[s](e)}):o[s](()=>a.val[d](a.ctx,r)))})(e,t);else if("effect"===e)o[s](kr(()=>{var e=mr(n,t);typeof e.val===W&&e.val[d](e.ctx,r)},hr));else if(e===I){$[s]({type:f,path:t}),r._s=n,r._h=r._h||{};var Br=r[S]===R||r[S]===z||"SELECT"===r[E]?"change":H;Br===H&&(r[B]("compositionstart",()=>r._c=!0),r[B]("compositionend",()=>{r._c=!1,C({target:r,type:H})})),(r._h[Br]=r._h[Br]||[])[Q]({model:!0,p:t}),L(Br)}else"ref"===e?h.$refs[Mr]=r:Nr[e]?$[s]({type:e,path:t}):(r._s=n,r._h=r._h||{},(r._h[e]=r._h[e]||[])[s]({p:t}),L(e))}}$[v]&&o[s](kr(()=>{for(var e=$[v];e--;){var t=$[e],a=mr(n,t.path),o=typeof a.val===W?a.val[d](a.ctx,r):a.val;t[S]===lr?(t.neg&&(o=!o),t[T]===G?Nr[G](r,o):Nr[lr](r,o,t[T])):Nr[t[S]](r,o)}},hr));for(var Hr=r.firstChild;Hr;){var Rr=Hr[j];Z(Hr,n,o),Hr=Rr}}};Z(a,h,g),h[tr]&&h[tr]();var nr={unmount:()=>{for(var r in h[er]&&h[er][d](h),g[u](r=>r()),b)a.removeEventListener(r,C);a._m=null}};return a._m=nr,nr}};return{data:(r,e)=>{sr[r]=e},start:()=>{for(var r=i.querySelectorAll("[s-data]"),e=r[v];e--;)wr(r[e])},store:(e,t)=>{if(void 0===t)return r[e];r[e]=t;var a=r[e];return a&&typeof a[tr]===W&&a[tr][d](a),a},raw:r=>r&&r._t||r,mount:r=>wr(r),unmount:r=>{r&&r._m&&r._m[ir]()}}})();export default spiki;
package/spiki.js CHANGED
@@ -550,7 +550,17 @@ var spiki = (() => {
550
550
  var i = els.length;
551
551
  while (i--) mount(els[i]);
552
552
  },
553
- store: (k, v) => v === undefined ? globalStore[k] : (globalStore[k] = v),
553
+ store: (name, value) => {
554
+ if (value === undefined) {
555
+ return globalStore[name];
556
+ }
557
+ globalStore[name] = value;
558
+ var store = globalStore[name];
559
+ if (store && typeof store.init === 'function') {
560
+ store.init.call(store);
561
+ }
562
+ return store;
563
+ },
554
564
  raw: (o) => (o && o._t) || o,
555
565
  mount: (el) => mount(el),
556
566
  unmount: (el) => { if (el && el._m) el._m.unmount(); }
@@ -558,4 +568,4 @@ var spiki = (() => {
558
568
  })();
559
569
 
560
570
  window.spiki = spiki;
561
- })();
571
+ })();
package/spiki.min.js CHANGED
@@ -1 +1 @@
1
- !function(){"use strict";var e=(()=>{var e,r=Object,t=Array,a=Reflect,n=Promise,o=Node,i=document,l=console,v="length",f="value",s="push",u="forEach",p="indexOf",c="split",_="slice",d="call",y="keys",h="get",m="prototype",g="hasOwnProperty",b="getPrototypeOf",x="defineProperty",P="create",w="isArray",A="getAttribute",k="removeAttribute",N="hasAttribute",E="tagName",S="type",T="name",$="checked",O="parentNode",j="nextSibling",C="textContent",L="innerHTML",q="replaceWith",M="insertBefore",D="cloneNode",F="remove",K="createTextNode",B="addEventListener",H="input",R="checkbox",W="function",z="radio",G="class",I="model",J="object",Q="unshift",U="scope",V="trim",X="cleanups",Y="nodes",Z="deps",ee="className",re="destroy",te="init",ae="charCodeAt",ne="sched",oe="string",ie="unmount",le="attr",ve="s-data",fe="s-if",se=r[P](null),ue=[],pe=!1,ce=null,_e=!1,de=n.resolve(),ye={blur:1,focus:1,scroll:1,load:1,error:1,mouseenter:1,mouseleave:1,toggle:1},he=e=>{e._q||(e._q=!0,ue[s](e),pe||(pe=!0,de.then(()=>{var e=ue;ue=[],pe=!1;for(var r=e[v];r--;)e[r]._q=!1,e[r]()})))},me=(e,r)=>{var a,n=e;if(typeof r===oe)a=e?e[r]:void 0;else{for(var o=0,i=r[v];o<i-1&&n;)n=n[r[o++]];a=n?n[r[i-1]]:void 0}if(void 0===a){var f=t[w](r)?r.join("."):r;l.warn("[spikijs] Property undefined: "+f)}return{ctx:n,val:a}},ge={};[s,"pop","shift",Q,"splice","sort","reverse"][u](e=>{ge[e]=function(...r){_e=!0;try{return t[m][e].apply(this,r)}finally{_e=!1,xe(this,v)}}});var be=(e,t)=>{if(ce){var a=e._d||(r[x](e,"_d",{value:r[P](null),writable:!0}),e._d),n=a[t]||(a[t]=[]);-1===n[p](ce)&&(n[s](ce),ce[Z][s](n))}},xe=(e,r)=>{if(!_e&&e._d&&e._d[r])for(var t=e._d[r][_](),a=0,n=t[v];a<n;a++){var o=t[a];o[ne]?o[ne](o):o()}},Pe=e=>{for(var r=e[Z][v];r--;){var t=e[Z][r],a=t[p](e);-1!==a&&(t[a]=t[t[v]-1],t.pop())}e[Z]=[]},we=(e,r)=>{var t=()=>{Pe(t);var r=ce;ce=t;try{e()}finally{ce=r}};return t[Z]=[],t[ne]=r,t(),()=>Pe(t)},Ae=e=>{if(!e||typeof e!==J||e._y||e instanceof o)return e;if(r[m][g][d](e,"_p"))return e._p;var n=new Proxy(e,{get:(e,n,i)=>{if("_y"===n)return i===e._p;if("_t"===n)return e;if("_d"===n)return e._d;if("_i"===n)return e._i;if(t[w](e)&&ge[g](n))return ge[n];var l=r.getOwnPropertyDescriptor(e,n);if(l&&l[h]){var v="_"+n;return v in e||we(()=>i[v]=l[h][d](i)),i[v]}be(e,n);var f=a[h](e,n,i);return!f||typeof f!==J||f instanceof o?f:Ae(f)},set:(e,n,o,i)=>{var l=e[n],f=t[w](e),s=f?Number(n)<e[v]:r[m][g][d](e,n);if(e._i&&!s)for(var u=r[b](e);u&&u!==r[m];){if(r[m][g][d](u,n)){var p=a.set(u,n,o);return _e||o===l||xe(e,n),p}u=r[b](u)}return p=a.set(e,n,o,i),!_e&&p&&(s&&o===l||(xe(e,n),f?xe(e,v):s||xe(e,"_k"))),p},deleteProperty:(e,n)=>{var o=r[m][g][d](e,n),i=a.deleteProperty(e,n);return i&&o&&(xe(e,n),t[w](e)?xe(e,v):xe(e,"_k")),i},ownKeys:e=>(be(e,"_k"),a.ownKeys(e))});return r[x](e,"_p",{value:n}),n};e=Ae({});var ke=r[P](null);ke.text=(e,r)=>{r=null==r?"":r,e[C]!==String(r)&&(e[C]=r)},ke.html=(e,r)=>{e[L]!=r&&(e[L]=null==r?"":r)},ke[f]=(e,r)=>{e[S]===R?e[$]=!!r:e[S]===z?e[$]=e[f]==r:e[f]!=r&&(e[f]=null==r?"":r)},ke[le]=(e,r,t)=>{if(null==r||!1===r)e[k](t);else{var a=!0===r?"":String(r);e[A](t)!==a&&e.setAttribute(t,a)}},ke[G]=(e,t)=>{var a=e._n||"",n=r[P](null);if(a[c](/\s+/)[u](e=>e&&(n[e]=1)),typeof t===oe)t[c](/\s+/)[u](e=>e&&(n[e]=1));else if(t)for(var o in t)t[o]?n[o]=1:delete n[o];var i=r[y](n).join(" ");e[ee]!==i&&(e[ee]=i)};var Ne=(a,n)=>{if(a._m)return a._m;var o=a[A](ve);if(se[o]){var l=se[o]();n&&r.setPrototypeOf(l,n);var h=Ae(l);h.$refs={},h.$root=a,h.$store=e,h.$parent=n;var g=[],b=r[P](null),C=e=>{var t=e.target;if(e[S]!==H||!t._c)for(var n=a[O],o=e[S];t&&t!==n;){var i=t._h&&t._h[o];if(i){var l=t._s;if(!l||l.$root!==h.$root){t=t[O];continue}for(var s=i[v];s--;){var u=i[s],p=u.p;if(u[I]){var c=t[S]===R?t[$]:t[f];if(typeof c===oe){var _=c[V]();_&&isFinite(_)&&(48===_[ae](0)&&1!==_[v]&&46!==_[ae](1)||(c=Number(_)))}if(typeof p===oe)l&&(l[p]=c);else{for(var y=l,m=0,g=p[v]-1;m<g&&y;)y=y[p[m++]];y&&(y[p[g]]=c)}}else{var b=me(l,p);typeof b.val===W&&(r[x](e,"currentTarget",{configurable:!0,value:t}),b.val[d](b.ctx,e))}}}t=t[O]}},L=e=>{b[e]||(b[e]=!0,a[B](e,C,!!ye[e]))},Z=(e,n,o)=>{if(1===e.nodeType&&!e[N]("s-ignore"))if(e!==a&&e[N](ve)){var l=Ne(e,n);l&&o[s](l[ie])}else{var g=e[A](fe),b=!g&&"TEMPLATE"===e[E]&&e[A]("s-for"),$=[];if(e[N](G)&&!e._n&&(e._n=e[ee]),g){var ne=i[K](""),oe=null,se=[];e[q](ne);var ue="!"===g[0],pe=ue?g[_](1):g,ce=-1===pe[p](".")?pe:pe[c](".");return o[s](()=>{se[u](e=>e())}),o[s](we(()=>{var r=me(n,ce).val;ue&&(r=!r),r?oe||((oe=e[D](!0))[k](fe),Z(oe,n,se),ne[O][M](oe,ne)):oe&&(se[u](e=>e()),se=[],oe[F](),oe=null)},he))}if(b){var _e=b[p](" in ");if(-1!==_e){var de,ye=b[_](0,_e)[V](),ge=b[_](_e+4)[V](),xe=ye.replace(/[()]/g,"")[c](","),Pe=xe[0][V](),Ee=xe[1]?xe[1][V]():null,Se=-1===ge[p](".")?ge:ge[c]("."),Te=e[A]("s-key"),$e=Te?-1===Te[p](".")?Te:Te[c]("."):null,Oe=(ne=i[K](""),r[P](null));return e[q](ne),o[s](()=>{for(var e in Oe)Oe[e][X][u](e=>e())}),o[s](we(()=>{var a=me(n,Se).val||[];"number"==typeof a&&(a=t.from({length:Math.max(0,Math.floor(a))},(e,r)=>r+1)),t[w](a)&&be(a,v);var o=i.createDocumentFragment(),l=ne;de=r[P](null);for(var f=t[w](a),s=f?a:r[y](a),p=f?a[v]:s[v],c=0;c<p;c++){var h,g=f?c:s[c],b=f?a[c]:a[g];h=null==b||typeof b!==J?String(b):$e?me(b,$e).val:String(g)+"_o",de[h]&&(h+="_"+c);var A=Oe[h];if(A)A[U][Pe]=b,Ee&&(A[U][Ee]=g);else{var k=e.content[D](!0),N=r[P](n);r[x](N,"_i",{value:!0});var E=Ae(N);E[Pe]=b,Ee&&(E[Ee]=g);for(var S=t[m][_][d](k.childNodes),T=[],$=0;$<S[v];$++)Z(S[$],E,T);A={nodes:S,scope:E,cleanups:T},Oe[h]=A}if(A[Y][0]!==l[j]){for($=0;$<A[Y][v];$++)o.appendChild(A[Y][$]);l[O][M](o,l[j])}l=A[Y][A[Y][v]-1],de[h]=!0}for(var C in Oe)de[C]||(Oe[C][X][u](e=>e()),Oe[C][Y][u](e=>e[F]()),delete Oe[C])},he))}}if(e.hasAttributes())for(var je=e.attributes,Ce=je[v];Ce--;){var Le=je[Ce],qe=Le[T],Me=Le[f];if(58===qe[ae](0)){var De=qe[_](1),Fe=33===Me[ae](0),Ke=Fe?Me[_](1):Me;ce=-1===Ke[p](".")?Ke:Ke[c]("."),$[s]({type:le,name:De,path:ce,neg:Fe})}else if(115===qe[ae](0)&&45===qe[ae](1)){let r=qe[_](2),t=-1===Me[p](".")?Me:Me[c](".");if(r===te||r===re)((r,t)=>{var a=me(n,t);typeof a.val===W&&(r===te?he(()=>{var r=a.val[d](a.ctx,e);typeof r===W&&o[s](r)}):o[s](()=>a.val[d](a.ctx,e)))})(r,t);else if("effect"===r)o[s](we(()=>{var r=me(n,t);typeof r.val===W&&r.val[d](r.ctx,e)},he));else if(r===I){$[s]({type:f,path:t}),e._s=n,e._h=e._h||{};var Be=e[S]===R||e[S]===z||"SELECT"===e[E]?"change":H;Be===H&&(e[B]("compositionstart",()=>e._c=!0),e[B]("compositionend",()=>{e._c=!1,C({target:e,type:H})})),(e._h[Be]=e._h[Be]||[])[Q]({model:!0,p:t}),L(Be)}else"ref"===r?h.$refs[Me]=e:ke[r]?$[s]({type:r,path:t}):(e._s=n,e._h=e._h||{},(e._h[r]=e._h[r]||[])[s]({p:t}),L(r))}}$[v]&&o[s](we(()=>{for(var r=$[v];r--;){var t=$[r],a=me(n,t.path),o=typeof a.val===W?a.val[d](a.ctx,e):a.val;t[S]===le?(t.neg&&(o=!o),t[T]===G?ke[G](e,o):ke[le](e,o,t[T])):ke[t[S]](e,o)}},he));for(var He=e.firstChild;He;){var Re=He[j];Z(He,n,o),He=Re}}};Z(a,h,g),h[te]&&h[te]();var ne={unmount:()=>{for(var e in h[re]&&h[re][d](h),g[u](e=>e()),b)a.removeEventListener(e,C);a._m=null}};return a._m=ne,ne}};return{data:(e,r)=>{se[e]=r},start:()=>{for(var e=i.querySelectorAll("[s-data]"),r=e[v];r--;)Ne(e[r])},store:(r,t)=>void 0===t?e[r]:e[r]=t,raw:e=>e&&e._t||e,mount:e=>Ne(e),unmount:e=>{e&&e._m&&e._m[ie]()}}})();window.spiki=e}();
1
+ (()=>{"use strict";var r=(()=>{var r,e=Object,t=Array,a=Reflect,n=Promise,o=Node,i=document,l=console,v="length",f="value",s="push",u="forEach",p="indexOf",c="split",_="slice",d="call",y="keys",h="get",m="prototype",g="hasOwnProperty",b="getPrototypeOf",x="defineProperty",P="create",w="isArray",A="getAttribute",k="removeAttribute",N="hasAttribute",E="tagName",S="type",T="name",$="checked",O="parentNode",j="nextSibling",C="textContent",L="innerHTML",q="replaceWith",M="insertBefore",D="cloneNode",F="remove",K="createTextNode",B="addEventListener",H="input",R="checkbox",W="function",z="radio",G="class",I="model",J="object",Q="unshift",U="scope",V="trim",X="cleanups",Y="nodes",Z="deps",rr="className",er="destroy",tr="init",ar="charCodeAt",nr="sched",or="string",ir="unmount",lr="attr",vr="s-data",fr="s-if",sr=e[P](null),ur=[],pr=!1,cr=null,_r=!1,dr=n.resolve(),yr={blur:1,focus:1,scroll:1,load:1,error:1,mouseenter:1,mouseleave:1,toggle:1},hr=r=>{r._q||(r._q=!0,ur[s](r),pr||(pr=!0,dr.then(()=>{var r=ur;ur=[],pr=!1;for(var e=r[v];e--;)r[e]._q=!1,r[e]()})))},mr=(r,e)=>{var a,n=r;if(typeof e===or)a=r?r[e]:void 0;else{for(var o=0,i=e[v];o<i-1&&n;)n=n[e[o++]];a=n?n[e[i-1]]:void 0}if(void 0===a){var f=t[w](e)?e.join("."):e;l.warn("[spikijs] Property undefined: "+f)}return{ctx:n,val:a}},gr={};[s,"pop","shift",Q,"splice","sort","reverse"][u](r=>{gr[r]=function(...e){_r=!0;try{return t[m][r].apply(this,e)}finally{_r=!1,xr(this,v)}}});var br=(r,t)=>{if(cr){var a=r._d||(e[x](r,"_d",{value:e[P](null),writable:!0}),r._d),n=a[t]||(a[t]=[]);-1===n[p](cr)&&(n[s](cr),cr[Z][s](n))}},xr=(r,e)=>{if(!_r&&r._d&&r._d[e])for(var t=r._d[e][_](),a=0,n=t[v];a<n;a++){var o=t[a];o[nr]?o[nr](o):o()}},Pr=r=>{for(var e=r[Z][v];e--;){var t=r[Z][e],a=t[p](r);-1!==a&&(t[a]=t[t[v]-1],t.pop())}r[Z]=[]},wr=(r,e)=>{var t=()=>{Pr(t);var e=cr;cr=t;try{r()}finally{cr=e}};return t[Z]=[],t[nr]=e,t(),()=>Pr(t)},Ar=r=>{if(!r||typeof r!==J||r._y||r instanceof o)return r;if(e[m][g][d](r,"_p"))return r._p;var n=new Proxy(r,{get:(r,n,i)=>{if("_y"===n)return i===r._p;if("_t"===n)return r;if("_d"===n)return r._d;if("_i"===n)return r._i;if(t[w](r)&&gr[g](n))return gr[n];var l=e.getOwnPropertyDescriptor(r,n);if(l&&l[h]){var v="_"+n;return v in r||wr(()=>i[v]=l[h][d](i)),i[v]}br(r,n);var f=a[h](r,n,i);return!f||typeof f!==J||f instanceof o?f:Ar(f)},set:(r,n,o,i)=>{var l=r[n],f=t[w](r),s=f?Number(n)<r[v]:e[m][g][d](r,n);if(r._i&&!s)for(var u=e[b](r);u&&u!==e[m];){if(e[m][g][d](u,n)){var p=a.set(u,n,o);return _r||o===l||xr(r,n),p}u=e[b](u)}return p=a.set(r,n,o,i),!_r&&p&&(s&&o===l||(xr(r,n),f?xr(r,v):s||xr(r,"_k"))),p},deleteProperty:(r,n)=>{var o=e[m][g][d](r,n),i=a.deleteProperty(r,n);return i&&o&&(xr(r,n),t[w](r)?xr(r,v):xr(r,"_k")),i},ownKeys:r=>(br(r,"_k"),a.ownKeys(r))});return e[x](r,"_p",{value:n}),n};r=Ar({});var kr=e[P](null);kr.text=(r,e)=>{e=null==e?"":e,r[C]!==String(e)&&(r[C]=e)},kr.html=(r,e)=>{r[L]!=e&&(r[L]=null==e?"":e)},kr[f]=(r,e)=>{r[S]===R?r[$]=!!e:r[S]===z?r[$]=r[f]==e:r[f]!=e&&(r[f]=null==e?"":e)},kr[lr]=(r,e,t)=>{if(null==e||!1===e)r[k](t);else{var a=!0===e?"":String(e);r[A](t)!==a&&r.setAttribute(t,a)}},kr[G]=(r,t)=>{var a=r._n||"",n=e[P](null);if(a[c](/\s+/)[u](r=>r&&(n[r]=1)),typeof t===or)t[c](/\s+/)[u](r=>r&&(n[r]=1));else if(t)for(var o in t)t[o]?n[o]=1:delete n[o];var i=e[y](n).join(" ");r[rr]!==i&&(r[rr]=i)};var Nr=(a,n)=>{if(a._m)return a._m;var o=a[A](vr);if(sr[o]){var l=sr[o]();n&&e.setPrototypeOf(l,n);var h=Ar(l);h.$refs={},h.$root=a,h.$store=r,h.$parent=n;var g=[],b=e[P](null),C=r=>{var t=r.target;if(r[S]!==H||!t._c)for(var n=a[O],o=r[S];t&&t!==n;){var i=t._h&&t._h[o];if(i){var l=t._s;if(!l||l.$root!==h.$root){t=t[O];continue}for(var s=i[v];s--;){var u=i[s],p=u.p;if(u[I]){var c=t[S]===R?t[$]:t[f];if(typeof c===or){var _=c[V]();_&&isFinite(_)&&(48===_[ar](0)&&1!==_[v]&&46!==_[ar](1)||(c=Number(_)))}if(typeof p===or)l&&(l[p]=c);else{for(var y=l,m=0,g=p[v]-1;m<g&&y;)y=y[p[m++]];y&&(y[p[g]]=c)}}else{var b=mr(l,p);typeof b.val===W&&(e[x](r,"currentTarget",{configurable:!0,value:t}),b.val[d](b.ctx,r))}}}t=t[O]}},L=r=>{b[r]||(b[r]=!0,a[B](r,C,!!yr[r]))},Z=(r,n,o)=>{if(1===r.nodeType&&!r[N]("s-ignore"))if(r!==a&&r[N](vr)){var l=Nr(r,n);l&&o[s](l[ir])}else{var g=r[A](fr),b=!g&&"TEMPLATE"===r[E]&&r[A]("s-for"),$=[];if(r[N](G)&&!r._n&&(r._n=r[rr]),g){var nr=i[K](""),or=null,sr=[];r[q](nr);var ur="!"===g[0],pr=ur?g[_](1):g,cr=-1===pr[p](".")?pr:pr[c](".");return o[s](()=>{sr[u](r=>r())}),o[s](wr(()=>{var e=mr(n,cr).val;ur&&(e=!e),e?or||((or=r[D](!0))[k](fr),Z(or,n,sr),nr[O][M](or,nr)):or&&(sr[u](r=>r()),sr=[],or[F](),or=null)},hr))}if(b){var _r=b[p](" in ");if(-1!==_r){var dr,yr=b[_](0,_r)[V](),gr=b[_](_r+4)[V](),xr=yr.replace(/[()]/g,"")[c](","),Pr=xr[0][V](),Er=xr[1]?xr[1][V]():null,Sr=-1===gr[p](".")?gr:gr[c]("."),Tr=r[A]("s-key"),$r=Tr?-1===Tr[p](".")?Tr:Tr[c]("."):null,Or=(nr=i[K](""),e[P](null));return r[q](nr),o[s](()=>{for(var r in Or)Or[r][X][u](r=>r())}),o[s](wr(()=>{var a=mr(n,Sr).val||[];"number"==typeof a&&(a=t.from({length:Math.max(0,Math.floor(a))},(r,e)=>e+1)),t[w](a)&&br(a,v);var o=i.createDocumentFragment(),l=nr;dr=e[P](null);for(var f=t[w](a),s=f?a:e[y](a),p=f?a[v]:s[v],c=0;c<p;c++){var h,g=f?c:s[c],b=f?a[c]:a[g];h=null==b||typeof b!==J?String(b):$r?mr(b,$r).val:String(g)+"_o",dr[h]&&(h+="_"+c);var A=Or[h];if(A)A[U][Pr]=b,Er&&(A[U][Er]=g);else{var k=r.content[D](!0),N=e[P](n);e[x](N,"_i",{value:!0});var E=Ar(N);E[Pr]=b,Er&&(E[Er]=g);for(var S=t[m][_][d](k.childNodes),T=[],$=0;$<S[v];$++)Z(S[$],E,T);A={nodes:S,scope:E,cleanups:T},Or[h]=A}if(A[Y][0]!==l[j]){for($=0;$<A[Y][v];$++)o.appendChild(A[Y][$]);l[O][M](o,l[j])}l=A[Y][A[Y][v]-1],dr[h]=!0}for(var C in Or)dr[C]||(Or[C][X][u](r=>r()),Or[C][Y][u](r=>r[F]()),delete Or[C])},hr))}}if(r.hasAttributes())for(var jr=r.attributes,Cr=jr[v];Cr--;){var Lr=jr[Cr],qr=Lr[T],Mr=Lr[f];if(58===qr[ar](0)){var Dr=qr[_](1),Fr=33===Mr[ar](0),Kr=Fr?Mr[_](1):Mr;cr=-1===Kr[p](".")?Kr:Kr[c]("."),$[s]({type:lr,name:Dr,path:cr,neg:Fr})}else if(115===qr[ar](0)&&45===qr[ar](1)){let e=qr[_](2),t=-1===Mr[p](".")?Mr:Mr[c](".");if(e===tr||e===er)((e,t)=>{var a=mr(n,t);typeof a.val===W&&(e===tr?hr(()=>{var e=a.val[d](a.ctx,r);typeof e===W&&o[s](e)}):o[s](()=>a.val[d](a.ctx,r)))})(e,t);else if("effect"===e)o[s](wr(()=>{var e=mr(n,t);typeof e.val===W&&e.val[d](e.ctx,r)},hr));else if(e===I){$[s]({type:f,path:t}),r._s=n,r._h=r._h||{};var Br=r[S]===R||r[S]===z||"SELECT"===r[E]?"change":H;Br===H&&(r[B]("compositionstart",()=>r._c=!0),r[B]("compositionend",()=>{r._c=!1,C({target:r,type:H})})),(r._h[Br]=r._h[Br]||[])[Q]({model:!0,p:t}),L(Br)}else"ref"===e?h.$refs[Mr]=r:kr[e]?$[s]({type:e,path:t}):(r._s=n,r._h=r._h||{},(r._h[e]=r._h[e]||[])[s]({p:t}),L(e))}}$[v]&&o[s](wr(()=>{for(var e=$[v];e--;){var t=$[e],a=mr(n,t.path),o=typeof a.val===W?a.val[d](a.ctx,r):a.val;t[S]===lr?(t.neg&&(o=!o),t[T]===G?kr[G](r,o):kr[lr](r,o,t[T])):kr[t[S]](r,o)}},hr));for(var Hr=r.firstChild;Hr;){var Rr=Hr[j];Z(Hr,n,o),Hr=Rr}}};Z(a,h,g),h[tr]&&h[tr]();var nr={unmount:()=>{for(var r in h[er]&&h[er][d](h),g[u](r=>r()),b)a.removeEventListener(r,C);a._m=null}};return a._m=nr,nr}};return{data:(r,e)=>{sr[r]=e},start:()=>{for(var r=i.querySelectorAll("[s-data]"),e=r[v];e--;)Nr(r[e])},store:(e,t)=>{if(void 0===t)return r[e];r[e]=t;var a=r[e];return a&&typeof a[tr]===W&&a[tr][d](a),a},raw:r=>r&&r._t||r,mount:r=>Nr(r),unmount:r=>{r&&r._m&&r._m[ir]()}}})();window.spiki=r})();