reconstruct and build @anthropic-ai/claude-code source from source map

- Extract 4756 source files from cli.js.map (57MB)
- Set up Bun build system with bun:bundle feature flag shim
- Configure 90+ compile-time feature flags matching production defaults
- Inject MACRO constants (VERSION, BUILD_TIME, etc.)
- Create stubs for private packages (color-diff-napi, modifiers-napi, etc.)
- Install all public dependencies via pnpm
- Patch commander v14 to allow multi-char short flags (-d2e)
- Build output: dist/cli.js (22MB), verified working
This commit is contained in:
janlaywss
2026-03-31 19:19:50 +08:00
commit 6187147b74
37865 changed files with 5438634 additions and 0 deletions

View File

@@ -0,0 +1,50 @@
export interface Options {
/**
Bind only the given methods.
*/
readonly include?: ReadonlyArray<string | RegExp>;
/**
Bind methods except for the given methods.
*/
readonly exclude?: ReadonlyArray<string | RegExp>;
}
/**
Automatically bind methods to their class instance.
@param self - An object with methods to bind.
@example
```
import autoBind from 'auto-bind';
class Unicorn {
constructor(name) {
this.name = name;
autoBind(this);
}
message() {
return `${this.name} is awesome!`;
}
}
const unicorn = new Unicorn('Rainbow');
// Grab the method off the class instance
const message = unicorn.message;
// Still bound to the class instance
message();
//=> 'Rainbow is awesome!'
// Without `autoBind(this)`, the above would have resulted in
message();
//=> Error: Cannot read property 'name' of undefined
```
*/
export default function autoBind<SelfType extends Record<string, any>>( // This has to use `any` to be compatible with classes.
self: SelfType,
options?: Options
): SelfType;

View File

@@ -0,0 +1,41 @@
// Gets all non-builtin properties up the prototype chain.
const getAllProperties = object => {
const properties = new Set();
do {
for (const key of Reflect.ownKeys(object)) {
properties.add([object, key]);
}
} while ((object = Reflect.getPrototypeOf(object)) && object !== Object.prototype);
return properties;
};
export default function autoBind(self, {include, exclude} = {}) {
const filter = key => {
const match = pattern => typeof pattern === 'string' ? key === pattern : pattern.test(key);
if (include) {
return include.some(match); // eslint-disable-line unicorn/no-array-callback-reference
}
if (exclude) {
return !exclude.some(match); // eslint-disable-line unicorn/no-array-callback-reference
}
return true;
};
for (const [object, key] of getAllProperties(self.constructor.prototype)) {
if (key === 'constructor' || !filter(key)) {
continue;
}
const descriptor = Reflect.getOwnPropertyDescriptor(object, key);
if (descriptor && typeof descriptor.value === 'function') {
self[key] = self[key].bind(self);
}
}
return self;
}

View File

@@ -0,0 +1,9 @@
MIT License
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

View File

@@ -0,0 +1,51 @@
{
"name": "auto-bind",
"version": "5.0.1",
"description": "Automatically bind methods to their class instance",
"license": "MIT",
"repository": "sindresorhus/auto-bind",
"funding": "https://github.com/sponsors/sindresorhus",
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "https://sindresorhus.com"
},
"type": "module",
"exports": {
".": "./index.js",
"./react": "./react.js"
},
"engines": {
"node": "^12.20.0 || ^14.13.1 || >=16.0.0"
},
"scripts": {
"test": "xo && ava && tsd"
},
"files": [
"index.js",
"index.d.ts",
"react.js",
"react.d.ts"
],
"keywords": [
"auto",
"bind",
"class",
"methods",
"method",
"automatically",
"prototype",
"instance",
"function",
"this",
"self",
"react",
"component"
],
"devDependencies": {
"@types/react": "^17.0.29",
"ava": "^3.15.0",
"tsd": "^0.18.0",
"xo": "^0.45.0"
}
}

View File

@@ -0,0 +1,26 @@
import {Component as ReactComponent} from 'react';
import autoBind, {Options} from './index.js';
/**
Same as `autoBind` but excludes the default [React component methods](https://reactjs.org/docs/react-component.html).
@param self - An object with methods to bind.
@example
```
import autoBindReact from 'auto-bind/react';
class Foo extends React.Component {
constructor(props) {
super(props);
autoBindReact(this);
}
// …
}
```
*/
export default function autoBindReact<SelfType extends ReactComponent>(
self: SelfType,
options?: Options
): SelfType;

View File

@@ -0,0 +1,28 @@
import autoBind from './index.js';
const excludedReactMethods = [
'componentWillMount',
'UNSAFE_componentWillMount',
'render',
'getSnapshotBeforeUpdate',
'componentDidMount',
'componentWillReceiveProps',
'UNSAFE_componentWillReceiveProps',
'shouldComponentUpdate',
'componentWillUpdate',
'UNSAFE_componentWillUpdate',
'componentDidUpdate',
'componentWillUnmount',
'componentDidCatch',
'setState',
'forceUpdate',
];
export default function autoBindReact(self, {exclude = [], ...options} = {}) {
options.exclude = [
...exclude,
...excludedReactMethods,
];
return autoBind(self, options);
}

View File

@@ -0,0 +1,92 @@
# auto-bind
> Automatically bind methods to their class instance
It also correctly binds inherited properties.
## Install
```sh
npm install auto-bind
```
## Usage
```js
import autoBind from 'auto-bind';
class Unicorn {
constructor(name) {
this.name = name;
autoBind(this);
}
message() {
return `${this.name} is awesome!`;
}
}
const unicorn = new Unicorn('Rainbow');
// Grab the method off the class instance
const message = unicorn.message;
// Still bound to the class instance
message();
//=> 'Rainbow is awesome!'
// Without `autoBind(this)`, the above would have resulted in
message();
//=> Error: Cannot read property 'name' of undefined
```
## API
### autoBind(self, options?)
Bind methods in `self` to their class instance.
Returns the `self` object.
#### self
Type: `object`
An object with methods to bind.
#### options
Type: `object`
##### include
Type: `Array<string | RegExp>`
Bind only the given methods.
##### exclude
Type: `Array<string | RegExp>`
Bind methods except for the given methods.
### React
Same as `autoBind` but excludes the default [React component methods](https://reactjs.org/docs/react-component.html).
```js
import autoBindReact from 'auto-bind/react';
class Foo extends React.Component {
constructor(props) {
super(props);
autoBindReact(this);
}
// …
}
```
## Related
- [bind-methods](https://github.com/sindresorhus/bind-methods) - Bind all methods in an object to itself or a specified context