iOS: implement slider style gallery

This commit is contained in:
王劲鹏 2023-06-13 20:28:22 +08:00 committed by osborn
parent bd5c5c48ee
commit 3393a474f9
5 changed files with 244 additions and 79 deletions

View File

@ -0,0 +1,29 @@
/*
* Copyright [2023] [Doric.Pub]
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
//
// DoricSliderNode.h
// Doric
//
// Created by jingpeng.wang on 2023/6/13.
//
#import <UIKit/UIKit.h>
@interface DoricSliderLayout : UICollectionViewFlowLayout
@property(nonatomic, assign) CGFloat galleryItemWidth;
@property(nonatomic, assign) CGFloat galleryMinScale;
@property(nonatomic, assign) CGFloat galleryMinAlpha;
@end

View File

@ -0,0 +1,60 @@
/*
* Copyright [2023] [Doric.Pub]
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
//
// DoricSliderNode.m
// Doric
//
// Created by jingpeng.wang on 2023/6/13.
//
#import "DoricSliderLayout.h"
@implementation DoricSliderLayout
- (NSArray<UICollectionViewLayoutAttributes *> *)layoutAttributesForElementsInRect:(CGRect)rect {
NSArray *attributes = [super layoutAttributesForElementsInRect:rect];
CGRect visitRect = {self.collectionView.contentOffset,self.collectionView.bounds.size};
NSMutableArray *attributesCopy = [NSMutableArray array];
for (UICollectionViewLayoutAttributes *attribute in attributes) {
UICollectionViewLayoutAttributes *attributeCopy = [attribute copy];
[attributesCopy addObject:attributeCopy];
}
for (UICollectionViewLayoutAttributes *attribute in attributesCopy) {
CGFloat distance = CGRectGetMidX(visitRect) - attribute.center.x;
float diff = fabs(distance);
CATransform3D scaleTransform = CATransform3DIdentity;
if (diff >= 0 && diff <= self.galleryItemWidth) {
float scale = 1 - (1 - self.galleryMinScale) * (diff / self.galleryItemWidth);
scaleTransform = CATransform3DMakeScale(scale, scale, scale);
attribute.alpha = 1 - (1 - self.galleryMinAlpha) * (diff / self.galleryItemWidth);
} else {
float scale = self.galleryMinScale;
scaleTransform = CATransform3DMakeScale(scale, scale, scale);
attribute.alpha = self.galleryMinAlpha;
}
attribute.transform3D = scaleTransform;
}
return attributesCopy;
}
- (BOOL)shouldInvalidateLayoutForBoundsChange:(CGRect)newBounds {
return YES;
}
@end

View File

@ -23,6 +23,7 @@
#import "DoricSliderNode.h" #import "DoricSliderNode.h"
#import "Doric.h" #import "Doric.h"
#import "DoricSlideItemNode.h" #import "DoricSlideItemNode.h"
#import "DoricSliderLayout.h"
@interface DoricSliderViewCell : UICollectionViewCell @interface DoricSliderViewCell : UICollectionViewCell
@property(nonatomic, strong) DoricSlideItemNode *doricSlideItemNode; @property(nonatomic, strong) DoricSlideItemNode *doricSlideItemNode;
@ -47,7 +48,11 @@ @interface DoricSliderNode () <UICollectionViewDataSource, UICollectionViewDeleg
@property(nonatomic, strong) NSString *slideStyle; @property(nonatomic, strong) NSString *slideStyle;
@property(nonatomic, assign) CGFloat minScale; @property(nonatomic, assign) CGFloat minScale;
@property(nonatomic, assign) CGFloat maxScale; @property(nonatomic, assign) CGFloat maxScale;
@property(nonatomic, assign) CGFloat galleryMinScale;
@property(nonatomic, assign) CGFloat galleryMinAlpha;
@property(nonatomic, assign) CGFloat galleryItemWidth;
@property(nonatomic, assign) BOOL scheduledLayout; @property(nonatomic, assign) BOOL scheduledLayout;
@property (nonatomic, assign) NSInteger currentPage;
@end @end
@interface DoricSliderView : UICollectionView @interface DoricSliderView : UICollectionView
@ -75,7 +80,7 @@ - (instancetype)initWithContext:(DoricContext *)doricContext {
} }
- (UICollectionView *)build { - (UICollectionView *)build {
UICollectionViewFlowLayout *flowLayout = [[UICollectionViewFlowLayout alloc] init]; DoricSliderLayout *flowLayout = [[DoricSliderLayout alloc] init];
[flowLayout setScrollDirection:UICollectionViewScrollDirectionHorizontal]; [flowLayout setScrollDirection:UICollectionViewScrollDirectionHorizontal];
return [[[DoricSliderView alloc] initWithFrame:CGRectZero return [[[DoricSliderView alloc] initWithFrame:CGRectZero
collectionViewLayout:flowLayout] collectionViewLayout:flowLayout]
@ -113,8 +118,21 @@ - (void)blendView:(UICollectionView *)view forPropName:(NSString *)name propValu
} else if ([@"slideStyle" isEqualToString:name]) { } else if ([@"slideStyle" isEqualToString:name]) {
if ([prop isKindOfClass:NSDictionary.class]) { if ([prop isKindOfClass:NSDictionary.class]) {
self.slideStyle = prop[@"type"]; self.slideStyle = prop[@"type"];
if ([self.slideStyle isEqualToString:@"zoomOut"]) {
self.maxScale = [prop[@"maxScale"] floatValue]; self.maxScale = [prop[@"maxScale"] floatValue];
self.minScale = [prop[@"minScale"] floatValue]; self.minScale = [prop[@"minScale"] floatValue];
} else if([self.slideStyle isEqualToString:@"gallery"]) {
self.galleryMinScale = [prop[@"minScale"] floatValue];
self.galleryMinAlpha = [prop[@"minAlpha"] floatValue];
self.galleryItemWidth = [prop[@"itemWidth"] floatValue];
self.view.pagingEnabled = NO;
DoricSliderLayout *layout = (DoricSliderLayout*)self.view.collectionViewLayout;
layout.galleryItemWidth = self.galleryItemWidth;
layout.galleryMinScale = self.galleryMinScale;
layout.galleryMinAlpha = self.galleryMinAlpha;
}
} else if ([prop isKindOfClass:NSString.class]) { } else if ([prop isKindOfClass:NSString.class]) {
self.slideStyle = prop; self.slideStyle = prop;
} }
@ -161,11 +179,18 @@ - (void)afterBlended:(NSDictionary *)props {
__strong typeof(_self) self = _self; __strong typeof(_self) self = _self;
[self.view reloadData]; [self.view reloadData];
NSUInteger position = (self.loop ? 1 : 0) + self.slidePosition; NSUInteger position = (self.loop ? 1 : 0) + self.slidePosition;
if (self.view.width == 0) { float itemWidth;
if ([self.slideStyle isEqualToString:@"gallery"]) {
itemWidth = self.galleryItemWidth;
} else {
itemWidth = self.view.width;
}
if (itemWidth == 0) {
self.needResetScroll = true; self.needResetScroll = true;
} else { } else {
self.needResetScroll = false; self.needResetScroll = false;
[self.view setContentOffset:CGPointMake(position * self.view.width, self.view.contentOffset.y) animated:false]; [self.view setContentOffset:CGPointMake(position * itemWidth, self.view.contentOffset.y) animated:false];
} }
}); });
} }
@ -180,6 +205,12 @@ - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSe
} }
- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath { - (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath {
if ([self.slideStyle isEqualToString:@"gallery"]) {
UICollectionViewFlowLayout *layout = (UICollectionViewFlowLayout *)self.view.collectionViewLayout;
int margin = (self.view.width - self.galleryItemWidth) / 2;
layout.sectionInset = UIEdgeInsetsMake(0, margin, 0, margin);
return CGSizeMake(self.galleryItemWidth, self.view.height);
}
return CGSizeMake(self.view.width, self.view.height); return CGSizeMake(self.view.width, self.view.height);
} }
@ -208,7 +239,12 @@ - (__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collection
DoricSlideItemNode *node = cell.doricSlideItemNode; DoricSlideItemNode *node = cell.doricSlideItemNode;
node.viewId = model[@"id"]; node.viewId = model[@"id"];
[node blend:props]; [node blend:props];
CGFloat maxWidth = collectionView.width; CGFloat maxWidth;
if ([self.slideStyle isEqualToString:@"gallery"]) {
maxWidth = self.galleryItemWidth;
} else {
maxWidth = collectionView.width;
}
if (collectionView.doricLayout.widthSpec == DoricLayoutFit) { if (collectionView.doricLayout.widthSpec == DoricLayoutFit) {
maxWidth = [[UIScreen mainScreen] bounds].size.width; maxWidth = [[UIScreen mainScreen] bounds].size.width;
} }
@ -322,7 +358,12 @@ - (void)blendSubNode:(NSDictionary *)subModel {
if (viewNode) { if (viewNode) {
CGSize originSize = viewNode.view.frame.size; CGSize originSize = viewNode.view.frame.size;
[viewNode blend:subModel[@"props"]]; [viewNode blend:subModel[@"props"]];
if ([self.slideStyle isEqualToString:@"gallery"]) {
[viewNode.view.doricLayout apply:CGSizeMake(self.galleryItemWidth, self.view.height)];
} else {
[viewNode.view.doricLayout apply:CGSizeMake(self.view.width, self.view.height)]; [viewNode.view.doricLayout apply:CGSizeMake(self.view.width, self.view.height)];
}
[viewNode requestLayout]; [viewNode requestLayout];
if (CGSizeEqualToSize(originSize, viewNode.view.frame.size)) { if (CGSizeEqualToSize(originSize, viewNode.view.frame.size)) {
skipReload = YES; skipReload = YES;
@ -343,6 +384,39 @@ - (void)blendSubNode:(NSDictionary *)subModel {
}]; }];
} }
//paging by cell | paging with one cell at a time
- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView
{
if ([self.slideStyle isEqualToString:@"gallery"]) {
CGFloat cellWidth = self.galleryItemWidth;
self.currentPage = (scrollView.contentOffset.x - cellWidth / 2) / (cellWidth) + 1;
}
}
- (void)scrollViewWillEndDragging:(UIScrollView *)scrollView withVelocity:(CGPoint)velocity targetContentOffset:(inout CGPoint *)targetContentOffset
{
if ([self.slideStyle isEqualToString:@"gallery"]) {
CGFloat cellWidth = self.galleryItemWidth;
NSInteger page = (scrollView.contentOffset.x - cellWidth / 2) / (cellWidth) + 1;
if (velocity.x > 0) page++;
if (velocity.x < 0) page--;
page = MAX(page, 0);
NSInteger prePage = self.currentPage - 1;
if(prePage > 0 && page < prePage){
page = prePage;
} else if (page > self.currentPage + 1){
page = self.currentPage + 1;
}
self.currentPage = page;
CGFloat newOffset = page * (cellWidth);
targetContentOffset->x = newOffset;
}
}
- (void)scrollViewDidScroll:(UIScrollView *)scrollView { - (void)scrollViewDidScroll:(UIScrollView *)scrollView {
if ([self.slideStyle isEqualToString:@"zoomOut"]) { if ([self.slideStyle isEqualToString:@"zoomOut"]) {
CGFloat centerX = scrollView.width / 2.f; CGFloat centerX = scrollView.width / 2.f;
@ -357,15 +431,28 @@ - (void)scrollViewDidScroll:(UIScrollView *)scrollView {
} }
- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView { - (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView {
NSUInteger pageIndex = (NSUInteger) (scrollView.contentOffset.x / scrollView.width); NSUInteger pageIndex;
if ([self.slideStyle isEqualToString:@"gallery"]) {
pageIndex = (NSUInteger) (scrollView.contentOffset.x / self.galleryItemWidth);
scrollView.contentOffset = CGPointMake(pageIndex * self.galleryItemWidth, scrollView.contentOffset.y);
} else {
pageIndex = (NSUInteger) (scrollView.contentOffset.x / scrollView.width);
scrollView.contentOffset = CGPointMake(pageIndex * scrollView.width, scrollView.contentOffset.y); scrollView.contentOffset = CGPointMake(pageIndex * scrollView.width, scrollView.contentOffset.y);
}
if (self.loop) { if (self.loop) {
float itemWidth;
if ([self.slideStyle isEqualToString:@"gallery"]) {
itemWidth = self.galleryItemWidth;
} else {
itemWidth = self.view.width;
}
if (pageIndex == 0) { if (pageIndex == 0) {
[self.view setContentOffset:CGPointMake(self.itemCount * self.view.width, self.view.contentOffset.y) animated:false]; [self.view setContentOffset:CGPointMake(self.itemCount * itemWidth, self.view.contentOffset.y) animated:false];
pageIndex = self.itemCount - 1; pageIndex = self.itemCount - 1;
} else if (pageIndex == self.itemCount + 1) { } else if (pageIndex == self.itemCount + 1) {
[self.view setContentOffset:CGPointMake(1 * self.view.width, self.view.contentOffset.y) animated:false]; [self.view setContentOffset:CGPointMake(1 * itemWidth, self.view.contentOffset.y) animated:false];
pageIndex = 0; pageIndex = 0;
} else { } else {
pageIndex = pageIndex - 1; pageIndex = pageIndex - 1;
@ -384,10 +471,17 @@ - (void)slidePage:(NSDictionary *)params withPromise:(DoricPromise *)promise {
NSUInteger pageIndex = [params[@"page"] unsignedIntegerValue]; NSUInteger pageIndex = [params[@"page"] unsignedIntegerValue];
BOOL smooth = [params[@"smooth"] boolValue]; BOOL smooth = [params[@"smooth"] boolValue];
if (self.loop) { float itemWidth;
[self.view setContentOffset:CGPointMake((pageIndex + 1) * self.view.width, self.view.contentOffset.y) animated:smooth]; if ([self.slideStyle isEqualToString:@"gallery"]) {
itemWidth = self.galleryItemWidth;
} else { } else {
[self.view setContentOffset:CGPointMake(pageIndex * self.view.width, self.view.contentOffset.y) animated:smooth]; itemWidth = self.view.width;
}
if (self.loop) {
[self.view setContentOffset:CGPointMake((pageIndex + 1) * itemWidth, self.view.contentOffset.y) animated:smooth];
} else {
[self.view setContentOffset:CGPointMake(pageIndex * itemWidth, self.view.contentOffset.y) animated:smooth];
} }
[promise resolve:nil]; [promise resolve:nil];
@ -398,7 +492,13 @@ - (void)slidePage:(NSDictionary *)params withPromise:(DoricPromise *)promise {
} }
- (NSNumber *)getSlidedPage { - (NSNumber *)getSlidedPage {
NSUInteger pageIndex = (NSUInteger) (self.view.contentOffset.x / self.view.width); NSUInteger pageIndex;
if ([self.slideStyle isEqualToString:@"gallery"]) {
pageIndex = (NSUInteger) (self.view.contentOffset.x / self.galleryItemWidth);
} else {
pageIndex = (NSUInteger) (self.view.contentOffset.x / self.view.width);
}
if (self.loop) { if (self.loop) {
return @(pageIndex - 1); return @(pageIndex - 1);
} else { } else {

View File

@ -293,10 +293,10 @@ var doric = (function (exports) {
(module.exports = function (key, value) { (module.exports = function (key, value) {
return sharedStore[key] || (sharedStore[key] = value !== undefined ? value : {}); return sharedStore[key] || (sharedStore[key] = value !== undefined ? value : {});
})('versions', []).push({ })('versions', []).push({
version: '3.29.0', version: '3.28.0',
mode: 'global', mode: 'global',
copyright: '© 2014-2023 Denis Pushkarev (zloirock.ru)', copyright: '© 2014-2023 Denis Pushkarev (zloirock.ru)',
license: 'https://github.com/zloirock/core-js/blob/v3.29.0/LICENSE', license: 'https://github.com/zloirock/core-js/blob/v3.28.0/LICENSE',
source: 'https://github.com/zloirock/core-js' source: 'https://github.com/zloirock/core-js'
}); });
}); });
@ -9562,7 +9562,7 @@ var doric = (function (exports) {
var aTypedArray$d = arrayBufferViewCore.aTypedArray; var aTypedArray$d = arrayBufferViewCore.aTypedArray;
var exportTypedArrayMethod$e = arrayBufferViewCore.exportTypedArrayMethod; var exportTypedArrayMethod$e = arrayBufferViewCore.exportTypedArrayMethod;
var WORKS_WITH_OBJECTS_AND_GENERIC_ON_TYPED_ARRAYS = !fails(function () { var WORKS_WITH_OBJECTS_AND_GEERIC_ON_TYPED_ARRAYS = !fails(function () {
// eslint-disable-next-line es/no-typed-arrays -- required for testing // eslint-disable-next-line es/no-typed-arrays -- required for testing
var array = new Uint8ClampedArray(2); var array = new Uint8ClampedArray(2);
functionCall($set, array, { length: 1, 0: 3 }, 1); functionCall($set, array, { length: 1, 0: 3 }, 1);
@ -9570,7 +9570,7 @@ var doric = (function (exports) {
}); });
// https://bugs.chromium.org/p/v8/issues/detail?id=11294 and other // https://bugs.chromium.org/p/v8/issues/detail?id=11294 and other
var TO_OBJECT_BUG = WORKS_WITH_OBJECTS_AND_GENERIC_ON_TYPED_ARRAYS && arrayBufferViewCore.NATIVE_ARRAY_BUFFER_VIEWS && fails(function () { var TO_OBJECT_BUG = WORKS_WITH_OBJECTS_AND_GEERIC_ON_TYPED_ARRAYS && arrayBufferViewCore.NATIVE_ARRAY_BUFFER_VIEWS && fails(function () {
var array = new Int8Array$2(2); var array = new Int8Array$2(2);
array.set(1); array.set(1);
array.set('2', 1); array.set('2', 1);
@ -9583,13 +9583,13 @@ var doric = (function (exports) {
aTypedArray$d(this); aTypedArray$d(this);
var offset = toOffset(arguments.length > 1 ? arguments[1] : undefined, 1); var offset = toOffset(arguments.length > 1 ? arguments[1] : undefined, 1);
var src = toObject(arrayLike); var src = toObject(arrayLike);
if (WORKS_WITH_OBJECTS_AND_GENERIC_ON_TYPED_ARRAYS) { return functionCall($set, this, src, offset); } if (WORKS_WITH_OBJECTS_AND_GEERIC_ON_TYPED_ARRAYS) { return functionCall($set, this, src, offset); }
var length = this.length; var length = this.length;
var len = lengthOfArrayLike(src); var len = lengthOfArrayLike(src);
var index = 0; var index = 0;
if (len + offset > length) { throw RangeError$2('Wrong length'); } if (len + offset > length) { throw RangeError$2('Wrong length'); }
while (index < len) { this[offset + index] = src[index++]; } while (index < len) { this[offset + index] = src[index++]; }
}, !WORKS_WITH_OBJECTS_AND_GENERIC_ON_TYPED_ARRAYS || TO_OBJECT_BUG); }, !WORKS_WITH_OBJECTS_AND_GEERIC_ON_TYPED_ARRAYS || TO_OBJECT_BUG);
var aTypedArray$c = arrayBufferViewCore.aTypedArray; var aTypedArray$c = arrayBufferViewCore.aTypedArray;
var exportTypedArrayMethod$d = arrayBufferViewCore.exportTypedArrayMethod; var exportTypedArrayMethod$d = arrayBufferViewCore.exportTypedArrayMethod;
@ -10566,14 +10566,14 @@ var doric = (function (exports) {
var Map$a = mapHelpers.Map; var Map$a = mapHelpers.Map;
var MapPrototype = mapHelpers.proto; var MapPrototype = mapHelpers.proto;
var forEach$2 = functionUncurryThis(MapPrototype.forEach); var forEach$1 = functionUncurryThis(MapPrototype.forEach);
var entries = functionUncurryThis(MapPrototype.entries); var entries = functionUncurryThis(MapPrototype.entries);
var next$1 = entries(new Map$a()).next; var next$1 = entries(new Map$a()).next;
var mapIterate = function (map, fn, interruptible) { var mapIterate = function (map, fn, interruptible) {
return interruptible ? iterateSimple(entries(map), function (entry) { return interruptible ? iterateSimple(entries(map), function (entry) {
return fn(entry[1], entry[0]); return fn(entry[1], entry[0]);
}, next$1) : forEach$2(map, fn); }, next$1) : forEach$1(map, fn);
}; };
var Map$9 = mapHelpers.Map; var Map$9 = mapHelpers.Map;
@ -11447,7 +11447,7 @@ var doric = (function (exports) {
var $TypeError$d = TypeError; var $TypeError$d = TypeError;
var $RangeIterator = iteratorCreateConstructor(function NumericRangeIterator(start, end, option, type, zero, one) { var $RangeIterator = iteratorCreateConstructor(function NumericRangeIterator(start, end, option, type, zero, one) {
// TODO: Drop the first `typeof` check after removing legacy methods in `core-js@4` // TODO: Drop the first `typeof` check after removing lagacy methods in `core-js@4`
if (typeof start != type || (end !== Infinity && end !== -Infinity && typeof end != type)) { if (typeof start != type || (end !== Infinity && end !== -Infinity && typeof end != type)) {
throw $TypeError$d(INCORRECT_RANGE); throw $TypeError$d(INCORRECT_RANGE);
} }
@ -12363,21 +12363,31 @@ var doric = (function (exports) {
var i = this.skip(IS_WHITESPACE$1, this.index); var i = this.skip(IS_WHITESPACE$1, this.index);
var fork = this.fork(i); var fork = this.fork(i);
var chr = at$1(source, i); var chr = at$1(source, i);
if (exec$6(IS_NUMBER_START, chr)) { return fork.number(); } var result;
switch (chr) { if (exec$6(IS_NUMBER_START, chr)) { result = fork.number(); }
else { switch (chr) {
case '{': case '{':
return fork.object(); result = fork.object();
break;
case '[': case '[':
return fork.array(); result = fork.array();
break;
case '"': case '"':
return fork.string(); result = fork.string();
break;
case 't': case 't':
return fork.keyword(true); result = fork.keyword(true);
break;
case 'f': case 'f':
return fork.keyword(false); result = fork.keyword(false);
break;
case 'n': case 'n':
return fork.keyword(null); result = fork.keyword(null);
} throw SyntaxError$2('Unexpected character: "' + chr + '" at: ' + i); break;
default:
throw SyntaxError$2('Unexpected character: "' + chr + '" at: ' + i);
} }
return result;
}, },
node: function (type, value, start, end, nodes) { node: function (type, value, start, end, nodes) {
return new Node(value, end, type ? null : slice$1(this.source, start, end), nodes); return new Node(value, end, type ? null : slice$1(this.source, start, end), nodes);
@ -13794,12 +13804,12 @@ var doric = (function (exports) {
var Set$7 = setHelpers.Set; var Set$7 = setHelpers.Set;
var SetPrototype = setHelpers.proto; var SetPrototype = setHelpers.proto;
var forEach$1 = functionUncurryThis(SetPrototype.forEach); var forEach = functionUncurryThis(SetPrototype.forEach);
var keys = functionUncurryThis(SetPrototype.keys); var keys = functionUncurryThis(SetPrototype.keys);
var next = keys(new Set$7()).next; var next = keys(new Set$7()).next;
var setIterate = function (set, fn, interruptible) { var setIterate = function (set, fn, interruptible) {
return interruptible ? iterateSimple(keys(set), fn, next) : forEach$1(set, fn); return interruptible ? iterateSimple(keys(set), fn, next) : forEach(set, fn);
}; };
var Set$6 = setHelpers.Set; var Set$6 = setHelpers.Set;
@ -15704,7 +15714,7 @@ var doric = (function (exports) {
var type = classof(value); var type = classof(value);
var deep = false; var deep = false;
var C, name, cloned, dataTransfer, i, length, keys, key, source, target, options; var C, name, cloned, dataTransfer, i, length, keys, key, source, target;
switch (type) { switch (type) {
case 'Array': case 'Array':
@ -15859,12 +15869,11 @@ var doric = (function (exports) {
if (!C && typeof value.slice != 'function') { throwUnpolyfillable(type); } if (!C && typeof value.slice != 'function') { throwUnpolyfillable(type); }
// detached buffers throws in `DataView` and `.slice` // detached buffers throws in `DataView` and `.slice`
try { try {
if (typeof value.slice == 'function' && !value.resizable) { if (typeof value.slice == 'function') {
cloned = value.slice(0); cloned = value.slice(0);
} else { } else {
length = value.byteLength; length = value.byteLength;
options = 'maxByteLength' in value ? { maxByteLength: value.maxByteLength } : undefined; cloned = new ArrayBuffer(length);
cloned = new ArrayBuffer(length, options);
source = new C(value); source = new C(value);
target = new C(cloned); target = new C(cloned);
for (i = 0; i < length; i++) { for (i = 0; i < length; i++) {
@ -16087,7 +16096,6 @@ var doric = (function (exports) {
result += key + value; result += key + value;
}); });
return (isPure && !url.toJSON) return (isPure && !url.toJSON)
|| (!searchParams.size && (isPure || !descriptors))
|| !searchParams.sort || !searchParams.sort
|| url.href !== 'http://a/c%20d?a=1&c=3' || url.href !== 'http://a/c%20d?a=1&c=3'
|| searchParams.get('c') !== '3' || searchParams.get('c') !== '3'
@ -16314,7 +16322,6 @@ var doric = (function (exports) {
var ITERATOR = wellKnownSymbol('iterator'); var ITERATOR = wellKnownSymbol('iterator');
@ -16490,22 +16497,20 @@ var doric = (function (exports) {
// `URLSearchParams` constructor // `URLSearchParams` constructor
// https://url.spec.whatwg.org/#interface-urlsearchparams // https://url.spec.whatwg.org/#interface-urlsearchparams
var URLSearchParamsConstructor = function URLSearchParams(/* init */) { var URLSearchParamsConstructor = function URLSearchParams(/* init */) {
anInstance(this, URLSearchParamsPrototype$1); anInstance(this, URLSearchParamsPrototype);
var init = arguments.length > 0 ? arguments[0] : undefined; var init = arguments.length > 0 ? arguments[0] : undefined;
var state = setInternalState$1(this, new URLSearchParamsState(init)); setInternalState$1(this, new URLSearchParamsState(init));
if (!descriptors) { this.length = state.entries.length; }
}; };
var URLSearchParamsPrototype$1 = URLSearchParamsConstructor.prototype; var URLSearchParamsPrototype = URLSearchParamsConstructor.prototype;
defineBuiltIns(URLSearchParamsPrototype$1, { defineBuiltIns(URLSearchParamsPrototype, {
// `URLSearchParams.prototype.append` method // `URLSearchParams.prototype.append` method
// https://url.spec.whatwg.org/#dom-urlsearchparams-append // https://url.spec.whatwg.org/#dom-urlsearchparams-append
append: function append(name, value) { append: function append(name, value) {
validateArgumentsLength(arguments.length, 2); validateArgumentsLength(arguments.length, 2);
var state = getInternalParamsState(this); var state = getInternalParamsState(this);
push$1(state.entries, { key: toString_1(name), value: toString_1(value) }); push$1(state.entries, { key: toString_1(name), value: toString_1(value) });
if (!descriptors) { this.length++; }
state.updateURL(); state.updateURL();
}, },
// `URLSearchParams.prototype.delete` method // `URLSearchParams.prototype.delete` method
@ -16520,7 +16525,6 @@ var doric = (function (exports) {
if (entries[index].key === key) { splice(entries, index, 1); } if (entries[index].key === key) { splice(entries, index, 1); }
else { index++; } else { index++; }
} }
if (!descriptors) { this.length = entries.length; }
state.updateURL(); state.updateURL();
}, },
// `URLSearchParams.prototype.get` method // `URLSearchParams.prototype.get` method
@ -16582,7 +16586,6 @@ var doric = (function (exports) {
} }
} }
if (!found) { push$1(entries, { key: key, value: val }); } if (!found) { push$1(entries, { key: key, value: val }); }
if (!descriptors) { this.length = entries.length; }
state.updateURL(); state.updateURL();
}, },
// `URLSearchParams.prototype.sort` method // `URLSearchParams.prototype.sort` method
@ -16620,24 +16623,14 @@ var doric = (function (exports) {
}, { enumerable: true }); }, { enumerable: true });
// `URLSearchParams.prototype[@@iterator]` method // `URLSearchParams.prototype[@@iterator]` method
defineBuiltIn(URLSearchParamsPrototype$1, ITERATOR, URLSearchParamsPrototype$1.entries, { name: 'entries' }); defineBuiltIn(URLSearchParamsPrototype, ITERATOR, URLSearchParamsPrototype.entries, { name: 'entries' });
// `URLSearchParams.prototype.toString` method // `URLSearchParams.prototype.toString` method
// https://url.spec.whatwg.org/#urlsearchparams-stringification-behavior // https://url.spec.whatwg.org/#urlsearchparams-stringification-behavior
defineBuiltIn(URLSearchParamsPrototype$1, 'toString', function toString() { defineBuiltIn(URLSearchParamsPrototype, 'toString', function toString() {
return getInternalParamsState(this).serialize(); return getInternalParamsState(this).serialize();
}, { enumerable: true }); }, { enumerable: true });
// `URLSearchParams.prototype.size` getter
// https://github.com/whatwg/url/pull/734
if (descriptors) { defineBuiltInAccessor(URLSearchParamsPrototype$1, 'size', {
get: function size() {
return getInternalParamsState(this).entries.length;
},
configurable: true,
enumerable: true
}); }
setToStringTag(URLSearchParamsConstructor, URL_SEARCH_PARAMS); setToStringTag(URLSearchParamsConstructor, URL_SEARCH_PARAMS);
_export({ global: true, constructor: true, forced: !urlConstructorDetection }, { _export({ global: true, constructor: true, forced: !urlConstructorDetection }, {
@ -17746,23 +17739,6 @@ var doric = (function (exports) {
} }
}); });
var URLSearchParamsPrototype = URLSearchParams.prototype;
var forEach = functionUncurryThis(URLSearchParamsPrototype.forEach);
// `URLSearchParams.prototype.size` getter
// https://github.com/whatwg/url/pull/734
if (descriptors && !('size' in URLSearchParamsPrototype)) {
defineBuiltInAccessor(URLSearchParamsPrototype, 'size', {
get: function size() {
var count = 0;
forEach(this, function () { count++; });
return count;
},
configurable: true,
enumerable: true
});
}
/* /*
* Copyright [2019] [Doric.Pub] * Copyright [2019] [Doric.Pub]
* *

File diff suppressed because one or more lines are too long