Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enable markdown language features for web/serverless
- Loading branch information
Showing
7 changed files
with
201 additions
and
7 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
29 changes: 29 additions & 0 deletions
29
extensions/markdown-language-features/extension-browser.webpack.config.js
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,29 @@ | ||
/*--------------------------------------------------------------------------------------------- | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. See License.txt in the project root for license information. | ||
*--------------------------------------------------------------------------------------------*/ | ||
|
||
//@ts-check | ||
|
||
'use strict'; | ||
|
||
const withDefaults = require('../shared.webpack.config'); | ||
const path = require('path'); | ||
|
||
const clientConfig = withDefaults({ | ||
context: __dirname, | ||
target: 'webworker', | ||
entry: { | ||
extension: './src/extension.ts' | ||
}, | ||
resolve: { | ||
alias: { | ||
'vscode-extension-telemetry': path.resolve(__dirname, 'polyfills/vscode-extension-telemetry.js'), | ||
'vscode-nls': path.resolve(__dirname, 'polyfills/vscode-nls.js'), | ||
}, | ||
} | ||
}); | ||
|
||
clientConfig.module.rules[0].use.shift(); // remove nls loader | ||
|
||
module.exports = clientConfig; |
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
26 changes: 26 additions & 0 deletions
26
extensions/markdown-language-features/polyfills/vscode-extension-telemetry.js
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,26 @@ | ||
/*--------------------------------------------------------------------------------------------- | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. See License.txt in the project root for license information. | ||
*--------------------------------------------------------------------------------------------*/ | ||
|
||
'use strict'; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
|
||
let TelemetryReporter = (function () { | ||
function TelemetryReporter(extensionId, extensionVersion, key) { | ||
} | ||
TelemetryReporter.prototype.updateUserOptIn = function (key) { | ||
}; | ||
TelemetryReporter.prototype.createAppInsightsClient = function (key) { | ||
}; | ||
TelemetryReporter.prototype.getCommonProperties = function () { | ||
}; | ||
TelemetryReporter.prototype.sendTelemetryEvent = function (eventName, properties, measurements) { | ||
}; | ||
TelemetryReporter.prototype.dispose = function () { | ||
}; | ||
TelemetryReporter.TELEMETRY_CONFIG_ID = 'telemetry'; | ||
TelemetryReporter.TELEMETRY_CONFIG_ENABLED_ID = 'enableTelemetry'; | ||
return TelemetryReporter; | ||
}()); | ||
exports.default = TelemetryReporter; |
79 changes: 79 additions & 0 deletions
79
extensions/markdown-language-features/polyfills/vscode-nls.js
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,79 @@ | ||
/*--------------------------------------------------------------------------------------------- | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. See License.txt in the project root for license information. | ||
*--------------------------------------------------------------------------------------------*/ | ||
|
||
'use strict'; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
|
||
function format(message, args) { | ||
let result; | ||
// if (isPseudo) { | ||
// // FF3B and FF3D is the Unicode zenkaku representation for [ and ] | ||
// message = '\uFF3B' + message.replace(/[aouei]/g, '$&$&') + '\uFF3D'; | ||
// } | ||
if (args.length === 0) { | ||
result = message; | ||
} | ||
else { | ||
result = message.replace(/\{(\d+)\}/g, function (match, rest) { | ||
let index = rest[0]; | ||
let arg = args[index]; | ||
let replacement = match; | ||
if (typeof arg === 'string') { | ||
replacement = arg; | ||
} | ||
else if (typeof arg === 'number' || typeof arg === 'boolean' || arg === void 0 || arg === null) { | ||
replacement = String(arg); | ||
} | ||
return replacement; | ||
}); | ||
} | ||
return result; | ||
} | ||
|
||
function localize(key, message) { | ||
let args = []; | ||
for (let _i = 2; _i < arguments.length; _i++) { | ||
args[_i - 2] = arguments[_i]; | ||
} | ||
return format(message, args); | ||
} | ||
|
||
function loadMessageBundle(file) { | ||
return localize; | ||
} | ||
|
||
let MessageFormat; | ||
(function (MessageFormat) { | ||
MessageFormat["file"] = "file"; | ||
MessageFormat["bundle"] = "bundle"; | ||
MessageFormat["both"] = "both"; | ||
})(MessageFormat = exports.MessageFormat || (exports.MessageFormat = {})); | ||
let BundleFormat; | ||
(function (BundleFormat) { | ||
// the nls.bundle format | ||
BundleFormat["standalone"] = "standalone"; | ||
BundleFormat["languagePack"] = "languagePack"; | ||
})(BundleFormat = exports.BundleFormat || (exports.BundleFormat = {})); | ||
|
||
exports.loadMessageBundle = loadMessageBundle; | ||
function config(opts) { | ||
if (opts) { | ||
if (isString(opts.locale)) { | ||
options.locale = opts.locale.toLowerCase(); | ||
options.language = options.locale; | ||
resolvedLanguage = undefined; | ||
resolvedBundles = Object.create(null); | ||
} | ||
if (opts.messageFormat !== undefined) { | ||
options.messageFormat = opts.messageFormat; | ||
} | ||
if (opts.bundleFormat === BundleFormat.standalone && options.languagePackSupport === true) { | ||
options.languagePackSupport = false; | ||
} | ||
} | ||
isPseudo = options.locale === 'pseudo'; | ||
return loadMessageBundle; | ||
} | ||
exports.config = config; |
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 |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/*--------------------------------------------------------------------------------------------- | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. See License.txt in the project root for license information. | ||
*--------------------------------------------------------------------------------------------*/ | ||
|
||
/** | ||
* Return a hash value for an object. | ||
*/ | ||
export function hash(obj: any, hashVal = 0): number { | ||
switch (typeof obj) { | ||
case 'object': | ||
if (obj === null) { | ||
return numberHash(349, hashVal); | ||
} else if (Array.isArray(obj)) { | ||
return arrayHash(obj, hashVal); | ||
} | ||
return objectHash(obj, hashVal); | ||
case 'string': | ||
return stringHash(obj, hashVal); | ||
case 'boolean': | ||
return booleanHash(obj, hashVal); | ||
case 'number': | ||
return numberHash(obj, hashVal); | ||
case 'undefined': | ||
return 937 * 31; | ||
default: | ||
return numberHash(obj, 617); | ||
} | ||
} | ||
|
||
function numberHash(val: number, initialHashVal: number): number { | ||
return (((initialHashVal << 5) - initialHashVal) + val) | 0; // hashVal * 31 + ch, keep as int32 | ||
} | ||
|
||
function booleanHash(b: boolean, initialHashVal: number): number { | ||
return numberHash(b ? 433 : 863, initialHashVal); | ||
} | ||
|
||
function stringHash(s: string, hashVal: number) { | ||
hashVal = numberHash(149417, hashVal); | ||
for (let i = 0, length = s.length; i < length; i++) { | ||
hashVal = numberHash(s.charCodeAt(i), hashVal); | ||
} | ||
return hashVal; | ||
} | ||
|
||
function arrayHash(arr: any[], initialHashVal: number): number { | ||
initialHashVal = numberHash(104579, initialHashVal); | ||
return arr.reduce((hashVal, item) => hash(item, hashVal), initialHashVal); | ||
} | ||
|
||
function objectHash(obj: any, initialHashVal: number): number { | ||
initialHashVal = numberHash(181387, initialHashVal); | ||
return Object.keys(obj).sort().reduce((hashVal, key) => { | ||
hashVal = stringHash(key, hashVal); | ||
return hash(obj[key], hashVal); | ||
}, initialHashVal); | ||
} |