spikijs 1.1.19 → 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/LICENSE +1 -1
- package/README.md +457 -36
- package/package.json +1 -1
- package/spiki.esm.js +24 -9
- package/spiki.esm.min.js +1 -1
- package/spiki.js +24 -9
- package/spiki.min.js +1 -1
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -1,11 +1,149 @@
|
|
|
1
1
|
# Spikijs
|
|
2
2
|
|
|
3
|
-
|
|
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
|
-
##
|
|
8
|
-
|
|
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
|
-
##
|
|
177
|
+
## Detailed Usage Examples
|
|
40
178
|
|
|
41
|
-
###
|
|
42
|
-
|
|
43
|
-
|
|
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
|
-
|
|
48
|
-
|
|
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
|
-
<
|
|
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
|
-
|
|
225
|
+
### 3. Dynamic Attributes (`:[attribute]`)
|
|
58
226
|
|
|
59
|
-
|
|
227
|
+
You can bind ANY HTML attribute to a variable by adding a colon `:` before the attribute name.
|
|
60
228
|
|
|
61
|
-
|
|
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
|
-
|
|
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="
|
|
67
|
-
<
|
|
68
|
-
<
|
|
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
|
-
|
|
71
|
-
|
|
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
|
-
|
|
320
|
+
> **Note:** Events receive the native Event Object (`e`). You can access the element via `e.target` or `e.currentTarget`.
|
|
77
321
|
|
|
78
|
-
|
|
322
|
+
### 6. Side Effects (`s-effect`)
|
|
79
323
|
|
|
80
|
-
|
|
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
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
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
|
-
|
|
89
|
-
this.
|
|
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
|
-
|
|
97
|
-
|
|
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
package/spiki.esm.js
CHANGED
|
@@ -130,11 +130,11 @@ var spiki = (() => {
|
|
|
130
130
|
|
|
131
131
|
var makeReactive = (obj) => {
|
|
132
132
|
if (!obj || typeof obj !== 'object' || obj._y || obj instanceof Node) return obj;
|
|
133
|
-
if (obj
|
|
133
|
+
if (Object.prototype.hasOwnProperty.call(obj, '_p')) return obj._p;
|
|
134
134
|
|
|
135
135
|
var proxy = new Proxy(obj, {
|
|
136
136
|
get: (target, key, receiver) => {
|
|
137
|
-
if (key === '_y') return
|
|
137
|
+
if (key === '_y') return receiver === target._p;
|
|
138
138
|
if (key === '_t') return target;
|
|
139
139
|
if (key === '_d') return target._d;
|
|
140
140
|
if (key === '_i') return target._i;
|
|
@@ -224,13 +224,15 @@ var spiki = (() => {
|
|
|
224
224
|
};
|
|
225
225
|
domOps.class = (el, val) => {
|
|
226
226
|
var base = el._n || '';
|
|
227
|
-
var
|
|
227
|
+
var obj = Object.create(null);
|
|
228
|
+
base.split(/\s+/).forEach(c => c && (obj[c] = 1));
|
|
229
|
+
|
|
228
230
|
if (typeof val === 'string') {
|
|
229
|
-
|
|
231
|
+
val.split(/\s+/).forEach(c => c && (obj[c] = 1));
|
|
230
232
|
} else if (val) {
|
|
231
|
-
for (var k in val)
|
|
232
|
-
}
|
|
233
|
-
var res =
|
|
233
|
+
for (var k in val) val[k] ? (obj[k] = 1) : delete obj[k];
|
|
234
|
+
}
|
|
235
|
+
var res = Object.keys(obj).join(' ');
|
|
234
236
|
if (el.className !== res) el.className = res;
|
|
235
237
|
};
|
|
236
238
|
|
|
@@ -378,6 +380,9 @@ var spiki = (() => {
|
|
|
378
380
|
|
|
379
381
|
return parentCleanups.push(effect(() => {
|
|
380
382
|
var list = evalPath(scope, listPath).val || [];
|
|
383
|
+
if (typeof list === 'number') {
|
|
384
|
+
list = Array.from({ length: Math.max(0, Math.floor(list)) }, (_, i) => i + 1);
|
|
385
|
+
}
|
|
381
386
|
if (Array.isArray(list)) track(list, 'length');
|
|
382
387
|
var frag = document.createDocumentFragment();
|
|
383
388
|
var cursor = end;
|
|
@@ -542,11 +547,21 @@ var spiki = (() => {
|
|
|
542
547
|
var i = els.length;
|
|
543
548
|
while (i--) mount(els[i]);
|
|
544
549
|
},
|
|
545
|
-
store: (
|
|
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
|
+
},
|
|
546
561
|
raw: (o) => (o && o._t) || o,
|
|
547
562
|
mount: (el) => mount(el),
|
|
548
563
|
unmount: (el) => { if (el && el._m) el._m.unmount(); }
|
|
549
564
|
};
|
|
550
565
|
})();
|
|
551
566
|
|
|
552
|
-
export default spiki;
|
|
567
|
+
export default spiki;
|
package/spiki.esm.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var spiki=(()=>{var
|
|
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
|
@@ -133,11 +133,11 @@ var spiki = (() => {
|
|
|
133
133
|
|
|
134
134
|
var makeReactive = (obj) => {
|
|
135
135
|
if (!obj || typeof obj !== 'object' || obj._y || obj instanceof Node) return obj;
|
|
136
|
-
if (obj
|
|
136
|
+
if (Object.prototype.hasOwnProperty.call(obj, '_p')) return obj._p;
|
|
137
137
|
|
|
138
138
|
var proxy = new Proxy(obj, {
|
|
139
139
|
get: (target, key, receiver) => {
|
|
140
|
-
if (key === '_y') return
|
|
140
|
+
if (key === '_y') return receiver === target._p;
|
|
141
141
|
if (key === '_t') return target;
|
|
142
142
|
if (key === '_d') return target._d;
|
|
143
143
|
if (key === '_i') return target._i;
|
|
@@ -227,13 +227,15 @@ var spiki = (() => {
|
|
|
227
227
|
};
|
|
228
228
|
domOps.class = (el, val) => {
|
|
229
229
|
var base = el._n || '';
|
|
230
|
-
var
|
|
230
|
+
var obj = Object.create(null);
|
|
231
|
+
base.split(/\s+/).forEach(c => c && (obj[c] = 1));
|
|
232
|
+
|
|
231
233
|
if (typeof val === 'string') {
|
|
232
|
-
|
|
234
|
+
val.split(/\s+/).forEach(c => c && (obj[c] = 1));
|
|
233
235
|
} else if (val) {
|
|
234
|
-
for (var k in val)
|
|
235
|
-
}
|
|
236
|
-
var res =
|
|
236
|
+
for (var k in val) val[k] ? (obj[k] = 1) : delete obj[k];
|
|
237
|
+
}
|
|
238
|
+
var res = Object.keys(obj).join(' ');
|
|
237
239
|
if (el.className !== res) el.className = res;
|
|
238
240
|
};
|
|
239
241
|
|
|
@@ -381,6 +383,9 @@ var spiki = (() => {
|
|
|
381
383
|
|
|
382
384
|
return parentCleanups.push(effect(() => {
|
|
383
385
|
var list = evalPath(scope, listPath).val || [];
|
|
386
|
+
if (typeof list === 'number') {
|
|
387
|
+
list = Array.from({ length: Math.max(0, Math.floor(list)) }, (_, i) => i + 1);
|
|
388
|
+
}
|
|
384
389
|
if (Array.isArray(list)) track(list, 'length');
|
|
385
390
|
var frag = document.createDocumentFragment();
|
|
386
391
|
var cursor = end;
|
|
@@ -545,7 +550,17 @@ var spiki = (() => {
|
|
|
545
550
|
var i = els.length;
|
|
546
551
|
while (i--) mount(els[i]);
|
|
547
552
|
},
|
|
548
|
-
store: (
|
|
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
|
+
},
|
|
549
564
|
raw: (o) => (o && o._t) || o,
|
|
550
565
|
mount: (el) => mount(el),
|
|
551
566
|
unmount: (el) => { if (el && el._m) el._m.unmount(); }
|
|
@@ -553,4 +568,4 @@ var spiki = (() => {
|
|
|
553
568
|
})();
|
|
554
569
|
|
|
555
570
|
window.spiki = spiki;
|
|
556
|
-
})();
|
|
571
|
+
})();
|
package/spiki.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(()=>{"use strict";var
|
|
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})();
|