Skip to content

Commit

Permalink
Front & Socket library reduced and simplified
Browse files Browse the repository at this point in the history
  • Loading branch information
sentivate committed Jan 10, 2022
1 parent 3b263e1 commit 2a7d439
Show file tree
Hide file tree
Showing 11 changed files with 48 additions and 156 deletions.
3 changes: 2 additions & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
**.min.js
.eslintrc.js
/build/**
bundle.js
bundle.js
**/lib/*
1 change: 1 addition & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"sourceType": "script",
"ecmaVersion": 12
},
"ignorePatterns": ["**/*.min.js", "bundle.js", "Sentivate.js", "**/lib/*"],
"rules": {
"no-setter-return": "error",
"no-dupe-else-if": "error",
Expand Down
1 change: 1 addition & 0 deletions uwBridge/.eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"sourceType": "script",
"ecmaVersion": 12
},
"ignorePatterns": ["**/*.min.js", "bundle.js", "Sentivate.js", "**/lib/*"],
"rules": {
"no-setter-return": "error",
"no-dupe-else-if": "error",
Expand Down
2 changes: 1 addition & 1 deletion uwBridge/system/compile/build/front/bundle.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion uwBridge/system/compile/build/front/coreBundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@
console.log(item);
}
if (restString(item, -3) === '.js') {
console.log(item, watch);
// console.log(item, watch);
if (!watchers[item]) {
watch(item, (thing) => {
console.log(thing, 'Live Reload');
Expand Down
74 changes: 15 additions & 59 deletions uwBridge/system/compile/build/socket/bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
debounce, eventAdd: eventAdd$1, isAgent, info, model
}
} = app;
const updateResize = debounce(() => {
Ractive.sharedSet(info);
const updateResize = debounce(async () => {
await Ractive.sharedSet(info);
const width = info.windowWidth;
let screenSize;
if (isAgent.mobile) {
Expand All @@ -30,17 +30,19 @@
screenSize = '4kScreen';
}
console.log(screenSize);
Ractive.sharedSet('screenSize', screenSize);
await Ractive.sharedSet('screenSize', screenSize);
}, 250);
function calculateScreen() {
requestAnimationFrame(updateResize);
}
eventAdd$1(
window,
'resize',
() => {
requestAnimationFrame(updateResize);
calculateScreen();
},
true
);
updateResize();
const smoothScroll = (element, to, duration) => {
if (duration <= 0) {
return;
Expand Down Expand Up @@ -83,7 +85,7 @@
findIndex,
hasValue,
get: get$1,
isPlainObject: isPlainObject$1,
isPlainObject,
findItem,
assignDeep,
ensureArray: ensureArray$1,
Expand Down Expand Up @@ -176,7 +178,7 @@
},
async syncCollection(path, newValArg, type = 'push', indexName = 'id') {
const oldVal = this.get(path);
if (isPlainObject$1(oldVal)) {
if (isPlainObject(oldVal)) {
assignDeep(oldVal, newValArg);
} else {
const newVal = ensureArray$1(newValArg);
Expand Down Expand Up @@ -217,7 +219,7 @@
}
}
};
assign$5(Ractive.Context, extendRactive);
assign$5(Ractive.prototype, extendRactive);
const getComponentName = (componentModel, componentName) => {
return componentModel === app.router.currentStateObject ? 'navState' : componentName;
};
Expand Down Expand Up @@ -300,31 +302,6 @@
}
});
};
const {
isEventNode,
utility: {
isEnter, apply: apply$1
}
} = app;
const preventDefault = function(callable) {
return function(componentEvent, ...args) {
if (componentEvent) {
console.log(componentEvent);
if (componentEvent.node && !isEventNode(componentEvent)) {
componentEvent.notTarget = false;
} else {
componentEvent.isTarget = true;
}
const original = componentEvent.original;
if (original && original.keyCode) {
componentEvent.isEnter = isEnter(original);
}
}
console.log(this);
apply$1(callable, this, [componentEvent, ...args]);
return false;
};
};
const {
utility: {
each: each$5, assign: assign$4, querySelector: querySelector$1
Expand Down Expand Up @@ -385,7 +362,7 @@
const {
watch: watch$1,
utility: {
map: map$1, each: each$4, get, apply, isPlainObject
each: each$4, get, apply
}
} = app;
const createWatchers = (currentView, item, key) => {
Expand Down Expand Up @@ -413,8 +390,8 @@
await currentView.syncCollection(key, json.item, createMethod);
currentView.fire(`${prefix}create${suffix}`, json.item, json);
},
delete(json) {
currentView.removeIndex(key, json.item.id);
async delete(json) {
await currentView.removeIndex(key, json.item.id);
currentView.fire(`${prefix}delete${suffix}`, json.item, json);
},
async read(json) {
Expand Down Expand Up @@ -444,31 +421,12 @@
});
}
};
const buildComponentEvents = function(componentConfig, componentEvent) {
const buildComponentEvents = function(componentConfig) {
const {
css, watchers, model: componentModel
css, watchers
} = componentConfig;
const thisComponent = this;
const sourceOn = thisComponent.on.bind(this);
console.log(thisComponent);
if (componentModel) {
app.navState = componentEvent.ractive;
}
thisComponent.onRaw = function(componentEvt) {
return sourceOn(componentEvt);
};
thisComponent.on = function(eventName, eventListener) {
console.log(eventName, eventListener);
console.log(this);
if (eventListener) {
return sourceOn(eventName, preventDefault(eventListener));
} else {
return sourceOn(map$1(eventName, preventDefault));
}
};
each$4(app.componentMethods, (item) => {
item(thisComponent, componentConfig);
});
thisComponent.watchers = watchers ? watchers(thisComponent) : {};
if (thisComponent.watchers) {
each$4(thisComponent.watchers, (item, key) => {
Expand All @@ -489,9 +447,7 @@
});
};
const onConstruct = function(componentConfig) {
console.log(this);
const sourceConstruct = componentConfig.onconstruct;
console.log(sourceConstruct);
componentConfig.onconstruct = function(...args) {
apply(buildComponentEvents, this, [componentConfig, ...args]);
if (sourceConstruct) {
Expand Down
74 changes: 15 additions & 59 deletions uwBridge/system/compile/build/socket/coreBundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
debounce, eventAdd: eventAdd$1, isAgent, info, model
}
} = app;
const updateResize = debounce(() => {
Ractive.sharedSet(info);
const updateResize = debounce(async () => {
await Ractive.sharedSet(info);
const width = info.windowWidth;
let screenSize;
if (isAgent.mobile) {
Expand All @@ -28,17 +28,19 @@
screenSize = '4kScreen';
}
console.log(screenSize);
Ractive.sharedSet('screenSize', screenSize);
await Ractive.sharedSet('screenSize', screenSize);
}, 250);
function calculateScreen() {
requestAnimationFrame(updateResize);
}
eventAdd$1(
window,
'resize',
() => {
requestAnimationFrame(updateResize);
calculateScreen();
},
true
);
updateResize();
const smoothScroll = (element, to, duration) => {
if (duration <= 0) {
return;
Expand Down Expand Up @@ -81,7 +83,7 @@
findIndex,
hasValue,
get: get$1,
isPlainObject: isPlainObject$1,
isPlainObject,
findItem,
assignDeep,
ensureArray: ensureArray$1,
Expand Down Expand Up @@ -174,7 +176,7 @@
},
async syncCollection(path, newValArg, type = 'push', indexName = 'id') {
const oldVal = this.get(path);
if (isPlainObject$1(oldVal)) {
if (isPlainObject(oldVal)) {
assignDeep(oldVal, newValArg);
} else {
const newVal = ensureArray$1(newValArg);
Expand Down Expand Up @@ -215,7 +217,7 @@
}
}
};
assign$5(Ractive.Context, extendRactive);
assign$5(Ractive.prototype, extendRactive);
const getComponentName = (componentModel, componentName) => {
return componentModel === app.router.currentStateObject ? 'navState' : componentName;
};
Expand Down Expand Up @@ -298,31 +300,6 @@
}
});
};
const {
isEventNode,
utility: {
isEnter, apply: apply$1
}
} = app;
const preventDefault = function(callable) {
return function(componentEvent, ...args) {
if (componentEvent) {
console.log(componentEvent);
if (componentEvent.node && !isEventNode(componentEvent)) {
componentEvent.notTarget = false;
} else {
componentEvent.isTarget = true;
}
const original = componentEvent.original;
if (original && original.keyCode) {
componentEvent.isEnter = isEnter(original);
}
}
console.log(this);
apply$1(callable, this, [componentEvent, ...args]);
return false;
};
};
const {
utility: {
each: each$5, assign: assign$4, querySelector: querySelector$1
Expand Down Expand Up @@ -383,7 +360,7 @@
const {
watch: watch$1,
utility: {
map: map$1, each: each$4, get, apply, isPlainObject
each: each$4, get, apply
}
} = app;
const createWatchers = (currentView, item, key) => {
Expand Down Expand Up @@ -411,8 +388,8 @@
await currentView.syncCollection(key, json.item, createMethod);
currentView.fire(`${prefix}create${suffix}`, json.item, json);
},
delete(json) {
currentView.removeIndex(key, json.item.id);
async delete(json) {
await currentView.removeIndex(key, json.item.id);
currentView.fire(`${prefix}delete${suffix}`, json.item, json);
},
async read(json) {
Expand Down Expand Up @@ -442,31 +419,12 @@
});
}
};
const buildComponentEvents = function(componentConfig, componentEvent) {
const buildComponentEvents = function(componentConfig) {
const {
css, watchers, model: componentModel
css, watchers
} = componentConfig;
const thisComponent = this;
const sourceOn = thisComponent.on.bind(this);
console.log(thisComponent);
if (componentModel) {
app.navState = componentEvent.ractive;
}
thisComponent.onRaw = function(componentEvt) {
return sourceOn(componentEvt);
};
thisComponent.on = function(eventName, eventListener) {
console.log(eventName, eventListener);
console.log(this);
if (eventListener) {
return sourceOn(eventName, preventDefault(eventListener));
} else {
return sourceOn(map$1(eventName, preventDefault));
}
};
each$4(app.componentMethods, (item) => {
item(thisComponent, componentConfig);
});
thisComponent.watchers = watchers ? watchers(thisComponent) : {};
if (thisComponent.watchers) {
each$4(thisComponent.watchers, (item, key) => {
Expand All @@ -487,9 +445,7 @@
});
};
const onConstruct = function(componentConfig) {
console.log(this);
const sourceConstruct = componentConfig.onconstruct;
console.log(sourceConstruct);
componentConfig.onconstruct = function(...args) {
apply(buildComponentEvents, this, [componentConfig, ...args]);
if (sourceConstruct) {
Expand Down
2 changes: 1 addition & 1 deletion uwBridge/system/compile/source/front/core/demand.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const buildFilePath = (itemArg) => {
console.log(item);
}
if (restString(item, -3) === '.js') {
console.log(item, watch);
// console.log(item, watch);
if (!watchers[item]) {
watch(item, (thing) => {
console.log(thing, 'Live Reload');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,4 +138,4 @@ export const extendRactive = {
}
}
};
assign(Ractive.Context, extendRactive);
assign(Ractive.prototype, extendRactive);
Loading

0 comments on commit 2a7d439

Please sign in to comment.