@php-wasm/scopes 3.0.15 → 3.0.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.cjs.map +1 -1
- package/index.js.map +1 -1
- package/package.json +2 -2
package/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":["../../../../packages/php-wasm/scopes/src/index.ts"],"sourcesContent":["/**\n * Scopes are unique strings, like `my-site`, used to uniquely brand\n * the outgoing HTTP traffic from each browser tab. This helps the\n * main thread distinguish between the relevant and irrelevant\n * messages received from the Service Worker.\n *\n * Scopes are included in the `PHPRequestHandler.absoluteUrl` as follows:\n *\n * An **unscoped** URL: http://localhost:8778/wp-login.php\n * A **scoped** URL: http://localhost:8778/scope:my-site/wp-login.php\n *\n * For more information, see the README section on scopes.\n */\n\n/**\n * Checks if the given URL contains scope information.\n *\n * @example\n * ```js\n * isURLScoped(new URL('http://localhost/scope:my-site/index.php'));\n * // true\n *\n * isURLScoped(new URL('http://localhost/index.php'));\n * // false\n * ```\n *\n * @param url The URL to check.\n * @returns `true` if the URL contains scope information, `false` otherwise.\n */\nexport function isURLScoped(url: URL): boolean {\n\treturn url.pathname.startsWith(`/scope:`);\n}\n\n/**\n * Returns the scope stored in the given URL.\n *\n * @example\n * ```js\n * getScopeFromURL(new URL('http://localhost/scope:my-site/index.php'));\n * // '96253'\n *\n * getScopeFromURL(new URL('http://localhost/index.php'));\n * // null\n * ```\n *\n * @param url The URL.\n * @returns The scope if the URL contains a scope, `null` otherwise.\n */\nexport function getURLScope(url: URL): string | null {\n\tif (isURLScoped(url)) {\n\t\treturn url.pathname.split('/')[1].split(':')[1];\n\t}\n\treturn null;\n}\n\n/**\n * Returns a new URL with the requested scope information.\n *\n * @example\n * ```js\n * setURLScope(new URL('http://localhost/index.php'), 'my-site');\n * // URL('http://localhost/scope:my-site/index.php')\n *\n * setURLScope(new URL('http://localhost/scope:my-site/index.php'), 'my-site');\n * // URL('http://localhost/scope:my-site/index.php')\n *\n * setURLScope(new URL('http://localhost/index.php'), null);\n * // URL('http://localhost/index.php')\n * ```\n *\n * @param url The URL to scope.\n * @param scope The scope value.\n * @returns A new URL with the scope information in it.\n */\nexport function setURLScope(url: URL | string, scope: string | null): URL {\n\tlet newUrl = new URL(url);\n\n\tif (isURLScoped(newUrl)) {\n\t\tif (scope) {\n\t\t\tconst parts = newUrl.pathname.split('/');\n\t\t\tparts[1] = `scope:${scope}`;\n\t\t\tnewUrl.pathname = parts.join('/');\n\t\t} else {\n\t\t\tnewUrl = removeURLScope(newUrl);\n\t\t}\n\t} else if (scope) {\n\t\tconst suffix = newUrl.pathname === '/' ? '' : newUrl.pathname;\n\t\tnewUrl.pathname = `/scope:${scope}${suffix}`;\n\t}\n\n\treturn newUrl;\n}\n\n/**\n * Returns a new URL without any scope information.\n *\n * @example\n * ```js\n * removeURLScope(new URL('http://localhost/scope:my-site/index.php'));\n * // URL('http://localhost/index.php')\n *\n * removeURLScope(new URL('http://localhost/index.php'));\n * // URL('http://localhost/index.php')\n * ```\n *\n * @param url The URL to remove scope information from.\n * @returns A new URL without the scope information.\n */\nexport function removeURLScope(url: URL): URL {\n\tif (!isURLScoped(url)) {\n\t\treturn url;\n\t}\n\tconst newUrl = new URL(url);\n\tconst parts = newUrl.pathname.split('/');\n\tnewUrl.pathname = '/' + parts.slice(2).join('/');\n\treturn newUrl;\n}\n"],"names":["isURLScoped","url","getURLScope","setURLScope","scope","newUrl","parts","removeURLScope","suffix"],"mappings":"gFA6BO,SAASA,EAAYC,EAAmB,
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../../../packages/php-wasm/scopes/src/index.ts"],"sourcesContent":["/**\n * Scopes are unique strings, like `my-site`, used to uniquely brand\n * the outgoing HTTP traffic from each browser tab. This helps the\n * main thread distinguish between the relevant and irrelevant\n * messages received from the Service Worker.\n *\n * Scopes are included in the `PHPRequestHandler.absoluteUrl` as follows:\n *\n * An **unscoped** URL: http://localhost:8778/wp-login.php\n * A **scoped** URL: http://localhost:8778/scope:my-site/wp-login.php\n *\n * For more information, see the README section on scopes.\n */\n\n/**\n * Checks if the given URL contains scope information.\n *\n * @example\n * ```js\n * isURLScoped(new URL('http://localhost/scope:my-site/index.php'));\n * // true\n *\n * isURLScoped(new URL('http://localhost/index.php'));\n * // false\n * ```\n *\n * @param url The URL to check.\n * @returns `true` if the URL contains scope information, `false` otherwise.\n */\nexport function isURLScoped(url: URL): boolean {\n\treturn url.pathname.startsWith(`/scope:`);\n}\n\n/**\n * Returns the scope stored in the given URL.\n *\n * @example\n * ```js\n * getScopeFromURL(new URL('http://localhost/scope:my-site/index.php'));\n * // '96253'\n *\n * getScopeFromURL(new URL('http://localhost/index.php'));\n * // null\n * ```\n *\n * @param url The URL.\n * @returns The scope if the URL contains a scope, `null` otherwise.\n */\nexport function getURLScope(url: URL): string | null {\n\tif (isURLScoped(url)) {\n\t\treturn url.pathname.split('/')[1].split(':')[1];\n\t}\n\treturn null;\n}\n\n/**\n * Returns a new URL with the requested scope information.\n *\n * @example\n * ```js\n * setURLScope(new URL('http://localhost/index.php'), 'my-site');\n * // URL('http://localhost/scope:my-site/index.php')\n *\n * setURLScope(new URL('http://localhost/scope:my-site/index.php'), 'my-site');\n * // URL('http://localhost/scope:my-site/index.php')\n *\n * setURLScope(new URL('http://localhost/index.php'), null);\n * // URL('http://localhost/index.php')\n * ```\n *\n * @param url The URL to scope.\n * @param scope The scope value.\n * @returns A new URL with the scope information in it.\n */\nexport function setURLScope(url: URL | string, scope: string | null): URL {\n\tlet newUrl = new URL(url);\n\n\tif (isURLScoped(newUrl)) {\n\t\tif (scope) {\n\t\t\tconst parts = newUrl.pathname.split('/');\n\t\t\tparts[1] = `scope:${scope}`;\n\t\t\tnewUrl.pathname = parts.join('/');\n\t\t} else {\n\t\t\tnewUrl = removeURLScope(newUrl);\n\t\t}\n\t} else if (scope) {\n\t\tconst suffix = newUrl.pathname === '/' ? '' : newUrl.pathname;\n\t\tnewUrl.pathname = `/scope:${scope}${suffix}`;\n\t}\n\n\treturn newUrl;\n}\n\n/**\n * Returns a new URL without any scope information.\n *\n * @example\n * ```js\n * removeURLScope(new URL('http://localhost/scope:my-site/index.php'));\n * // URL('http://localhost/index.php')\n *\n * removeURLScope(new URL('http://localhost/index.php'));\n * // URL('http://localhost/index.php')\n * ```\n *\n * @param url The URL to remove scope information from.\n * @returns A new URL without the scope information.\n */\nexport function removeURLScope(url: URL): URL {\n\tif (!isURLScoped(url)) {\n\t\treturn url;\n\t}\n\tconst newUrl = new URL(url);\n\tconst parts = newUrl.pathname.split('/');\n\tnewUrl.pathname = '/' + parts.slice(2).join('/');\n\treturn newUrl;\n}\n"],"names":["isURLScoped","url","getURLScope","setURLScope","scope","newUrl","parts","removeURLScope","suffix"],"mappings":"gFA6BO,SAASA,EAAYC,EAAmB,CAC9C,OAAOA,EAAI,SAAS,WAAW,SAAS,CACzC,CAiBO,SAASC,EAAYD,EAAyB,CACpD,OAAID,EAAYC,CAAG,EACXA,EAAI,SAAS,MAAM,GAAG,EAAE,CAAC,EAAE,MAAM,GAAG,EAAE,CAAC,EAExC,IACR,CAqBO,SAASE,EAAYF,EAAmBG,EAA2B,CACzE,IAAIC,EAAS,IAAI,IAAIJ,CAAG,EAExB,GAAID,EAAYK,CAAM,EACrB,GAAID,EAAO,CACV,MAAME,EAAQD,EAAO,SAAS,MAAM,GAAG,EACvCC,EAAM,CAAC,EAAI,SAASF,CAAK,GACzBC,EAAO,SAAWC,EAAM,KAAK,GAAG,CACjC,MACCD,EAASE,EAAeF,CAAM,UAErBD,EAAO,CACjB,MAAMI,EAASH,EAAO,WAAa,IAAM,GAAKA,EAAO,SACrDA,EAAO,SAAW,UAAUD,CAAK,GAAGI,CAAM,EAC3C,CAEA,OAAOH,CACR,CAiBO,SAASE,EAAeN,EAAe,CAC7C,GAAI,CAACD,EAAYC,CAAG,EACnB,OAAOA,EAER,MAAMI,EAAS,IAAI,IAAIJ,CAAG,EACpBK,EAAQD,EAAO,SAAS,MAAM,GAAG,EACvC,OAAAA,EAAO,SAAW,IAAMC,EAAM,MAAM,CAAC,EAAE,KAAK,GAAG,EACxCD,CACR"}
|
package/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../packages/php-wasm/scopes/src/index.ts"],"sourcesContent":["/**\n * Scopes are unique strings, like `my-site`, used to uniquely brand\n * the outgoing HTTP traffic from each browser tab. This helps the\n * main thread distinguish between the relevant and irrelevant\n * messages received from the Service Worker.\n *\n * Scopes are included in the `PHPRequestHandler.absoluteUrl` as follows:\n *\n * An **unscoped** URL: http://localhost:8778/wp-login.php\n * A **scoped** URL: http://localhost:8778/scope:my-site/wp-login.php\n *\n * For more information, see the README section on scopes.\n */\n\n/**\n * Checks if the given URL contains scope information.\n *\n * @example\n * ```js\n * isURLScoped(new URL('http://localhost/scope:my-site/index.php'));\n * // true\n *\n * isURLScoped(new URL('http://localhost/index.php'));\n * // false\n * ```\n *\n * @param url The URL to check.\n * @returns `true` if the URL contains scope information, `false` otherwise.\n */\nexport function isURLScoped(url: URL): boolean {\n\treturn url.pathname.startsWith(`/scope:`);\n}\n\n/**\n * Returns the scope stored in the given URL.\n *\n * @example\n * ```js\n * getScopeFromURL(new URL('http://localhost/scope:my-site/index.php'));\n * // '96253'\n *\n * getScopeFromURL(new URL('http://localhost/index.php'));\n * // null\n * ```\n *\n * @param url The URL.\n * @returns The scope if the URL contains a scope, `null` otherwise.\n */\nexport function getURLScope(url: URL): string | null {\n\tif (isURLScoped(url)) {\n\t\treturn url.pathname.split('/')[1].split(':')[1];\n\t}\n\treturn null;\n}\n\n/**\n * Returns a new URL with the requested scope information.\n *\n * @example\n * ```js\n * setURLScope(new URL('http://localhost/index.php'), 'my-site');\n * // URL('http://localhost/scope:my-site/index.php')\n *\n * setURLScope(new URL('http://localhost/scope:my-site/index.php'), 'my-site');\n * // URL('http://localhost/scope:my-site/index.php')\n *\n * setURLScope(new URL('http://localhost/index.php'), null);\n * // URL('http://localhost/index.php')\n * ```\n *\n * @param url The URL to scope.\n * @param scope The scope value.\n * @returns A new URL with the scope information in it.\n */\nexport function setURLScope(url: URL | string, scope: string | null): URL {\n\tlet newUrl = new URL(url);\n\n\tif (isURLScoped(newUrl)) {\n\t\tif (scope) {\n\t\t\tconst parts = newUrl.pathname.split('/');\n\t\t\tparts[1] = `scope:${scope}`;\n\t\t\tnewUrl.pathname = parts.join('/');\n\t\t} else {\n\t\t\tnewUrl = removeURLScope(newUrl);\n\t\t}\n\t} else if (scope) {\n\t\tconst suffix = newUrl.pathname === '/' ? '' : newUrl.pathname;\n\t\tnewUrl.pathname = `/scope:${scope}${suffix}`;\n\t}\n\n\treturn newUrl;\n}\n\n/**\n * Returns a new URL without any scope information.\n *\n * @example\n * ```js\n * removeURLScope(new URL('http://localhost/scope:my-site/index.php'));\n * // URL('http://localhost/index.php')\n *\n * removeURLScope(new URL('http://localhost/index.php'));\n * // URL('http://localhost/index.php')\n * ```\n *\n * @param url The URL to remove scope information from.\n * @returns A new URL without the scope information.\n */\nexport function removeURLScope(url: URL): URL {\n\tif (!isURLScoped(url)) {\n\t\treturn url;\n\t}\n\tconst newUrl = new URL(url);\n\tconst parts = newUrl.pathname.split('/');\n\tnewUrl.pathname = '/' + parts.slice(2).join('/');\n\treturn newUrl;\n}\n"],"names":["isURLScoped","url","getURLScope","setURLScope","scope","newUrl","parts","removeURLScope","suffix"],"mappings":"AA6BO,SAASA,EAAYC,GAAmB;
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../packages/php-wasm/scopes/src/index.ts"],"sourcesContent":["/**\n * Scopes are unique strings, like `my-site`, used to uniquely brand\n * the outgoing HTTP traffic from each browser tab. This helps the\n * main thread distinguish between the relevant and irrelevant\n * messages received from the Service Worker.\n *\n * Scopes are included in the `PHPRequestHandler.absoluteUrl` as follows:\n *\n * An **unscoped** URL: http://localhost:8778/wp-login.php\n * A **scoped** URL: http://localhost:8778/scope:my-site/wp-login.php\n *\n * For more information, see the README section on scopes.\n */\n\n/**\n * Checks if the given URL contains scope information.\n *\n * @example\n * ```js\n * isURLScoped(new URL('http://localhost/scope:my-site/index.php'));\n * // true\n *\n * isURLScoped(new URL('http://localhost/index.php'));\n * // false\n * ```\n *\n * @param url The URL to check.\n * @returns `true` if the URL contains scope information, `false` otherwise.\n */\nexport function isURLScoped(url: URL): boolean {\n\treturn url.pathname.startsWith(`/scope:`);\n}\n\n/**\n * Returns the scope stored in the given URL.\n *\n * @example\n * ```js\n * getScopeFromURL(new URL('http://localhost/scope:my-site/index.php'));\n * // '96253'\n *\n * getScopeFromURL(new URL('http://localhost/index.php'));\n * // null\n * ```\n *\n * @param url The URL.\n * @returns The scope if the URL contains a scope, `null` otherwise.\n */\nexport function getURLScope(url: URL): string | null {\n\tif (isURLScoped(url)) {\n\t\treturn url.pathname.split('/')[1].split(':')[1];\n\t}\n\treturn null;\n}\n\n/**\n * Returns a new URL with the requested scope information.\n *\n * @example\n * ```js\n * setURLScope(new URL('http://localhost/index.php'), 'my-site');\n * // URL('http://localhost/scope:my-site/index.php')\n *\n * setURLScope(new URL('http://localhost/scope:my-site/index.php'), 'my-site');\n * // URL('http://localhost/scope:my-site/index.php')\n *\n * setURLScope(new URL('http://localhost/index.php'), null);\n * // URL('http://localhost/index.php')\n * ```\n *\n * @param url The URL to scope.\n * @param scope The scope value.\n * @returns A new URL with the scope information in it.\n */\nexport function setURLScope(url: URL | string, scope: string | null): URL {\n\tlet newUrl = new URL(url);\n\n\tif (isURLScoped(newUrl)) {\n\t\tif (scope) {\n\t\t\tconst parts = newUrl.pathname.split('/');\n\t\t\tparts[1] = `scope:${scope}`;\n\t\t\tnewUrl.pathname = parts.join('/');\n\t\t} else {\n\t\t\tnewUrl = removeURLScope(newUrl);\n\t\t}\n\t} else if (scope) {\n\t\tconst suffix = newUrl.pathname === '/' ? '' : newUrl.pathname;\n\t\tnewUrl.pathname = `/scope:${scope}${suffix}`;\n\t}\n\n\treturn newUrl;\n}\n\n/**\n * Returns a new URL without any scope information.\n *\n * @example\n * ```js\n * removeURLScope(new URL('http://localhost/scope:my-site/index.php'));\n * // URL('http://localhost/index.php')\n *\n * removeURLScope(new URL('http://localhost/index.php'));\n * // URL('http://localhost/index.php')\n * ```\n *\n * @param url The URL to remove scope information from.\n * @returns A new URL without the scope information.\n */\nexport function removeURLScope(url: URL): URL {\n\tif (!isURLScoped(url)) {\n\t\treturn url;\n\t}\n\tconst newUrl = new URL(url);\n\tconst parts = newUrl.pathname.split('/');\n\tnewUrl.pathname = '/' + parts.slice(2).join('/');\n\treturn newUrl;\n}\n"],"names":["isURLScoped","url","getURLScope","setURLScope","scope","newUrl","parts","removeURLScope","suffix"],"mappings":"AA6BO,SAASA,EAAYC,GAAmB;AAC9C,SAAOA,EAAI,SAAS,WAAW,SAAS;AACzC;AAiBO,SAASC,EAAYD,GAAyB;AACpD,SAAID,EAAYC,CAAG,IACXA,EAAI,SAAS,MAAM,GAAG,EAAE,CAAC,EAAE,MAAM,GAAG,EAAE,CAAC,IAExC;AACR;AAqBO,SAASE,EAAYF,GAAmBG,GAA2B;AACzE,MAAIC,IAAS,IAAI,IAAIJ,CAAG;AAExB,MAAID,EAAYK,CAAM;AACrB,QAAID,GAAO;AACV,YAAME,IAAQD,EAAO,SAAS,MAAM,GAAG;AACvC,MAAAC,EAAM,CAAC,IAAI,SAASF,CAAK,IACzBC,EAAO,WAAWC,EAAM,KAAK,GAAG;AAAA,IACjC;AACC,MAAAD,IAASE,EAAeF,CAAM;AAAA,WAErBD,GAAO;AACjB,UAAMI,IAASH,EAAO,aAAa,MAAM,KAAKA,EAAO;AACrD,IAAAA,EAAO,WAAW,UAAUD,CAAK,GAAGI,CAAM;AAAA,EAC3C;AAEA,SAAOH;AACR;AAiBO,SAASE,EAAeN,GAAe;AAC7C,MAAI,CAACD,EAAYC,CAAG;AACnB,WAAOA;AAER,QAAMI,IAAS,IAAI,IAAIJ,CAAG,GACpBK,IAAQD,EAAO,SAAS,MAAM,GAAG;AACvC,SAAAA,EAAO,WAAW,MAAMC,EAAM,MAAM,CAAC,EAAE,KAAK,GAAG,GACxCD;AACR;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@php-wasm/scopes",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.17",
|
|
4
4
|
"description": "PHP.wasm – scoped URLs utils",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"main": "./index.cjs",
|
|
33
33
|
"module": "./index.js",
|
|
34
34
|
"types": "index.d.ts",
|
|
35
|
-
"gitHead": "
|
|
35
|
+
"gitHead": "11e92b1431bd01ee27049678aec2932b8b4d9f44",
|
|
36
36
|
"engines": {
|
|
37
37
|
"node": ">=20.18.3",
|
|
38
38
|
"npm": ">=10.1.0"
|