Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
lisonge committed Dec 14, 2024
1 parent ef85306 commit 2a2f1ad
Show file tree
Hide file tree
Showing 18 changed files with 120 additions and 26 deletions.
2 changes: 1 addition & 1 deletion packages/create-monkey/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# v1.37.0
# v1.38.0

## Features

Expand Down
2 changes: 1 addition & 1 deletion packages/create-monkey/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "create-monkey",
"version": "1.37.0",
"version": "1.38.0",
"description": "create-monkey",
"main": "index.js",
"type": "module",
Expand Down
2 changes: 1 addition & 1 deletion packages/create-monkey/template-empty-ts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@
"devDependencies": {
"typescript": "^5.7.2",
"vite": "^6.0.3",
"vite-plugin-monkey": "5.0.0-beta.2"
"vite-plugin-monkey": "^5.0.0"
}
}
2 changes: 1 addition & 1 deletion packages/create-monkey/template-empty/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@
},
"devDependencies": {
"vite": "^6.0.3",
"vite-plugin-monkey": "5.0.0-beta.2"
"vite-plugin-monkey": "^5.0.0"
}
}
2 changes: 1 addition & 1 deletion packages/create-monkey/template-preact-ts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@
"@preact/preset-vite": "^2.9.3",
"typescript": "^5.7.2",
"vite": "^6.0.3",
"vite-plugin-monkey": "5.0.0-beta.2"
"vite-plugin-monkey": "^5.0.0"
}
}
2 changes: 1 addition & 1 deletion packages/create-monkey/template-preact/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@
"devDependencies": {
"@preact/preset-vite": "^2.9.3",
"vite": "^6.0.3",
"vite-plugin-monkey": "5.0.0-beta.2"
"vite-plugin-monkey": "^5.0.0"
}
}
2 changes: 1 addition & 1 deletion packages/create-monkey/template-react-ts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@
"@vitejs/plugin-react": "^4.3.4",
"typescript": "^5.7.2",
"vite": "^6.0.3",
"vite-plugin-monkey": "5.0.0-beta.2"
"vite-plugin-monkey": "^5.0.0"
}
}
2 changes: 1 addition & 1 deletion packages/create-monkey/template-react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@
"@types/react-dom": "^18.3.5",
"@vitejs/plugin-react": "^4.3.4",
"vite": "^6.0.3",
"vite-plugin-monkey": "5.0.0-beta.2"
"vite-plugin-monkey": "^5.0.0"
}
}
2 changes: 1 addition & 1 deletion packages/create-monkey/template-solid-ts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"devDependencies": {
"typescript": "^5.7.2",
"vite": "^6.0.3",
"vite-plugin-monkey": "5.0.0-beta.2",
"vite-plugin-monkey": "^5.0.0",
"vite-plugin-solid": "^2.11.0"
},
"dependencies": {
Expand Down
2 changes: 1 addition & 1 deletion packages/create-monkey/template-solid/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
},
"devDependencies": {
"vite": "^6.0.3",
"vite-plugin-monkey": "5.0.0-beta.2",
"vite-plugin-monkey": "^5.0.0",
"vite-plugin-solid": "^2.11.0"
},
"dependencies": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
const INERT = 1 << 13;
const DESTROYED = 1 << 14;
const EFFECT_RAN = 1 << 15;
const EFFECT_TRANSPARENT = 1 << 16;
const HEAD_EFFECT = 1 << 19;
const EFFECT_HAS_DERIVED = 1 << 20;
function equals(value) {
Expand Down Expand Up @@ -306,10 +307,20 @@
}
return effect2;
}
function effect_root(fn) {
function component_root(fn) {
const effect2 = create_effect(ROOT_EFFECT, fn, true);
return () => {
destroy_effect(effect2);
return (options = {}) => {
return new Promise((fulfil) => {
if (options.outro) {
pause_effect(effect2, () => {
destroy_effect(effect2);
fulfil(void 0);
});
} else {
destroy_effect(effect2);
fulfil(void 0);
}
});
};
}
function effect(fn) {
Expand Down Expand Up @@ -407,6 +418,43 @@
if (parent.last === effect2) parent.last = prev;
}
}
function pause_effect(effect2, callback) {
var transitions = [];
pause_children(effect2, transitions, true);
run_out_transitions(transitions, () => {
destroy_effect(effect2);
if (callback) callback();
});
}
function run_out_transitions(transitions, fn) {
var remaining = transitions.length;
if (remaining > 0) {
var check = () => --remaining || fn();
for (var transition of transitions) {
transition.out(check);
}
} else {
fn();
}
}
function pause_children(effect2, transitions, local) {
if ((effect2.f & INERT) !== 0) return;
effect2.f ^= INERT;
if (effect2.transitions !== null) {
for (const transition of effect2.transitions) {
if (transition.is_global || local) {
transitions.push(transition);
}
}
}
var child2 = effect2.first;
while (child2 !== null) {
var sibling2 = child2.next;
var transparent = (child2.f & EFFECT_TRANSPARENT) !== 0 || (child2.f & BRANCH_EFFECT) !== 0;
pause_children(child2, transitions, transparent ? local : false);
child2 = sibling2;
}
}
let is_throwing_error = false;
let is_micro_task_queued = false;
let last_scheduled_effect = null;
Expand Down Expand Up @@ -1084,7 +1132,7 @@
event_handle(array_from(all_registered_events));
root_event_handles.add(event_handle);
var component = void 0;
var unmount = effect_root(() => {
var unmount = component_root(() => {
var anchor_node = anchor ?? target.appendChild(create_text());
branch(() => {
if (context) {
Expand Down Expand Up @@ -1119,7 +1167,6 @@
}
}
root_event_handles.delete(event_handle);
mounted_components.delete(component);
if (anchor_node !== anchor) {
(_a = anchor_node.parentNode) == null ? void 0 : _a.removeChild(anchor_node);
}
Expand Down
2 changes: 1 addition & 1 deletion packages/create-monkey/template-svelte-ts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@
"tslib": "^2.8.1",
"typescript": "^5.7.2",
"vite": "^6.0.3",
"vite-plugin-monkey": "5.0.0-beta.2"
"vite-plugin-monkey": "^5.0.0"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
const INERT = 1 << 13;
const DESTROYED = 1 << 14;
const EFFECT_RAN = 1 << 15;
const EFFECT_TRANSPARENT = 1 << 16;
const HEAD_EFFECT = 1 << 19;
const EFFECT_HAS_DERIVED = 1 << 20;
function equals(value) {
Expand Down Expand Up @@ -306,10 +307,20 @@
}
return effect2;
}
function effect_root(fn) {
function component_root(fn) {
const effect2 = create_effect(ROOT_EFFECT, fn, true);
return () => {
destroy_effect(effect2);
return (options = {}) => {
return new Promise((fulfil) => {
if (options.outro) {
pause_effect(effect2, () => {
destroy_effect(effect2);
fulfil(void 0);
});
} else {
destroy_effect(effect2);
fulfil(void 0);
}
});
};
}
function effect(fn) {
Expand Down Expand Up @@ -407,6 +418,43 @@
if (parent.last === effect2) parent.last = prev;
}
}
function pause_effect(effect2, callback) {
var transitions = [];
pause_children(effect2, transitions, true);
run_out_transitions(transitions, () => {
destroy_effect(effect2);
if (callback) callback();
});
}
function run_out_transitions(transitions, fn) {
var remaining = transitions.length;
if (remaining > 0) {
var check = () => --remaining || fn();
for (var transition of transitions) {
transition.out(check);
}
} else {
fn();
}
}
function pause_children(effect2, transitions, local) {
if ((effect2.f & INERT) !== 0) return;
effect2.f ^= INERT;
if (effect2.transitions !== null) {
for (const transition of effect2.transitions) {
if (transition.is_global || local) {
transitions.push(transition);
}
}
}
var child2 = effect2.first;
while (child2 !== null) {
var sibling2 = child2.next;
var transparent = (child2.f & EFFECT_TRANSPARENT) !== 0 || (child2.f & BRANCH_EFFECT) !== 0;
pause_children(child2, transitions, transparent ? local : false);
child2 = sibling2;
}
}
let is_throwing_error = false;
let is_micro_task_queued = false;
let last_scheduled_effect = null;
Expand Down Expand Up @@ -1084,7 +1132,7 @@
event_handle(array_from(all_registered_events));
root_event_handles.add(event_handle);
var component = void 0;
var unmount = effect_root(() => {
var unmount = component_root(() => {
var anchor_node = anchor ?? target.appendChild(create_text());
branch(() => {
if (context) {
Expand Down Expand Up @@ -1119,7 +1167,6 @@
}
}
root_event_handles.delete(event_handle);
mounted_components.delete(component);
if (anchor_node !== anchor) {
(_a = anchor_node.parentNode) == null ? void 0 : _a.removeChild(anchor_node);
}
Expand Down
2 changes: 1 addition & 1 deletion packages/create-monkey/template-svelte/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@
"@sveltejs/vite-plugin-svelte": "5.0.2",
"svelte": "^5.11.2",
"vite": "^6.0.3",
"vite-plugin-monkey": "5.0.0-beta.2"
"vite-plugin-monkey": "^5.0.0"
}
}
2 changes: 1 addition & 1 deletion packages/create-monkey/template-vanilla-ts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@
"devDependencies": {
"typescript": "^5.7.2",
"vite": "^6.0.3",
"vite-plugin-monkey": "5.0.0-beta.2"
"vite-plugin-monkey": "^5.0.0"
}
}
2 changes: 1 addition & 1 deletion packages/create-monkey/template-vanilla/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@
},
"devDependencies": {
"vite": "^6.0.3",
"vite-plugin-monkey": "5.0.0-beta.2"
"vite-plugin-monkey": "^5.0.0"
}
}
2 changes: 1 addition & 1 deletion packages/create-monkey/template-vue-ts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"@vitejs/plugin-vue": "^5.2.1",
"typescript": "^5.7.2",
"vite": "^6.0.3",
"vite-plugin-monkey": "5.0.0-beta.2",
"vite-plugin-monkey": "^5.0.0",
"vue-tsc": "^2.1.10"
}
}
2 changes: 1 addition & 1 deletion packages/create-monkey/template-vue/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@
"devDependencies": {
"@vitejs/plugin-vue": "^5.2.1",
"vite": "^6.0.3",
"vite-plugin-monkey": "5.0.0-beta.2"
"vite-plugin-monkey": "^5.0.0"
}
}

0 comments on commit 2a2f1ad

Please sign in to comment.