mirror of
https://github.com/neocities/neocities.git
synced 2025-07-24 11:28:29 +02:00
added monaco code to public js folder and removed cdn
This commit is contained in:
parent
165e17f844
commit
4a7483509e
1387 changed files with 1185013 additions and 24 deletions
55
public/js/monaco/esm/vs/base/common/marshalling.js
Normal file
55
public/js/monaco/esm/vs/base/common/marshalling.js
Normal file
|
@ -0,0 +1,55 @@
|
|||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
import { VSBuffer } from './buffer.js';
|
||||
import { URI } from './uri.js';
|
||||
export function stringify(obj) {
|
||||
return JSON.stringify(obj, replacer);
|
||||
}
|
||||
export function parse(text) {
|
||||
let data = JSON.parse(text);
|
||||
data = revive(data);
|
||||
return data;
|
||||
}
|
||||
function replacer(key, value) {
|
||||
// URI is done via toJSON-member
|
||||
if (value instanceof RegExp) {
|
||||
return {
|
||||
$mid: 2 /* MarshalledId.Regexp */,
|
||||
source: value.source,
|
||||
flags: value.flags,
|
||||
};
|
||||
}
|
||||
return value;
|
||||
}
|
||||
export function revive(obj, depth = 0) {
|
||||
if (!obj || depth > 200) {
|
||||
return obj;
|
||||
}
|
||||
if (typeof obj === 'object') {
|
||||
switch (obj.$mid) {
|
||||
case 1 /* MarshalledId.Uri */: return URI.revive(obj);
|
||||
case 2 /* MarshalledId.Regexp */: return new RegExp(obj.source, obj.flags);
|
||||
case 17 /* MarshalledId.Date */: return new Date(obj.source);
|
||||
}
|
||||
if (obj instanceof VSBuffer
|
||||
|| obj instanceof Uint8Array) {
|
||||
return obj;
|
||||
}
|
||||
if (Array.isArray(obj)) {
|
||||
for (let i = 0; i < obj.length; ++i) {
|
||||
obj[i] = revive(obj[i], depth + 1);
|
||||
}
|
||||
}
|
||||
else {
|
||||
// walk object
|
||||
for (const key in obj) {
|
||||
if (Object.hasOwnProperty.call(obj, key)) {
|
||||
obj[key] = revive(obj[key], depth + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return obj;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue