@observablehq/notebook-kit 2.6.0 → 2.6.1

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/dist/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/observablehq/notebook-kit.git"
7
7
  },
8
- "version": "2.6.0",
8
+ "version": "2.6.1",
9
9
  "type": "module",
10
10
  "scripts": {
11
11
  "test": "TZ=America/Los_Angeles vitest",
@@ -11,5 +11,5 @@ export declare function toSpecialIdentifier(identifier: Identifier, type: "viewo
11
11
  export declare function toSpecialImportSpecifier(specifier: ImportSpecifier, type: "viewof" | "mutable"): ImportSpecifier;
12
12
  export declare function isViewImport(node: NamedImportSpecifier): node is ImportSpecifier;
13
13
  export declare function isMutableImport(node: NamedImportSpecifier): node is ImportSpecifier;
14
- /** Turns e.g. "viewof$foo" into "viewof foo", and "$$" into "$". */
14
+ /** Turns e.g. "viewof$foo" into "viewof foo", and "viewof$$foo" into "viewof$foo". */
15
15
  export declare function dedollar(input: string): string;
@@ -1,5 +1,4 @@
1
1
  import { flatMapImportSpecifiers, getImportedName, getLocalName } from "../imports.js";
2
- const CODE_DOLLAR = 36;
3
2
  /** If specifier is an observable: protocol import, resolves it. */
4
3
  export function resolveObservableImport(specifier) {
5
4
  if (!specifier.startsWith("observable:"))
@@ -75,29 +74,8 @@ export function isViewImport(node) {
75
74
  export function isMutableImport(node) {
76
75
  return "mutable" in node && !!node.mutable;
77
76
  }
78
- /** Turns e.g. "viewof$foo" into "viewof foo", and "$$" into "$". */
77
+ /** Turns e.g. "viewof$foo" into "viewof foo", and "viewof$$foo" into "viewof$foo". */
79
78
  export function dedollar(input) {
80
- const start = 0;
81
- const end = input.length;
82
- let dollars = 0;
83
- for (let i = start; i < end; ++i) {
84
- switch (input.charCodeAt(i)) {
85
- case CODE_DOLLAR: {
86
- ++dollars;
87
- break;
88
- }
89
- default: {
90
- if (dollars > 0) {
91
- input = `${input.slice(0, i - 1)}${dollars === 1 ? " " : ""}${input.slice(i)}`;
92
- dollars = 0;
93
- }
94
- break;
95
- }
96
- }
97
- }
98
- if (dollars > 0) {
99
- input = `${input.slice(0, end - 1)}${dollars === 1 ? " " : ""}`;
100
- dollars = 0;
101
- }
102
- return input;
79
+ const match = /^(viewof|mutable)([$]+)([^$].*)$/.exec(input);
80
+ return match ? `${match[1]}${match[2].length > 1 ? match[2].slice(1) : " "}${match[3]}` : input;
103
81
  }
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/observablehq/notebook-kit.git"
7
7
  },
8
- "version": "2.6.0",
8
+ "version": "2.6.1",
9
9
  "type": "module",
10
10
  "scripts": {
11
11
  "test": "TZ=America/Los_Angeles vitest",