-
Notifications
You must be signed in to change notification settings - Fork 2
/
bundle.js
4030 lines (3300 loc) · 95 KB
/
bundle.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/******/ (function(modules) { // webpackBootstrap
/******/ // The module cache
/******/ var installedModules = {};
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/ // Check if module is in cache
/******/ if(installedModules[moduleId])
/******/ return installedModules[moduleId].exports;
/******/ // Create a new module (and put it into the cache)
/******/ var module = installedModules[moduleId] = {
/******/ exports: {},
/******/ id: moduleId,
/******/ loaded: false
/******/ };
/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/ // Flag the module as loaded
/******/ module.loaded = true;
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/ // expose the modules object (__webpack_modules__)
/******/ __webpack_require__.m = modules;
/******/ // expose the module cache
/******/ __webpack_require__.c = installedModules;
/******/ // __webpack_public_path__
/******/ __webpack_require__.p = "";
/******/ // Load entry module and return exports
/******/ return __webpack_require__(0);
/******/ })
/************************************************************************/
/******/ ([
/* 0 */
/***/ function(module, exports, __webpack_require__) {
'use strict'
__webpack_require__(1)
__webpack_require__(77)
__webpack_require__(80)
__webpack_require__(82)
/***/ },
/* 1 */
/***/ function(module, exports, __webpack_require__) {
'use strict'
module.exports = __webpack_require__(2)
/***/ },
/* 2 */
/***/ function(module, exports, __webpack_require__) {
'use strict'
var nx
if (typeof Proxy === 'undefined') {
nx = { supported: false }
} else {
nx = {
component: __webpack_require__(3),
middlewares: __webpack_require__(14),
components: __webpack_require__(50),
utils: __webpack_require__(57),
supported: true
}
__webpack_require__(58)
__webpack_require__(69)
}
if (typeof module !== 'undefined' && module.exports) {
module.exports = nx
}
if (typeof window !== 'undefined') {
window.nx = nx
}
/***/ },
/* 3 */
/***/ function(module, exports, __webpack_require__) {
'use strict'
__webpack_require__(4)
module.exports = __webpack_require__(6)
/***/ },
/* 4 */
/***/ function(module, exports, __webpack_require__) {
'use strict'
__webpack_require__(5)
/***/ },
/* 5 */
/***/ function(module, exports) {
'use strict'
const secret = {
registered: Symbol('registered')
}
if (!document.registerElement) {
const registry = new Map()
const observer = new MutationObserver(onMutations)
observer.observe(document, {childList: true, subtree: true})
function onMutations (mutations) {
for (let mutation of mutations) {
Array.prototype.forEach.call(mutation.addedNodes, onNodeAdded)
Array.prototype.forEach.call(mutation.removedNodes, onNodeRemoved)
}
mutations = observer.takeRecords()
if (mutations.length) {
onMutations(mutations)
}
}
function onNodeAdded (node) {
if (!(node instanceof Element)) return
let config = registry.get(node.getAttribute('is'))
if (!config || config.extends !== node.tagName.toLowerCase()) {
config = registry.get(node.tagName.toLowerCase())
}
if (config && !node[secret.registered]) {
Object.assign(node, config.prototype)
node[secret.registered] = true
}
if (node[secret.registered] && node.attachedCallback) {
node.attachedCallback()
}
Array.prototype.forEach.call(node.childNodes, onNodeAdded)
}
function onNodeRemoved (node) {
if (node[secret.registered] && node.detachedCallback) {
node.detachedCallback()
}
Array.prototype.forEach.call(node.childNodes, onNodeRemoved)
}
document.registerElement = function registerElement (name, config) {
name = name.toLowerCase()
if (config.extends) {
config.extends = config.extends.toLowerCase()
}
registry.set(name, config)
if (config.extends) {
Array.prototype.forEach.call(document.querySelectorAll(`[is=${name}]`), onNodeAdded)
} else {
Array.prototype.forEach.call(document.getElementsByTagName(name), onNodeAdded)
}
}
const originalCreateElement = document.createElement
document.createElement = function createElement (name, is) {
const element = originalCreateElement.call(document, name)
if (is) {
element.setAttribute('is', is)
}
return element
}
}
/***/ },
/* 6 */
/***/ function(module, exports, __webpack_require__) {
'use strict'
module.exports = __webpack_require__(7)
/***/ },
/* 7 */
/***/ function(module, exports, __webpack_require__) {
'use strict'
const validateConfig = __webpack_require__(8)
const validateMiddlewares = __webpack_require__(9)
const getContext = __webpack_require__(10)
const onNodeAdded = __webpack_require__(11)
const onNodeRemoved = __webpack_require__(13)
const secret = {
config: Symbol('component config')
}
const observerConfig = {
childList: true,
subtree: true
}
let context
let prevParent
const addedNodes = new Set()
module.exports = function component (rawConfig) {
return {use, useOnContent, register, [secret.config]: validateConfig(rawConfig)}
}
function use (middleware) {
if (typeof middleware !== 'function') {
throw new TypeError('first argument must be a function')
}
if (middleware.$type && middleware.$type !== 'component') {
throw new Error(`${middleware.$name} can't be used as a component middleware`)
}
const config = this[secret.config]
config.middlewares = config.middlewares || []
config.middlewares.push(middleware)
return this
}
function useOnContent (middleware) {
if (typeof middleware !== 'function') {
throw new TypeError('first argument must be a function')
}
if (middleware.$type && middleware.$type !== 'content') {
throw new Error(`${middleware.$name} can't be used as a content middleware`)
}
const config = this[secret.config]
if (config.isolate === true) {
console.log('warning: content middlewares have no effect inside isolated components')
}
config.contentMiddlewares = config.contentMiddlewares || []
config.contentMiddlewares.push(middleware)
return this
}
function register (name) {
if (typeof name !== 'string') {
throw new TypeError('first argument must be a string')
}
const config = this[secret.config]
const parentProto = config.element ? config.elementProto : HTMLElement.prototype
const proto = Object.create(parentProto)
config.shouldValidate = validateMiddlewares(config.contentMiddlewares, config.middlewares)
proto[secret.config] = config
proto.attachedCallback = attachedCallback
if (config.root) {
proto.detachedCallback = detachedCallback
}
return document.registerElement(name, {prototype: proto, extends: config.element})
}
function attachedCallback () {
const config = this[secret.config]
if (!this.$registered) {
if (typeof config.state === 'object') {
this.$state = config.state
} else if (config.state === true) {
this.$state = {}
} else if (config.state === 'inherit') {
this.$state = {}
this.$inheritState = true
}
this.$isolate = config.isolate
this.$contentMiddlewares = config.contentMiddlewares
this.$middlewares = config.middlewares
this.$shouldValidate = config.shouldValidate
this.$registered = true
if (config.root) {
this.$root = this
const contentObserver = new MutationObserver(onMutations)
contentObserver.observe(this, observerConfig)
}
if (addedNodes.size === 0) {
Promise.resolve().then(processAddedNodes)
}
addedNodes.add(this)
}
}
function detachedCallback () {
onNodeRemoved(this)
}
function onMutations (mutations, contentObserver) {
let mutationIndex = mutations.length
while (mutationIndex--) {
const mutation = mutations[mutationIndex]
let nodes = mutation.removedNodes
let nodeIndex = nodes.length
while (nodeIndex--) {
onNodeRemoved(nodes[nodeIndex])
}
nodes = mutation.addedNodes
nodeIndex = nodes.length
while (nodeIndex--) {
addedNodes.add(nodes[nodeIndex])
}
}
processAddedNodes()
mutations = contentObserver.takeRecords()
if (mutations.length) {
onMutations(mutations, contentObserver)
}
}
function processAddedNodes () {
addedNodes.forEach(processAddedNode)
addedNodes.clear()
context = prevParent = undefined
}
function processAddedNode (node) {
const parentNode = node.parentNode || node.host
if (prevParent !== parentNode) {
prevParent = parentNode
context = getContext(parentNode)
}
onNodeAdded(node, context)
if (node.shadowRoot) {
const shadowObserver = new MutationObserver(onMutations)
shadowObserver.observe(node.shadowRoot, observerConfig)
}
}
/***/ },
/* 8 */
/***/ function(module, exports) {
'use strict'
module.exports = function validateConfig (rawConfig) {
if (rawConfig === undefined) {
rawConfig = {}
}
if (typeof rawConfig !== 'object') {
throw new TypeError('invalid component config, must be an object or undefined')
}
const resultConfig = {}
if (typeof rawConfig.state === 'boolean' || rawConfig.state === 'inherit') {
resultConfig.state = rawConfig.state
} else if (typeof rawConfig.state === 'object') {
resultConfig.state = rawConfig.state
} else if (rawConfig.state === undefined) {
resultConfig.state = true
} else {
throw new Error('invalid state config: ' + rawConfig.state)
}
if (typeof rawConfig.isolate === 'boolean' || rawConfig.isolate === 'middlewares') {
resultConfig.isolate = rawConfig.isolate
} else if (rawConfig.isolate === undefined) {
resultConfig.isolate = false
} else {
throw new Error(`invalid isolate config: ${rawConfig.isolate}, must be a boolean, undefined or 'middlewares'`)
}
if (typeof rawConfig.root === 'boolean') {
resultConfig.root = rawConfig.root
} else if (rawConfig.root === undefined) {
resultConfig.root = false
} else {
throw new Error('invalid root config: ' + rawConfig.root)
}
if (resultConfig.root && (resultConfig.isolate === true || !resultConfig.state)) {
throw new Error('root components must have a state and must not be isolated')
}
if (typeof rawConfig.element === 'string') {
try {
resultConfig.elementProto = Object.getPrototypeOf(document.createElement(rawConfig.element))
resultConfig.element = rawConfig.element
} catch (err) {
throw new Error(`invalid element config: ${rawConfig.element}, must be the name of a native element`)
}
} else if (rawConfig.element !== undefined) {
throw new Error(`invalid element config: ${rawConfig.element}, must be the name of a native element`)
}
return resultConfig
}
/***/ },
/* 9 */
/***/ function(module, exports) {
'use strict'
const names = new Set()
const missing = new Set()
const duplicates = new Set()
module.exports = function validateMiddlewares (contentMiddlewares, middlewares, strict) {
names.clear()
missing.clear()
duplicates.clear()
if (contentMiddlewares) {
contentMiddlewares.forEach(validateMiddleware)
}
if (middlewares) {
middlewares.forEach(validateMiddleware)
}
if (missing.size) {
if (!strict) return true
throw new Error(`missing middlewares: ${Array.from(missing).join()}`)
}
if (duplicates.size) {
if (!strict) return true
throw new Error(`duplicate middlewares: ${Array.from(duplicates).join()}`)
}
}
function validateMiddleware (middleware) {
const name = middleware.$name
const require = middleware.$require
if (name) {
if (names.has(name)) {
duplicates.add(name)
}
names.add(name)
}
if (require) {
for (let dependency of require) {
if (!names.has(dependency)) {
missing.add(dependency)
}
}
}
}
/***/ },
/* 10 */
/***/ function(module, exports) {
'use strict'
module.exports = function getContext (node) {
const context = {contentMiddlewares: []}
while (node) {
if (!context.state && node.$state) {
context.state = node.$state
}
if (!context.state && node.$contextState) {
context.state = node.$contextState
}
if (!context.isolate) {
context.isolate = node.$isolate
if (node.$contentMiddlewares) {
context.contentMiddlewares = node.$contentMiddlewares.concat(context.contentMiddlewares)
}
}
if (node === node.$root) {
context.root = context.root || node
return context
}
if (node.host) {
context.root = context.root || node
node = node.host
} else {
node = node.parentNode
}
}
return context
}
/***/ },
/* 11 */
/***/ function(module, exports, __webpack_require__) {
'use strict'
const validateMiddlewares = __webpack_require__(9)
const runMiddlewares = __webpack_require__(12)
module.exports = function onNodeAdded (node, context) {
const parent = node.parentNode
const validParent = (parent && parent.$lifecycleStage === 'attached')
if (validParent && node === node.$root) {
throw new Error(`Nested root component: ${node.tagName}`)
}
if ((validParent || node === node.$root) && context.isolate !== true) {
setupNodeAndChildren(node, context.state, context.contentMiddlewares, context.root)
}
}
function setupNodeAndChildren (node, state, contentMiddlewares, root) {
const type = node.nodeType
if (!shouldProcess(node, type)) return
node.$lifecycleStage = 'attached'
node.$contextState = node.$contextState || state || node.$state
node.$state = node.$state || node.$contextState
if (node.$inheritState) {
Object.setPrototypeOf(node.$state, node.$contextState)
}
node.$root = node.$root || root
if (node.$isolate === 'middlewares') {
contentMiddlewares = node.$contentMiddlewares || []
} else if (node.$contentMiddlewares) {
contentMiddlewares = contentMiddlewares.concat(node.$contentMiddlewares)
}
if (node.$shouldValidate) {
validateMiddlewares(contentMiddlewares, node.$middlewares, true)
}
node.$cleanup = $cleanup
runMiddlewares(node, contentMiddlewares, node.$middlewares)
if (type === 1 && node.$isolate !== true) {
let child = node.firstChild
while (child) {
setupNodeAndChildren(child, node.$state, contentMiddlewares, node.$root)
child = child.nextSibling
}
child = node.shadowRoot ? node.shadowRoot.firstChild : undefined
while (child) {
setupNodeAndChildren(child, node.$state, contentMiddlewares, node.shadowRoot)
child = child.nextSibling
}
}
}
function shouldProcess (node, type) {
if (node.$lifecycleStage) {
return false
}
if (type === 1) {
return ((!node.hasAttribute('is') && node.tagName.indexOf('-') === -1) || node.$registered)
}
if (type === 3) {
return node.nodeValue.trim()
}
}
function $cleanup (fn, ...args) {
if (typeof fn !== 'function') {
throw new TypeError('first argument must be a function')
}
this.$cleaners = this.$cleaners || []
this.$cleaners.push({fn, args})
}
/***/ },
/* 12 */
/***/ function(module, exports) {
'use strict'
let node
let index, middlewares, middlewaresLength
let contentIndex, contentMiddlewares, contentMiddlewaresLength
module.exports = function runMiddlewares (currNode, currContentMiddlewares, currMiddlewares) {
node = currNode
middlewares = currMiddlewares
contentMiddlewares = currContentMiddlewares
middlewaresLength = currMiddlewares ? currMiddlewares.length : 0
contentMiddlewaresLength = currContentMiddlewares ? currContentMiddlewares.length : 0
index = contentIndex = 0
next()
node = middlewares = contentMiddlewares = undefined
}
function next () {
if (contentIndex < contentMiddlewaresLength) {
contentMiddlewares[contentIndex++].call(node, node, node.$state, next)
next()
} else if (index < middlewaresLength) {
middlewares[index++].call(node, node, node.$state, next)
next()
}
}
/***/ },
/* 13 */
/***/ function(module, exports) {
'use strict'
module.exports = function onNodeRemoved (node) {
const parent = node.parentNode
if (!parent || parent.$lifecycleStage === 'detached') {
cleanupNodeAndChildren(node)
}
}
function cleanupNodeAndChildren (node) {
if (node.$lifecycleStage !== 'attached') return
node.$lifecycleStage = 'detached'
if (node.$cleaners) {
node.$cleaners.forEach(runCleaner, node)
node.$cleaners = undefined
}
let child = node.firstChild
while (child) {
cleanupNodeAndChildren(child)
child = child.nextSibling
}
child = node.shadowRoot ? node.shadowRoot.firstChild : undefined
while (child) {
cleanupNodeAndChildren(child, node.$state, contentMiddlewares)
child = child.nextSibling
}
}
function runCleaner (cleaner) {
cleaner.fn.apply(this, cleaner.args)
}
/***/ },
/* 14 */
/***/ function(module, exports, __webpack_require__) {
'use strict'
module.exports = {
attributes: __webpack_require__(15),
props: __webpack_require__(22),
events: __webpack_require__(23),
interpolate: __webpack_require__(24),
render: __webpack_require__(25),
flow: __webpack_require__(26),
bindable: __webpack_require__(28),
bind: __webpack_require__(29),
style: __webpack_require__(30),
animate: __webpack_require__(31),
route: __webpack_require__(32),
params: __webpack_require__(33),
ref: __webpack_require__(35),
observe: __webpack_require__(39),
meta: __webpack_require__(49)
}
/***/ },
/* 15 */
/***/ function(module, exports, __webpack_require__) {
'use strict'
const compiler = __webpack_require__(16)
let currElem
let currAttributes = new Map()
const attributeCache = new Map()
function attributes (elem, state, next) {
if (elem.nodeType !== 1) return
elem.$attribute = $attribute
initAttributes(elem)
next()
processAttributes(elem)
}
attributes.$name = 'attributes'
attributes.$require = ['observe']
module.exports = attributes
function $attribute (name, config) {
const attr = currAttributes.get(name)
if (!attr) return
if (currElem !== this) {
throw new Error(`${name} attribute handler for ${this.tagName} is defined too late.`)
}
if (typeof config === 'function') {
config = { handler: config }
}
if (!config.handler) {
throw new Error(`${name} attribute must have a handler`)
}
processCustomAttribute.call(this, attr, name, config)
currAttributes.delete(name)
}
function initAttributes (elem) {
currElem = elem
const cloneId = elem.getAttribute('clone-id')
if (cloneId) {
const attributes = attributeCache.get(cloneId)
if (attributes) {
currAttributes = new Map(attributes)
} else {
extractAttributes(elem)
attributeCache.set(cloneId, new Map(currAttributes))
}
}
extractAttributes(elem)
}
function extractAttributes (elem) {
const attributes = elem.attributes
let i = attributes.length
while (i--) {
const attribute = attributes[i]
let type = attribute.name[0]
let name = attribute.name
if (type === '$' || type === '@') {
name = name.slice(1)
} else {
type = ''
}
currAttributes.set(name, {value: attribute.value, type})
}
}
function processAttributes (elem) {
currAttributes.forEach(processAttribute, elem)
currAttributes.clear()
currElem = undefined
}
function processAttribute (attr, name) {
if (attr.type === '$') {
const expression = compiler.compileExpression(attr.value || name)
processExpression.call(this, expression, name, defaultHandler)
} else if (attr.type === '@') {
const expression = compiler.compileExpression(attr.value || name)
this.$observe(processExpression, expression, name, defaultHandler)
}
}
function processCustomAttribute (attr, name, config) {
if (config.type && config.type.indexOf(attr.type) === -1) {
throw new Error(`${name} attribute is not allowed to be ${attr.type || 'normal'} type`)
}
if (config.init) {
config.init.call(this)
}
if (attr.type === '@') {
const expression = compiler.compileExpression(attr.value || name)
this.$observe(processExpression, expression, name, config.handler)
} else if (attr.type === '$') {
const expression = compiler.compileExpression(attr.value || name)
processExpression.call(this, expression, name, config.handler)
} else {
config.handler.call(this, attr.value, name)
}
}
function processExpression (expression, name, handler) {
const value = expression(this.$contextState)
handler.call(this, value, name)
}
function defaultHandler (value, name) {
if (value) {
this.setAttribute(name, value)
} else {
this.removeAttribute(name)
}
}
/***/ },
/* 16 */
/***/ function(module, exports, __webpack_require__) {
'use strict'
const context = __webpack_require__(17)
const modifiers = __webpack_require__(18)
const compiler = __webpack_require__(19)
module.exports = {
compileExpression: compiler.compileExpression,
compileCode: compiler.compileCode,
expose: context.expose,
hide: context.hide,
hideAll: context.hideAll,
filter: modifiers.filter,
limiter: modifiers.limiter
}
/***/ },
/* 17 */
/***/ function(module, exports) {
/* WEBPACK VAR INJECTION */(function(global) {'use strict'
const globals = new Set()
const proxies = new WeakMap()
const handlers = {has}
let globalObj
if (typeof window !== 'undefined') globalObj = window // eslint-disable-line
else if (typeof global !== 'undefined') globalObj = global // eslint-disable-line
else if (typeof self !== 'undefined') globalObj = self // eslint-disable-line
globalObj.$nxCompileToSandbox = toSandbox
globalObj.$nxCompileCreateBackup = createBackup
module.exports = {
expose,
hide,
hideAll
}
function expose (...globalNames) {
for (let globalName of globalNames) {
globals.add(globalName)
}
return this
}
function hide (...globalNames) {
for (let globalName of globalNames) {
globals.delete(globalName)
}
return this
}
function hideAll () {
globals.clear()
return this
}
function has (target, key) {
return globals.has(key) ? Reflect.has(target, key) : true
}
function toSandbox (obj) {
if (typeof obj !== 'object') {
throw new TypeError('first argument must be an object')
}
let sandbox = proxies.get(obj)
if (!sandbox) {
sandbox = new Proxy(obj, handlers)
proxies.set(obj, sandbox)
}
return sandbox
}
function createBackup (context, tempVars) {
if (typeof tempVars === 'object') {
const backup = {}
for (let key of Object.keys(tempVars)) {
backup[key] = context[key]
}
return backup
}
}
/* WEBPACK VAR INJECTION */}.call(exports, (function() { return this; }())))
/***/ },
/* 18 */
/***/ function(module, exports) {
'use strict'
const filters = new Map()
const limiters = new Map()
module.exports = {
filters,
limiters,
filter,
limiter
}
function filter (name, handler) {
if (typeof name !== 'string') {
throw new TypeError('First argument must be a string.')
}
if (typeof handler !== 'function') {
throw new TypeError('Second argument must be a function.')
}
if (filters.has(name)) {
throw new Error(`A filter named ${name} is already registered.`)
}
filters.set(name, handler)
return this
}
function limiter (name, handler) {
if (typeof name !== 'string') {
throw new TypeError('First argument must be a string.')
}
if (typeof handler !== 'function') {
throw new TypeError('Second argument must be a function.')
}
if (limiters.has(name)) {
throw new Error(`A limiter named ${name} is already registered.`)
}
limiters.set(name, handler)
return this
}
/***/ },
/* 19 */
/***/ function(module, exports, __webpack_require__) {
'use strict'
const parser = __webpack_require__(20)
const expressionCache = new Map()
const codeCache = new Map()
module.exports = {
compileExpression,
compileCode
}
function compileExpression (src) {
if (typeof src !== 'string') {
throw new TypeError('First argument must be a string.')
}
let expression = expressionCache.get(src)
if (!expression) {
expression = parser.parseExpression(src)
expressionCache.set(src, expression)
}
if (typeof expression === 'function') {
return expression
}
return function evaluateExpression (context) {
let value = expression.exec(context)
for (let filter of expression.filters) {
const args = filter.argExpressions.map(evaluateArgExpression, context)
value = filter.effect(value, ...args)
}
return value
}
}
function compileCode (src) {
if (typeof src !== 'string') {
throw new TypeError('First argument must be a string.')
}
let code = codeCache.get(src)
if (!code) {
code = parser.parseCode(src)
codeCache.set(src, code)
}
if (typeof code === 'function') {
return code
}
const context = {}
return function evaluateCode (state, tempVars) {
let i = 0
function next () {
Object.assign(context, tempVars)
if (i < code.limiters.length) {
const limiter = code.limiters[i++]
const args = limiter.argExpressions.map(evaluateArgExpression, state)
limiter.effect(next, context, ...args)
} else {
code.exec(state, tempVars)
}
}