Skip to content

Commit

Permalink
修复global的BUG
Browse files Browse the repository at this point in the history
  • Loading branch information
robincodex committed Jan 12, 2023
1 parent bb1d1da commit cf69b9c
Show file tree
Hide file tree
Showing 7 changed files with 88 additions and 2,929 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,7 @@ dist
*.vcss_c
*.vxml_c
*.bin
*.cfg
*.cfg
.yarn
yarn.lock
pnpm-lock.yaml
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
This is an example of [solid-panorama](https://github.com/RobinCodeX/solid-panorama).

Start watch and build:

```
yarn start
pnpm start
```
15 changes: 11 additions & 4 deletions addon/content/solid-example/panorama/scripts/custom_game/libs.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ function createRoot(fn, detachedOwner) {
const listener = Listener,
owner = Owner,
unowned = fn.length === 0,
root = unowned && !false ? UNOWNED : {
root = unowned ? UNOWNED : {
owned: null,
cleanups: null,
context: null,
Expand Down Expand Up @@ -522,6 +522,7 @@ const propTraps = {
return _.get(property);
},
has(_, property) {
if (property === $PROXY) return true;
return _.has(property);
},
set: trueFn,
Expand All @@ -545,7 +546,13 @@ function resolveSource(s) {
return !(s = typeof s === "function" ? s() : s) ? {} : s;
}
function mergeProps$1(...sources) {
if (sources.some(s => s && ($PROXY in s || typeof s === "function"))) {
let proxy = false;
for (let i = 0; i < sources.length; i++) {
const s = sources[i];
proxy = proxy || !!s && $PROXY in s;
sources[i] = typeof s === "function" ? (proxy = true, createMemo(s)) : s;
}
if (proxy) {
return new Proxy({
get(property) {
for (let i = sources.length - 1; i >= 0; i--) {
Expand Down Expand Up @@ -591,13 +598,13 @@ function For(props) {
const fallback = "fallback" in props && {
fallback: () => props.fallback
};
return createMemo(mapArray(() => props.each, props.children, fallback ? fallback : undefined));
return createMemo(mapArray(() => props.each, props.children, fallback || undefined));
}
function Index(props) {
const fallback = "fallback" in props && {
fallback: () => props.fallback
};
return createMemo(indexArray(() => props.each, props.children, fallback ? fallback : undefined));
return createMemo(indexArray(() => props.each, props.children, fallback || undefined));
}

function createRenderer$1({
Expand Down

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

104 changes: 52 additions & 52 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,52 +1,52 @@
{
"name": "solid-panorama-example",
"version": "0.0.1",
"description": "Solid.js example in Dota2 Panorama",
"main": "index.js",
"author": "RobinCode",
"license": "MIT",
"scripts": {
"start": "ts-node -r ./scripts/build-write-file.ts ./scripts/build.ts",
"build": "ts-node -r ./scripts/build-write-file.ts ./scripts/build.ts"
},
"dependencies": {
"@babel/core": "^7.20.5",
"@babel/plugin-transform-typescript": "^7.20.2",
"@babel/preset-env": "^7.20.2",
"@babel/preset-typescript": "^7.18.6",
"@babel/types": "^7.20.5",
"@moddota/panorama-types": "^1.21.0",
"@rollup/plugin-alias": "^4.0.2",
"@rollup/plugin-babel": "^6.0.3",
"@rollup/plugin-commonjs": "^23.0.3",
"@rollup/plugin-node-resolve": "^15.0.1",
"@rollup/plugin-replace": "^5.0.1",
"@rollup/plugin-typescript": "^10.0.1",
"@rollup/plugin-url": "^8.0.1",
"@types/babel__core": "^7.1.20",
"@types/cli-color": "^2.0.2",
"@types/fs-extra": "^9.0.13",
"@types/glob": "^8.0.0",
"@types/lodash": "^4.14.191",
"@types/node": "^18.11.10",
"babel-plugin-jsx-panorama-expressions": "^0.1.7",
"babel-plugin-macros": "^3.1.0",
"babel-preset-solid-panorama": "^0.1.5",
"chokidar": "^3.5.3",
"cli-color": "^2.0.3",
"dota2-panorama-xml-static-element": "^0.0.4",
"fs-extra": "^11.1.0",
"glob": "^8.0.3",
"lodash": "^4.17.21",
"npm-run-all": "^4.1.5",
"rollup": "^3.5.1",
"sass": "^1.56.1",
"solid-js": "^1.6.2",
"solid-panorama-all-in-jsx": "^0.2.5",
"solid-panorama-polyfill": "^0.1.5",
"solid-panorama-runtime": "^0.2.9",
"ts-node": "^10.9.1",
"typescript": "~4.9.3",
"typescript-styled-plugin": "^0.18.2"
}
}
{
"name": "solid-panorama-example",
"version": "0.0.1",
"description": "Solid.js example in Dota2 Panorama",
"main": "index.js",
"author": "RobinCode",
"license": "MIT",
"scripts": {
"start": "ts-node -r ./scripts/build-write-file.ts ./scripts/build.ts",
"build": "ts-node -r ./scripts/build-write-file.ts ./scripts/build.ts"
},
"dependencies": {
"@babel/core": "^7.20.5",
"@babel/plugin-transform-typescript": "^7.20.2",
"@babel/preset-env": "^7.20.2",
"@babel/preset-typescript": "^7.18.6",
"@babel/types": "^7.20.5",
"@moddota/panorama-types": "^1.21.0",
"@rollup/plugin-alias": "^4.0.2",
"@rollup/plugin-babel": "^6.0.3",
"@rollup/plugin-commonjs": "^23.0.3",
"@rollup/plugin-node-resolve": "^15.0.1",
"@rollup/plugin-replace": "^5.0.1",
"@rollup/plugin-typescript": "^10.0.1",
"@rollup/plugin-url": "^8.0.1",
"@types/babel__core": "^7.1.20",
"@types/cli-color": "^2.0.2",
"@types/fs-extra": "^9.0.13",
"@types/glob": "^8.0.0",
"@types/lodash": "^4.14.191",
"@types/node": "^18.11.10",
"babel-plugin-jsx-panorama-expressions": "^0.1.7",
"babel-plugin-macros": "^3.1.0",
"babel-preset-solid-panorama": "^0.1.5",
"chokidar": "^3.5.3",
"cli-color": "^2.0.3",
"dota2-panorama-xml-static-element": "^0.0.4",
"fs-extra": "^11.1.0",
"glob": "^8.0.3",
"lodash": "^4.17.21",
"npm-run-all": "^4.1.5",
"rollup": "^3.5.1",
"sass": "^1.56.1",
"solid-js": "^1.6.2",
"solid-panorama-all-in-jsx": "^0.2.5",
"solid-panorama-polyfill": "^0.1.7",
"solid-panorama-runtime": "^0.2.9",
"ts-node": "^10.9.1",
"typescript": "~4.9.3",
"typescript-styled-plugin": "^0.18.2"
}
}
10 changes: 7 additions & 3 deletions scripts/custom-polyfill.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
(function () {
const global = new Function('return this')();
})();
var polyfillModule = (function () {
return {
default: global => {
// global.x = 1
}
};
})();
Loading

0 comments on commit cf69b9c

Please sign in to comment.