#include "root.h" #include "ZigGlobalObject.h" #include "helpers.h" #include "JavaScriptCore/JSObject.h" #include "JavaScriptCore/ObjectConstructor.h" extern "C" size_t Bun__getEnvNames(JSGlobalObject*, ZigString* names, size_t max); extern "C" bool Bun__getEnvValue(JSGlobalObject* globalObject, ZigString* name, ZigString* value); namespace Bun { JSC_DEFINE_CUSTOM_GETTER(jsGetterEnvironmentVariable, (JSGlobalObject * globalObject, EncodedJSValue thisValue, PropertyName propertyName)) { VM& vm = globalObject->vm(); auto scope = DECLARE_THROW_SCOPE(vm); auto* thisObject = jsDynamicCast(JSValue::decode(thisValue)); if (UNLIKELY(!thisObject)) return JSValue::encode(jsUndefined()); ZigString name = toZigString(propertyName.publicName()); ZigString value = { nullptr, 0 }; if (UNLIKELY(name.len == 0)) return JSValue::encode(jsUndefined()); if (!Bun__getEnvValue(globalObject, &name, &value) || value.len == 0) { return JSValue::encode(jsUndefined()); } JSValue result = jsString(vm, Zig::toStringCopy(value)); thisObject->putDirect(vm, propertyName, result, 0); return JSValue::encode(result); } JSC_DEFINE_CUSTOM_SETTER(jsSetterEnvironmentVariable, (JSGlobalObject * globalObject, EncodedJSValue thisValue, EncodedJSValue value, PropertyName propertyName)) { VM& vm = globalObject->vm(); JSC::JSObject* object = JSValue::decode(thisValue).getObject(); if (!object) return false; object->putDirect(vm, propertyName, JSValue::decode(value), 0); return true; } JSValue createEnvironmentVariablesMap(Zig::GlobalObject* globalObject) { VM& vm = globalObject->vm(); auto scope = DECLARE_THROW_SCOPE(vm); size_t max = 768; ZigString names[max]; size_t count = Bun__getEnvNames(globalObject, names, max); JSC::JSObject* object = nullptr; if (count < 63) { object = constructEmptyObject(globalObject, globalObject->objectPrototype(), count); } else { object = constructEmptyObject(globalObject, globalObject->objectPrototype()); } for (size_t i = 0; i < count; i++) { auto name = Zig::toStringCopy(names[i]); object->putDirectCustomAccessor(vm, Identifier::fromString(vm, name), JSC::CustomGetterSetter::create(vm, jsGetterEnvironmentVariable, jsSetterEnvironmentVariable), JSC::PropertyAttribute::CustomAccessor | 0); } return object; } }piler-02-new-build Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/packages/markdown (unfollow)
AgeCommit message (Expand)AuthorFilesLines
2023-01-12[ci] release (beta) (#5792)create-astro@2.0.0-beta.0astro@2.0.0-beta.2@astrojs/webapi@2.0.0-beta.0@astrojs/vue@2.0.0-beta.1@astrojs/vercel@3.0.0-beta.1@astrojs/telemetry@2.0.0-beta.0@astrojs/tailwind@3.0.0-beta.1@astrojs/svelte@2.0.0-beta.1@astrojs/solid-js@2.0.0-beta.0@astrojs/react@2.0.0-beta.0@astrojs/prism@2.0.0-beta.0@astrojs/preact@2.0.0-beta.0@astrojs/partytown@1.0.3-beta.0@astrojs/node@5.0.0-beta.1@astrojs/netlify@2.0.0-beta.2@astrojs/mdx@1.0.0-beta.2@astrojs/markdown-remark@2.0.0-beta.2@astrojs/lit@1.0.2-beta.0@astrojs/image@1.0.0-beta.2@astrojs/deno@4.0.0-beta.2@astrojs/cloudflare@6.0.0-beta.1Gravatar Fred K. Bot 2-3/+32
2023-01-12 Add `.astro/` to `.gitignore` in example projects (#5841)Gravatar Chris Swithinbank 24-98/+46
2023-01-12chore: update changeset for `_astro` directory (#5843)Gravatar Nate Moore 1-2/+2
2023-01-12fix: pass flags to dev (#5840)Gravatar Sam Chen 3-1/+9
2023-01-12chore: update changelogs, add changeset for `_astro` directory (#5842)Gravatar Nate Moore 5-18/+10
2023-01-12[ci] formatGravatar natemoo-re 1-1/+1
2023-01-12fix(core): handle encoded characters when matching routes (#5836)Gravatar Nate Moore 8-2/+85
2023-01-12Handle compiler breaking change (#5803)Gravatar Bjorn Lu 12-328/+109
2023-01-12fix shiki css class replace logic in md and mdx integrations (#5837)Gravatar Giuseppe La Torre 3-3/+9
2023-01-11[ci] formatGravatar matthewp 2-2/+2
2023-01-11Simplify HMR handling (#5811)Gravatar Bjorn Lu 8-108/+46
2023-01-11[Content collections] Remove experimental flag (#5825)Gravatar Ben Holmes 27-103/+58
2023-01-11[Content collections] Improve content config handling (#5824)Gravatar Ben Holmes 5-58/+78
2023-01-11Run sync as part of `astro check` (#5823)Gravatar Chris Swithinbank 3-2/+13
2023-01-11[ci] update lockfile (#5815)Gravatar Fred K. Bot 1-257/+256
2023-01-11Fix order-of-execution bug when generating pages (#5822)Gravatar Nate Moore 2-2/+7
2023-01-11Fix `Code.astro` shiki css class replace logic (#5829)Gravatar Giuseppe La Torre 2-1/+6