-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
112 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
<div className="col-sm-6 smallpad"> | ||
<button type="button" className="btn btn-primary btn-block" id="{{id}}" @click="{{cb}}">{{title}}</button> | ||
<button type="button" className="btn btn-primary btn-block" id="{{sid}}" @click="{{cb}}">{{title}}</button> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,10 @@ | ||
import type { GetState } from "./useState"; | ||
|
||
import { idleCallback } from "./useState"; | ||
|
||
export const useEffect = (fn: Function, deps: GetState[]) => { | ||
for (const dep of deps) dep((v) => idleCallback(() => fn(v))) | ||
for (const dep of deps) | ||
dep((v) => { | ||
idleCallback(() => fn(v)); | ||
return; | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './worker' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export const MAX_WORKER_COUNT = navigator.hardwareConcurrency / 2 + 1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import { getRandomID, findDomStr, addDomID } from "../core/dom-str"; | ||
import type { Ref } from "../hooks"; | ||
|
||
export type PropsRef = Record<string, Ref> | null; | ||
export type PropsState = Record<string, string | (() => string)> | null; | ||
|
||
export const markIdHandler = ( | ||
template: string, | ||
{ | ||
ref, | ||
state, | ||
}: { | ||
ref?: PropsRef; | ||
state?: PropsState; | ||
} = {} | ||
) => { | ||
const usageDomSet = new Set<string>(); | ||
template.replace(/{{(.*?)}}/g, (_, _key, start) => { | ||
usageDomSet.add(findDomStr(start, template)); | ||
return _; | ||
}); | ||
usageDomSet.forEach((dom) => { | ||
if (dom.indexOf("id=") === -1) { | ||
const [newDom] = addDomID(dom, getRandomID); | ||
template = template.replace(dom, newDom); | ||
} | ||
}); | ||
template = template.replace(/id="{{(.*?)}}"/g, (_, key) => { | ||
const _key = key.trim(); | ||
if (ref && _key in ref) { | ||
return `id="${ref[_key]}"`; | ||
} | ||
if (state && _key in state && typeof state[_key] === "string") { | ||
// TODO: 增加对state function的支持 | ||
return `id="${state[_key]}"`; | ||
} | ||
return _; | ||
}); | ||
return template; | ||
}; | ||
|
||
export const collectMethodHanlder=()=>{ | ||
|
||
} |